Skip to content

Commit a83768d

Browse files
fix: make contract checks always run but skip when no changes
Modified contract workflows to always run required checks (lint, slither, build-and-test, deployment-dry-run) even when no contract files changed. When no changes are detected in PRs, these jobs now run but immediately skip their steps, allowing them to pass quickly. This fixes the issue where PRs without contract changes would be blocked waiting for required checks that never started.
1 parent 4e11dd7 commit a83768d

File tree

2 files changed

+68
-26
lines changed

2 files changed

+68
-26
lines changed

.github/workflows/contracts-ecdsa.yml

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,19 @@ jobs:
5757
5858
contracts-lint:
5959
needs: contracts-detect-changes
60-
if: |
61-
github.event_name == 'push'
62-
|| needs.contracts-detect-changes.outputs.path-filter == 'true'
6360
runs-on: ubuntu-latest
6461
defaults:
6562
run:
6663
working-directory: ./solidity/ecdsa
6764
steps:
6865
- uses: actions/checkout@v3
6966

67+
- name: Skip if no contract changes
68+
if: github.event_name == 'pull_request' && needs.contracts-detect-changes.outputs.path-filter != 'true'
69+
run: echo "No contract changes detected, skipping lint"
70+
7071
- uses: actions/setup-node@v3
72+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
7173
with:
7274
# Using fixed version, because 18.16 was sometimes causing issues with
7375
# artifacts generation during `hardhat compile` - see
@@ -77,27 +79,32 @@ jobs:
7779
cache-dependency-path: solidity/ecdsa/yarn.lock
7880

7981
- name: Install dependencies
82+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
8083
run: yarn install
8184

8285
- name: Build
86+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
8387
run: yarn build
8488

8589
- name: Lint
90+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
8691
run: yarn lint
8792

8893
contracts-slither:
8994
needs: contracts-detect-changes
90-
if: |
91-
github.event_name == 'push'
92-
|| needs.contracts-detect-changes.outputs.path-filter == 'true'
9395
runs-on: ubuntu-latest
9496
defaults:
9597
run:
9698
working-directory: ./solidity/ecdsa
9799
steps:
98100
- uses: actions/checkout@v3
99101

102+
- name: Skip if no contract changes
103+
if: github.event_name == 'pull_request' && needs.contracts-detect-changes.outputs.path-filter != 'true'
104+
run: echo "No contract changes detected, skipping slither"
105+
100106
- uses: actions/setup-node@v3
107+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
101108
with:
102109
# Using fixed version, because 18.16 was sometimes causing issues with
103110
# artifacts generation during `hardhat compile` - see
@@ -107,10 +114,12 @@ jobs:
107114
cache-dependency-path: solidity/ecdsa/yarn.lock
108115

109116
- uses: actions/setup-python@v4
117+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
110118
with:
111119
python-version: 3.10.8
112120

113121
- name: Install Solidity
122+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
114123
env:
115124
SOLC_VERSION: 0.8.9 # according to solidity.version in hardhat.config.ts
116125
run: |
@@ -119,31 +128,36 @@ jobs:
119128
solc-select use $SOLC_VERSION
120129
121130
- name: Install Slither
131+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
122132
env:
123133
SLITHER_VERSION: 0.8.3
124134
run: pip3 install slither-analyzer==$SLITHER_VERSION
125135

126136
- name: Install dependencies
137+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
127138
run: yarn install
128139

129140
# As a workaround for a slither issue https://github.com/crytic/slither/issues/1140
130141
# we disable compilation of dependencies when running slither.
131142
- name: Run Slither
143+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
132144
run: SKIP_DEPENDENCY_COMPILER=true slither .
133145

134146
contracts-build-and-test:
135147
needs: contracts-detect-changes
136-
if: |
137-
github.event_name != 'pull_request'
138-
|| needs.contracts-detect-changes.outputs.path-filter == 'true'
139148
runs-on: ubuntu-latest
140149
defaults:
141150
run:
142151
working-directory: ./solidity/ecdsa
143152
steps:
144153
- uses: actions/checkout@v3
145154

155+
- name: Skip if no contract changes
156+
if: github.event_name == 'pull_request' && needs.contracts-detect-changes.outputs.path-filter != 'true'
157+
run: echo "No contract changes detected, skipping tests"
158+
146159
- uses: actions/setup-node@v3
160+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
147161
with:
148162
# Using fixed version, because 18.16 was sometimes causing issues with
149163
# artifacts generation during `hardhat compile` - see
@@ -153,28 +167,32 @@ jobs:
153167
cache-dependency-path: solidity/ecdsa/yarn.lock
154168

155169
- name: Install dependencies
170+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
156171
run: yarn install
157172

158173
- name: Build solidity contracts
174+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
159175
run: yarn build
160176

161177
- name: Run tests
162-
if: github.ref != 'refs/heads/dapp-development'
178+
if: (github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true') && github.ref != 'refs/heads/dapp-development'
163179
run: yarn test
164180

165181
contracts-deployment-dry-run:
166182
needs: contracts-detect-changes
167-
if: |
168-
github.event_name != 'pull_request'
169-
|| needs.contracts-detect-changes.outputs.path-filter == 'true'
170183
runs-on: ubuntu-latest
171184
defaults:
172185
run:
173186
working-directory: ./solidity/ecdsa
174187
steps:
175188
- uses: actions/checkout@v3
176189

190+
- name: Skip if no contract changes
191+
if: github.event_name == 'pull_request' && needs.contracts-detect-changes.outputs.path-filter != 'true'
192+
run: echo "No contract changes detected, skipping deployment dry run"
193+
177194
- uses: actions/setup-node@v3
195+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
178196
with:
179197
# Using fixed version, because 18.16 was sometimes causing issues with
180198
# artifacts generation during `hardhat compile` - see
@@ -184,12 +202,15 @@ jobs:
184202
cache-dependency-path: solidity/ecdsa/yarn.lock
185203

186204
- name: Install dependencies
205+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
187206
run: yarn install --frozen-lockfile
188207

189208
- name: Deploy contracts
209+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
190210
run: yarn deploy:test
191211

192212
- name: Build Docker Image
213+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
193214
uses: ./.github/actions/docker-build-push
194215
with:
195216
imageName: keep-ecdsa-hardhat

.github/workflows/contracts-random-beacon.yml

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,19 @@ jobs:
5757
5858
contracts-lint:
5959
needs: contracts-detect-changes
60-
if: |
61-
github.event_name == 'push'
62-
|| needs.contracts-detect-changes.outputs.path-filter == 'true'
6360
runs-on: ubuntu-latest
6461
defaults:
6562
run:
6663
working-directory: ./solidity/random-beacon
6764
steps:
6865
- uses: actions/checkout@v3
6966

67+
- name: Skip if no contract changes
68+
if: github.event_name == 'pull_request' && needs.contracts-detect-changes.outputs.path-filter != 'true'
69+
run: echo "No contract changes detected, skipping lint"
70+
7071
- uses: actions/setup-node@v3
72+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
7173
with:
7274
# Using fixed version, because 18.16 was sometimes causing issues with
7375
# artifacts generation during `hardhat compile` - see
@@ -77,27 +79,32 @@ jobs:
7779
cache-dependency-path: solidity/random-beacon/yarn.lock
7880

7981
- name: Install dependencies
82+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
8083
run: yarn install --network-concurrency 1
8184

8285
- name: Build
86+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
8387
run: yarn build
8488

8589
- name: Lint
90+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
8691
run: yarn lint
8792

8893
contracts-slither:
8994
needs: contracts-detect-changes
90-
if: |
91-
github.event_name == 'push'
92-
|| needs.contracts-detect-changes.outputs.path-filter == 'true'
9395
runs-on: ubuntu-latest
9496
defaults:
9597
run:
9698
working-directory: ./solidity/random-beacon
9799
steps:
98100
- uses: actions/checkout@v3
99101

102+
- name: Skip if no contract changes
103+
if: github.event_name == 'pull_request' && needs.contracts-detect-changes.outputs.path-filter != 'true'
104+
run: echo "No contract changes detected, skipping slither"
105+
100106
- uses: actions/setup-node@v3
107+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
101108
with:
102109
# Using fixed version, because 18.16 was sometimes causing issues with
103110
# artifacts generation during `hardhat compile` - see
@@ -107,10 +114,12 @@ jobs:
107114
cache-dependency-path: solidity/random-beacon/yarn.lock
108115

109116
- uses: actions/setup-python@v4
117+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
110118
with:
111119
python-version: 3.10.8
112120

113121
- name: Install Solidity
122+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
114123
env:
115124
SOLC_VERSION: 0.8.9 # according to solidity.version in hardhat.config.js
116125
run: |
@@ -119,29 +128,34 @@ jobs:
119128
solc-select use $SOLC_VERSION
120129
121130
- name: Install Slither
131+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
122132
env:
123133
SLITHER_VERSION: 0.8.3
124134
run: pip3 install slither-analyzer==$SLITHER_VERSION
125135

126136
- name: Install dependencies
137+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
127138
run: yarn install --network-concurrency 1
128139

129140
- name: Run Slither
141+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
130142
run: slither .
131143

132144
contracts-build-and-test:
133145
needs: contracts-detect-changes
134-
if: |
135-
github.event_name != 'pull_request'
136-
|| needs.contracts-detect-changes.outputs.path-filter == 'true'
137146
runs-on: ubuntu-latest
138147
defaults:
139148
run:
140149
working-directory: ./solidity/random-beacon
141150
steps:
142151
- uses: actions/checkout@v3
143152

153+
- name: Skip if no contract changes
154+
if: github.event_name == 'pull_request' && needs.contracts-detect-changes.outputs.path-filter != 'true'
155+
run: echo "No contract changes detected, skipping tests"
156+
144157
- uses: actions/setup-node@v3
158+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
145159
with:
146160
# Using fixed version, because 18.16 was sometimes causing issues with
147161
# artifacts generation during `hardhat compile` - see
@@ -151,28 +165,32 @@ jobs:
151165
cache-dependency-path: solidity/random-beacon/yarn.lock
152166

153167
- name: Install dependencies
168+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
154169
run: yarn install --network-concurrency 1
155170

156171
- name: Build solidity contracts
172+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
157173
run: yarn build
158174

159175
- name: Run tests
160-
if: github.ref != 'refs/heads/dapp-development'
176+
if: (github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true') && github.ref != 'refs/heads/dapp-development'
161177
run: yarn test
162178

163179
contracts-deployment-dry-run:
164180
needs: contracts-detect-changes
165-
if: |
166-
github.event_name != 'pull_request'
167-
|| needs.contracts-detect-changes.outputs.path-filter == 'true'
168181
runs-on: ubuntu-latest
169182
defaults:
170183
run:
171184
working-directory: ./solidity/random-beacon
172185
steps:
173186
- uses: actions/checkout@v3
174187

188+
- name: Skip if no contract changes
189+
if: github.event_name == 'pull_request' && needs.contracts-detect-changes.outputs.path-filter != 'true'
190+
run: echo "No contract changes detected, skipping deployment dry run"
191+
175192
- uses: actions/setup-node@v3
193+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
176194
with:
177195
# Using fixed version, because 18.16 was sometimes causing issues with
178196
# artifacts generation during `hardhat compile` - see
@@ -182,12 +200,15 @@ jobs:
182200
cache-dependency-path: solidity/random-beacon/yarn.lock
183201

184202
- name: Install dependencies
203+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
185204
run: yarn install --network-concurrency 1 --frozen-lockfile
186205

187206
- name: Deploy contracts
207+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
188208
run: yarn deploy:test
189209

190210
- name: Build Docker Image
211+
if: github.event_name != 'pull_request' || needs.contracts-detect-changes.outputs.path-filter == 'true'
191212
uses: ./.github/actions/docker-build-push
192213
with:
193214
imageName: keep-random-beacon-hardhat

0 commit comments

Comments
 (0)