Skip to content

Commit 3347398

Browse files
authored
add: statically analyze CI workflows (#51)
resolves #46 includes changes to satisfy warnings/errors raised by zizmor
1 parent 9820dbf commit 3347398

File tree

10 files changed

+78
-25
lines changed

10 files changed

+78
-25
lines changed

.github/workflows/ci-check.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
on:
2+
workflow_call:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
8+
permissions: {}
9+
10+
jobs:
11+
check-ci-workflows:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
steps:
16+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
17+
with:
18+
persist-credentials: false
19+
repository: ${{ github.repository }}
20+
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
21+
with:
22+
python-version: '3.x'
23+
- name: Run zizmor
24+
env:
25+
GH_TOKEN: ${{ github.token }}
26+
FORCE_COLOR: 1
27+
run: pipx run zizmor --format=github .github/workflows/*.yml

.github/workflows/codeql.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ jobs:
4444
steps:
4545
- name: Checkout repository
4646
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5
47+
with:
48+
persist-credentials: false
4749

4850
# Initializes the CodeQL tools for scanning.
4951
- name: Initialize CodeQL

.github/workflows/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ on:
66
pull_request:
77
branches: [main]
88

9+
permissions: {}
10+
911
jobs:
1012
main:
13+
permissions:
14+
contents: read
1115
uses: ./.github/workflows/pre-commit.yml
1216
stale:
17+
permissions:
18+
contents: read
19+
issues: write
20+
pull-requests: write
1321
uses: ./.github/workflows/stale.yml

.github/workflows/pre-commit.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ jobs:
2222
python-version: '3.x'
2323
- name: Run commands
2424
if: inputs.commands
25-
run: ${{ inputs.commands }}
25+
run: ${INPUTS_COMMANDS}
26+
env:
27+
INPUTS_COMMANDS: ${{ inputs.commands }}
2628
- name: Cache pre-commit environments
2729
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
2830
with:
@@ -61,14 +63,16 @@ jobs:
6163
env:
6264
GITHUB_TOKEN: ${{ github.token }}
6365
- name: conventional-commit
66+
env:
67+
PR_TITLE: ${{ github.event.pull_request.title }}
6468
run: >-
65-
echo "${{ github.event.pull_request.title }}"
69+
echo "${PR_TITLE}"
6670
| committed --config ${{ github.workspace }}/org-repo/.github/committed.toml --commit-file -
6771
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
6872
with:
6973
node-version: latest
7074
- name: spell check
7175
working-directory: project-repo
72-
run: >-
73-
echo "${{ github.event.pull_request.title }}"
74-
| npx cspell-cli lint stdin
76+
env:
77+
PR_TITLE: ${{ github.event.pull_request.title }}
78+
run: echo "${PR_TITLE}" | npx cspell-cli lint stdin

.github/workflows/py-coverage.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5
11+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
12+
with:
13+
persist-credentials: false
1214

1315
- name: Download all artifacts
14-
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 #v5
16+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
1517
with:
1618
pattern: coverage-data-*
1719
merge-multiple: true
1820

1921
- name: Setup python
20-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #v5
22+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
2123
with:
2224
python-version: '3.x'
2325

@@ -28,14 +30,14 @@ jobs:
2830
coverage html
2931
3032
- name: Upload comprehensive coverage HTML report
31-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 #v4
33+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
3234
with:
3335
name: coverage-report
3436
path: htmlcov/
3537

3638
- run: coverage report && coverage xml
3739

38-
- uses: codecov/codecov-action@fdcc8476540edceab3de004e990f80d881c6cc00 #v5
40+
- uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
3941
env:
4042
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
4143
with:

.github/workflows/py-publish.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5
16+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1717
# use fetch --all for setuptools_scm to work
1818
with:
1919
fetch-depth: 0
20+
persist-credentials: false
2021
- name: Set up Python
21-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #v5
22+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
2223
with:
2324
python-version: '3.x'
2425

@@ -32,19 +33,19 @@ jobs:
3233
run: twine check dist/*
3334

3435
- name: Create attestations
35-
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a #v3
36+
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
3637
with:
3738
subject-path: 'dist/*'
3839

3940
- name: Publish package (to TestPyPI)
40-
if: github.event_name == 'workflow_dispatch' && startsWith(github.repository, 'cpp-linter')
41+
if: startsWith(github.repository, 'cpp-linter') && !startsWith(github.ref, 'refs/tags/')
4142
env:
4243
TWINE_USERNAME: __token__
4344
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
4445
run: twine upload --repository testpypi dist/*
4546

4647
- name: Publish package (to PyPI)
47-
if: github.event_name != 'workflow_dispatch' && startsWith(github.repository, 'cpp-linter')
48+
if: startsWith(github.repository, 'cpp-linter') && startsWith(github.ref, 'refs/tags/')
4849
env:
4950
TWINE_USERNAME: __token__
5051
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/snyk-container.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ jobs:
77
snyk:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5
10+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
11+
with:
12+
persist-credentials: false
1113
- name: Run Snyk to check Docker image for vulnerabilities
1214
continue-on-error: true
13-
uses: snyk/actions/docker@b98d498629f1c368650224d6d212bf7dfa89e4bf #v0.4.0
15+
uses: snyk/actions/docker@b98d498629f1c368650224d6d212bf7dfa89e4bf # v0.4.0
1416
env:
1517
# In order to use the Snyk Action you will need to have a Snyk API token.
1618
# More details in https://github.com/snyk/actions#getting-your-snyk-token

.github/workflows/sphinx.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ jobs:
2020
- name: Install dependencies
2121
run: uv sync --group docs
2222
- name: Build docs
23-
run: uv run sphinx-build docs ${{ inputs.path-to-doc }}
23+
run: uv run sphinx-build docs ${INPUTS_PATH_TO_DOC}
24+
env:
25+
INPUTS_PATH_TO_DOC: ${{ inputs.path-to-doc }}
2426
- name: Upload docs build as artifact
2527
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
2628
with:

.github/workflows/stale.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
name: 'Close stale issues'
1+
name: "Close stale issues"
22

33
on: [workflow_call]
44

55
jobs:
66
stale:
7+
permissions:
8+
contents: read
9+
issues: write
10+
pull-requests: write
711
runs-on: ubuntu-latest
812
steps:
913
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 #v9
1014
with:
11-
stale-issue-message: >-
12-
This issue has been automatically marked as stale because
13-
it has not had recent activity.
14-
It will be closed if no further activity occurs.
15-
# Better to exclude certain issues from being marked as stale
16-
exempt-issue-labels: 'help wanted,security,pinned,bug'
15+
stale-issue-message: >-
16+
This issue has been automatically marked as stale because
17+
it has not had recent activity.
18+
It will be closed if no further activity occurs.
19+
# Better to exclude certain issues from being marked as stale
20+
exempt-issue-labels: "help wanted,security,pinned,bug"

cspell.config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ words:
1717
- testpypi
1818
- venv
1919
- xianpengshen
20+
- zizmor
2021
ignorePaths:
2122
- .env/**
2223
- .venv/**

0 commit comments

Comments
 (0)