-
Notifications
You must be signed in to change notification settings - Fork 159
Harden GitHub Actions workflow #1122
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
Merged
seifertm
merged 10 commits into
pytest-dev:main
from
seifertm:harden-gh-actions-workflow
Jun 25, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9d5c5b8
ci: Pin third-party actions to a commit hash.
seifertm 6791c49
ci: Avoid persisting credentials in the checkout action.
seifertm 81a5273
ci: Narrow permissions of Github Actions.
seifertm 4af8586
ci: Silence zizmore warning about not using trusted publishing.
seifertm 7583d22
ci: Avoid template expression in Bash script for assembling release n…
seifertm 6adaba4
build: Add zizmor to the pre-commit hooks.
seifertm c60f3c7
ci: Add linting job with GitHub Actions with zizmor.
seifertm d6e646d
ci: Update zizmor workflow.
seifertm 3ad8609
ci: Remove obsolete password from PyPI upload.
seifertm 28fc1de
ci: Remove unnecssary arguments and linting ignores from publishing a…
seifertm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ on: | |
merge_group: | ||
workflow_dispatch: | ||
|
||
permissions: {} | ||
|
||
env: | ||
PYTHON_LATEST: 3.13 | ||
|
||
|
@@ -24,6 +26,7 @@ jobs: | |
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PYTHON_LATEST }} | ||
|
@@ -75,6 +78,8 @@ jobs: | |
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
@@ -95,17 +100,25 @@ jobs: | |
path: coverage/coverage.* | ||
if-no-files-found: error | ||
|
||
lint-github-actions: | ||
name: Lint GitHub Actions | ||
permissions: | ||
security-events: write | ||
uses: zizmorcore/workflow/.github/workflows/reusable-zizmor.yml@3bb5e95068d0f44b6d2f3f7e91379bed1d2f96a8 | ||
|
||
check: | ||
name: Check | ||
if: always() | ||
needs: [lint, test] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Decide whether the needed jobs succeeded or failed | ||
uses: re-actors/alls-green@release/v1 | ||
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2 | ||
with: | ||
jobs: ${{ toJSON(needs) }} | ||
- uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PYTHON_LATEST }} | ||
|
@@ -124,7 +137,7 @@ jobs: | |
coverage combine | ||
coverage xml | ||
- name: Upload coverage report | ||
uses: codecov/codecov-action@v5 | ||
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2 | ||
with: | ||
files: coverage.xml | ||
fail_ci_if_error: true | ||
|
@@ -139,6 +152,7 @@ jobs: | |
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
- name: Install Python | ||
uses: actions/setup-python@v5 | ||
- name: Install towncrier | ||
|
@@ -150,7 +164,9 @@ jobs: | |
run: pip install . | ||
- name: Compile Release Notes Draft | ||
if: ${{ !contains(github.ref, 'refs/tags/') }} | ||
run: towncrier build --draft --version "${{ needs.lint.outputs.version }}" > release-notes.rst | ||
run: towncrier build --draft --version "${version}" > release-notes.rst | ||
env: | ||
version: ${{ needs.lint.outputs.version }} | ||
- name: Extract release notes from Git tag | ||
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | ||
run: | | ||
|
@@ -174,6 +190,8 @@ jobs: | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | ||
needs: [lint, check, prepare-release-notes] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
seifertm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
steps: | ||
- name: Download distributions | ||
uses: actions/download-artifact@v4 | ||
|
@@ -184,18 +202,14 @@ jobs: | |
run: | | ||
tree dist | ||
- name: PyPI upload | ||
uses: pypa/[email protected] | ||
with: | ||
attestations: true | ||
packages-dir: dist | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4 | ||
- name: Download Release Notes | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: release-notes.md | ||
path: release-notes.md | ||
- name: GitHub Release | ||
uses: ncipollo/release-action@v1 | ||
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0 | ||
seifertm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
with: | ||
name: pytest-asyncio ${{ needs.lint.outputs.version }} | ||
artifacts: dist/* | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.