-
Notifications
You must be signed in to change notification settings - Fork 1.7k
274 lines (267 loc) · 10.9 KB
/
ci-core.yml
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
name: CI Core
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Run on key branches to make sure integration is good, otherwise run on all PR's
on:
push:
branches:
- master
- develop
- "release/*"
merge_group:
pull_request:
schedule:
- cron: "0 0 * * *"
jobs:
golangci:
if: ${{ github.event_name == 'pull_request' || github.event_name == 'schedule' }}
name: lint
runs-on: ubuntu20.04-8cores-32GB
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Golang Lint
uses: ./.github/actions/golangci-lint
with:
gc-basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
gc-host: ${{ secrets.GRAFANA_CLOUD_HOST }}
- name: Notify Slack
if: ${{ failure() && (github.event_name == 'merge_group' || github.event.branch == 'develop')}}
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
env:
SLACK_BOT_TOKEN: ${{ secrets.QA_SLACK_API_KEY }}
with:
channel-id: "#team-core"
slack-message: "golangci-lint failed: ${{ job.html_url }}\n${{ format('https://github.com/smartcontractkit/chainlink/actions/runs/{0}', github.run_id) }}"
core:
strategy:
fail-fast: false
matrix:
cmd: ["go_core_tests", "go_core_race_tests", "go_core_fuzz"]
name: Core Tests (${{ matrix.cmd }})
runs-on: ubuntu20.04-64cores-256GB
env:
CL_DATABASE_URL: postgresql://postgres:postgres@localhost:5432/chainlink_test?sslmode=disable
steps:
- name: Checkout the repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup node
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
- name: Setup NodeJS
uses: ./.github/actions/setup-nodejs
with:
prod: "true"
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Setup Solana
uses: ./.github/actions/setup-solana
- name: Setup wasmd
uses: ./.github/actions/setup-wasmd
- name: Setup Postgres
uses: ./.github/actions/setup-postgres
- name: Touching core/web/assets/index.html
run: mkdir -p core/web/assets && touch core/web/assets/index.html
- name: Download Go vendor packages
run: go mod download
- name: Build binary
run: go build -o chainlink.test .
- name: Setup DB
run: ./chainlink.test local db preparetest
- name: Install LOOP Plugins
run: |
pushd $(go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-feeds)
go install ./cmd/chainlink-feeds
popd
pushd $(go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-solana)
go install ./pkg/solana/cmd/chainlink-solana
popd
pushd $(go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-starknet/relayer)
go install ./pkg/chainlink/cmd/chainlink-starknet
popd
- name: Increase Race Timeout
if: github.event.schedule != ''
run: |
echo "TIMEOUT=10m" >> $GITHUB_ENV
echo "COUNT=50" >> $GITHUB_ENV
- name: Run tests
id: run-tests
env:
OUTPUT_FILE: ./output.txt
USE_TEE: false
run: ./tools/bin/${{ matrix.cmd }} ./...
- name: Print Filtered Test Results
if: ${{ failure() && matrix.cmd == 'go_core_tests' }}
uses: smartcontractkit/chainlink-github-actions/go/go-test-results-parsing@a052942591aaa12716eb9835b490d812a77d0831 # v2.3.1
with:
results-file: ./output.txt
output-file: ./output-short.txt
- name: Print Races
if: ${{ failure() && matrix.cmd == 'go_core_race_tests' }}
run: find race.* | xargs cat
- name: Print postgres logs
if: always()
run: docker compose logs postgres | tee ../../../postgres_logs.txt
working-directory: ./.github/actions/setup-postgres
- name: Store logs artifacts
if: always()
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: ${{ matrix.cmd }}_logs
path: |
./output.txt
./output-short.txt
./race.*
./coverage.txt
./postgres_logs.txt
- name: Notify Slack
if: ${{ failure() && matrix.cmd == 'go_core_race_tests' && (github.event_name == 'merge_group' || github.event.branch == 'develop') }}
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
env:
SLACK_BOT_TOKEN: ${{ secrets.QA_SLACK_API_KEY }}
with:
channel-id: "#topic-data-races"
slack-message: "Race tests failed: ${{ job.html_url }}\n${{ format('https://github.com/smartcontractkit/chainlink/actions/runs/{0}', github.run_id) }}"
- name: Collect Metrics
if: always()
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@d1618b772a97fd87e6505de97b872ee0b1f1729a # v2.0.2
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: Core Tests (${{ matrix.cmd }})
test-results-file: '{"testType":"go","filePath":"./output.txt"}'
continue-on-error: true
detect-flakey-tests:
needs: [core]
name: Flakey Test Detection
runs-on: ubuntu-latest
if: always()
env:
CL_DATABASE_URL: postgresql://postgres:postgres@localhost:5432/chainlink_test?sslmode=disable
steps:
- name: Checkout the repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup node
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
- name: Setup NodeJS
uses: ./.github/actions/setup-nodejs
with:
prod: "true"
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Setup Postgres
uses: ./.github/actions/setup-postgres
- name: Touching core/web/assets/index.html
run: mkdir -p core/web/assets && touch core/web/assets/index.html
- name: Download Go vendor packages
run: go mod download
- name: Build binary
run: go build -o chainlink.test .
- name: Setup DB
run: ./chainlink.test local db preparetest
- name: Load test outputs
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
path: ./artifacts
- name: Build flakey test runner
run: go build ./tools/flakeytests/cmd/runner
- name: Re-run tests
env:
GRAFANA_CLOUD_BASIC_AUTH: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
GRAFANA_CLOUD_HOST: ${{ secrets.GRAFANA_CLOUD_HOST }}
GITHUB_EVENT_PATH: ${{ github.event_path }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_REPO: ${{ github.repository }}
GITHUB_RUN_ID: ${{ github.run_id }}
run: |
./runner \
-grafana_auth=$GRAFANA_CLOUD_BASIC_AUTH \
-grafana_host=$GRAFANA_CLOUD_HOST \
-gh_sha=$GITHUB_SHA \
-gh_event_path=$GITHUB_EVENT_PATH \
-gh_event_name=$GITHUB_EVENT_NAME \
-gh_run_id=$GITHUB_RUN_ID \
-gh_repo=$GITHUB_REPO \
-command=./tools/bin/go_core_tests \
`ls -R ./artifacts/go_core_tests*/output.txt`
- name: Store logs artifacts
if: always()
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: flakey_test_runner_logs
path: |
./output.txt
scan:
name: SonarQube Scan
needs: [core]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0 # fetches all history for all tags and branches to provide more metadata for sonar reports
- name: Download all workflow run artifacts
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1
- name: Set SonarQube Report Paths
id: sonarqube_report_paths
shell: bash
run: |
echo "sonarqube_tests_report_paths=$(find go_core_tests_logs -name output.txt | paste -sd "," -)" >> $GITHUB_OUTPUT
echo "sonarqube_coverage_report_paths=$(find go_core_tests_logs -name coverage.txt | paste -sd "," -)" >> $GITHUB_OUTPUT
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@69c1a75940dec6249b86dace6b630d3a2ae9d2a7 # v2.0.1
with:
args: >
-Dsonar.go.tests.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_tests_report_paths }}
-Dsonar.go.coverage.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_coverage_report_paths }}
-Dsonar.go.golangci-lint.reportPaths=golangci-lint-report/golangci-lint-report.xml
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- name: Collect Metrics
if: always()
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@d1618b772a97fd87e6505de97b872ee0b1f1729a # v2.0.2
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: SonarQube Scan
continue-on-error: true
clean:
name: Clean Go Tidy & Generate
if: ${{ !contains(join(github.event.pull_request.labels.*.name, ' '), 'skip-smoke-tests') }}
runs-on: ubuntu20.04-8cores-32GB
defaults:
run:
shell: bash
steps:
- name: Check for Skip Tests Label
if: contains(join(github.event.pull_request.labels.*.name, ' '), 'skip-smoke-tests')
run: |
echo "## \`skip-smoke-tests\` label is active, skipping E2E smoke tests" >>$GITHUB_STEP_SUMMARY
exit 0
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Setup Go
uses: ./.github/actions/setup-go
with:
only-modules: "true"
- name: Setup NodeJS
uses: ./.github/actions/setup-nodejs
- run: make generate # generate install go deps
- name: Ensure clean after generate
run: git diff --stat --exit-code
- run: make gomodtidy
- name: Ensure clean after tidy
run: git diff --minimal --exit-code
- name: Collect Metrics
if: always()
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@d1618b772a97fd87e6505de97b872ee0b1f1729a # v2.0.2
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: Clean Go Tidy & Generate
continue-on-error: true