Skip to content

Commit 95f9cc7

Browse files
authored
Improve GitHub Actions workflow (#1194)
Tidy up some problematic patterns, including some found with [zizmor](https://docs.zizmor.sh/), and use [gha-update](https://gha-update.readthedocs.io/en/latest/) to pin GitHub Actions to specific hashes.
1 parent fcf7fdc commit 95f9cc7

2 files changed

Lines changed: 51 additions & 52 deletions

File tree

.github/dependabot.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,17 @@ jobs:
5050
DB_PASSWORD: hunter2
5151

5252
steps:
53-
- uses: actions/checkout@v6
53+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
54+
with:
55+
persist-credentials: false
5456

55-
- uses: actions/setup-python@v6
57+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
5658
with:
5759
python-version: ${{ matrix.python-version }}
5860
allow-prereleases: true
5961

6062
- name: Install uv
61-
uses: astral-sh/setup-uv@v7
63+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
6264
with:
6365
enable-cache: true
6466

@@ -81,7 +83,7 @@ jobs:
8183
id: format_db_id
8284

8385
- name: Upload coverage data
84-
uses: actions/upload-artifact@v7
86+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
8587
with:
8688
name: coverage-data-${{ matrix.python-version }}-${{ steps.format_db_id.outputs.db_id }}
8789
path: '${{ github.workspace }}/.coverage/*'
@@ -92,40 +94,43 @@ jobs:
9294
name: Coverage
9395
runs-on: ubuntu-24.04
9496
needs: tests
97+
if: always()
9598
steps:
96-
- uses: actions/checkout@v6
97-
98-
- uses: actions/setup-python@v6
99-
with:
100-
python-version: '3.13'
101-
102-
- name: Install uv
103-
uses: astral-sh/setup-uv@v7
104-
105-
- name: Install dependencies
106-
run: uv pip install --system coverage[toml]
107-
108-
- name: Download data
109-
uses: actions/download-artifact@v8
110-
with:
111-
path: .coverage
112-
pattern: coverage-data-*
113-
merge-multiple: true
114-
115-
- name: Combine coverage and fail if it's <100%
116-
run: |
117-
python -m coverage combine
118-
python -m coverage html --skip-covered --skip-empty
119-
python -m coverage report --fail-under=100
120-
echo "## Coverage summary" >> $GITHUB_STEP_SUMMARY
121-
python -m coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
122-
123-
- name: Upload HTML report
124-
if: ${{ failure() }}
125-
uses: actions/upload-artifact@v7
126-
with:
127-
name: html-report
128-
path: htmlcov
99+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
100+
with:
101+
persist-credentials: false
102+
103+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
104+
with:
105+
python-version: '3.13'
106+
107+
- name: Install uv
108+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
109+
110+
- name: Install dependencies
111+
run: uv pip install --system coverage[toml]
112+
113+
- name: Download data
114+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
115+
with:
116+
path: .coverage
117+
pattern: coverage-data-*
118+
merge-multiple: true
119+
120+
- name: Combine coverage and fail if it's <100%
121+
run: |
122+
python -m coverage combine
123+
python -m coverage html --skip-covered --skip-empty
124+
python -m coverage report --fail-under=100
125+
echo "## Coverage summary" >> $GITHUB_STEP_SUMMARY
126+
python -m coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
127+
128+
- name: Upload HTML report
129+
if: failure()
130+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
131+
with:
132+
name: html-report
133+
path: htmlcov
129134

130135
release:
131136
needs: [coverage]
@@ -138,11 +143,15 @@ jobs:
138143
id-token: write
139144

140145
steps:
141-
- uses: actions/checkout@v6
146+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
147+
with:
148+
persist-credentials: false
142149

143-
- uses: astral-sh/setup-uv@v7
150+
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
151+
with:
152+
enable-cache: false
144153

145-
- name: Build
146-
run: uv build
154+
- name: Build
155+
run: uv build
147156

148-
- uses: pypa/gh-action-pypi-publish@release/v1
157+
- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0

0 commit comments

Comments
 (0)