Skip to content

Commit c7effff

Browse files
author
FS
committed
ci: harden workflows and switch automation to pnpm
Pin GitHub Actions to commit SHAs, set default empty permissions, add job timeouts, and disable checkout credential persistence to tighten workflow security. Update CI, release, and repo scripts to use pnpm instead of npm so automation matches the project's package manager and produces more consistent installs and builds.ci: harden workflows and switch automation to pnpm Pin GitHub Actions to commit SHAs, set default empty permissions, add job timeouts, and disable checkout credential persistence to tighten workflow security. Update CI, release, and repo scripts to use pnpm instead of npm so automation matches the project's package manager and produces more consistent installs and builds.
1 parent 22ae103 commit c7effff

7 files changed

Lines changed: 529 additions & 1373 deletions

File tree

.github/workflows/ci.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,31 @@ on:
44
push:
55
pull_request:
66

7+
permissions: {}
8+
79
jobs:
810
ci:
911
runs-on: ubuntu-latest
12+
timeout-minutes: 15
1013
permissions:
1114
contents: read
12-
pull-requests: read
1315
steps:
14-
- uses: actions/checkout@v4
15-
- uses: actions/setup-node@v4
16+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
with:
18+
persist-credentials: false
19+
- uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0
20+
with:
21+
version: 8.15.4
22+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
1623
with:
1724
node-version: 20
18-
cache: npm
19-
- run: npm ci
20-
- run: npm run lint
21-
- run: npm run typecheck
22-
- run: npm run coverage
23-
- run: npm run build
24-
- uses: actions/upload-artifact@v4
25+
cache: pnpm
26+
- run: pnpm install --frozen-lockfile
27+
- run: pnpm run lint
28+
- run: pnpm run typecheck
29+
- run: pnpm run coverage
30+
- run: pnpm run build
31+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
2532
if: always()
2633
with:
2734
name: coverage-report

.github/workflows/release.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,32 @@ on:
55
tags:
66
- 'v*'
77

8+
permissions: {}
9+
810
jobs:
911
release:
1012
runs-on: ubuntu-latest
13+
timeout-minutes: 20
1114
permissions:
1215
contents: write
13-
pull-requests: read
1416
steps:
15-
- uses: actions/checkout@v4
16-
- uses: actions/setup-node@v4
17+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+
with:
19+
persist-credentials: false
20+
- uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0
21+
with:
22+
version: 8.15.4
23+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
1724
with:
1825
node-version: 20
19-
cache: npm
20-
- run: npm ci
21-
- run: npm run lint
22-
- run: npm run typecheck
23-
- run: npm run coverage
24-
- run: npm run validate
25-
- run: npm run build
26+
cache: pnpm
27+
- run: pnpm install --frozen-lockfile
28+
- run: pnpm run lint
29+
- run: pnpm run typecheck
30+
- run: pnpm run coverage
31+
- run: pnpm run validate
32+
- run: pnpm run build
2633
- run: test -f action.yml
27-
- uses: softprops/action-gh-release@v2
34+
- uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1
2835
with:
2936
generate_release_notes: true

.github/workflows/self-test.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,34 @@ name: self-test
33
on:
44
pull_request:
55

6+
permissions: {}
7+
68
jobs:
79
pass-case:
810
runs-on: ubuntu-latest
11+
timeout-minutes: 10
912
permissions:
1013
contents: read
1114
pull-requests: read
1215
steps:
13-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
with:
18+
persist-credentials: false
1419
- uses: ./
1520
with:
1621
github-token: ${{ github.token }}
1722
config-path: tests/fixtures/self-test/pass.yml
1823

1924
fail-case:
2025
runs-on: ubuntu-latest
26+
timeout-minutes: 10
2127
permissions:
2228
contents: read
2329
pull-requests: read
2430
steps:
25-
- uses: actions/checkout@v4
31+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
32+
with:
33+
persist-credentials: false
2634
- id: policy-gate
2735
continue-on-error: true
2836
uses: ./

AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ unless there is a concrete, high-signal need.
182182

183183
A change is not done unless the repo still supports:
184184

185-
- `npm run check`
186-
- `npm run validate`
187-
- `npm run release-dry-run`
185+
- `pnpm run check`
186+
- `pnpm run validate`
187+
- `pnpm run release-dry-run`
188188

189189
Coverage is part of the contract. Do not weaken it casually.
190190

dist/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4199,15 +4199,15 @@ var require_util2 = __commonJS({
41994199
return referrerOrigin;
42004200
}
42014201
case "strict-origin":
4202-
4202+
// eslint-disable-line
42034203
/**
42044204
* 1. If referrerURL is a potentially trustworthy URL and
42054205
* request’s current URL is not a potentially trustworthy URL,
42064206
* then return no referrer.
42074207
* 2. Return referrerOrigin
42084208
*/
42094209
case "no-referrer-when-downgrade":
4210-
4210+
// eslint-disable-line
42114211
/**
42124212
* 1. If referrerURL is a potentially trustworthy URL and
42134213
* request’s current URL is not a potentially trustworthy URL,
@@ -5692,7 +5692,7 @@ var require_client_h1 = __commonJS({
56925692
}
56935693
return await WebAssembly.instantiate(mod, {
56945694
env: {
5695-
5695+
/* eslint-disable camelcase */
56965696
wasm_on_url: (p, at, len) => {
56975697
return 0;
56985698
},
@@ -5728,7 +5728,7 @@ var require_client_h1 = __commonJS({
57285728
assert(currentParser.ptr === p);
57295729
return currentParser.onMessageComplete() || 0;
57305730
}
5731-
5731+
/* eslint-enable camelcase */
57325732
}
57335733
});
57345734
}

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"node": ">=20"
1717
},
1818
"scripts": {
19-
"build": "npm run clean && tsup --config tsup.config.ts",
19+
"build": "pnpm run clean && tsup --config tsup.config.ts",
2020
"clean": "rm -rf build dist coverage .vitest",
2121
"compile": "tsc --outDir build",
2222
"lint": "mkdir -p build && eslint src tests scripts eslint.config.cjs",
@@ -28,11 +28,11 @@
2828
"test:watch": "vitest",
2929
"coverage": "vitest run --coverage",
3030
"typecheck": "tsc --noEmit",
31-
"validate:config": "npm run compile && node scripts/validate-example-config.js",
32-
"validate": "npm run validate:config",
33-
"check": "npm run lint:ci && npm run format:check && npm run typecheck && npm run test && npm run coverage && npm run build",
34-
"prepare": "npm run build",
35-
"release-dry-run": "npm run build && npm pack --dry-run"
31+
"validate:config": "pnpm run compile && node scripts/validate-example-config.js",
32+
"validate": "pnpm run validate:config",
33+
"check": "pnpm run lint:ci && pnpm run format:check && pnpm run typecheck && pnpm run test && pnpm run coverage && pnpm run build",
34+
"prepare": "pnpm run build",
35+
"release-dry-run": "pnpm run build && pnpm pack --dry-run"
3636
},
3737
"keywords": [
3838
"github action",

0 commit comments

Comments
 (0)