|
6 | 6 | workflow_dispatch:
|
7 | 7 |
|
8 | 8 | jobs:
|
| 9 | + build: |
| 10 | + name: Build package |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + - name: Set up Python |
| 15 | + uses: actions/setup-python@v5 |
| 16 | + with: |
| 17 | + cache: "pip" |
| 18 | + - name: Install pypa/build |
| 19 | + run: >- |
| 20 | + python3 -m pip install --user |
| 21 | + build |
| 22 | + twine |
| 23 | + - name: Build a binary wheel and a source tarball |
| 24 | + run: python3 -m build |
| 25 | + - name: Check the distribution files with `twine` |
| 26 | + run: twine check --strict dist/* |
| 27 | + - name: Upload artifact |
| 28 | + id: artifact-upload-step |
| 29 | + uses: actions/upload-artifact@v4 |
| 30 | + with: |
| 31 | + name: dist-files |
| 32 | + path: dist/* |
| 33 | + if-no-files-found: error |
| 34 | + compression-level: 0 # They are already compressed |
9 | 35 | test-run:
|
10 | 36 | runs-on: ubuntu-latest
|
| 37 | + needs: build |
11 | 38 | strategy:
|
12 | 39 | matrix:
|
13 | 40 | include:
|
14 |
| - - python-version: "3.8" |
15 |
| - toxfactor: py3.8 |
16 |
| - ignore-typecheck-outcome: true |
17 |
| - ignore-test-outcome: false |
18 | 41 | - python-version: "3.9"
|
19 | 42 | toxfactor: py3.9
|
20 |
| - ignore-typecheck-outcome: true |
| 43 | + ignore-typecheck-outcome: false |
21 | 44 | ignore-test-outcome: false
|
22 | 45 | - python-version: "3.10"
|
23 | 46 | toxfactor: py3.10
|
24 |
| - ignore-typecheck-outcome: true |
| 47 | + ignore-typecheck-outcome: false |
25 | 48 | ignore-test-outcome: false
|
26 | 49 | - python-version: "3.11"
|
27 | 50 | toxfactor: py3.11
|
28 |
| - ignore-typecheck-outcome: true |
| 51 | + ignore-typecheck-outcome: false |
29 | 52 | ignore-test-outcome: false
|
30 | 53 | - python-version: "3.12"
|
31 | 54 | toxfactor: py3.12
|
32 |
| - ignore-typecheck-outcome: true |
| 55 | + ignore-typecheck-outcome: false |
| 56 | + ignore-test-outcome: false |
| 57 | + - python-version: "3.13" |
| 58 | + toxfactor: py3.13 |
| 59 | + ignore-typecheck-outcome: false |
33 | 60 | ignore-test-outcome: false
|
34 | 61 |
|
35 | 62 | steps:
|
36 |
| - - uses: actions/checkout@v3 |
| 63 | + - uses: actions/checkout@v4 |
37 | 64 |
|
38 |
| - - name: Set up Python ${{ matrix.python-version }} |
39 |
| - uses: actions/setup-python@v4 |
40 |
| - id: setup-python |
41 |
| - with: |
42 |
| - python-version: ${{ matrix.python-version }} |
| 65 | + - name: Set up Python ${{ matrix.python-version }} |
| 66 | + uses: actions/setup-python@v4 |
| 67 | + id: setup-python |
| 68 | + with: |
| 69 | + python-version: ${{ matrix.python-version }} |
43 | 70 |
|
44 |
| - - name: Install poetry |
45 |
| - run: | |
46 |
| - python -m pip install poetry==1.6.1 |
| 71 | + - name: Install poetry |
| 72 | + run: | |
| 73 | + python -m pip install poetry==1.8.3 |
47 | 74 |
|
48 |
| - - name: Configure poetry |
49 |
| - run: | |
50 |
| - python -m poetry config virtualenvs.in-project true |
| 75 | + - name: Configure poetry |
| 76 | + run: | |
| 77 | + python -m poetry config virtualenvs.in-project true |
51 | 78 |
|
52 |
| - - name: Cache the virtualenv |
53 |
| - id: poetry-dependencies-cache |
54 |
| - uses: actions/cache@v3 |
55 |
| - with: |
56 |
| - path: ./.venv |
57 |
| - key: ${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} |
| 79 | + - name: Cache the virtualenv |
| 80 | + id: poetry-dependencies-cache |
| 81 | + uses: actions/cache@v3 |
| 82 | + with: |
| 83 | + path: ./.venv |
| 84 | + key: ${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} |
58 | 85 |
|
59 |
| - - name: Install dev dependencies |
60 |
| - if: steps.poetry-dependencies-cache.outputs.cache-hit != 'true' |
61 |
| - run: | |
62 |
| - python -m poetry install --only=dev |
| 86 | + - name: Install dev dependencies |
| 87 | + if: steps.poetry-dependencies-cache.outputs.cache-hit != 'true' |
| 88 | + run: | |
| 89 | + python -m poetry install --only=dev |
63 | 90 |
|
64 |
| - - name: Type checking |
65 |
| - # Ignore errors for older pythons |
66 |
| - continue-on-error: ${{ matrix.ignore-typecheck-outcome }} |
67 |
| - run: | |
68 |
| - source .venv/bin/activate |
69 |
| - tox -e mypy |
| 91 | + - name: Download artifact |
| 92 | + uses: actions/download-artifact@v4 |
| 93 | + with: |
| 94 | + name: dist-files |
| 95 | + path: dist/ |
70 | 96 |
|
71 |
| - - name: Test with tox |
72 |
| - continue-on-error: ${{ matrix.ignore-test-outcome }} |
73 |
| - run: | |
74 |
| - source .venv/bin/activate |
75 |
| - coverage erase |
76 |
| - tox run-parallel -f ${{ matrix.toxfactor }} --parallel-no-spinner --parallel-live |
77 |
| - coverage combine |
78 |
| - coverage xml |
| 97 | + - name: Type checking |
| 98 | + # Ignore errors for older pythons |
| 99 | + continue-on-error: ${{ matrix.ignore-typecheck-outcome }} |
| 100 | + run: | |
| 101 | + source .venv/bin/activate |
| 102 | + tox -e mypy |
79 | 103 |
|
80 |
| - - uses: codecov/codecov-action@v3 |
81 |
| - with: |
82 |
| - # Explicitly using the token to avoid Codecov rate limit errors |
83 |
| - # See https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954 |
84 |
| - token: ${{ secrets.CODECOV_TOKEN }} |
85 |
| - fail_ci_if_error: true |
86 |
| - verbose: true # optional (default = false) |
| 104 | + - name: Test with tox |
| 105 | + continue-on-error: ${{ matrix.ignore-test-outcome }} |
| 106 | + run: | |
| 107 | + source .venv/bin/activate |
| 108 | + coverage erase |
| 109 | + # Using `installpkg dist/*.tar.gz` because we want to install the pre-built package (want to test against that) |
| 110 | + tox run-parallel -f ${{ matrix.toxfactor }} --parallel-no-spinner --parallel-live --installpkg dist/*.whl |
| 111 | + coverage combine |
| 112 | + coverage xml |
| 113 | +
|
| 114 | + - uses: codecov/codecov-action@v4 |
| 115 | + with: |
| 116 | + # Explicitly using the token to avoid Codecov rate limit errors |
| 117 | + # See https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954 |
| 118 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 119 | + fail_ci_if_error: false |
| 120 | + verbose: true # optional (default = false) |
| 121 | + |
| 122 | + pypi-publish: |
| 123 | + name: Upload release to PyPI |
| 124 | + runs-on: ubuntu-latest |
| 125 | + environment: |
| 126 | + name: pypi |
| 127 | + url: https://pypi.org/p/pytest-bdd |
| 128 | + permissions: |
| 129 | + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing |
| 130 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
| 131 | + needs: |
| 132 | + - "test-run" |
| 133 | + - "build" |
| 134 | + steps: |
| 135 | + - name: Download artifact |
| 136 | + uses: actions/download-artifact@v4 |
| 137 | + with: |
| 138 | + name: dist-files |
| 139 | + path: dist/ |
| 140 | + - name: Publish package distributions to PyPI |
| 141 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments