From ac4acb9828279e6c16280cfb638c22c951dd8671 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Tue, 23 Apr 2024 14:25:36 +0200 Subject: [PATCH] Update dependencies and make tests more robust (GSI-707) (#23) --- .devcontainer/devcontainer.json | 4 +- .devcontainer/license_header.txt | 2 +- .github/workflows/check_config_docs.yaml | 17 +- .github/workflows/check_openapi_spec.yaml | 21 +- .github/workflows/check_pyproject.yaml | 17 +- .github/workflows/check_readme.yaml | 19 +- .github/workflows/check_template_files.yaml | 17 +- .github/workflows/ci_release.yaml | 3 + .github/workflows/ci_workflow_dispatch.yaml | 2 + .github/workflows/static_code_analysis.yaml | 26 +- .github/workflows/tests.yaml | 21 +- .pre-commit-config.yaml | 2 +- .pyproject_generation/README.md | 2 +- .pyproject_generation/pyproject_custom.toml | 10 +- .pyproject_generation/pyproject_template.toml | 14 +- .readme_generation/README.md | 2 +- .template/README.md | 2 +- Dockerfile | 2 +- LICENSE | 2 +- README.md | 8 +- config_schema.json | 4 +- lock/README.md | 2 +- lock/requirements-dev-template.in | 39 +- lock/requirements-dev.txt | 629 +++++++++--------- lock/requirements.txt | 488 +++++++------- openapi.yaml | 2 +- pyproject.toml | 20 +- scripts/__init__.py | 2 +- scripts/get_package_name.py | 2 +- scripts/license_checker.py | 13 +- scripts/list_outdated_dependencies.py | 2 +- scripts/script_utils/__init__.py | 2 +- scripts/script_utils/cli.py | 2 +- scripts/script_utils/deps.py | 2 +- scripts/script_utils/fastapi_app_location.py | 2 +- scripts/script_utils/lock_deps.py | 2 +- scripts/update_all.py | 2 +- scripts/update_config_docs.py | 2 +- scripts/update_hook_revs.py | 2 +- scripts/update_lock.py | 10 +- scripts/update_openapi_docs.py | 2 +- scripts/update_pyproject.py | 2 +- scripts/update_readme.py | 2 +- scripts/update_template_files.py | 2 +- src/wps/__init__.py | 2 +- src/wps/__main__.py | 2 +- src/wps/adapters/__init__.py | 2 +- src/wps/adapters/inbound/__init__.py | 2 +- src/wps/adapters/inbound/event_sub.py | 5 +- src/wps/adapters/inbound/fastapi_/__init__.py | 2 +- src/wps/adapters/inbound/fastapi_/auth.py | 2 +- .../adapters/inbound/fastapi_/configure.py | 2 +- src/wps/adapters/inbound/fastapi_/dummies.py | 2 +- src/wps/adapters/inbound/fastapi_/routes.py | 2 +- src/wps/adapters/outbound/__init__.py | 2 +- src/wps/adapters/outbound/dao.py | 2 +- src/wps/adapters/outbound/http.py | 2 +- src/wps/cli.py | 2 +- src/wps/config.py | 2 +- src/wps/core/__init__.py | 2 +- src/wps/core/crypt.py | 2 +- src/wps/core/models.py | 2 +- src/wps/core/repository.py | 2 +- src/wps/core/tokens.py | 2 +- src/wps/inject.py | 2 +- src/wps/main.py | 2 +- src/wps/ports/__init__.py | 2 +- src/wps/ports/inbound/__init__.py | 2 +- src/wps/ports/inbound/repository.py | 2 +- src/wps/ports/outbound/__init__.py | 2 +- src/wps/ports/outbound/access.py | 2 +- src/wps/ports/outbound/dao.py | 2 +- tests/__init__.py | 2 +- tests/conftest.py | 55 +- tests/fixtures/__init__.py | 37 +- tests/fixtures/access.py | 2 +- tests/fixtures/auth_keys.py | 2 +- tests/fixtures/crypt.py | 2 +- tests/fixtures/datasets.py | 2 +- tests/fixtures/utils.py | 2 +- tests/test_access.py | 12 +- tests/test_api.py | 22 +- tests/test_crypt.py | 22 +- tests/test_events.py | 111 ++-- tests/test_models.py | 12 +- tests/test_repository.py | 37 +- tests/test_tokens.py | 2 +- 87 files changed, 949 insertions(+), 862 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c49da2b..ca1f921 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: // https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/python-3-postgres -// Update the VARIANT arg in docker-compose.yml to pick a Python version: 3, 3.8, 3.7, 3.6 +// Update the VARIANT arg in docker-compose.yml to pick a Python version: 3, 3.12, 3.11, 3.10, 3.9 { "name": "${localWorkspaceFolderBasename}", "dockerComposeFile": "docker-compose.yml", @@ -75,4 +75,4 @@ // details can be found here: https://github.com/devcontainers/features/tree/main/src/docker-outside-of-docker "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {} } -} +} \ No newline at end of file diff --git a/.devcontainer/license_header.txt b/.devcontainer/license_header.txt index 5757817..3e70646 100644 --- a/.devcontainer/license_header.txt +++ b/.devcontainer/license_header.txt @@ -1,4 +1,4 @@ -Copyright 2021 - 2023 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln +Copyright 2021 - 2024 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln for the German Human Genome-Phenome Archive (GHGA) Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/.github/workflows/check_config_docs.yaml b/.github/workflows/check_config_docs.yaml index bb88b57..1bffe59 100644 --- a/.github/workflows/check_config_docs.yaml +++ b/.github/workflows/check_config_docs.yaml @@ -1,17 +1,26 @@ -name: Check if the config schema and the example are up to date. +name: Check if the config schema and the example are up to date on: push jobs: static-code-analysis: + name: Check config schema and example + runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 + - name: Checkout repository + id: checkout + uses: actions/checkout@v4 - - id: common - uses: ghga-de/gh-action-common@v4 + - name: Common steps + id: common + uses: ghga-de/gh-action-common@v5 + with: + python-version: '3.12' - name: Check config docs + id: check-config-docs run: | export ${{ steps.common.outputs.CONFIG_YAML_ENV_VAR_NAME }}="${{ steps.common.outputs.CONFIG_YAML }}" diff --git a/.github/workflows/check_openapi_spec.yaml b/.github/workflows/check_openapi_spec.yaml index f5db766..252b84d 100644 --- a/.github/workflows/check_openapi_spec.yaml +++ b/.github/workflows/check_openapi_spec.yaml @@ -1,18 +1,27 @@ -# This file is only needed, if your repository uses FastAPI -name: Check if openapi.yaml is up to date +# This file is only needed if your repository uses FastAPI +name: Check if OpenAPI spec is up to date on: push jobs: static-code-analysis: + name: Check OpenAPI spec + runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 + - name: Checkout repository + id: checkout + uses: actions/checkout@v4 - - id: common - uses: ghga-de/gh-action-common@v4 + - name: Common steps + id: common + uses: ghga-de/gh-action-common@v5 + with: + python-version: '3.12' - - name: Check if openapi.yaml is up to date + - name: Check openapi.yaml + id: check-openapi-docs run: | export ${{ steps.common.outputs.CONFIG_YAML_ENV_VAR_NAME }}="${{ steps.common.outputs.CONFIG_YAML }}" diff --git a/.github/workflows/check_pyproject.yaml b/.github/workflows/check_pyproject.yaml index d929c79..4600d0a 100644 --- a/.github/workflows/check_pyproject.yaml +++ b/.github/workflows/check_pyproject.yaml @@ -1,16 +1,25 @@ -name: Check if the config schema and the example are up to date. +name: Check if pyproject.toml file is up to date on: push jobs: static-code-analysis: + name: Check pyproject file + runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 + - name: Checkout repository + id: checkout + uses: actions/checkout@v4 - - id: common - uses: ghga-de/gh-action-common@v4 + - name: Common steps + id: common + uses: ghga-de/gh-action-common@v5 + with: + python-version: '3.12' - name: Check pyproject.toml + id: check-pyproject run: | ./scripts/update_pyproject.py --check diff --git a/.github/workflows/check_readme.yaml b/.github/workflows/check_readme.yaml index 7414554..c24bb1d 100644 --- a/.github/workflows/check_readme.yaml +++ b/.github/workflows/check_readme.yaml @@ -1,16 +1,25 @@ -name: Check if the readme is up to date. +name: Check if the README file is up to date on: push jobs: static-code-analysis: + name: Check README file + runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 + - name: Checkout repository + id: checkout + uses: actions/checkout@v4 - - id: common - uses: ghga-de/gh-action-common@v4 + - name: Common steps + id: common + uses: ghga-de/gh-action-common@v5 + with: + python-version: '3.12' - - name: Check readme + - name: Check README + id: check-readme run: | ./scripts/update_readme.py --check diff --git a/.github/workflows/check_template_files.yaml b/.github/workflows/check_template_files.yaml index 9fb5cbf..e6b7e60 100644 --- a/.github/workflows/check_template_files.yaml +++ b/.github/workflows/check_template_files.yaml @@ -4,14 +4,23 @@ on: push jobs: check-template-files: + name: Check template files + runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.9 - uses: actions/setup-python@v4 + - name: Checkout repository + id: checkout + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + id: setup-python + uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: '3.12' + - name: Check template files + id: check-template-files run: | if [ "${{ github.event.repository.name }}" == "microservice-repository-template" ] then diff --git a/.github/workflows/ci_release.yaml b/.github/workflows/ci_release.yaml index d8547b4..4a28624 100644 --- a/.github/workflows/ci_release.yaml +++ b/.github/workflows/ci_release.yaml @@ -6,7 +6,10 @@ on: jobs: push_to_docker_hub: + name: Push to Docker Hub + runs-on: ubuntu-latest + steps: - uses: ghga-de/gh-action-ci@v1 with: diff --git a/.github/workflows/ci_workflow_dispatch.yaml b/.github/workflows/ci_workflow_dispatch.yaml index eab7d5a..a49be97 100644 --- a/.github/workflows/ci_workflow_dispatch.yaml +++ b/.github/workflows/ci_workflow_dispatch.yaml @@ -11,6 +11,7 @@ on: jobs: fetch-tag: + name: Fetch Tag runs-on: ubuntu-latest if: github.event_name == 'workflow_dispatch' || ( github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'build') ) || ( github.event.action == 'labeled' && github.event.label.name == 'build' ) steps: @@ -20,6 +21,7 @@ jobs: latest_tag: ${{ steps.fetch-tag.outputs.latest_tag }} push_to_docker_hub: + name: Push to Docker Hub needs: fetch-tag runs-on: ubuntu-latest steps: diff --git a/.github/workflows/static_code_analysis.yaml b/.github/workflows/static_code_analysis.yaml index 86a014d..12134ed 100644 --- a/.github/workflows/static_code_analysis.yaml +++ b/.github/workflows/static_code_analysis.yaml @@ -4,24 +4,36 @@ on: push jobs: static-code-analysis: - runs-on: ubuntu-latest name: Static Code Analysis + + runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 + - name: Checkout repository + id: checkout + uses: actions/checkout@v4 - - id: common - uses: ghga-de/gh-action-common@v4 + - name: Common steps + id: common + uses: ghga-de/gh-action-common@v5 - - uses: pre-commit/action@v3.0.0 + - name: Run pre-commit + uses: pre-commit/action@v3.0.1 env: SKIP: no-commit-to-branch - - name: ruff + + - name: Run ruff + id: ruff run: | ruff check --output-format=github . ruff format --check . - - name: mypy + + - name: Run mypy + id: mypy run: | mypy . + - name: Check license header and file + id: license-checker run: | ./scripts/license_checker.py diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index dacc9f5..33ce3d0 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,19 +1,24 @@ -name: Tests +name: Run test suite and measure coverage on: push jobs: tests: + name: Run test suite + runs-on: ubuntu-latest - name: Tests steps: - - uses: actions/checkout@v3 + - name: Checkout repository + id: checkout + uses: actions/checkout@v4 - - id: common - uses: ghga-de/gh-action-common@v4 + - name: Common steps + id: common + uses: ghga-de/gh-action-common@v5 - - id: pytest + - name: Run tests + id: pytest run: | export ${{ steps.common.outputs.CONFIG_YAML_ENV_VAR_NAME }}="${{ steps.common.outputs.CONFIG_YAML }}" @@ -22,8 +27,8 @@ jobs: --cov-report=xml \ tests - - id: coveralls - name: Upload coverage to coveralls + - name: Upload coverage to coveralls + id: coveralls env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2ac76cd..c661ebd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,7 +48,7 @@ repos: - id: no-commit-to-branch args: [--branch, dev, --branch, int, --branch, main] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.4 + rev: v0.4.1 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/.pyproject_generation/README.md b/.pyproject_generation/README.md index 93b988f..4434a8f 100644 --- a/.pyproject_generation/README.md +++ b/.pyproject_generation/README.md @@ -1,5 +1,5 @@