From 44b31883a58e670608c9a6df5ef95e125bc3236a Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 31 Oct 2023 16:33:45 -0700 Subject: [PATCH 01/47] Start using hatch in pyproject.toml --- pyproject.toml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b05c55a0..65c9db93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,8 +35,8 @@ dynamic = ["version"] [build-system] -requires = ['setuptools>=40.8.0', 'wheel'] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" [project.urls] @@ -79,3 +79,8 @@ minversion = "6.0" addopts = "--ds=anvil_consortium_manager.tests.settings.test --reuse-db --ignore=anvil_consortium_manager/tests/test_app/" python_files = ["anvil_consortium_manager/tests/test*.py"] python_classes = ["!TestWorkspaceDataFactory"] + +[tool.hatch] + +[tool.hatch.version] +path = "anvil_consortium_manager/__init__.py" From 09748e7733d899539e59bab8fee9b0440b2dc01f Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 31 Oct 2023 17:06:54 -0700 Subject: [PATCH 02/47] Add a dev environment for hatch This environment has the django-debug-toolbar installed. As part of this, I realized that ACM needs to specify the requests package as one of its dependencies; apparently google.auth does not. --- pyproject.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 65c9db93..2ca636ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ dependencies = [ "pytz >= 0", "crispy-bootstrap5 >= 0.6", "django-crispy-forms >= 1.12", - "google-auth >= 2.6", + "google-auth [requests] >= 2.6", "fontawesomefree >= 6.1", "django-autocomplete-light >= 3.9", "django-filter >= 23.0", @@ -84,3 +84,9 @@ python_classes = ["!TestWorkspaceDataFactory"] [tool.hatch.version] path = "anvil_consortium_manager/__init__.py" + +[tool.hatch.envs.dev] +dependencies = ["django-debug-toolbar"] + +[tool.hatch.envs.dev.scripts] +dj = "python manage.py" From 48f5f589a913f22556294a0c2134c810f6635cac Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 31 Oct 2023 17:38:46 -0700 Subject: [PATCH 03/47] Optionally store environment variables in a .env file Since virtual environments are defined by hatch, we don't want to set the environment variable for the service account file directly in the hatch env definition, since the file is different for every developer. Instead, modify the example project settings to read the service account file from a .env file (optionally). This requires adding the django-environ package to the dev dependencies. --- .gitignore | 1 + README.md | 2 ++ example_site/settings.py | 9 ++++++++- pyproject.toml | 8 ++++---- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 95f7f69a..4717ca98 100644 --- a/.gitignore +++ b/.gitignore @@ -277,3 +277,4 @@ example_site/media/ ### My additions db.sqlite3 *.sqlite3 +.env diff --git a/README.md b/README.md index 2e81a44c..a91cea48 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ $ pip install -r requirements/dev.txt $ export ANVIL_API_SERVICE_ACCOUNT_FILE="///.json" ``` +You can also create a .env file to store environment variables. + 5. Run the example site: ``` diff --git a/example_site/settings.py b/example_site/settings.py index 24f79c94..6411c1c6 100644 --- a/example_site/settings.py +++ b/example_site/settings.py @@ -4,8 +4,15 @@ import os from pathlib import Path +import environ + ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent +# Optionally read environment variables from a .env file. +env = environ.Env() +if os.path.exists(str(ROOT_DIR / ".env")): + env.read_env(str(ROOT_DIR / ".env")) + # GENERAL # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#debug @@ -206,7 +213,7 @@ # django-anvil-consortium-manager # ------------------------------------------------------------------------------ # Specify the path to the service account to use for managing access on AnVIL. -ANVIL_API_SERVICE_ACCOUNT_FILE = os.getenv("ANVIL_API_SERVICE_ACCOUNT_FILE") +ANVIL_API_SERVICE_ACCOUNT_FILE = env("ANVIL_API_SERVICE_ACCOUNT_FILE") # Specify the URL for AccountLinkVerify view redirect ANVIL_ACCOUNT_LINK_REDIRECT = "home" # Specify the subject for AnVIL account verification emails. diff --git a/pyproject.toml b/pyproject.toml index 2ca636ca..1f0bf6bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,7 +86,7 @@ python_classes = ["!TestWorkspaceDataFactory"] path = "anvil_consortium_manager/__init__.py" [tool.hatch.envs.dev] -dependencies = ["django-debug-toolbar"] - -[tool.hatch.envs.dev.scripts] -dj = "python manage.py" +dependencies = [ + "django-debug-toolbar", + "django-environ", +] From 74a0815a2a786d7d6c729ce1a85cdbe78bb87579 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 31 Oct 2023 17:46:33 -0700 Subject: [PATCH 04/47] Add a tests environment that runs tox --- pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 1f0bf6bc..8cdcef13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,3 +90,9 @@ dependencies = [ "django-debug-toolbar", "django-environ", ] + +[tool.hatch.envs.test] +dependencies = ["tox"] + +[tool.hatch.envs.dev.test] +test = "tox" From e1839d45fa09342a119c9d132bd9e8743a21a867 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Wed, 1 Nov 2023 14:23:22 -0700 Subject: [PATCH 05/47] Start migrating tests to hatch Add test dependencies to the test env. Set up a python matrix that runs tests using two different versions of python. Add scripts for running all test environments vs just one test environment. --- pyproject.toml | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8cdcef13..d8ba00ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,14 +85,41 @@ python_classes = ["!TestWorkspaceDataFactory"] [tool.hatch.version] path = "anvil_consortium_manager/__init__.py" -[tool.hatch.envs.dev] +[tool.hatch.envs.default] dependencies = [ + "Django >= 3.2,<=5.0", "django-debug-toolbar", + # Process a .env file for environment variables "django-environ", + # Interactive debugging + # "ipdb", +] +[tool.hatch.envs.default.scripts] +dj = "python manage.py {args}" +test = "hatch run +py=3.8 test:test" +all = [ + "hatch run test:test", ] [tool.hatch.envs.test] -dependencies = ["tox"] - -[tool.hatch.envs.dev.test] -test = "tox" +dependencies = [ + "django-debug-toolbar", + # Process a .env file for environment variables + "django-environ", + # For testing migrations + "django-test-migrations", # https://github.com/wemake-services/django-test-migrations + # Test coverage + "coverage[toml]>=6.5", + # Model factories + "factory-boy", + # Set the system time in tests + "freezegun", # https://github.com/spulec/freezegun + "pytest", + "pytest-django", + # Mocked responses in tests + "responses", # https://github.com/getsentry/responses +] +[tool.hatch.envs.test.scripts] +test = "pytest {args}" +[[tool.hatch.envs.test.matrix]] +python = ["3.8", '3.9'] From fdf411727de48100fd0ca9fde6a6573b66fcd403 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Wed, 1 Nov 2023 14:48:35 -0700 Subject: [PATCH 06/47] Add testing using different versions of django --- pyproject.toml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d8ba00ac..c69ba3d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,8 +75,7 @@ plugins = ["django_coverage_plugin"] [tool.pytest.ini_options] -minversion = "6.0" -addopts = "--ds=anvil_consortium_manager.tests.settings.test --reuse-db --ignore=anvil_consortium_manager/tests/test_app/" +addopts = "--reuse-db --ignore=anvil_consortium_manager/tests/test_app/" python_files = ["anvil_consortium_manager/tests/test*.py"] python_classes = ["!TestWorkspaceDataFactory"] @@ -96,7 +95,7 @@ dependencies = [ ] [tool.hatch.envs.default.scripts] dj = "python manage.py {args}" -test = "hatch run +py=3.8 test:test" +test = "hatch run +py=3.8 test:test {args}" all = [ "hatch run test:test", ] @@ -114,12 +113,21 @@ dependencies = [ "factory-boy", # Set the system time in tests "freezegun", # https://github.com/spulec/freezegun - "pytest", + "pytest >= 6.0", "pytest-django", # Mocked responses in tests "responses", # https://github.com/getsentry/responses ] [tool.hatch.envs.test.scripts] -test = "pytest {args}" +test = [ + "pytest --ds=anvil_consortium_manager.tests.settings.test {args}" +] [[tool.hatch.envs.test.matrix]] -python = ["3.8", '3.9'] +python = ["3.8"] +django = ["3.2", "4.2"] + +[tool.hatch.envs.test.overrides] +matrix.django.dependencies = [ + { value = "django ~= 3.2.0", if = ["3.2"] }, + { value = "django ~= 4.2.0", if = ["4.2"] }, +] From 602aad546c88d5bffd0ab5a5d841d6fd04a63df5 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Wed, 1 Nov 2023 14:49:09 -0700 Subject: [PATCH 07/47] Move a pytest option into the test environment --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c69ba3d9..cced2cad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,7 +75,6 @@ plugins = ["django_coverage_plugin"] [tool.pytest.ini_options] -addopts = "--reuse-db --ignore=anvil_consortium_manager/tests/test_app/" python_files = ["anvil_consortium_manager/tests/test*.py"] python_classes = ["!TestWorkspaceDataFactory"] @@ -120,7 +119,7 @@ dependencies = [ ] [tool.hatch.envs.test.scripts] test = [ - "pytest --ds=anvil_consortium_manager.tests.settings.test {args}" + "pytest --ds=anvil_consortium_manager.tests.settings.test --reuse-db --ignore=anvil_consortium_manager/tests/test_app/ {args}" ] [[tool.hatch.envs.test.matrix]] python = ["3.8"] From 95c0c3c18ec205fc79a97001f7f81de368ce4539 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Wed, 1 Nov 2023 14:53:13 -0700 Subject: [PATCH 08/47] Add CI to run hatch github actions --- .github/workflows/ci_hatch.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/ci_hatch.yml diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml new file mode 100644 index 00000000..a40ce185 --- /dev/null +++ b/.github/workflows/ci_hatch.yml @@ -0,0 +1,29 @@ +name: Run tests with hatch + +on: + pull_request: + branches: [ "master", "main" ] + paths-ignore: [ "docs/**" ] + + push: + branches: [ "master", "main" ] + paths-ignore: [ "docs/**" ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v4 + with: + python-version: | + 3.8 + 3.11 + + - name: Install hatch + run: pipx install hatch + + - name: Run Tests + run: hatch run test:run From d8e19a2816a0ee5b580ec26181e33621e661b373 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Wed, 1 Nov 2023 14:57:11 -0700 Subject: [PATCH 09/47] Fix CI hatch run command --- .github/workflows/ci_hatch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index a40ce185..5ac96924 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -26,4 +26,4 @@ jobs: run: pipx install hatch - name: Run Tests - run: hatch run test:run + run: hatch run test:test From 6e51b69c7d66068cb3bba69db0cebaeb41cf95d8 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Wed, 1 Nov 2023 15:06:24 -0700 Subject: [PATCH 10/47] Run CI using different python versions in a matrix --- .github/workflows/ci_hatch.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index 5ac96924..ea1bddac 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -11,19 +11,22 @@ on: jobs: test: + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.11"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 with: - python-version: | - 3.8 - 3.11 + python-version: ${{ matrix.python-version }} - name: Install hatch - run: pipx install hatch + run: python -m pip install --upgrade hatch - name: Run Tests - run: hatch run test:test + run: hatch run +py=${{ matrix.python-version }} test:test From 8d523ab516941c0ff3b618e06ef25eaeb8e8428d Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Wed, 1 Nov 2023 15:09:04 -0700 Subject: [PATCH 11/47] Add py311 environment to hatch test env --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index cced2cad..7c399f83 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -124,6 +124,9 @@ test = [ [[tool.hatch.envs.test.matrix]] python = ["3.8"] django = ["3.2", "4.2"] +[[tool.hatch.envs.test.matrix]] +python = ["3.11"] +django = ["4.2"] [tool.hatch.envs.test.overrides] matrix.django.dependencies = [ From 7f03aab0fa4664ae0c2beb1428a9157076183473 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Wed, 1 Nov 2023 15:22:18 -0700 Subject: [PATCH 12/47] Remove tox ci so it doesn't run on push to this branch --- .github/workflows/ci.yml | 160 --------------------------------------- 1 file changed, 160 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index b5f5335c..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,160 +0,0 @@ -name: ci-tox - -# Enable Buildkit and let compose use it to speed up image building -env: - DOCKER_BUILDKIT: 1 - COMPOSE_DOCKER_CLI_BUILD: 1 - -on: - pull_request: - branches: [ "master", "main" ] - paths-ignore: [ "docs/**" ] - - push: - branches: [ "master", "main" ] - paths-ignore: [ "docs/**" ] - - -jobs: - - linter: - runs-on: ubuntu-latest - steps: - - - name: Checkout Code Repository - uses: actions/checkout@v4.1.1 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.9" - - - name: Run pre-commit - uses: pre-commit/action@v3.0.0 - - - sqlite: - runs-on: ubuntu-latest - strategy: - fail-fast: false - max-parallel: 10 - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] - - steps: - - uses: actions/checkout@v4.1.1 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install --upgrade tox tox-gh-actions - - - name: Test with tox - # Sometimes tox fails to build the package correctly and intermittently throws an OSError or BadZipFile error. - # Upon retry, it seems to work. - uses: nick-fields/retry@v2 - id: retry-sqlite - with: - timeout_minutes: 10 - max_attempts: 3 - retry_on: error - command: tox - env: - DBBACKEND: sqlite3 - DBNAME: ":memory:" - - - name: Upload coverage data - uses: actions/upload-artifact@v3 - with: - name: coverage-data - path: ".coverage.*" - - - mysql: - runs-on: ubuntu-latest - strategy: - fail-fast: false - max-parallel: 10 - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] - mariadb-version: ["10.4"] - - services: - database: - image: mariadb:${{ matrix.mariadb-version }} - env: - MYSQL_ROOT_PASSWORD: rootpw - MYSQL_DATABASE: test - ports: - - 3306:3306 - options: --tmpfs /var/lib/mysql - - steps: - - uses: actions/checkout@v4.1.1 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install --upgrade tox tox-gh-actions - - - name: Test with tox - # Sometimes tox fails to build the package correctly and intermittently throws an OSError or BadZipFile error. - # Upon retry, it seems to work. - uses: nick-fields/retry@v2 - id: retry-mysql - with: - timeout_minutes: 10 - max_attempts: 3 - retry_on: error - command: tox - env: - DBBACKEND: mysql - DBNAME: test - DBUSER: root - DBPASSWORD: rootpw - DBHOST: 127.0.0.1 - - - name: Upload coverage data - uses: actions/upload-artifact@v3 - with: - name: coverage-data - path: ".coverage.*" - - - coverage: - name: Check coverage. - runs-on: "ubuntu-latest" - needs: [sqlite, mysql] - steps: - - uses: actions/checkout@v4.1.1 - - uses: actions/setup-python@v4 - with: - # Use latest, so it understands all syntax. - python-version: "3.10" - - - run: python -m pip install --upgrade coverage[toml] django==3.2.16 django-coverage-plugin - - - name: Download coverage data. - uses: actions/download-artifact@v3 - with: - name: coverage-data - - - name: Combine coverage & check percentage - run: | - python -m coverage combine - python -m coverage xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} From 978a236ecc8dca3fbebc58b3c2358974ea314beb Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Wed, 1 Nov 2023 16:39:28 -0700 Subject: [PATCH 13/47] Try adding coverage to pyproject and CI --- .coveragerc | 8 ------- .github/workflows/ci_hatch.yml | 40 +++++++++++++++++++++++++++++++++- pyproject.toml | 36 +++++++++++++++++++++++++++--- 3 files changed, 72 insertions(+), 12 deletions(-) delete mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 440827e7..00000000 --- a/.coveragerc +++ /dev/null @@ -1,8 +0,0 @@ -[run] -plugins=django_coverage_plugin -source=anvil_consortium_manager -omit=anvil_consortium_manager/tests/integration/integration_tests_anvil_api.py - -[report] -exclude_lines = - @abstractproperty diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index ea1bddac..c6c80cdb 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -29,4 +29,42 @@ jobs: run: python -m pip install --upgrade hatch - name: Run Tests - run: hatch run +py=${{ matrix.python-version }} test:test + run: hatch run +py=${{ matrix.python-version }} test:cov + + - name: Upload coverage data + uses: actions/upload-artifact@v3 + with: + name: coverage-data + path: ".coverage.*" + + + coverage: + + + name: Check coverage. + runs-on: "ubuntu-latest" + needs: [test] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install hatch + run: python -m pip install --upgrade hatch + + - name: Download coverage data. + uses: actions/download-artifact@v3 + with: + name: coverage-data + + - name: Combine coverage & check percentage + run: hatch run cov-combine:combine + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml index 7c399f83..1a5888ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,11 @@ omit = ["*migrations*", "*tests*"] plugins = ["django_coverage_plugin"] +[tool.coverage.report] +exclude_lines = ["@abstractproperty"] + [tool.pytest.ini_options] +addopts = "--reuse-db --ignore=anvil_consortium_manager/tests/test_app --ds=anvil_consortium_manager.tests.settings.test" python_files = ["anvil_consortium_manager/tests/test*.py"] python_classes = ["!TestWorkspaceDataFactory"] @@ -95,12 +99,16 @@ dependencies = [ [tool.hatch.envs.default.scripts] dj = "python manage.py {args}" test = "hatch run +py=3.8 test:test {args}" -all = [ - "hatch run test:test", +cov = [ + "hatch run test:cov", + "hatch run cov-combine:combine", + "hatch run cov-combine:html", ] [tool.hatch.envs.test] dependencies = [ + # Coverage for django templates + "django-coverage-plugin", "django-debug-toolbar", # Process a .env file for environment variables "django-environ", @@ -119,8 +127,12 @@ dependencies = [ ] [tool.hatch.envs.test.scripts] test = [ - "pytest --ds=anvil_consortium_manager.tests.settings.test --reuse-db --ignore=anvil_consortium_manager/tests/test_app/ {args}" + "pytest {args}" +] +cov = [ + "coverage run -p -m pytest", ] + [[tool.hatch.envs.test.matrix]] python = ["3.8"] django = ["3.2", "4.2"] @@ -133,3 +145,21 @@ matrix.django.dependencies = [ { value = "django ~= 3.2.0", if = ["3.2"] }, { value = "django ~= 4.2.0", if = ["4.2"] }, ] +matrix.type.scripts = [ + { key = "with-coverage", value = "_coverage", if = ["default"] }, +] + +[tool.hatch.envs.cov-combine] +dependencies = [ + # Coverage for django templates + "django-coverage-plugin", + "coverage[toml]>=6.5" +] +[tool.hatch.envs.cov-combine.scripts] +combine = [ + # Clean up old files first. + "rm -f .coverage", + "coverage combine" +] +report = ["coverage report"] +html = ["coverage html"] From c62bc711da6d2dd1d625c05e227e3abe16a50e1b Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Wed, 1 Nov 2023 16:45:48 -0700 Subject: [PATCH 14/47] Try not removing the .coverage file before combining --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1a5888ed..7ca70c1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -158,7 +158,6 @@ dependencies = [ [tool.hatch.envs.cov-combine.scripts] combine = [ # Clean up old files first. - "rm -f .coverage", "coverage combine" ] report = ["coverage report"] From 7e9510993ddcb0b315634c242cc9f82df6c4a11c Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Wed, 1 Nov 2023 17:00:05 -0700 Subject: [PATCH 15/47] Skip install of the package when combining coverage --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 7ca70c1e..050aa410 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,6 +100,7 @@ dependencies = [ dj = "python manage.py {args}" test = "hatch run +py=3.8 test:test {args}" cov = [ + "rm -f .coverage.*", "hatch run test:cov", "hatch run cov-combine:combine", "hatch run cov-combine:html", @@ -150,14 +151,17 @@ matrix.type.scripts = [ ] [tool.hatch.envs.cov-combine] +skip-install = true dependencies = [ # Coverage for django templates "django-coverage-plugin", + "Django ~= 4.2", "coverage[toml]>=6.5" ] [tool.hatch.envs.cov-combine.scripts] combine = [ # Clean up old files first. + "rm -f .coverage", "coverage combine" ] report = ["coverage report"] From e6643e711ead2207fb8498a8baf29fadd3c60b14 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Wed, 1 Nov 2023 17:25:09 -0700 Subject: [PATCH 16/47] Fix default testing environment with hatch run test --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 050aa410..e01232eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,7 +98,7 @@ dependencies = [ ] [tool.hatch.envs.default.scripts] dj = "python manage.py {args}" -test = "hatch run +py=3.8 test:test {args}" +test = "hatch run +py=3.8 +django=4.2 test:test {args}" cov = [ "rm -f .coverage.*", "hatch run test:cov", From d63282310ded56bd6affaf71d872a11879012034 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 11:02:26 -0700 Subject: [PATCH 17/47] Run tests on mysql and sqlite3 In pyproject.toml, set env variables in hatch environments to specify whether we are using the MySQL or sqlite3 backend in tests. Note: one test is breaking when running in MySQL; need to look into this. Also, I expect CI to fail because I have not set up the MySQL/MariaDB service in the github action workflow yet. --- pyproject.toml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e01232eb..c882d57e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,6 +82,8 @@ addopts = "--reuse-db --ignore=anvil_consortium_manager/tests/test_app --ds=anvi python_files = ["anvil_consortium_manager/tests/test*.py"] python_classes = ["!TestWorkspaceDataFactory"] +# HATCH +# ------------------------------------------------------------------------------ [tool.hatch] [tool.hatch.version] @@ -98,7 +100,7 @@ dependencies = [ ] [tool.hatch.envs.default.scripts] dj = "python manage.py {args}" -test = "hatch run +py=3.8 +django=4.2 test:test {args}" +test = "hatch run -e py3.8-4.2 test:test {args}" cov = [ "rm -f .coverage.*", "hatch run test:cov", @@ -133,22 +135,35 @@ test = [ cov = [ "coverage run -p -m pytest", ] +printenv = [ + "echo DBBACKEND=$DBBACKEND", + "echo DBNAME=$DBNAME" +] [[tool.hatch.envs.test.matrix]] python = ["3.8"] django = ["3.2", "4.2"] +backend = ["sqlite3", "mysql"] [[tool.hatch.envs.test.matrix]] python = ["3.11"] django = ["4.2"] +backend = ["sqlite3", "mysql"] [tool.hatch.envs.test.overrides] matrix.django.dependencies = [ { value = "django ~= 3.2.0", if = ["3.2"] }, { value = "django ~= 4.2.0", if = ["4.2"] }, ] -matrix.type.scripts = [ - { key = "with-coverage", value = "_coverage", if = ["default"] }, +# Specify additional dependency for mysql tests. +matrix.backend.dependencies = [ + { value = "mysqlclient", if = ["mysql"] }, +] +# Set environment variables for testing using sqlite vs. mariadb. +name."sqlite3".env-vars = [ + "DBBACKEND=sqlite3", + "DBNAME=:memory:", ] +name."mysql".env-vars = "DBBACKEND=mysql" [tool.hatch.envs.cov-combine] skip-install = true From e1bf7effd33684351761e7aad814bffe406fac3a Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 11:38:40 -0700 Subject: [PATCH 18/47] Parallelize CI by hatch environment This will fail for a couple reasons: - no mariadb service yet - not all matrix options exist - mysql tests are failing --- .github/workflows/ci_hatch.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index c6c80cdb..7aaa354d 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -15,6 +15,8 @@ jobs: fail-fast: false matrix: python-version: ["3.8", "3.11"] + django: ["3.2", "4.2"] + backend: ["sqlite3", "mysql"] runs-on: ubuntu-latest steps: @@ -28,8 +30,8 @@ jobs: - name: Install hatch run: python -m pip install --upgrade hatch - - name: Run Tests - run: hatch run +py=${{ matrix.python-version }} test:cov + - name: Run Tests (${{ matrix.python-version }}, ${{ matrix.django-version }}, ${{ matrix.python-backend }}) + run: hatch run test.py${{ matrix.python-version }}-${{ matrix.django-version }}-${{ matrix.python-backend }}:cov - name: Upload coverage data uses: actions/upload-artifact@v3 From 1379d25562446cd796096b81cb3318ec48991f69 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 11:40:40 -0700 Subject: [PATCH 19/47] Fix matrix variable name in CI CI will still break for the previous reasons --- .github/workflows/ci_hatch.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index 7aaa354d..b9875699 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -30,8 +30,8 @@ jobs: - name: Install hatch run: python -m pip install --upgrade hatch - - name: Run Tests (${{ matrix.python-version }}, ${{ matrix.django-version }}, ${{ matrix.python-backend }}) - run: hatch run test.py${{ matrix.python-version }}-${{ matrix.django-version }}-${{ matrix.python-backend }}:cov + - name: Run Tests (${{ matrix.python-version }}, ${{ matrix.django-version }}, ${{ matrix.backend }}) + run: hatch run test.py${{ matrix.python-version }}-${{ matrix.django-version }}-${{ matrix.backend }}:cov - name: Upload coverage data uses: actions/upload-artifact@v3 From ef47d94f82bd3fe2b11bca0cc56823e2968cf0a1 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 11:41:54 -0700 Subject: [PATCH 20/47] Fix django CI variable this time --- .github/workflows/ci_hatch.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index b9875699..e39ab655 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false matrix: python-version: ["3.8", "3.11"] - django: ["3.2", "4.2"] + django-version: ["3.2", "4.2"] backend: ["sqlite3", "mysql"] runs-on: ubuntu-latest @@ -30,7 +30,7 @@ jobs: - name: Install hatch run: python -m pip install --upgrade hatch - - name: Run Tests (${{ matrix.python-version }}, ${{ matrix.django-version }}, ${{ matrix.backend }}) + - name: Run Tests (py${{ matrix.python-version }}, dj${{ matrix.django-version }}, ${{ matrix.backend }}) run: hatch run test.py${{ matrix.python-version }}-${{ matrix.django-version }}-${{ matrix.backend }}:cov - name: Upload coverage data From 466bd75f03d8c7a484f3573cb82a917d9eafb2d4 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 11:48:01 -0700 Subject: [PATCH 21/47] Add concurrency check to hatch tests --- .github/workflows/ci_hatch.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index e39ab655..58965179 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -1,4 +1,4 @@ -name: Run tests with hatch +name: hatch-tests on: pull_request: @@ -9,6 +9,10 @@ on: branches: [ "master", "main" ] paths-ignore: [ "docs/**" ] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: test: strategy: From fb7eb2321abd54c1841227e74faa1d56259c853e Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 15:08:43 -0700 Subject: [PATCH 22/47] Specify overriden SITE_ID setting differently in tests One test was failing in only mysql when run with pytest, but not with unittest/manage.py test. This failure happened because the pytest settings are to reuse the database between tests; in mysql, that means that the autoincrement value for id columns is not reset between tests. Therefore, hard coding SITE_ID=2 in the tests caused the second test overriding SITE_ID to fail, since the new site created in the second test had an id of 3. Change this to setting the SITE_ID setting using a context manager to the value of the of the site that was just created instead of using the override_settings decorator. Now they pass! --- .../tests/test_commands.py | 38 +++++++++---------- anvil_consortium_manager/tests/test_views.py | 36 +++++++++--------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/anvil_consortium_manager/tests/test_commands.py b/anvil_consortium_manager/tests/test_commands.py index 73dccd78..9358ccd9 100644 --- a/anvil_consortium_manager/tests/test_commands.py +++ b/anvil_consortium_manager/tests/test_commands.py @@ -222,29 +222,29 @@ def test_command_run_audit_not_ok_email_has_html_link(self): ) self.assertInHTML(html_fragment, email.alternatives[0][0]) - @override_settings(SITE_ID=2) def test_command_run_audit_not_ok_email_has_html_link_different_domain(self): """Test command output when BillingProject audit is not ok with email specified.""" site = Site.objects.create(domain="foobar.com", name="test") site.save() - billing_project = factories.BillingProjectFactory.create() - # Add a response. - api_url = self.get_api_url_billing_project(billing_project.name) - self.anvil_response_mock.add(responses.GET, api_url, status=404, json={"message": "error"}) - out = StringIO() - call_command( - "run_anvil_audit", - "--no-color", - models=["BillingProject"], - email="test@example.com", - stdout=out, - ) - email = mail.outbox[0] - self.assertEqual(len(email.alternatives), 1) - html_fragment = """{obj}""".format( - obj=str(billing_project), url=billing_project.get_absolute_url() - ) - self.assertInHTML(html_fragment, email.alternatives[0][0]) + with self.settings(SITE_ID=site.id): + billing_project = factories.BillingProjectFactory.create() + # Add a response. + api_url = self.get_api_url_billing_project(billing_project.name) + self.anvil_response_mock.add(responses.GET, api_url, status=404, json={"message": "error"}) + out = StringIO() + call_command( + "run_anvil_audit", + "--no-color", + models=["BillingProject"], + email="test@example.com", + stdout=out, + ) + email = mail.outbox[0] + self.assertEqual(len(email.alternatives), 1) + html_fragment = """{obj}""".format( + obj=str(billing_project), url=billing_project.get_absolute_url() + ) + self.assertInHTML(html_fragment, email.alternatives[0][0]) def test_command_run_audit_api_error(self): """Test command output when BillingProject audit is not ok.""" diff --git a/anvil_consortium_manager/tests/test_views.py b/anvil_consortium_manager/tests/test_views.py index 091ad4b8..2a795f20 100644 --- a/anvil_consortium_manager/tests/test_views.py +++ b/anvil_consortium_manager/tests/test_views.py @@ -2043,29 +2043,29 @@ def test_email_is_sent(self): # The body contains the correct url. self.assertIn(url, mail.outbox[0].body) - @override_settings(SITE_ID=2) @freeze_time("2022-11-22 03:12:34") def test_email_is_sent_site_domain(self): """An email is sent when the form is submitted correctly.""" site = Site.objects.create(domain="foobar.com", name="test") site.save() - email = "test@example.com" - api_url = self.get_api_url(email) - self.anvil_response_mock.add(responses.GET, api_url, status=200, json=self.get_api_json_response(email)) - # Need a client because messages are added. - self.client.force_login(self.user) - self.client.post(self.get_url(), {"email": email}) - email_entry = models.UserEmailEntry.objects.get(email=email) - # One message has been sent. - self.assertEqual(len(mail.outbox), 1) - # The subject is correct. - self.assertEqual(mail.outbox[0].subject, "account activation") - url = "http://foobar.com" + reverse( - "anvil_consortium_manager:accounts:verify", - args=[email_entry.uuid, account_verification_token.make_token(email_entry)], - ) - # The body contains the correct url. - self.assertIn(url, mail.outbox[0].body) + with self.settings(SITE_ID=site.id): + email = "test@example.com" + api_url = self.get_api_url(email) + self.anvil_response_mock.add(responses.GET, api_url, status=200, json=self.get_api_json_response(email)) + # Need a client because messages are added. + self.client.force_login(self.user) + self.client.post(self.get_url(), {"email": email}) + email_entry = models.UserEmailEntry.objects.get(email=email) + # One message has been sent. + self.assertEqual(len(mail.outbox), 1) + # The subject is correct. + self.assertEqual(mail.outbox[0].subject, "account activation") + url = "http://foobar.com" + reverse( + "anvil_consortium_manager:accounts:verify", + args=[email_entry.uuid, account_verification_token.make_token(email_entry)], + ) + # The body contains the correct url. + self.assertIn(url, mail.outbox[0].body) def test_get_user_already_linked_to_an_existing_verified_account(self): """View redirects with a message when the user already has an AnVIL account linked.""" From 2458cbe7eed171dd860633e4bb9f29ac245cdc51 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 15:11:25 -0700 Subject: [PATCH 23/47] Read from the .env file in test settings This lets me set DBHOST to localhost locally, and to 127.0.0.1 in CI. --- .../tests/settings/test.py | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/anvil_consortium_manager/tests/settings/test.py b/anvil_consortium_manager/tests/settings/test.py index 6ed4ac80..382a457a 100644 --- a/anvil_consortium_manager/tests/settings/test.py +++ b/anvil_consortium_manager/tests/settings/test.py @@ -2,9 +2,19 @@ Base test settings file. """ import os +from pathlib import Path + +import environ from django import VERSION as DJANGO_VERSION +ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent.parent.parent + +# Optionally read environment variables from a .env file. +env = environ.Env() +if os.path.exists(str(ROOT_DIR / ".env")): + env.read_env(str(ROOT_DIR / ".env")) + # GENERAL # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#debug @@ -30,12 +40,12 @@ DATABASES = { "default": { - "ENGINE": "django.db.backends.{}".format(os.getenv("DBBACKEND", default="sqlite3")), - "NAME": os.getenv("DBNAME", default="anvil_consortium_manager"), - "USER": os.getenv("DBUSER", default="django"), - "PASSWORD": os.getenv("DBPASSWORD", default="password"), - "HOST": os.getenv("DBHOST", default="127.0.0.1"), - "PORT": os.getenv("DBPORT", default="3306"), + "ENGINE": "django.db.backends.{}".format(env("DBBACKEND", default="sqlite3")), + "NAME": env("DBNAME", default="anvil_consortium_manager"), + "USER": env("DBUSER", default="django"), + "PASSWORD": env("DBPASSWORD", default="password"), + "HOST": env("DBHOST", default="127.0.0.1"), + "PORT": env("DBPORT", default="3306"), } } From 119bb22830cef5b94b1ae18d7d9e1e9d5f7733e4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 2 Nov 2023 22:12:56 +0000 Subject: [PATCH 24/47] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- anvil_consortium_manager/tests/settings/test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/anvil_consortium_manager/tests/settings/test.py b/anvil_consortium_manager/tests/settings/test.py index 382a457a..3647c92b 100644 --- a/anvil_consortium_manager/tests/settings/test.py +++ b/anvil_consortium_manager/tests/settings/test.py @@ -5,7 +5,6 @@ from pathlib import Path import environ - from django import VERSION as DJANGO_VERSION ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent.parent.parent From 237f0f0813e45de89c6de20eb47bc6a51888eff3 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 15:15:42 -0700 Subject: [PATCH 25/47] Remove concurrency from ci --- .github/workflows/ci_hatch.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index 58965179..47f84017 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -9,9 +9,6 @@ on: branches: [ "master", "main" ] paths-ignore: [ "docs/**" ] -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true jobs: test: From 3255b074b2751620708d3478f84e082a4600e188 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 15:26:15 -0700 Subject: [PATCH 26/47] Add max failures option to pytest --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c882d57e..31bae869 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,7 +78,7 @@ plugins = ["django_coverage_plugin"] exclude_lines = ["@abstractproperty"] [tool.pytest.ini_options] -addopts = "--reuse-db --ignore=anvil_consortium_manager/tests/test_app --ds=anvil_consortium_manager.tests.settings.test" +addopts = "--maxfail=10 --reuse-db --ignore=anvil_consortium_manager/tests/test_app --ds=anvil_consortium_manager.tests.settings.test" python_files = ["anvil_consortium_manager/tests/test*.py"] python_classes = ["!TestWorkspaceDataFactory"] From 32a0797c6b77c3831695d3adc131bddad1af8722 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 15:56:52 -0700 Subject: [PATCH 27/47] Move pytest max failures to CI Instead of hardcoding the max failures for pytest in pyproject.toml, put it as an environment variable in the CI. This will stop CI after too many failures, but will still allow all the tests to be run locally. --- .github/workflows/ci_hatch.yml | 2 ++ pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index 47f84017..3863b899 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -19,6 +19,8 @@ jobs: django-version: ["3.2", "4.2"] backend: ["sqlite3", "mysql"] runs-on: ubuntu-latest + env: + PYTEST_ADDOPTS: "--maxfail=20" # Stop testing after too many failures. steps: - uses: actions/checkout@v4 diff --git a/pyproject.toml b/pyproject.toml index 31bae869..c882d57e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,7 +78,7 @@ plugins = ["django_coverage_plugin"] exclude_lines = ["@abstractproperty"] [tool.pytest.ini_options] -addopts = "--maxfail=10 --reuse-db --ignore=anvil_consortium_manager/tests/test_app --ds=anvil_consortium_manager.tests.settings.test" +addopts = "--reuse-db --ignore=anvil_consortium_manager/tests/test_app --ds=anvil_consortium_manager.tests.settings.test" python_files = ["anvil_consortium_manager/tests/test*.py"] python_classes = ["!TestWorkspaceDataFactory"] From 6fe03e0b40dae546dbdc9ab2f70cffe15b31bbaa Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 16:21:24 -0700 Subject: [PATCH 28/47] Add a mysql service to CI --- .github/workflows/ci_hatch.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index 3863b899..c6215e4f 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -22,6 +22,17 @@ jobs: env: PYTEST_ADDOPTS: "--maxfail=20" # Stop testing after too many failures. + services: + database: + image: mariadb:10.4 + env: + MYSQL_ROOT_PASSWORD: rootpw + MYSQL_DATABASE: test + + ports: + - 3306:3306 + options: --tmpfs /var/lib/mysql + steps: - uses: actions/checkout@v4 @@ -33,6 +44,14 @@ jobs: - name: Install hatch run: python -m pip install --upgrade hatch + - name: Set environment variables for mysql + if: ${{ matrix.backend == "mysql" }} + run: | + echo "DBNAME=test" >> $GITHUB_ENV + echo "DBUSER=root" >> $GITHUB_ENV + echo "DBPASSWORD=rootpw" >> $GITHUB_ENV + echo "DBHOST=127.0.0.1" >> $GITHUB_ENV + - name: Run Tests (py${{ matrix.python-version }}, dj${{ matrix.django-version }}, ${{ matrix.backend }}) run: hatch run test.py${{ matrix.python-version }}-${{ matrix.django-version }}-${{ matrix.backend }}:cov From fc900160d290032264bc90fc608ef079d8e5b2a3 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 16:23:41 -0700 Subject: [PATCH 29/47] Fix flake8 error --- anvil_consortium_manager/tests/test_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anvil_consortium_manager/tests/test_commands.py b/anvil_consortium_manager/tests/test_commands.py index 9358ccd9..48125ba6 100644 --- a/anvil_consortium_manager/tests/test_commands.py +++ b/anvil_consortium_manager/tests/test_commands.py @@ -8,7 +8,7 @@ from django.contrib.sites.models import Site from django.core import mail from django.core.management import CommandError, call_command -from django.test import TestCase, override_settings +from django.test import TestCase from ..audit import audit from ..management.commands.run_anvil_audit import ErrorTableWithLink From 750dc60bf2fe8782a4bbc1ea4e03147a53b7e5e0 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 16:33:20 -0700 Subject: [PATCH 30/47] Try fixing if statement in CI --- .github/workflows/ci_hatch.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index c6215e4f..e972d0ea 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -44,8 +44,8 @@ jobs: - name: Install hatch run: python -m pip install --upgrade hatch - - name: Set environment variables for mysql - if: ${{ matrix.backend == "mysql" }} + - name: Set environment variables + if: ${{ matrix.backend == 'mysql' }} run: | echo "DBNAME=test" >> $GITHUB_ENV echo "DBUSER=root" >> $GITHUB_ENV From d5ac8d0df7dc812fde3fee6ae94833d79a41c210 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 16:46:35 -0700 Subject: [PATCH 31/47] Only define one matrix block for both test envs This plays more nicely with the github actions for now. --- pyproject.toml | 52 +++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c882d57e..e4615353 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -107,6 +107,10 @@ cov = [ "hatch run cov-combine:combine", "hatch run cov-combine:html", ] +printenv = [ + "echo DBBACKEND=$DBBACKEND", + "echo DBNAME=$DBNAME" +] [tool.hatch.envs.test] dependencies = [ @@ -123,6 +127,8 @@ dependencies = [ "factory-boy", # Set the system time in tests "freezegun", # https://github.com/spulec/freezegun + # For interactive debugging if necessary. + "ipdb", "pytest >= 6.0", "pytest-django", # Mocked responses in tests @@ -135,35 +141,37 @@ test = [ cov = [ "coverage run -p -m pytest", ] -printenv = [ - "echo DBBACKEND=$DBBACKEND", - "echo DBNAME=$DBNAME" -] -[[tool.hatch.envs.test.matrix]] -python = ["3.8"] +[tool.hatch.envs.test-sqlite] +template = "test" +[tool.hatch.envs.test-sqlite.env-vars] +DBBACKEND = "sqlite3" +DBNAME = ":memory:" +[[tool.hatch.envs.test-sqlite.matrix]] +python = ["3.8", "3.11"] django = ["3.2", "4.2"] -backend = ["sqlite3", "mysql"] -[[tool.hatch.envs.test.matrix]] -python = ["3.11"] -django = ["4.2"] -backend = ["sqlite3", "mysql"] - -[tool.hatch.envs.test.overrides] -matrix.django.dependencies = [ +[tool.hatch.envs.test-sqlite.overrides] +matrix.django.extra-dependencies = [ { value = "django ~= 3.2.0", if = ["3.2"] }, { value = "django ~= 4.2.0", if = ["4.2"] }, ] -# Specify additional dependency for mysql tests. -matrix.backend.dependencies = [ - { value = "mysqlclient", if = ["mysql"] }, + +[tool.hatch.envs.test-mysql] +template = "test" +extra-dependencies = [ + "mysqlclient" ] -# Set environment variables for testing using sqlite vs. mariadb. -name."sqlite3".env-vars = [ - "DBBACKEND=sqlite3", - "DBNAME=:memory:", +[tool.hatch.envs.test-mysql.env-vars] +DBBACKEND = "mysql" +[[tool.hatch.envs.test-mysql.matrix]] +python = ["3.8", "3.11"] +django = ["3.2", "4.2"] +[tool.hatch.envs.test-mysql.overrides] +matrix.django.extra-dependencies = [ + { value = "django ~= 3.2.0", if = ["3.2"] }, + { value = "django ~= 4.2.0", if = ["4.2"] }, ] -name."mysql".env-vars = "DBBACKEND=mysql" + [tool.hatch.envs.cov-combine] skip-install = true From aecca9df16f2afc4a09ec72f7cbdec35d63bfe46 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 16:48:46 -0700 Subject: [PATCH 32/47] Change CI to match new hatch environments --- .github/workflows/ci_hatch.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index e972d0ea..dfd67ca5 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -52,8 +52,8 @@ jobs: echo "DBPASSWORD=rootpw" >> $GITHUB_ENV echo "DBHOST=127.0.0.1" >> $GITHUB_ENV - - name: Run Tests (py${{ matrix.python-version }}, dj${{ matrix.django-version }}, ${{ matrix.backend }}) - run: hatch run test.py${{ matrix.python-version }}-${{ matrix.django-version }}-${{ matrix.backend }}:cov + - name: Run Tests (test-${{ matrix.backend }}.py${{ matrix.python-version }}-${{ matrix.django-version }}) + run: hatch run test-${{ matrix.backend }}.py${{ matrix.python-version }}-${{ matrix.django-version }}:cov - name: Upload coverage data uses: actions/upload-artifact@v3 From 9a0c921222d5c407ed00f0737c39db901ade0aee Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 2 Nov 2023 16:50:48 -0700 Subject: [PATCH 33/47] Fix sqlite backend string in CI to match hatch --- .github/workflows/ci_hatch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index dfd67ca5..dcc0b1bf 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -17,7 +17,7 @@ jobs: matrix: python-version: ["3.8", "3.11"] django-version: ["3.2", "4.2"] - backend: ["sqlite3", "mysql"] + backend: ["sqlite", "mysql"] runs-on: ubuntu-latest env: PYTEST_ADDOPTS: "--maxfail=20" # Stop testing after too many failures. From 84572b14dbfc06dece7074bd863aa44e2a2c73be Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Fri, 3 Nov 2023 09:33:56 -0700 Subject: [PATCH 34/47] Fix default env commands for new structure --- pyproject.toml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e4615353..6f83067c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,10 +100,11 @@ dependencies = [ ] [tool.hatch.envs.default.scripts] dj = "python manage.py {args}" -test = "hatch run -e py3.8-4.2 test:test {args}" -cov = [ +tests = "hatch run test-sqlite.py3.11-4.2:test {args}" +all = [ "rm -f .coverage.*", - "hatch run test:cov", + "hatch run test-sqlite:cov", + "hatch run test-mysql:cov", "hatch run cov-combine:combine", "hatch run cov-combine:html", ] @@ -112,7 +113,7 @@ printenv = [ "echo DBNAME=$DBNAME" ] -[tool.hatch.envs.test] +[tool.hatch.envs.testing] dependencies = [ # Coverage for django templates "django-coverage-plugin", @@ -134,7 +135,7 @@ dependencies = [ # Mocked responses in tests "responses", # https://github.com/getsentry/responses ] -[tool.hatch.envs.test.scripts] +[tool.hatch.envs.testing.scripts] test = [ "pytest {args}" ] @@ -143,7 +144,7 @@ cov = [ ] [tool.hatch.envs.test-sqlite] -template = "test" +template = "testing" [tool.hatch.envs.test-sqlite.env-vars] DBBACKEND = "sqlite3" DBNAME = ":memory:" @@ -157,7 +158,7 @@ matrix.django.extra-dependencies = [ ] [tool.hatch.envs.test-mysql] -template = "test" +template = "testing" extra-dependencies = [ "mysqlclient" ] From f3ddcee03e12a3ae1597f535fb01e2691ba7a6b2 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Fri, 3 Nov 2023 09:35:54 -0700 Subject: [PATCH 35/47] Add linting to hatch environments and scripts --- pyproject.toml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 6f83067c..a1b6d231 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -102,6 +102,7 @@ dependencies = [ dj = "python manage.py {args}" tests = "hatch run test-sqlite.py3.11-4.2:test {args}" all = [ + "hatch run lint:run", "rm -f .coverage.*", "hatch run test-sqlite:cov", "hatch run test-mysql:cov", @@ -112,6 +113,7 @@ printenv = [ "echo DBBACKEND=$DBBACKEND", "echo DBNAME=$DBNAME" ] +lint = "hatch run lint:run" [tool.hatch.envs.testing] dependencies = [ @@ -190,3 +192,13 @@ combine = [ ] report = ["coverage report"] html = ["coverage html"] + + +[tool.hatch.envs.lint] +detached = true +python = "3.11" +dependencies = [ + "pre-commit" +] +[tool.hatch.envs.lint.scripts] +run = "pre-commit run --all-files" From bcabe7819154e1203224dcdd0df53d322fa237f3 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Fri, 3 Nov 2023 09:49:17 -0700 Subject: [PATCH 36/47] Add precommit and ipdb to default shell --- pyproject.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a1b6d231..618b2e38 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -96,7 +96,9 @@ dependencies = [ # Process a .env file for environment variables "django-environ", # Interactive debugging - # "ipdb", + "ipdb", + # Pre-commit hooks + "pre-commit", ] [tool.hatch.envs.default.scripts] dj = "python manage.py {args}" From 9337ec87dea2b2f0072b21455705d1b8689fe686 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Fri, 3 Nov 2023 13:56:43 -0700 Subject: [PATCH 37/47] Update README to use hatch commands --- README.md | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index a91cea48..4a80b13a 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,7 @@ $ git clone git@github.com:UW-GAC/django-anvil-consortium-manager.git 2. Set up the environment: ``` -$ python -m venv venv -$ source venv/bin/activate -$ pip install -r requirements/dev.txt +$ hatch env create ``` 3. Ask Ben to make a service account and register it with AnVIL. @@ -40,39 +38,27 @@ You can also create a .env file to store environment variables. 5. Run the example site: ``` -$ python manage.py migrate -$ python manage.py createsuperuser -$ python manage.py runserver +hatch shell +python manage.py migrate +python manage.py createsuperuser +python manage.py runserver ``` ### Tests -#### Using pytest +To run quick tests: ``` -$ pytest +hatch run test ``` -#### Using manage.py -``` -$ python manage.py test --settings=anvil_consortium_manager.tests.settings.test -``` - -#### Using tox - -Running tox will test the code using both the sqlite and the MariaDB backend. +To run the full set of tests using different python versions, different django versions, and different backends, run: ``` -$ tox +hatch run all ``` -#### Test coverage - -To run the tests, check your test coverage, and generate an HTML coverage report: - - $ coverage run ./manage.py test anvil_consortium_manager --settings=anvil_consortium_manager.tests.settings.test - $ coverage html - $ open htmlcov/index.html +This will also run test coverage and create an html report to view. ### Maria DB setup @@ -135,14 +121,10 @@ GRANT ALL PRIVILEGES ON test_anvil_consortium_manager.* TO django@127.0.0.1; To run tests using MariaDB as the backend, run: ``` -./manage.py test anvil_consortium_manager --settings=anvil_consortium_manager.tests.settings.test_mariadb -``` - -``` -pytest --ds=anvil_consortium_manager.tests.settings.test_mariadb +hatch run test-mysql.py3.11-4.2:test ``` -If you run into errors with `mysqclient>=2.2`, you will need to set some environment variables before installing mysqlclient: +If you run into errors with `mysqclient>=2.2`, you may need to set some environment variables before installing mysqlclient: ``` export PKG_CONFIG_PATH="/opt/local/lib/mariadb-10.5/pkgconfig/" From 732ac15a4631ff33188af8bf6569bce0f9b843d1 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Fri, 3 Nov 2023 14:03:33 -0700 Subject: [PATCH 38/47] Set python version explicitly for code coverage job --- .github/workflows/ci_hatch.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index dcc0b1bf..28a0c2fc 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -72,10 +72,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python-version }} + python-version: "3.11" - name: Install hatch run: python -m pip install --upgrade hatch From bd6ee5fb87280878d94788d7c81336cdf64e851e Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Fri, 3 Nov 2023 14:10:43 -0700 Subject: [PATCH 39/47] Try adding a name to the testing job --- .github/workflows/ci_hatch.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index 28a0c2fc..11bbf847 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -12,6 +12,7 @@ on: jobs: test: + name: "Test (test-${{ matrix.backend }}.py${{ matrix.python-version }}-${{ matrix.django-version }})" strategy: fail-fast: false matrix: From b955f6199b0490f039edbfea37055ac93465ce1a Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Fri, 3 Nov 2023 14:19:08 -0700 Subject: [PATCH 40/47] Set a test env variable for reuse throughout the CI action --- .github/workflows/ci_hatch.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index 11bbf847..59feeaa7 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -12,7 +12,7 @@ on: jobs: test: - name: "Test (test-${{ matrix.backend }}.py${{ matrix.python-version }}-${{ matrix.django-version }})" + name: "Test ($TEST_ENV)" strategy: fail-fast: false matrix: @@ -22,6 +22,7 @@ jobs: runs-on: ubuntu-latest env: PYTEST_ADDOPTS: "--maxfail=20" # Stop testing after too many failures. + TEST_ENV: "test-${{ matrix.backend }}.py${{ matrix.python-version }}-${{ matrix.django-version }}" services: database: @@ -53,8 +54,8 @@ jobs: echo "DBPASSWORD=rootpw" >> $GITHUB_ENV echo "DBHOST=127.0.0.1" >> $GITHUB_ENV - - name: Run Tests (test-${{ matrix.backend }}.py${{ matrix.python-version }}-${{ matrix.django-version }}) - run: hatch run test-${{ matrix.backend }}.py${{ matrix.python-version }}-${{ matrix.django-version }}:cov + - name: Run Tests ($TEST_ENV) + run: hatch run $TEST_ENV:cov - name: Upload coverage data uses: actions/upload-artifact@v3 From 4b85c4641116cce3b63acf43b183789ce6e2ce3a Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Fri, 3 Nov 2023 14:28:21 -0700 Subject: [PATCH 41/47] Remove env variable from job names --- .github/workflows/ci_hatch.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index 59feeaa7..776f964e 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -12,7 +12,6 @@ on: jobs: test: - name: "Test ($TEST_ENV)" strategy: fail-fast: false matrix: @@ -54,7 +53,7 @@ jobs: echo "DBPASSWORD=rootpw" >> $GITHUB_ENV echo "DBHOST=127.0.0.1" >> $GITHUB_ENV - - name: Run Tests ($TEST_ENV) + - name: Run Tests run: hatch run $TEST_ENV:cov - name: Upload coverage data From db3b03154eba834b7e18115438d35c41f941f311 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Fri, 3 Nov 2023 14:34:14 -0700 Subject: [PATCH 42/47] Rename file to match previous CI name --- .github/workflows/{ci_hatch.yml => ci.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{ci_hatch.yml => ci.yml} (100%) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci.yml similarity index 100% rename from .github/workflows/ci_hatch.yml rename to .github/workflows/ci.yml From 63269e35159f5fc007cc7c6e29f121d19e737a01 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Fri, 3 Nov 2023 14:55:27 -0700 Subject: [PATCH 43/47] Add linting to CI --- .github/workflows/ci_hatch.yml | 111 +++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 .github/workflows/ci_hatch.yml diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml new file mode 100644 index 00000000..bd5c5394 --- /dev/null +++ b/.github/workflows/ci_hatch.yml @@ -0,0 +1,111 @@ +name: hatch-tests + +on: + pull_request: + branches: [ "master", "main" ] + paths-ignore: [ "docs/**" ] + + push: + branches: [ "master", "main" ] + paths-ignore: [ "docs/**" ] + + +jobs: + + linter: + runs-on: ubuntu-latest + steps: + + - name: Checkout Code Repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Run pre-commit + uses: pre-commit/action@v3 + + test: + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.11"] + django-version: ["3.2", "4.2"] + backend: ["sqlite", "mysql"] + runs-on: ubuntu-latest + env: + PYTEST_ADDOPTS: "--maxfail=20" # Stop testing after too many failures. + TEST_ENV: "test-${{ matrix.backend }}.py${{ matrix.python-version }}-${{ matrix.django-version }}" + + services: + database: + image: mariadb:10.4 + env: + MYSQL_ROOT_PASSWORD: rootpw + MYSQL_DATABASE: test + + ports: + - 3306:3306 + options: --tmpfs /var/lib/mysql + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install hatch + run: python -m pip install --upgrade hatch + + - name: Set environment variables + if: ${{ matrix.backend == 'mysql' }} + run: | + echo "DBNAME=test" >> $GITHUB_ENV + echo "DBUSER=root" >> $GITHUB_ENV + echo "DBPASSWORD=rootpw" >> $GITHUB_ENV + echo "DBHOST=127.0.0.1" >> $GITHUB_ENV + + - name: Run Tests + run: hatch run $TEST_ENV:cov + + - name: Upload coverage data + uses: actions/upload-artifact@v3 + with: + name: coverage-data + path: ".coverage.*" + + + coverage: + + + name: Check coverage. + runs-on: "ubuntu-latest" + needs: [test] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Install hatch + run: python -m pip install --upgrade hatch + + - name: Download coverage data. + uses: actions/download-artifact@v3 + with: + name: coverage-data + + - name: Combine coverage & check percentage + run: hatch run cov-combine:combine + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} From b5957a486dc78ab600b8494fc29cf7dae364fba6 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Fri, 3 Nov 2023 14:56:00 -0700 Subject: [PATCH 44/47] Remove linting from CI Unnecessary because we're using the pre-commit.ci bot instead. --- .github/workflows/ci_hatch.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index bd5c5394..a84fff3c 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -12,21 +12,6 @@ on: jobs: - linter: - runs-on: ubuntu-latest - steps: - - - name: Checkout Code Repository - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.11" - - - name: Run pre-commit - uses: pre-commit/action@v3 - test: strategy: fail-fast: false From cc6eaae2329a852f8a351add31ce118f4b5a65e2 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Fri, 3 Nov 2023 15:03:01 -0700 Subject: [PATCH 45/47] Bump version number and update CHANGELOG --- CHANGELOG.md | 1 + anvil_consortium_manager/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92f554a8..61f2f6c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Devel * Switch to using `pyproject.toml` where possible. +* Use hatch for backend building. ## 0.19 (2023-10-27) diff --git a/anvil_consortium_manager/__init__.py b/anvil_consortium_manager/__init__.py index 887278f1..fbdbdf7d 100644 --- a/anvil_consortium_manager/__init__.py +++ b/anvil_consortium_manager/__init__.py @@ -1 +1 @@ -__version__ = "0.20dev1" +__version__ = "0.20.dev2" From 1ce9f7a80b5565b077603cbbff1293a00033b3ed Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Fri, 3 Nov 2023 15:05:22 -0700 Subject: [PATCH 46/47] Remove requirements files Now managed through hatch --- requirements/base.txt | 24 ------------------- requirements/dev.txt | 55 ------------------------------------------- 2 files changed, 79 deletions(-) delete mode 100644 requirements/base.txt delete mode 100644 requirements/dev.txt diff --git a/requirements/base.txt b/requirements/base.txt deleted file mode 100644 index 04400b47..00000000 --- a/requirements/base.txt +++ /dev/null @@ -1,24 +0,0 @@ -pytz==2023.3 # https://github.com/stub42/pytz -django==3.2.12 # pyup: < 4.0 # https://www.djangoproject.com/ - -crispy-bootstrap5==0.7 # https://github.com/django-crispy-forms/crispy-bootstrap5 -django-crispy-forms==2.0 # https://github.com/django-crispy-forms/django-crispy-forms -django-extensions==3.2.3 # https://github.com/django-extensions/django-extensions -django-tables2==2.6.0 -django-filter==23.2 -google-auth==2.16.0 -fontawesomefree==6.1.1 - -# Model history tracking. -django-simple-history==3.3.0 # https://github.com/jazzband/django-simple-history - -# Autocomplete -django-autocomplete-light==3.9.7 # https://github.com/yourlabs/django-autocomplete-light - -# Managed Group graph visualization -plotly==5.14.1 -networkx==3.1 -numpy==1.26.1 - -# Requests -requests==2.31.0 diff --git a/requirements/dev.txt b/requirements/dev.txt deleted file mode 100644 index eba16753..00000000 --- a/requirements/dev.txt +++ /dev/null @@ -1,55 +0,0 @@ --r base.txt - -# Werkzeug[watchdog]==2.0.3 # https://github.com/pallets/werkzeug -ipdb==0.13.13 # https://github.com/gotcha/ipdb - -# Testing -# ------------------------------------------------------------------------------ -mypy==0.991 # https://github.com/python/mypy -django-stubs==1.9.0 # https://github.com/typeddjango/django-stubs -pytest==7.2.1 # https://github.com/pytest-dev/pytest -pytest-sugar==0.9.7 # https://github.com/Frozenball/pytest-sugar -freezegun==1.2.2 # https://github.com/spulec/freezegun - Fixing the time in tests. -tox==4.4.2 - -# Documentation -# ------------------------------------------------------------------------------ -sphinx==4.4.0 # https://github.com/sphinx-doc/sphinx -sphinx-autobuild==2021.3.14 # https://github.com/GaretJax/sphinx-autobuild -sphinx-rtd-theme==1.2.1 # sphinx docs theme - -# Code quality -# ------------------------------------------------------------------------------ -flake8==6.1.0 # https://github.com/PyCQA/flake8 -flake8-isort==6.1.0 # https://github.com/gforcada/flake8-isort -coverage==7.2.7 # https://github.com/nedbat/coveragepy -black==22.3.0 # https://github.com/psf/black -pylint-django==2.5.3 # https://github.com/PyCQA/pylint-django -pre-commit==3.3.2 # https://github.com/pre-commit/pre-commit - -# Django -# ------------------------------------------------------------------------------ -factory-boy==3.3.0 # https://github.com/FactoryBoy/factory_boy - -django-debug-toolbar==4.2.0 # https://github.com/jazzband/django-debug-toolbar -django-coverage-plugin==2.0.2 # https://github.com/nedbat/django_coverage_plugin -pytest-django==4.6.0 # https://github.com/pytest-dev/pytest-django - -# Packaging -# ------------------------------------------------------------------------------ -build==0.10.0 -setuptools==67.7.2 - -# My stuff -# ------------------------------------------------------------------------------ - -# Mocked responses in tests: -responses==0.23.1 # https://github.com/getsentry/responses - -# For mariadb/mysql backend: -mysqlclient==2.1.0 - -# Testing migrations: -django-test-migrations==1.2.0 # https://github.com/wemake-services/django-test-migrations - for testing migrations - -urllib3==2.0.7 # This broke some of the code in CI. From 94954a7e0618befef66a6b665d8618e57ca18568 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Fri, 3 Nov 2023 15:06:25 -0700 Subject: [PATCH 47/47] Add concurrency cancellation to CI --- .github/workflows/ci_hatch.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci_hatch.yml b/.github/workflows/ci_hatch.yml index a84fff3c..8cfdfd03 100644 --- a/.github/workflows/ci_hatch.yml +++ b/.github/workflows/ci_hatch.yml @@ -9,6 +9,9 @@ on: branches: [ "master", "main" ] paths-ignore: [ "docs/**" ] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: