Skip to content

Commit 410c62b

Browse files
Add GH workflow linters (#134)
Co-authored-by: Stan Ulbrych <stan@python.org>
1 parent 1ed8943 commit 410c62b

5 files changed

Lines changed: 58 additions & 18 deletions

File tree

.github/workflows/auto-tag.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,32 @@ jobs:
1515
steps:
1616
- name: Check out repository
1717
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18+
with:
19+
persist-credentials: true # Needed to push the tag
1820

1921
- name: Get current version
2022
id: version
2123
run: |
2224
VERSION=$(cat VERSION)
23-
echo "version=$VERSION" >> $GITHUB_OUTPUT
25+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
2426
2527
- name: Check if tag already exists
2628
id: checktag
29+
env:
30+
VERSION: ${{ steps.version.outputs.version }}
2731
run: |
28-
if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
29-
echo "skip=true" >> $GITHUB_OUTPUT
32+
if git rev-parse "${VERSION}" >/dev/null 2>&1; then
33+
echo "skip=true" >> "$GITHUB_OUTPUT"
3034
else
31-
echo "skip=false" >> $GITHUB_OUTPUT
35+
echo "skip=false" >> "$GITHUB_OUTPUT"
3236
fi
3337
3438
- name: Push tag
3539
if: steps.checktag.outputs.skip == 'false'
40+
env:
41+
VERSION: ${{ steps.version.outputs.version }}
3642
run: |
3743
git config user.name "github-actions[bot]"
3844
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
39-
git tag "${{ steps.version.outputs.version }}"
40-
git push origin "${{ steps.version.outputs.version }}"
45+
git tag "${VERSION}"
46+
git push origin "${VERSION}"

.github/workflows/check-for-updates.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ on:
55
- cron: '0 9 * * *' # Runs daily at 9AM UTC
66
workflow_dispatch:
77

8+
permissions: {}
9+
810
jobs:
911
check-pr-exists:
1012
runs-on: ubuntu-latest
13+
permissions:
14+
pull-requests: read
1115
outputs:
1216
pr_exists: ${{ steps.check_pr_exists.outputs.pr_exists }}
1317
steps:
@@ -16,15 +20,15 @@ jobs:
1620
env:
1721
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1822
run: |
19-
PR_EXISTS=$(gh pr --repo $GITHUB_REPOSITORY \
23+
PR_EXISTS=$(gh pr --repo "$GITHUB_REPOSITORY" \
2024
list --search "Update tzdata to version" \
2125
--json number --jq '.[] | .number')
2226
if [ -n "$PR_EXISTS" ]; then
2327
echo "A PR updating the tzdata version already exists: https://github.com/python/tzdata/pulls/${PR_EXISTS}"
24-
echo "pr_exists=true" >> $GITHUB_OUTPUT
28+
echo "pr_exists=true" >> "$GITHUB_OUTPUT"
2529
exit 0
2630
else
27-
echo "pr_exists=false" >> $GITHUB_OUTPUT
31+
echo "pr_exists=false" >> "$GITHUB_OUTPUT"
2832
fi
2933
3034
check-for-updates:
@@ -39,6 +43,7 @@ jobs:
3943
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4044
with:
4145
fetch-depth: 1 # Shallow clone to save time
46+
persist-credentials: true # Needed to push the update
4247

4348
- name: Set up Python 3.12
4449
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
@@ -62,7 +67,7 @@ jobs:
6267
# Check for changes
6368
if git diff --quiet; then
6469
echo "No changes detected."
65-
echo "CHANGES_DETECTED=false" >> $GITHUB_ENV
70+
echo "CHANGES_DETECTED=false" >> "$GITHUB_ENV"
6671
exit 0
6772
fi
6873
@@ -75,19 +80,19 @@ jobs:
7580
exit 1
7681
fi
7782
78-
if [ $(echo "$news_files" | wc -l) -ne 1 ]; then
83+
if [ "$(echo "$news_files" | wc -l)" -ne 1 ]; then
7984
echo "More than one new file added in news.d, failing the job."
8085
exit 1
8186
fi
82-
echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
87+
echo "CHANGES_DETECTED=true" >> "$GITHUB_ENV"
8388
8489
# Extract TZDATA_VERSION from filename
8590
TZDATA_VERSION=$(basename "$news_files" .md)
8691
8792
# Extract TZDATA_NEWS from file content
8893
TZDATA_NEWS=$(cat "$news_files")
8994
90-
echo "TZDATA_VERSION=$TZDATA_VERSION" >> $GITHUB_ENV
95+
echo "TZDATA_VERSION=$TZDATA_VERSION" >> "$GITHUB_ENV"
9196
{
9297
echo "TZDATA_NEWS<<EOF"
9398
echo "$TZDATA_NEWS"
@@ -111,5 +116,5 @@ jobs:
111116
gh pr create --title "Update tzdata to version $TZDATA_VERSION" \
112117
--body "$TZDATA_NEWS" \
113118
--base master \
114-
--head $(git rev-parse --abbrev-ref HEAD) \
119+
--head "$(git rev-parse --abbrev-ref HEAD)" \
115120
--label "automatic-updates"

.github/workflows/publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
id-token: write
2626
steps:
2727
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
28+
with:
29+
persist-credentials: false
2830
- name: Set up Python
2931
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
3032
with:

.github/workflows/tests.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
pull_request:
88
workflow_dispatch:
99

10+
permissions: {}
11+
1012
jobs:
1113
tests:
1214

@@ -25,9 +27,11 @@ jobs:
2527
env:
2628
TOXENV: py
2729
container:
28-
image: ${{ matrix.use-container && format('python:{0}', matrix.python-version) || '' }}
30+
image: ${{ matrix.use-container && format('python:{0}', matrix.python-version) || '' }} # zizmor: ignore[unpinned-images]
2931
steps:
3032
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
33+
with:
34+
persist-credentials: false
3135
- if: ${{ !matrix.use-container }}
3236
name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} (non-containers)
3337
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
@@ -52,6 +56,8 @@ jobs:
5256

5357
steps:
5458
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
59+
with:
60+
persist-credentials: false
5561
- name: ${{ matrix.toxenv }}
5662
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
5763
with:

.pre-commit-config.yaml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 25.9.0
3+
rev: 26.3.1
44
hooks:
55
- id: black
66
language_version: "python3.12"
77

88
- repo: https://github.com/pycqa/isort
9-
rev: 7.0.0
9+
rev: 8.0.1
1010
hooks:
1111
- id: isort
1212
additional_dependencies: [ toml ]
@@ -18,7 +18,28 @@ repos:
1818
- id: trailing-whitespace
1919
- id: debug-statements
2020

21+
- repo: https://github.com/python-jsonschema/check-jsonschema
22+
rev: 0.37.1
23+
hooks:
24+
- id: check-dependabot
25+
- id: check-github-workflows
26+
27+
- repo: https://github.com/rhysd/actionlint
28+
rev: v1.7.12
29+
hooks:
30+
- id: actionlint
31+
32+
- repo: https://github.com/zizmorcore/zizmor-pre-commit
33+
rev: v1.24.1
34+
hooks:
35+
- id: zizmor
36+
2137
- repo: https://github.com/asottile/setup-cfg-fmt
22-
rev: v3.1.0
38+
rev: v3.2.0
2339
hooks:
2440
- id: setup-cfg-fmt
41+
42+
- repo: meta
43+
hooks:
44+
- id: check-hooks-apply
45+
- id: check-useless-excludes

0 commit comments

Comments
 (0)