From 37cfd0a9590630873acb580a1cc97c965a36d359 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 4 Oct 2024 16:15:40 +0400 Subject: [PATCH 1/9] Upgrade to GitHub Actions Artifacts v4 --- .github/workflows/ci.yml | 60 ++++++++++++++++++++++------------- .github/workflows/release.yml | 4 +-- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afe229a..29a8f98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,11 +26,12 @@ jobs: run: ./ci.sh shell: bash - name: "Upload coverage data" - uses: "actions/upload-artifact@v3" + uses: "actions/upload-artifact@v4" with: - name: coverage-data - path: "empty/.coverage.*" - if-no-files-found: error + name: coverage-data-${{ matrix.python }} + path: .coverage.* + include-hidden-files: true + if-no-files-found: ignore Ubuntu: name: 'Ubuntu (${{ matrix.python }})' @@ -50,11 +51,12 @@ jobs: - name: Run tests run: ./ci.sh - name: "Upload coverage data" - uses: "actions/upload-artifact@v3" + uses: "actions/upload-artifact@v4" with: - name: coverage-data - path: "empty/.coverage.*" - if-no-files-found: error + name: coverage-data-${{ matrix.python }} + path: .coverage.* + include-hidden-files: true + if-no-files-found: ignore macOS: name: 'macOS (${{ matrix.python }})' @@ -74,13 +76,15 @@ jobs: - name: Run tests run: ./ci.sh - name: "Upload coverage data" - uses: "actions/upload-artifact@v3" + uses: "actions/upload-artifact@v4" with: - name: coverage-data - path: "empty/.coverage.*" - if-no-files-found: error + name: coverage-data-${{ matrix.python }} + path: .coverage.* + include-hidden-files: true + if-no-files-found: ignore coverage: + name: Combine & check coverage if: always() runs-on: "ubuntu-latest" needs: ["Windows", "Ubuntu", "macOS"] @@ -91,15 +95,27 @@ jobs: with: python-version: "3.x" - - name: "Install coverage" - run: "python -m pip install --upgrade coverage[toml]" - - - name: "Download coverage data" - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: - name: coverage-data + pattern: coverage-data-* + merge-multiple: true + + - name: Combine coverage & fail if it's <100% + run: + python -Im pip install --upgrade coverage[toml]| + + python -Im coverage combine + python -Im coverage html --skip-covered --skip-empty - - name: "Combine & check coverage" - run: | - python -m coverage combine - python -m coverage report --ignore-errors --show-missing --fail-under=100 + # Report and write to summary. + python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY + + # Report again and fail if under 100%. + python -Im coverage report --fail-under=100 + + - name: Upload HTML report if check failed + uses: actions/upload-artifact@v4 + with: + name: html-report + path: htmlcov + if: ${{ failure() }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 64fb4e7..8d9e04d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,7 @@ jobs: - name: Build dists run: python -m build - name: Upload dists - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: "dist" path: "dist/" @@ -44,7 +44,7 @@ jobs: steps: - name: Download dists - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: "dist" path: "dist/" From 7a36ddf2da05822aa8a0f52cab324ae8ea3e3b8c Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 4 Oct 2024 16:08:57 +0400 Subject: [PATCH 2/9] Bump all remaining GitHub Actions --- .github/workflows/ci.yml | 16 ++++++++-------- .github/workflows/lint.yml | 4 ++-- .github/workflows/release.yml | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29a8f98..08fa927 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,9 +17,9 @@ jobs: python: ['3.8', '3.9', '3.10', '3.11', '3.12-dev'] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '${{ matrix.python }}' - name: Run tests @@ -43,9 +43,9 @@ jobs: python: ['3.8', '3.9', '3.10', '3.11', '3.12-dev', 'pypy3.9', 'pypy-3.10'] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '${{ matrix.python }}' - name: Run tests @@ -68,9 +68,9 @@ jobs: python: ['3.8', '3.9', '3.10', '3.11', '3.12-dev'] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '${{ matrix.python }}' - name: Run tests @@ -89,9 +89,9 @@ jobs: runs-on: "ubuntu-latest" needs: ["Windows", "Ubuntu", "macOS"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Use latest Python so it understands all syntax" - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.x" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 947a7d3..dd4872f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,9 +13,9 @@ jobs: runs-on: 'ubuntu-latest' steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: Run lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8d9e04d..97eaaa2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,9 +16,9 @@ jobs: steps: - name: Checkout - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Setup python - uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0 # v4.6.1 + uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 with: python-version: 3.x - name: Install dependencies @@ -49,4 +49,4 @@ jobs: name: "dist" path: "dist/" - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@f5622bde02b04381239da3573277701ceca8f6a0 # v1.8.7 + uses: pypa/gh-action-pypi-publish@f7600683efdcb7656dec5b29656edb7bc586e597 # v1.10.3 From 06a253ac7a4164357d068b5d3f038461fb6dc1b3 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 4 Oct 2024 16:23:48 +0400 Subject: [PATCH 3/9] Fix YAML syntax --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08fa927..e7a169b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,6 +88,7 @@ jobs: if: always() runs-on: "ubuntu-latest" needs: ["Windows", "Ubuntu", "macOS"] + steps: - uses: actions/checkout@v4 - name: "Use latest Python so it understands all syntax" @@ -101,8 +102,8 @@ jobs: merge-multiple: true - name: Combine coverage & fail if it's <100% - run: - python -Im pip install --upgrade coverage[toml]| + run: | + python -Im pip install --upgrade coverage[toml] python -Im coverage combine python -Im coverage html --skip-covered --skip-empty From e8527e71314a51cd42b983893aa6051df46991f9 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 4 Oct 2024 16:39:00 +0400 Subject: [PATCH 4/9] Fix coverage upload name --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7a169b..c19fb66 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: - name: "Upload coverage data" uses: "actions/upload-artifact@v4" with: - name: coverage-data-${{ matrix.python }} + name: coverage-data-windows-${{ matrix.python }} path: .coverage.* include-hidden-files: true if-no-files-found: ignore @@ -53,7 +53,7 @@ jobs: - name: "Upload coverage data" uses: "actions/upload-artifact@v4" with: - name: coverage-data-${{ matrix.python }} + name: coverage-data-ubuntu-${{ matrix.python }} path: .coverage.* include-hidden-files: true if-no-files-found: ignore @@ -78,7 +78,7 @@ jobs: - name: "Upload coverage data" uses: "actions/upload-artifact@v4" with: - name: coverage-data-${{ matrix.python }} + name: coverage-data-macos-${{ matrix.python }} path: .coverage.* include-hidden-files: true if-no-files-found: ignore From 7718ad28e57f925e22cb1f13e4c0649903afae7c Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 4 Oct 2024 17:02:09 +0400 Subject: [PATCH 5/9] Move coverage file in ci.sh itself --- ci.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index 1b5f230..99a7e0b 100755 --- a/ci.sh +++ b/ci.sh @@ -14,8 +14,9 @@ python -m pip install dist/*.zip python -m pip install -Ur test-requirements.txt if [ -n "${OLD_CRYPTOGRAPHY:-}" ]; then - python -m pip install cryptography=="${OLD_CRYPTOGRAPHY}" + python -m pip install cryptography=="${OLD_CRYPTOGRAPHY}" fi mkdir empty pushd empty coverage run --parallel-mode -m pytest -W error -ra -s ../tests +mv empty/.coverage.* . From 4ab33920790bf96dd377167749df45a7b030faee Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 4 Oct 2024 17:04:27 +0400 Subject: [PATCH 6/9] popd --- ci.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci.sh b/ci.sh index 99a7e0b..4928ab9 100755 --- a/ci.sh +++ b/ci.sh @@ -19,4 +19,5 @@ fi mkdir empty pushd empty coverage run --parallel-mode -m pytest -W error -ra -s ../tests +popd mv empty/.coverage.* . From 6a489ef5e09bc4636c0c0e02ac8c5e79758bfb14 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 4 Oct 2024 17:11:13 +0400 Subject: [PATCH 7/9] Fix coverage paths --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 74b54c0..29cdcb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ omit = ["*/setup.py"] source = ["trustme"] [tool.coverage.paths] -source = ["trustme", "*/trustme", "*\\trustme"] +source = ["src/trustme", "*/trustme", "*\\trustme"] [tool.coverage.setup] precision = 1 From fa6a3435bb3298febeddc068c9ef649a045d9f2a Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 4 Oct 2024 17:16:34 +0400 Subject: [PATCH 8/9] Drop the empty trick It's nice to be isolated, but makes working with coverage hard. --- ci.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ci.sh b/ci.sh index 4928ab9..17c2cc4 100755 --- a/ci.sh +++ b/ci.sh @@ -16,8 +16,5 @@ python -m pip install -Ur test-requirements.txt if [ -n "${OLD_CRYPTOGRAPHY:-}" ]; then python -m pip install cryptography=="${OLD_CRYPTOGRAPHY}" fi -mkdir empty -pushd empty -coverage run --parallel-mode -m pytest -W error -ra -s ../tests -popd -mv empty/.coverage.* . + +coverage run --parallel-mode -m pytest -W error -ra -s tests From 0bd953577e63c7f6c3829f1938afc8a3ec068f5e Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Sun, 6 Oct 2024 21:34:32 +0400 Subject: [PATCH 9/9] Ignore uncovered lines --- pyproject.toml | 4 ++-- src/trustme/_cli.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 29cdcb6..5bc78c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ warn_unused_ignores = true [tool.coverage.run] branch = true -omit = ["*/setup.py"] +omit = ["*/trustme/__main__.py"] source = ["trustme"] [tool.coverage.paths] @@ -48,6 +48,6 @@ source = ["src/trustme", "*/trustme", "*\\trustme"] [tool.coverage.setup] precision = 1 exclude_lines = [ - "pragma: no cover", + "pragma: no cover.*", "if TYPE_CHECKING:" ] diff --git a/src/trustme/_cli.py b/src/trustme/_cli.py index 3e73673..714673b 100644 --- a/src/trustme/_cli.py +++ b/src/trustme/_cli.py @@ -12,7 +12,7 @@ def main(argv: Optional[List[str]] = None) -> None: if argv is None: - argv = sys.argv[1:] + argv = sys.argv[1:] # pragma: no cover (used in tests) parser = argparse.ArgumentParser(prog="trustme") parser.add_argument(