diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index b5259b2d..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: python:3.7 - steps: - - checkout - - run: apt-get update && apt-get install -y python3-dev python-pip python-dev - - run: pip install --upgrade pip - - run: pip install virtualenv - - run: pip install virtualenvwrapper - - run: pip install tox - - run: tox diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..b7b834d0 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +version: 2 +updates: + # python dependencies + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "weekly" + # Disable version updates for pip dependencies in deference to https://github.com/dbt-labs/dbt-core/issues/8409 + # this will not affect secrity related updates + open-pull-requests-limit: 0 + + # github dependencies + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + rebase-strategy: "disabled" \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..1f00c471 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,21 @@ +resolves # + + + +### Description + + + +### Checklist + +- [ ] I have read [the contributing guide](https://github.com/dbt-labs/dbt-oss-template/blob/main/CONTRIBUTING.md) and understand what's expected of me +- [ ] I have signed the [CLA](https://docs.getdbt.com/docs/contributor-license-agreements) +- [ ] I have run this code in development and it appears to resolve the stated issue + diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..c33544f2 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,55 @@ +# **what?** +# Runs basic tests on code base + +# **why?** +# Ensure code meets a certain quality standard. + +# **when?** +# This will run for all PRs, when code is pushed to a release +# branch, and when manually triggered. + +name: Tests + +on: + push: + branches: + - "master" + pull_request: + workflow_dispatch: + +permissions: read-all + +# will cancel previous workflows triggered by the same event and for the same ref for PRs or same SHA otherwise +concurrency: + group: ${{ github.workflow }}-${{ github.event_name }}-${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref || github.sha }} + cancel-in-progress: true + +defaults: + run: + shell: bash + +jobs: + tests: + name: "Python 3.7 / ubuntu-latest" + + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Check out the repository + uses: actions/checkout@v4 + + - name: "Set up Python 3.7" + uses: actions/setup-python@v5 + with: + python-version: '3.7' + + - name: Install python dependencies + run: | + python -m pip install --user --upgrade pip + python -m pip --version + python -m pip install tox + tox --version + + - name: Run tox + run: tox diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..37e6a7b6 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,102 @@ +# Contributing to `snowplow-python-tracker` + +`snowplow-python-tracker` is a fork of the original Snowplow Python tracker v0.8.0. + + +1. [About this document](#about-this-document) +2. [Getting the code](#getting-the-code) +3. [Setting up an environment](#setting-up-an-environment) +4. [Running in development](#running-snowplow-python-tracker-in-development) +5. [Testing](#testing) +6. [Debugging](#debugging) +7. [Adding or modifying a changelog entry](#adding-or-modifying-a-changelog-entry) +8. [Submitting a Pull Request](#submitting-a-pull-request) +9. [Troubleshooting Tips](#troubleshooting-tips) + +## About this document + +There are many ways to contribute to the ongoing development of `snowplow-python-tracker`, such as by participating in discussions and issues. We encourage you to first read our higher-level document: ["Expectations for Open Source Contributors"](https://docs.getdbt.com/docs/contributing/oss-expectations). + +The rest of this document serves as a more granular guide for contributing code changes to `snowplow-python-tracker` (this repository). It is not intended as a guide for using `snowplow-python-tracker`, and some pieces assume a level of familiarity with Python development (virtualenvs, `pip`, etc). Specific code snippets in this guide assume you are using macOS or Linux and are comfortable with the command line. + +### Notes + +- **CLA:** Please note that anyone contributing code to `snowplow-python-tracker` must sign the [Contributor License Agreement](https://docs.getdbt.com/docs/contributor-license-agreements). If you are unable to sign the CLA, the `snowplow-python-tracker` maintainers will unfortunately be unable to merge any of your Pull Requests. We welcome you to participate in discussions, open issues, and comment on existing ones. +- **Branches:** All pull requests from community contributors should target the `master` branch (default). +- **Releases**: This repository is released only as needed. + +## Getting the code + +### Installing git + +You will need `git` in order to download and modify the source code. + +### External contributors + +If you are not a member of the `dbt-labs` GitHub organization, you can contribute to `snowplow-python-tracker` by forking the `snowplow-python-tracker` repository. For a detailed overview on forking, check out the [GitHub docs on forking](https://help.github.com/en/articles/fork-a-repo). In short, you will need to: + +1. Fork the `snowplow-python-tracker` repository +2. Clone your fork locally +3. Check out a new branch for your proposed changes +4. Push changes to your fork +5. Open a pull request against `dbt-labs/snowplow-python-tracker` from your forked repository + +### dbt Labs contributors + +If you are a member of the `dbt-labs` GitHub organization, you will have push access to the `snowplow-python-tracker` repo. Rather than forking `snowplow-python-tracker` to make your changes, just clone the repository, check out a new branch, and push directly to that branch. + +## Setting up an environment + +There are some tools that will be helpful to you in developing locally. While this is the list relevant for `snowplow-python-tracker` development, many of these tools are used commonly across open-source python projects. + +#### Virtual environments + +We strongly recommend using virtual environments when developing code in `snowplow-python-tracker`. We recommend creating this virtualenv +in the root of the `snowplow-python-tracker` repository. To create a new virtualenv, run: +```sh +python3 -m venv env +source env/bin/activate +``` + +This will create and activate a new Python virtual environment. + +## Running `snowplow-python-tracker` in development + +### Installation + +First make sure that you set up your `virtualenv` as described in [Setting up an environment](#setting-up-an-environment). Also ensure you have the latest version of pip installed with `pip install --upgrade pip`. Next, install `snowplow-python-tracker` (and its dependencies): + +```sh +git +pre-commit install +``` + +## Testing + +Once you're able to manually test that your code change is working as expected, it's important to run existing automated tests, as well as adding some new ones. These tests will ensure that: +- Your code changes do not unexpectedly break other established functionality +- Your code changes can handle all known edge cases +- The functionality you're adding will _keep_ working in the future + +### Initial setup + +None needed. + +### Test commands + +docker-compose run --rm test tox + + +### Assorted development tips +* This is a fork of [snowplow-python-tracker](https://github.com/snowplow/snowplow-python-tracker) and bets practices in that repository should be followed here + +## Submitting a Pull Request + +Code can be merged into the current development branch `main` by opening a pull request. A `snowplow-python-tracker` maintainer will review your PR. They may suggest code revision for style or clarity, or request that you add unit or integration test(s). These are good things! We believe that, with a little bit of help, anyone can contribute high-quality code. + +Automated tests run via GitHub Actions. If you're a first-time contributor, all tests (including code checks and unit tests) will require a maintainer to approve. Changes in the `snowplow-python-tracker` repository trigger integration tests against Postgres. dbt Labs also provides CI environments in which to test changes to other adapters, triggered by PRs in those adapters' repositories, as well as periodic maintenance checks of each adapter in concert with the latest `snowplow-python-tracker` code changes. + +Once all tests are passing and your PR has been approved, a `snowplow-python-tracker` maintainer will merge your changes into the active development branch. And that's it! Happy developing :tada: + +## Troubleshooting Tips +- Sometimes, the content license agreement auto-check bot doesn't find a user's entry in its roster. If you need to force a rerun, add `@cla-bot check` in a comment on the pull request. diff --git a/README.md b/README.md new file mode 100644 index 00000000..ed827922 --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +## Understanding snowplow-python-tracker + +Add analytics to your Python apps and Python games with the +[Snowplow](http://snowplowanalytics.com) event tracker for +[Python](http://python.org). + +With this tracker you can collect event data from your Python-based +applications, games or Python web servers/frameworks. + +This is a fork of the original Snowplow Python tracker v0.8.0, with a number of changes: + + - All emitters except for the basic one removed + - Tests converted to docker + - All tracking event methods except for structured/unstructured + removed + - Python 3.7 supported + +## Getting started + +- Read the [introduction](https://docs.getdbt.com/docs/introduction/) and [viewpoint](https://docs.getdbt.com/docs/about/viewpoint/) + +## Join the dbt Community + +- Be part of the conversation in the [dbt Community Slack](http://community.getdbt.com/) +- Read more on the [dbt Community Discourse](https://discourse.getdbt.com) + +## Reporting bugs and contributing code + +- Want to report a bug or request a feature? Let us know and open [an issue](https://github.com/dbt-labs/snowplow-python-tracker/issues/new) +- Want to help us build dbt? Check out the [Contributing Guide](https://github.com/dbt-labs/snowplow-python-tracker/blob/HEAD/CONTRIBUTING.md) + +## Code of Conduct + +Everyone interacting in the dbt project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [dbt Code of Conduct](https://community.getdbt.com/code-of-conduct). + +# Copyright and license + +The Snowplow Python Tracker is copyright 2013-2014 Snowplow Analytics +Ltd. + +Licensed under the [Apache License, Version +2.0](http://www.apache.org/licenses/LICENSE-2.0) (the \"License\"); you +may not use this software except in compliance with the License. + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an \"AS IS\" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +This software has been modified by Fishtown Analytics. Changes are +copyright 2018 Fishtown Analytics LLC. diff --git a/README.rst b/README.rst deleted file mode 100644 index 0cfd4328..00000000 --- a/README.rst +++ /dev/null @@ -1,54 +0,0 @@ -====================================================== -Python Analytics for Snowplow -====================================================== -.. image:: https://circleci.com/gh/fishtown-analytics/snowplow-python-tracker/tree/master.svg?style=svg - :alt: Build Status - :target: https://circleci.com/gh/fishtown-analytics/snowplow-python-tracker - - -Overview -######## - -Add analytics to your Python apps and Python games with the Snowplow_ event tracker for Python_. - -.. _Snowplow: http://snowplowanalytics.com -.. _Python: http://python.org - -With this tracker you can collect event data from your Python-based applications, games or Python web servers/frameworks. - -This is a fork of the original Snowplow Python tracker v0.8.0, with a number of changes: - - All emitters except for the basic one removed - - Tests converted to docker - - All tracking event methods except for structured/unstructured removed - - Python 3.7 supported - - -Contributing quickstart -####################### - -Assuming Git and Docker_ (with docker-compose) are installed: - -:: - - host$ git clone git@github.com:snowplow/snowplow-python-tracker.git - host$ docker-compose run --rm test tox - -.. _Docker: https://www.docker.com/community-edition - -Copyright and license -##################### - -The Snowplow Python Tracker is copyright 2013-2014 Snowplow Analytics Ltd. - -Licensed under the `Apache License, Version 2.0`_ (the "License"); -you may not use this software except in compliance with the License. - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -This software has been modified by Fishtown Analytics. Changes are copyright 2018 Fishtown Analytics LLC. - -.. _Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 diff --git a/setup.py b/setup.py index 96b9a199..4f1193d5 100644 --- a/setup.py +++ b/setup.py @@ -48,6 +48,10 @@ ] authors_str = ', '.join(authors_list) +this_directory = os.path.abspath(os.path.dirname(__file__)) +with open(os.path.join(this_directory, "README.md")) as f: + long_description = f.read() + setup( name='minimal-snowplow-tracker', version=__version__, @@ -56,20 +60,14 @@ url='https://www.fishtownanalytics.com', license='Apache License 2.0', description='A minimal snowplow event tracker for Python. Add analytics to your Python and Django apps, webapps and games', - long_description=open('README.rst').read(), + long_description=long_description, + long_description_content_type="text/markdown", classifiers=[ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Operating System :: OS Independent", ], diff --git a/tox.ini b/tox.ini index f417f520..e614f388 100644 --- a/tox.ini +++ b/tox.ini @@ -1,17 +1,10 @@ [tox] skipsdist = True -envlist = unit-py27, unit-py37 - -[testenv:unit-py27] -basepython = python2.7 -commands = /bin/bash -c '$(which pytest) -v {posargs} snowplow_tracker/test' -deps = - -e {toxinidir} - -r{toxinidir}/requirements-test.txt +envlist = unit-py37 [testenv:unit-py37] basepython = python3.7 -commands = /bin/bash -c '{envpython} $(which pytest) -v {posargs} snowplow_tracker/test' +commands = {envpython} -m pytest -v {posargs} snowplow_tracker/test deps = -e {toxinidir} -r{toxinidir}/requirements-test.txt