|
1 | 1 | name: Python Tests |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
| 4 | + push: |
5 | 5 | branches: |
6 | 6 | - '*' |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - test: |
| 9 | + changelog-check: |
| 10 | + # Do not run this on master itself |
| 11 | + if: github.ref != 'refs/heads/master' |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + fetch-depth: 0 # we need history to diff properly |
| 18 | + |
| 19 | + - name: Fetch master for comparison |
| 20 | + run: git fetch origin master |
| 21 | + |
| 22 | + - name: Verify CHANGELOG.md was updated |
| 23 | + run: | |
| 24 | + echo "Checking whether CHANGELOG.md was modified compared to master..." |
| 25 | +
|
| 26 | + if git diff --name-only origin/master...HEAD | grep -qx "CHANGELOG.md"; then |
| 27 | + echo "✅ CHANGELOG.md was updated." |
| 28 | + else |
| 29 | + echo "❌ CHANGELOG.md was NOT updated." |
| 30 | + echo "Please document your changes in CHANGELOG.md." |
| 31 | + exit 1 |
| 32 | + fi |
| 33 | +
|
| 34 | + test: |
| 35 | + needs: changelog-check # ensures this runs first |
10 | 36 | runs-on: ubuntu-latest |
11 | 37 | strategy: |
12 | 38 | matrix: |
13 | 39 | python-version: [3.11, 3.12, 3.13, 3.14] |
| 40 | + |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + |
| 44 | + - name: Set up Python ${{ matrix.python-version }} |
| 45 | + uses: actions/setup-python@v5 |
| 46 | + with: |
| 47 | + python-version: ${{ matrix.python-version }} |
| 48 | + check-latest: true |
| 49 | + |
| 50 | + - name: Install task to make use of Taskfile.yml |
| 51 | + run: | |
| 52 | + sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin |
| 53 | + task --version |
| 54 | +
|
| 55 | + - name: Install dependencies |
| 56 | + run: | |
| 57 | + task dependencies-with-pip |
| 58 | + pip install -U coveralls |
| 59 | +
|
| 60 | + - name: Run tests with pytest |
| 61 | + run: | |
| 62 | + task tests-with-cov |
| 63 | +
|
| 64 | + - name: Coveralls |
| 65 | + uses: coverallsapp/github-action@v2.3.6 |
| 66 | + with: |
| 67 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 68 | + file: .coverage |
| 69 | + |
| 70 | + deploy: |
| 71 | + needs: test |
| 72 | + runs-on: ubuntu-latest |
| 73 | + if: github.ref == 'refs/heads/master' |
| 74 | + environment: |
| 75 | + name: pypi-deployment |
14 | 76 | steps: |
15 | | - - uses: actions/checkout@v4 |
16 | | - - name: Set up Python ${{ matrix.python-version }} |
17 | | - uses: actions/setup-python@v5 |
18 | | - with: |
19 | | - python-version: ${{ matrix.python-version }} |
20 | | - check-latest: true |
21 | | - - name: Install task to make use of Taskfile.yml |
22 | | - run: | |
23 | | - sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin |
24 | | - task --version |
25 | | - - name: Install dependencies |
26 | | - run: | |
27 | | - task dependencies-with-pip |
28 | | - pip install -U coveralls |
29 | | - - name: Run tests with pytest |
30 | | - run: | |
31 | | - task tests-with-cov |
32 | | - - name: Coveralls |
33 | | - uses: coverallsapp/github-action@v2.3.6 |
34 | | - with: |
35 | | - github-token: ${{ secrets.GITHUB_TOKEN }} |
36 | | - file: .coverage |
37 | | - deploy: |
38 | | - needs: test |
39 | | - runs-on: ubuntu-latest |
40 | | - if: github.ref == 'refs/heads/master' |
41 | | - environment: |
42 | | - name: pypi-deployment |
43 | | - steps: |
44 | | - - uses: actions/checkout@v4 |
45 | | - - name: Set up Python |
46 | | - uses: actions/setup-python@v5 |
47 | | - with: |
48 | | - python-version: 3.12 |
49 | | - - name: Install Build Tools |
50 | | - run: | |
51 | | - pip install -U build twine |
52 | | - - name: Set Twine Environment Variables |
53 | | - run: | |
54 | | - echo "TWINE_USERNAME=${{ secrets.PYPI_USERNAME }}" >> $GITHUB_ENV |
55 | | - echo "TWINE_PASSWORD=${{ secrets.PYPI_PASSWORD }}" >> $GITHUB_ENV |
56 | | - - name: Build and Upload to PyPI |
57 | | - run: | |
58 | | - python -m build |
59 | | - twine upload dist/* |
| 77 | + - uses: actions/checkout@v4 |
| 78 | + |
| 79 | + - name: Set up Python |
| 80 | + uses: actions/setup-python@v5 |
| 81 | + with: |
| 82 | + python-version: 3.12 |
| 83 | + |
| 84 | + - name: Install Build Tools |
| 85 | + run: | |
| 86 | + pip install -U build twine |
| 87 | +
|
| 88 | + - name: Set Twine Environment Variables |
| 89 | + run: | |
| 90 | + echo "TWINE_USERNAME=${{ secrets.PYPI_USERNAME }}" >> $GITHUB_ENV |
| 91 | + echo "TWINE_PASSWORD=${{ secrets.PYPI_PASSWORD }}" >> $GITHUB_ENV |
| 92 | +
|
| 93 | + - name: Build and Upload to PyPI |
| 94 | + run: | |
| 95 | + python -m build |
| 96 | + twine upload dist/* |
0 commit comments