Repository navigation
271 lines (262 loc) · 10.9 KB
/
Copy pathci-deployments.yml
File metadata and controls
271 lines (262 loc) · 10.9 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
name: Deployment Tests
run-name: Deployment Tests
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name
}}-deployments-tests
cancel-in-progress: true
# Run on key branches to make sure integration is good, otherwise run on all PR's
on:
push:
branches:
- develop
- "release/*"
merge_group:
pull_request:
schedule:
- cron: "0 0,1,2,3,4,5,6,20,21,22,23 * * *" # Run regularly at night to get better flaky test data
workflow_dispatch:
jobs:
filter:
name: Detect Changes
permissions:
pull-requests: read
outputs:
# Runs on workflow changes, any deployment change, or any (non-ignored) core change
should-run: >-
${{
steps.match-some.outputs.workflow == 'true' ||
steps.match-some.outputs.deployment == 'true' ||
steps.match-every.outputs.core-non-ignored == 'true' ||
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch'
}}
spot_flag: ${{ steps.spot.outputs.spot_flag }}
spot_param: ${{ steps.spot.outputs.spot_param }}
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v7
with:
persist-credentials: false
repository: smartcontractkit/chainlink
- uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # 4.0.2
id: match-some
with:
# "if any changed file matches one or more of the conditions" (https://github.com/dorny/paths-filter/issues/225)
predicate-quantifier: some
# deployment - any changes in the deployment module
# workflow - any changes that could affect this workflow definition
# - Assume any repository action changes affect this workflow
filters: |
deployment:
- 'deployment/**'
workflow:
- '.github/workflows/ci-deployments.yml'
- '.github/actions/**'
- uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # 4.0.2
id: match-every
with:
# "if any changed file match all of the conditions" (https://github.com/dorny/paths-filter/issues/225)
# - Enables listing of files matching each filter.
# - Paths to files will be available in `${FILTER_NAME}_files` output variable.
# - Paths will be formatted as JSON array
predicate-quantifier: every
# core-non-ignored - all changes except for paths which do not affect core module
# - This is opt-in on purpose. To be safe, new files are assumed to have an affect on core unless listed here specifically.
# - For example: core module does not depend on deployment or integration-tests module.
# all - changes in any directory
# - This is used resolve all affected modules based on changed files
list-files: json
filters: |
core-non-ignored:
- '**'
- '!deployment/**'
- '!integration-tests/**'
- '!tools/secrets/**'
- '!tools/docker/**'
- '!tools/benchmark/**'
- '!**/README.md'
- '!**/CHANGELOG.md'
- '!*.nix'
- '!sonar-project.properties'
- '!nix.conf'
- '!nix-darwin-shell-hook.sh'
- '!LICENSE'
- '!.github/**'
- '!core/scripts/cre/environment/examples/workflows/**'
all:
- '**'
- name: Decide which tests to run (rollout-only)
# To validate that this properly tests, we will run this beside the dorny/paths-filter actions
# before using its output to actually gate any jobs.
id: triggers
uses: smartcontractkit/.github/actions/advanced-triggers@advanced-triggers/v1
continue-on-error: true
with:
file-sets: |
included-files:
- "**/*.go"
- "**/go.mod"
- "**/go.sum"
- "core/**"
- "deployment/**"
- ".github/workflows/ci-deployments.yml"
- ".github/actions/**"
- "tools/bin/go_deployment_tests"
excluded-files:
- "testdata/**"
- "core/**/testdata/**"
- "core/**/*_test.go"
- "system-tests/**"
- "integration-tests/**"
- "core/scripts/cre/environment/examples/workflows/**"
# Note:
# - for pull_request, merge_group, and push events, a trigger will resolve to true if any changed files match the path/glob patterns
# - exclusion-sets/negations are applied first, and therefore filter all changed files before inclusion sets are applied
# - by default these will resolve to true for schedule, and workflow_dispatch events
triggers: |
deployment-tests:
exclusion-sets: [ excluded-files ]
inclusion-sets: [ included-files ]
- name: Resolve Spot Setting
id: spot
uses: $/.github/actions/setup-runner-spot
deployment-tests:
env:
# We explicitly have this env var not be "CL_DATABASE_URL" to avoid having it be used by core related tests
# when they should not be using it, while still allowing us to DRY up the setup
DB_URL: postgresql://postgres:postgres@localhost:5432/chainlink_test?sslmode=disable
strategy:
fail-fast: false
matrix:
shard-id: [1, 2, 3, 4, 5, 6, 7]
name: Deployment Tests (go_deployment_tests shard ${{ matrix.shard-id }}/${{ strategy.job-total }})
if: ${{ github.actor != 'dependabot[bot]' && needs.filter.outputs.should-run == 'true' }}
needs: [filter]
timeout-minutes: 35
runs-on:
- runs-on=${{ github.run_id }}-deployment-${{ matrix.shard-id }}
- cpu=8
- ram=32
- family=m6id+m8id
- ${{ needs.filter.outputs.spot_param }}
- image=ubuntu24-full-x64
- extras=s3-cache
permissions:
id-token: write
contents: read
actions: read
steps:
- name: Enable S3 Cache for Self-Hosted Runners
uses: runs-on/action@4e5f72399b6b17f2e79c511c1b38a315a64d22dc # v2.2.0
- name: Checkout the repo
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Setup Go
uses: ./.github/actions/setup-go
with:
build-cache-version: go_deployment_tests
build-cache-write: ${{ matrix.shard-id == 1 && 'default-branch-only' || 'never' }}
go-version-file: deployment/go.mod
go-module-file: deployment/go.sum
- name: Download Go vendor packages
working-directory: deployment
run: go mod download
- name: Setup Solana
uses: ./.github/actions/setup-solana
- name: Setup Aptos
uses: ./.github/actions/setup-aptos
- name: Setup Sui CLI v1.72.2
uses: ./.github/actions/setup-sui
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: mainnet-v1.72.2
- name: Setup Postgres
uses: smartcontractkit/.github/actions/setup-postgres@setup-postgres/v1
with:
image-tag: "16.15-alpine"
postgres-options: "-c max_connections=1000 -c shared_buffers=2GB -c fsync=off -c synchronous_commit=off -c full_page_writes=off -c client_min_messages=warning" # Turn off some prod-protections to make postgres go brrr. https://github.com/peterldowns/pgtestdb#how-do-i-make-it-go-faster
- name: Setup DB
run: |
go install ./core/store/cmd/preparetest
preparetest
env:
CL_DATABASE_URL: ${{ env.DB_URL }}
- name: Install LOOP Plugins
uses: ./.github/actions/setup-loop-plugins
- name: Run tests
timeout-minutes: 25
continue-on-error: true
id: run-tests
shell: bash
env:
CL_DATABASE_URL: ${{ env.DB_URL }}
OUTPUT_FILE: ./output.txt
PRODUCE_JUNIT_XML: "true"
TRUNK_AUTO_QUARANTINE: "true"
RUN_QUARANTINED_TESTS: "true"
JUNIT_FILE: ${{ github.workspace }}/junit.xml
GO_TEST_SHARD_COUNT: ${{ strategy.job-total }}
GO_TEST_SHARD_INDEX: ${{ strategy.job-index }}
run: |
GODEBUG=goindex=0 "./tools/bin/go_deployment_tests" ./...
# See: https://github.com/golang/go/issues/69179
- name: Analyze and upload test results
if: ${{ !cancelled() }}
uses: smartcontractkit/.github/actions/branch-out-upload@branch-out-upload/v1
with:
junit-file-path: "./junit.xml"
trunk-org-slug: chainlink
trunk-token: ${{ secrets.TRUNK_API_KEY }}
trunk-previous-step-outcome: ${{ steps.run-tests.outcome }}
trunk-upload-only: false
artifact-name: "go_deployment_tests_logs_shard_${{ matrix.shard-id }}"
trunk-test-collection-id: "NNIoAFxX" # chainlink-unit
- name: Print postgres logs
if: ${{ always() }}
uses: smartcontractkit/.github/actions/setup-postgres@setup-postgres/v1
with:
print-logs: "true"
- name: Store logs artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v7
with:
name: "go_deployment_tests_logs_shard_${{ matrix.shard-id }}_always"
path: |
./deployment/coverage.txt
./postgres_logs.txt
./junit.xml
./deployment/output.txt
./deployment/output-short.txt
retention-days: 7
deployment-tests-result:
# Do not modify this job name, it is used by branch protection rules
name: Core Tests (go_core_deployment_tests)
if: ${{ always() && github.actor != 'dependabot[bot]' && needs.filter.outputs.should-run == 'true' }}
needs: [filter, deployment-tests]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
# Read the matrix result from the workflow engine instead of the Jobs API.
# The Jobs API can report `conclusion: null` for shards that finished seconds
# ago, and this job always starts seconds after the last shard, so querying it
# produced false failures that evicted runs from the merge queue.
- name: Check deployment shard results
env:
FILTER_RESULT: ${{ needs.filter.result }}
SHARDS_RESULT: ${{ needs.deployment-tests.result }}
run: |
if [[ "${FILTER_RESULT}" == "failure" || "${FILTER_RESULT}" == "cancelled" ]]; then
echo "::error::'Detect Changes' did not succeed - shard results cannot be trusted."
exit 1
fi
case "${SHARDS_RESULT}" in
success) echo "All deployment shards succeeded." ;;
skipped) echo "Deployment shards were skipped." ;;
*)
echo "::error::Deployment shards concluded '${SHARDS_RESULT}'."
exit 1
;;
esac