Skip to content

Commit c1317ad

Browse files
committed
chore(ci): harden
1 parent 39d7f4d commit c1317ad

File tree

9 files changed

+48
-76
lines changed

9 files changed

+48
-76
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: monthly

.github/workflows/add-action-project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
name: Add issue to project
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/add-to-project@v0.3.0
13+
- uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e # v1.0.2
1414
with:
1515
project-url: https://github.com/orgs/cowprotocol/projects/8
1616
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}

.github/workflows/ci.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,15 @@ on:
77

88
jobs:
99
test:
10-
strategy:
11-
matrix:
12-
node-version: [18.x]
13-
os: [ubuntu-latest]
14-
runs-on: ${{ matrix.os }}
10+
runs-on: ubuntu-latest
1511
steps:
16-
- uses: actions/checkout@v4
17-
- uses: actions/setup-node@v4
12+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1813
with:
19-
node-version: ${{ matrix.node }}
20-
- id: yarn-cache
21-
run: echo "::set-output name=dir::$(yarn cache dir)"
22-
- uses: actions/cache@v4
14+
persist-credentials: false
15+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
2316
with:
24-
path: ${{ steps.yarn-cache.outputs.dir }}
25-
key: ${{ matrix.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
26-
restore-keys: |
27-
${{ matrix.os }}-yarn-
17+
node-version: 18.x
18+
cache: yarn
2819
- run: yarn --frozen-lockfile
2920
- run: yarn build
3021
- run: yarn lint

.github/workflows/cla.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
steps:
1313
- name: "CLA Assistant"
1414
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
15-
uses: contributor-assistant/github-action@v2.6.1
15+
uses: contributor-assistant/github-action@ca4a40a7d1004f18d9960b404b97e5f30a505a08 # v2.6.1
1616
env:
1717
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1818
with:

.github/workflows/gas.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,19 @@ jobs:
2727
gas:
2828
runs-on: ubuntu-latest
2929
steps:
30-
- uses: actions/checkout@v4
30+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3131
with:
3232
submodules: recursive
33+
persist-credentials: false
3334

34-
- uses: actions/setup-node@v4
35-
- id: yarn-cache
36-
run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT"
37-
- uses: actions/cache@v4
35+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
3836
with:
39-
path: ${{ steps.yarn-cache.outputs.dir }}
40-
key: yarn-${{ hashFiles('**/yarn.lock') }}
41-
restore-keys: |
42-
yarn-
37+
cache: yarn
38+
4339
- run: yarn --frozen-lockfile
4440

4541
- name: Install Foundry
46-
uses: foundry-rs/foundry-toolchain@v1
42+
uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de # v1.4.0
4743
with:
4844
version: nightly
4945

.github/workflows/lint.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,16 @@ env:
1616

1717
jobs:
1818
lint:
19-
strategy:
20-
fail-fast: true
21-
2219
name: Foundry project
2320
runs-on: ubuntu-latest
2421
steps:
25-
- uses: actions/checkout@v4
22+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2623
with:
2724
submodules: recursive
25+
persist-credentials: false
2826

2927
- name: Install Foundry
30-
uses: foundry-rs/foundry-toolchain@v1
28+
uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de # v1.4.0
3129
with:
3230
version: nightly
3331

.github/workflows/publish.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
deploy:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v3
1615
- name: Print warning
1716
run: echo 'Publishing this branch to NPM is not supported'
1817
- name: Make the action fail

.github/workflows/review-check.yml

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,23 @@ name: Enforce Review Rules
33
on:
44
pull_request:
55
types: [opened, edited, synchronize]
6+
paths:
7+
- "src/contracts/**"
68

79
jobs:
810
enforce-review-rules:
911
runs-on: ubuntu-latest
1012

1113
steps:
1214
- name: Checkout code
13-
uses: actions/checkout@v4
14-
15-
- name: Check if PR modifies specific path
16-
shell: bash
17-
id: check-path
18-
run: |
19-
BASE_SHA=$(jq -r .pull_request.base.sha < $GITHUB_EVENT_PATH)
20-
HEAD_SHA=$(jq -r .pull_request.head.sha < $GITHUB_EVENT_PATH)
21-
git fetch origin $BASE_SHA $HEAD_SHA
22-
files=$(git diff --name-only $BASE_SHA $HEAD_SHA | tr '\n' ' ')
23-
echo "files=$files" >> $GITHUB_OUTPUT
24-
if echo "$files" | grep -q 'src/contracts/'; then
25-
echo "specific_path=true" >> $GITHUB_OUTPUT
26-
else
27-
echo "specific_path=false" >> $GITHUB_OUTPUT
28-
fi
15+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
16+
with:
17+
persist-credentials: false
2918

3019
- name: Ensure required reviewers
3120
shell: bash
3221
id: ensure-reviewers
3322
run: |
34-
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
35-
PR_NUMBER=${{ github.event.pull_request.number }}
36-
REPO=${{ github.repository }}
37-
3823
# Fetch approved and non-dismissed reviews of the PR
3924
REVIEWERS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
4025
"https://api.github.com/repos/$REPO/pulls/$PR_NUMBER/reviews" \
@@ -48,15 +33,17 @@ jobs:
4833
NUM_REVIEWERS=$(echo "$REVIEWERS" | wc -w)
4934
5035
# Check review requirements
51-
if [ "${{ steps.check-path.outputs.specific_path }}" == "true" ]; then
52-
if [ "$NUM_REVIEWERS" -lt 2 ]; then
53-
echo "Insufficient reviewers for src/contracts/ path. Required: 2 reviewers."
54-
echo "review_check_passed=false" >> $GITHUB_OUTPUT
55-
exit 1
56-
fi
36+
if [ "$NUM_REVIEWERS" -lt 2 ]; then
37+
echo "Insufficient reviewers for src/contracts/ path. Required: 2 reviewers."
38+
echo "review_check_passed=false" >> $GITHUB_OUTPUT
39+
exit 1
5740
fi
5841
5942
echo "review_check_passed=true" >> $GITHUB_OUTPUT
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
PR_NUMBER: ${{ github.event.pull_request.number }}
46+
REPO: ${{ github.repository }}
6047

6148
- name: Success message
6249
if: steps.ensure-reviewers.outputs.review_check_passed == 'true'

.github/workflows/test.yml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,39 +32,34 @@ jobs:
3232
name: Foundry project
3333
runs-on: ubuntu-latest
3434
steps:
35-
- uses: actions/checkout@v4
35+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3636
with:
3737
submodules: recursive
38+
persist-credentials: false
3839

39-
- uses: actions/setup-node@v4
40-
- id: yarn-cache
41-
run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT"
42-
- uses: actions/cache@v4
40+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
4341
with:
44-
path: ${{ steps.yarn-cache.outputs.dir }}
45-
key: yarn-${{ hashFiles('**/yarn.lock') }}
46-
restore-keys: |
47-
yarn-
42+
cache: yarn
43+
4844
- run: yarn --frozen-lockfile
4945

5046
- name: Install Foundry
51-
uses: foundry-rs/foundry-toolchain@v1
47+
uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de # v1.4.0
5248
with:
5349
version: nightly
5450

5551
- name: Run Forge build with ${{ matrix.profile }}
5652
# We always build with 0.7.6 to ensure that the project is compatible with the oldest version
5753
run: |
5854
forge --version
59-
if [ "${{ matrix.profile }}" == "solc-0.7.6" ]; then
60-
FOUNDRY_PROFILE=ci forge build --sizes --use 0.7.6 --skip 'test/*' --skip 'script/*'
55+
if [ "$PROFILE" == "solc-0.7.6" ]; then
56+
forge build --sizes --use 0.7.6 --skip 'test/*' --skip 'script/*'
6157
else
62-
FOUNDRY_PROFILE=ci forge build --sizes
58+
forge build --sizes
6359
fi
64-
id: build
60+
env:
61+
PROFILE: ${{ matrix.profile }}
6562

6663
- name: Run Forge tests
6764
if: matrix.profile != 'solc-0.7.6'
68-
run: |
69-
FOUNDRY_PROFILE=ci forge test -vvv
70-
id: test
65+
run: forge test -vvv

0 commit comments

Comments
 (0)