Repository navigation
323 lines (289 loc) · 11.8 KB
/
Copy pathsolidity.yml
File metadata and controls
323 lines (289 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
name: Solidity
on:
merge_group:
pull_request:
push:
tags:
- 'contracts-v*'
- 'contracts-cre-v*'
defaults:
run:
shell: bash
permissions: {}
jobs:
readonly_changes:
name: Detect readonly solidity file changes
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.ch.outputs.changes }}
steps:
- name: Checkout the repo
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Detect readonly solidity file changes
id: ch
uses: ./.github/actions/detect-solidity-readonly-file-changes
changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.ch.outputs.changes }}
steps:
- name: Checkout the repo
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Detect changes
id: ch
uses: ./.github/actions/detect-solidity-file-changes
tag-check:
needs: [changes]
name: Tag Check
runs-on: ubuntu-latest
outputs:
is-release-core: ${{ steps.release-tag-check-core.outputs.is-release }}
is-pre-release-core: ${{ steps.release-tag-check-core.outputs.is-pre-release }}
release-version-core: ${{ steps.release-tag-check-core.outputs.release-version }}
pre-release-version-core: ${{ steps.release-tag-check-core.outputs.pre-release-version }}
is-release-cre: ${{ steps.release-tag-check-cre.outputs.is-release }}
is-pre-release-cre: ${{ steps.release-tag-check-cre.outputs.is-pre-release }}
release-version-cre: ${{ steps.release-tag-check-cre.outputs.release-version }}
pre-release-version-cre: ${{ steps.release-tag-check-cre.outputs.pre-release-version }}
is-release: ${{ steps.release-tag-check-core.outputs.is-release == 'true' || steps.release-tag-check-cre.outputs.is-release == 'true'}}
is-pre-release: ${{ steps.release-tag-check-core.outputs.is-pre-release == 'true' || steps.release-tag-check-cre.outputs.is-pre-release == 'true' }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check release tag (core)
id: release-tag-check-core
uses: smartcontractkit/.github/actions/release-tag-check@c5c4a8186da4218cff6cac8184e47dd3dec69ba3 # release-tag-check@0.1.0
env:
# Match semver git tags with a "contracts-" prefix.
RELEASE_REGEX: '^contracts-v[0-9]+\.[0-9]+\.[0-9]+$'
PRE_RELEASE_REGEX: '^contracts-v[0-9]+\.[0-9]+\.[0-9]+-(.+)$'
# Get the version by stripping the "contracts-v" prefix.
VERSION_PREFIX: "contracts-v"
- name: Check release tag (CRE)
id: release-tag-check-cre
uses: smartcontractkit/.github/actions/release-tag-check@c5c4a8186da4218cff6cac8184e47dd3dec69ba3 # release-tag-check@0.1.0
env:
# Match semver git tags with a "contracts-cre-" prefix.
RELEASE_REGEX: '^contracts-cre-v[0-9]+\.[0-9]+\.[0-9]+$'
PRE_RELEASE_REGEX: '^contracts-cre-v[0-9]+\.[0-9]+\.[0-9]+-(.+)$'
# Get the version by stripping the "contracts-cre-v" prefix.
VERSION_PREFIX: "contracts-cre-v"
native-compile:
needs: [changes, tag-check]
if: needs.changes.outputs.changes == 'true' || needs.tag-check.outputs.is-release == 'true' || needs.tag-check.outputs.is-pre-release == 'true'
name: Native Compilation
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
with:
persist-credentials: false
path: chainlink
- name: Checkout diff-so-fancy
uses: actions/checkout@v4
with:
persist-credentials: false
repository: so-fancy/diff-so-fancy
ref: a673cb4d2707f64d92b86498a2f5f71c8e2643d5 # v1.4.3
path: diff-so-fancy
- name: Install diff-so-fancy
run: echo "$GITHUB_WORKSPACE/diff-so-fancy" >> $GITHUB_PATH
- name: Setup NodeJS
uses: ./chainlink/.github/actions/setup-nodejs
with:
base-path: "chainlink"
prod: "true"
- name: Setup Go
uses: ./chainlink/.github/actions/setup-go
with:
go-version-file: "chainlink/go.mod"
- name: Install Foundry
uses: ./chainlink/.github/actions/install-solidity-foundry
with:
working-directory: chainlink/contracts
- name: Run native compile and generate wrappers
working-directory: ./chainlink/contracts
run: make wrappers-all
- name: Check if Go solidity wrappers are updated
working-directory: chainlink
run: |
git add --all
git diff --minimal --color --cached --exit-code | diff-so-fancy
wrapper-result-validation:
if: ${{ always() }}
needs: [changes, native-compile]
runs-on: ubuntu-latest
steps:
- name: Check if Go solidity wrappers are updated
if: needs.changes.outputs.changes == 'true' && needs.native-compile.result != 'success'
run: exit 1
# The if statements for steps after checkout repo is a workaround for
# passing required check for PRs that don't have filtered changes.
lint:
defaults:
run:
working-directory: contracts
needs: [changes, tag-check]
if: needs.changes.outputs.changes == 'true' || needs.tag-check.outputs.is-pre-release == 'true' || needs.tag-check.outputs.is-release == 'true'
name: Solidity Lint
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup NodeJS
uses: ./.github/actions/setup-nodejs
- name: Run solhint
run: pnpm solhint
- name: Run solhint on tests
run: pnpm solhint-test
publish-beta:
name: Publish Beta NPM
environment: publish-contracts
needs: [tag-check, changes, lint, native-compile]
if: needs.tag-check.outputs.is-pre-release-core == 'true' || needs.tag-check.outputs.is-pre-release-cre == 'true'
runs-on: ubuntu-latest
permissions:
id-token: write # Required for OIDC
steps:
- name: Checkout the repo
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup NodeJS
uses: ./.github/actions/setup-nodejs
- name: Install Foundry
uses: ./.github/actions/install-solidity-foundry
- name: Run native compile and generate wrappers
working-directory: contracts
run: make wrappers-all
- name: Version package.json - Core
if: needs.tag-check.outputs.is-pre-release-core == 'true'
working-directory: contracts
shell: bash
env:
IS_PRE_RELEASE_CORE: ${{ needs.tag-check.outputs.is-pre-release-core }}
PRE_RELEASE_VERSION_CORE: ${{ needs.tag-check.outputs.pre-release-version-core }}
run: |
version=""
if [[ $IS_PRE_RELEASE_CORE == 'true' ]]; then
version="${PRE_RELEASE_VERSION_CORE}"
else
echo "::error::No pre-release version found."
exit 1
fi
echo "Bumping version to ${version}"
pnpm version "${version}" --no-git-tag-version --no-commit-hooks --no-git-checks
- name: Publish to NPM (beta) - Core
if: needs.tag-check.outputs.is-pre-release-core == 'true'
uses: smartcontractkit/.github/actions/ci-publish-npm@1861140c62d65adc4b573f826446ba7106beed1a #v1
with:
create-github-release: false
publish-command: "pnpm publish-beta --no-git-checks"
package-json-directory: contracts
- name: Version package.json - CRE
if: needs.tag-check.outputs.is-pre-release-cre == 'true'
working-directory: contracts/cre
shell: bash
env:
IS_PRE_RELEASE_CRE: ${{ needs.tag-check.outputs.is-pre-release-cre }}
PRE_RELEASE_VERSION_CRE: ${{ needs.tag-check.outputs.pre-release-version-cre }}
run: |
version=""
if [[ $IS_PRE_RELEASE_CRE == 'true' ]]; then
version="${PRE_RELEASE_VERSION_CRE}"
else
echo "::error::No pre-release version found."
exit 1
fi
echo "Bumping version to ${version}"
pnpm version "${version}" --no-git-tag-version --no-commit-hooks --no-git-checks
- name: Publish to NPM (beta) - CRE
if: needs.tag-check.outputs.is-pre-release-cre == 'true'
uses: smartcontractkit/.github/actions/ci-publish-npm@1861140c62d65adc4b573f826446ba7106beed1a #v1
with:
create-github-release: false
publish-command: "pnpm publish-beta --no-git-checks"
package-json-directory: contracts/cre
publish-prod:
name: Publish Prod NPM
environment: publish-contracts
needs: [tag-check, changes, lint, native-compile]
if: needs.tag-check.outputs.is-release == 'true' || needs.tag-check.outputs.is-release-cre == 'true'
runs-on: ubuntu-latest
permissions:
id-token: write # Required for OIDC
contents: write # Required to create the GitHub release
steps:
- name: Checkout the repo
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup NodeJS
uses: ./.github/actions/setup-nodejs
- name: Install Foundry
uses: ./.github/actions/install-solidity-foundry
- name: Run native compile and generate wrappers
working-directory: contracts
run: make wrappers-all
- name: Validate version - Core
if: needs.tag-check.outputs.is-release-core == 'true'
working-directory: contracts
shell: bash
env:
IS_RELEASE_CORE: ${{ needs.tag-check.outputs.is-release-core }}
RELEASE_VERSION_CORE: ${{ needs.tag-check.outputs.release-version-core }}
run: |
VERSION=""
if [[ "${IS_RELEASE_CORE}" == 'true' ]]; then
VERSION="${RELEASE_VERSION_CORE}"
else
echo "::error::No release version found."
exit 1
fi
PACKAGE_JSON_VERSION="$(jq -r '.version' package.json)"
if [[ "${PACKAGE_JSON_VERSION}" != "${VERSION}" ]]; then
echo "::error::Version mismatch: package.json version (${PACKAGE_JSON_VERSION}) does not match version computed from tag ${VERSION}"
exit 1
fi
- name: Publish to NPM (latest)
if: needs.tag-check.outputs.is-release-core == 'true'
uses: smartcontractkit/.github/actions/ci-publish-npm@1861140c62d65adc4b573f826446ba7106beed1a #v1
with:
create-github-release: true
publish-command: "pnpm publish-prod --no-git-checks"
package-json-directory: contracts
- name: Validate version - CRE
if: needs.tag-check.outputs.is-release-cre == 'true'
working-directory: contracts/cre
shell: bash
env:
IS_RELEASE_CRE: ${{ needs.tag-check.outputs.is-release-cre }}
RELEASE_VERSION_CRE: ${{ needs.tag-check.outputs.release-version-cre }}
run: |
VERSION=""
if [[ "${IS_RELEASE_CRE}" == 'true' ]]; then
VERSION="${RELEASE_VERSION_CRE}"
else
echo "::error::No release version found."
exit 1
fi
PACKAGE_JSON_VERSION="$(jq -r '.version' package.json)"
if [[ "${PACKAGE_JSON_VERSION}" != "${VERSION}" ]]; then
echo "::error::Version mismatch: package.json version (${PACKAGE_JSON_VERSION}) does not match version computed from tag ${VERSION}"
exit 1
fi
- name: Publish to NPM (latest)
if: needs.tag-check.outputs.is-release-cre == 'true'
uses: smartcontractkit/.github/actions/ci-publish-npm@1861140c62d65adc4b573f826446ba7106beed1a #v1
with:
create-github-release: true
publish-command: "pnpm publish-prod --no-git-checks"
package-json-directory: contracts/cre