Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump GitHub Actions, fix CI and coverage #663

Merged
merged 9 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 46 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@ 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
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-windows-${{ matrix.python }}
path: .coverage.*
include-hidden-files: true
if-no-files-found: ignore

Ubuntu:
name: 'Ubuntu (${{ matrix.python }})'
Expand All @@ -42,19 +43,20 @@ 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
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-ubuntu-${{ matrix.python }}
path: .coverage.*
include-hidden-files: true
if-no-files-found: ignore

macOS:
name: 'macOS (${{ matrix.python }})'
Expand All @@ -66,40 +68,55 @@ 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
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-macos-${{ 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"]

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"

- 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 & check coverage"
- name: Combine coverage & fail if it's <100%
run: |
python -m coverage combine
python -m coverage report --ignore-errors --show-missing --fail-under=100
python -Im pip install --upgrade coverage[toml]

python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty

# 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() }}
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ 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
run: python -m pip install build
- 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/"
Expand All @@ -44,9 +44,9 @@ 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/"
- 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
7 changes: 3 additions & 4 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ 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

coverage run --parallel-mode -m pytest -W error -ra -s tests
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ warn_unused_ignores = true

[tool.coverage.run]
branch = true
omit = ["*/setup.py"]
omit = ["*/trustme/__main__.py"]
source = ["trustme"]

[tool.coverage.paths]
source = ["trustme", "*/trustme", "*\\trustme"]
source = ["src/trustme", "*/trustme", "*\\trustme"]

[tool.coverage.setup]
precision = 1
exclude_lines = [
"pragma: no cover",
"pragma: no cover.*",
"if TYPE_CHECKING:"
]
2 changes: 1 addition & 1 deletion src/trustme/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading