Skip to content

Commit f7824fe

Browse files
committed
add: statically analyze CI workflows
resolves #46 - includes changes to satisfy warnings/errors raised by zizmor
1 parent 724d561 commit f7824fe

11 files changed

Lines changed: 71 additions & 15 deletions

File tree

.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@a26af69be951a213d495a4c3e4e4022e16d87065 #v5
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/mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5
11+
with:
12+
persist-credentials: false
1113
- uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
1214
- name: Install dependencies
1315
run: uv sync --group docs

.github/workflows/pre-commit.yml

Lines changed: 8 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:
@@ -60,15 +62,16 @@ jobs:
6062
run: cargo binstall -y committed
6163
env:
6264
GITHUB_TOKEN: ${{ github.token }}
65+
PR_TITLE: ${{ github.event.pull_request.title }}
6366
- name: conventional-commit
6467
run: >-
65-
echo "${{ github.event.pull_request.title }}"
68+
echo "${PR_TITLE}"
6669
| committed --config ${{ github.workspace }}/org-repo/.github/committed.toml --commit-file -
6770
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
6871
with:
6972
node-version: latest
7073
- name: spell check
7174
working-directory: project-repo
72-
run: >-
73-
echo "${{ github.event.pull_request.title }}"
74-
| npx cspell-cli lint stdin
75+
env:
76+
PR_TITLE: ${{ github.event.pull_request.title }}
77+
run: echo "${PR_TITLE}" | npx cspell-cli lint stdin

.github/workflows/py-coverage.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ jobs:
99

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

1315
- name: Download all artifacts
1416
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 #v5

.github/workflows/py-publish.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
# use fetch --all for setuptools_scm to work
1818
with:
1919
fetch-depth: 0
20+
persist-credentials: false
2021
- name: Set up Python
2122
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #v5
2223
with:
@@ -37,14 +38,14 @@ jobs:
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5
11+
with:
12+
persist-credentials: false
1113
- name: Run Snyk to check Docker image for vulnerabilities
1214
continue-on-error: true
1315
uses: snyk/actions/docker@b98d498629f1c368650224d6d212bf7dfa89e4bf #v0.4.0

.github/workflows/sphinx.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5
17+
with:
18+
persist-credentials: false
1719
- uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
1820

1921
- name: Install dependencies
2022
run: uv sync --group docs
2123

2224
- name: Build docs
23-
run: uv run sphinx-build docs ${{ inputs.path-to-doc }}
25+
run: uv run sphinx-build docs ${INPUTS_PATH_TO_DOC}
26+
env:
27+
INPUTS_PATH_TO_DOC: ${{ inputs.path-to-doc }}
2428

2529
- name: Upload docs build as artifact
2630
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 #v4

.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"

0 commit comments

Comments
 (0)