Skip to content

Commit a3f4220

Browse files
committed
ci: align CI config
Signed-off-by: Rifa Achrinza <[email protected]>
1 parent 9045ad8 commit a3f4220

File tree

4 files changed

+1656
-21
lines changed

4 files changed

+1656
-21
lines changed

.github/workflows/ci.yml

Lines changed: 67 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
# The branches below must be a subset of the branches above
77
branches: [master]
88

9+
permissions: {}
10+
911
jobs:
1012
build:
1113
runs-on: ubuntu-22.04
@@ -16,53 +18,98 @@ jobs:
1618
strategy:
1719
matrix:
1820
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
19-
node-version: [18, 20]
21+
node-version:
22+
- 18
23+
- 20
24+
- 21
2025
steps:
21-
- uses: actions/checkout@v4
26+
- uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
27+
with:
28+
egress-policy: audit
29+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2230
- name: Use Node.js ${{ matrix.node-version }}
23-
uses: actions/setup-node@v4
31+
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
2432
with:
33+
cache: npm
2534
node-version: ${{ matrix.node-version }}
26-
- uses: ankane/setup-mysql@v1
35+
- uses: ankane/setup-mysql@0066c6761a230df8a1ce7f26f3f434c7f3405ae7 # v1
2736
with:
2837
mysql-version: 8.0
2938
- run: |
30-
sudo mysql -e "CREATE USER '$MYSQL_USER'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD'"
31-
sudo mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'localhost'"
32-
sudo mysql -u root -e "ALTER USER '$MYSQL_USER'@'localhost' IDENTIFIED WITH mysql_native_password by '$MYSQL_PASSWORD'"
33-
sudo mysql -u root -e "FLUSH PRIVILEGES"
34-
- run: npm install
35-
- run: npm test
39+
cat <<EOF | sudo mysql -e
40+
CREATE USER
41+
'$MYSQL_USER'@'localhost'
42+
IDENTIFIED BY '$MYSQL_PASSWORD';
43+
44+
GRANT ALL PRIVILEGES
45+
ON *.*
46+
TO '$MYSQL_USER'@'localhost';
47+
48+
ALTER USER
49+
'$MYSQL_USER'@'localhost'
50+
IDENTIFIED WITH mysql_native_password
51+
BY '$MYSQL_PASSWORD';
52+
53+
FLUSH PRIVILEGES;
54+
EOF
55+
- run: |
56+
npm ci \
57+
--ignore-scripts \
58+
--prefer-offline
59+
- run: npm test --ignore-scripts
3660
code-lint:
3761
name: Code Lint
3862
runs-on: ubuntu-latest
39-
timeout-minutes: 60
63+
timeout-minutes: 5
4064
steps:
41-
- uses: actions/checkout@v4
65+
- uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
66+
with:
67+
egress-policy: audit
68+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
4269
- name: Use Node.js 18
43-
uses: actions/setup-node@v4
70+
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
4471
with:
72+
cache: npm
4573
node-version: 18
4674
- name: Bootstrap project
4775
run: |
48-
npm ci --ignore-scripts
76+
npm ci \
77+
--ignore-scripts \
78+
--prefer-offline
4979
- name: Verify code linting
50-
run: npm run lint
80+
run: |
81+
npm run \
82+
--ignore-script \
83+
lint
5184
5285
commit-lint:
5386
name: Commit Lint
5487
runs-on: ubuntu-latest
55-
timeout-minutes: 60
88+
timeout-minutes: 5
5689
steps:
57-
- uses: actions/checkout@v4
90+
- uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
91+
with:
92+
egress-policy: audit
93+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
5894
with:
5995
fetch-depth: 0
6096
- name: Use Node.js 18
61-
uses: actions/setup-node@v4
97+
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
6298
with:
99+
cache: npm
63100
node-version: 18
64101
- name: Bootstrap project
65102
run: |
66-
npm ci --ignore-scripts
103+
npm ci \
104+
--ignore-scripts \
105+
--prefer-offline
67106
- name: Verify commit linting
68-
run: npx commitlint --from origin/master --to HEAD --verbose
107+
run: |
108+
npm exec \
109+
--package=@commitlint/cli \
110+
-- \
111+
commitlint \
112+
--from=origin/master \
113+
--to=HEAD \
114+
--verbose
115+

.github/workflows/scorecards.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Based on `scorecard.yml` Github Actions starter workflow:
2+
# https://github.com/actions/starter-workflows/blob/b1df8a546ed4d0f27d46aaf2f8ac1118bc522638/code-scanning/scorecard.yml
3+
4+
# This is separate from the CI workflow due to certain restrictions imposed by the GitHub Action action:
5+
# https://github.com/ossf/scorecard-action/tree/99cc02c8ee27bab5f5f41e79066e0de91d313dec#workflow-restrictions
6+
# For consistency, we should keep it a separate workflow across all our Github repositories, regardless if it's actually needed.
7+
8+
name: OSSF Scorecard
9+
on:
10+
# For Branch-Protection check. Only the default branch is supported. See
11+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
12+
branch_protection_rule: {}
13+
# To guarantee Maintained check is occasionally updated. See
14+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
15+
schedule:
16+
- cron: '30 6 * * 5'
17+
push:
18+
branches: [master]
19+
20+
# Declare default permissions as read only.
21+
# permissions: read-all
22+
permissions: {}
23+
24+
jobs:
25+
analysis:
26+
name: Scorecard analysis
27+
runs-on: ubuntu-latest
28+
permissions:
29+
# Needed to upload the results to code-scanning dashboard.
30+
security-events: write
31+
# Needed to publish results and get a badge (see publish_results below).
32+
id-token: write
33+
34+
steps:
35+
- uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
36+
if: ${{ matrix.os == 'ubuntu-latest' }}
37+
with:
38+
disable-sudo: true
39+
egress-policy: block
40+
allowed-endpoints: >
41+
api.github.com:443
42+
api.osv.dev:443
43+
api.securityscorecards.dev:443
44+
fulcio.sigstore.dev:443
45+
github.com:443
46+
oss-fuzz-build-logs.storage.googleapis.com:443
47+
rekor.sigstore.dev:443
48+
tuf-repo-cdn.sigstore.dev:443
49+
www.bestpractices.dev:443
50+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
51+
with:
52+
persist-credentials: false
53+
54+
- uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
55+
with:
56+
results_file: results.sarif
57+
results_format: sarif
58+
# Public repositories:
59+
# - Publish results to OpenSSF REST API for easy access by consumers
60+
# - Allows the repository to include the Scorecard badge.
61+
# - See https://github.com/ossf/scorecard-action#publishing-results.
62+
# For private repositories:
63+
# - `publish_results` will always be set to `false`, regardless
64+
# of the value entered here.
65+
publish_results: true
66+
67+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
68+
# format to the repository Actions tab.
69+
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
70+
with:
71+
name: OSSF Scorecard SARIF file
72+
path: results.sarif
73+
retention-days: 90
74+
75+
# Upload the results to GitHub's code scanning dashboard.
76+
- uses: github/codeql-action/upload-sarif@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
77+
with:
78+
sarif_file: results.sarif

0 commit comments

Comments
 (0)