forked from smartcontractkit/chainlink
-
Notifications
You must be signed in to change notification settings - Fork 1
279 lines (269 loc) · 9.07 KB
/
continuous-integration-workflow.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
275
276
277
278
279
name: Continuous Integration Workflow
on: [push]
env:
CACHE_VERSION: 9c3bfa173ea0aca1f9939f8896feb4a4
jobs:
core:
strategy:
fail-fast: false
matrix:
cmd: ['go_core_tests']
name: Core Tests
runs-on: [self-hosted, sdlc-ghr-prod]
container:
image: smartcontract/builder:1.0.37
credentials:
username: ${{ secrets.DOCKER_READONLY_USERNAME }}
password: ${{ secrets.DOCKER_READONLY_PASSWORD }}
env:
DATABASE_URL: postgres://chainlink@postgres:5432/chainlink_test?sslmode=disable
services:
postgres:
image: postgres
credentials:
username: ${{ secrets.DOCKER_READONLY_USERNAME }}
password: ${{ secrets.DOCKER_READONLY_PASSWORD }}
env:
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Set up Postgres user
uses: docker://postgres
with:
args: psql -v ON_ERROR_STOP=1 --username postgres -h postgres -c "CREATE USER chainlink NOSUPERUSER CREATEDB;"
- name: Cache Yarn dependencies
uses: actions/cache@v2
with:
path: /usr/local/share/.cache/yarn
key: yarn-${{ env.CACHE_VERSION }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-${{ env.CACHE_VERSION }}
- name: Install Yarn dependencies
run: make yarndep
- name: Cache Go vendor packages
uses: actions/cache@v2
with:
path: /go/pkg/mod
key: go-mod-${{ env.CACHE_VERSION }}-${{ hashFiles('go.sum') }}
restore-keys: |
go-mod-${{ env.CACHE_VERSION }}
- name: Download Go vendor packages
run: go mod download
- name: Set up Yarn for Contracts
run: yarn setup:contracts
- name: Setup DB
run: go run ./core local db preparetest
- name: Run tests
run: ./tools/bin/${{ matrix.cmd }}
- name: Store logs artifacts on failure
if: failure()
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.cmd }}_logs
path: ./output.txt
- name: Print postgres logs
if: always()
uses: docker://docker:latest
with:
args: logs ${{ job.services.postgres.id }}
integration:
name: Integration tests
runs-on: [self-hosted, sdlc-ghr-prod]
strategy:
matrix:
test: ['test', 'test:ts']
geth: [true, false]
explorer: ['latest', 'develop']
env:
GETH_MODE: ${{ matrix.geth }}
CI: true
CHAINLINK_DB_NAME: postgres
EXPLORER_DOCKER_TAG: ${{ matrix.explorer }}
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_READONLY_USERNAME }}
password: ${{ secrets.DOCKER_READONLY_PASSWORD }}
- name: Run tests
run: cd ./tools/docker && timeout --foreground 1200s ./compose ${{ matrix.test }}
- name: Capture logs on failure
if: failure()
run: cd ./tools/docker && CI_SKIP_PRE_HOOK=1 ./compose logs:test:save
- name: Store logs artifacts on failure
if: failure()
uses: actions/upload-artifact@v1
with:
name: logs
path: ./tools/docker/logs
solidity:
name: Solidity
runs-on: [self-hosted, sdlc-ghr-prod]
container:
image: smartcontract/builder:1.0.37
credentials:
username: ${{ secrets.DOCKER_READONLY_USERNAME }}
password: ${{ secrets.DOCKER_READONLY_PASSWORD }}
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Cache Yarn dependencies
uses: actions/cache@v2
with:
path: /usr/local/share/.cache/yarn
key: yarn-${{ env.CACHE_VERSION }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-${{ env.CACHE_VERSION }}
- name: Install Yarn dependencies
run: make yarndep
- name: Run tests
run: ./tools/ci/solidity_test
operator-ui:
name: Operator UI
runs-on: ubuntu-latest
container:
image: smartcontract/builder:1.0.37
credentials:
username: ${{ secrets.DOCKER_READONLY_USERNAME }}
password: ${{ secrets.DOCKER_READONLY_PASSWORD }}
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Cache Yarn dependencies
uses: actions/cache@v2
with:
path: /usr/local/share/.cache/yarn
key: yarn-${{ env.CACHE_VERSION }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-${{ env.CACHE_VERSION }}
- name: Install Yarn dependencies
run: make yarndep
- name: Run Operator UI tests
run: ./tools/ci/operator_ui_test
lint:
name: Yarn lint
runs-on: ubuntu-latest
container:
image: smartcontract/builder:1.0.37
credentials:
username: ${{ secrets.DOCKER_READONLY_USERNAME }}
password: ${{ secrets.DOCKER_READONLY_PASSWORD }}
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Cache Yarn dependencies
uses: actions/cache@v2
with:
path: /usr/local/share/.cache/yarn
key: yarn-${{ env.CACHE_VERSION }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-${{ env.CACHE_VERSION }}
- name: Install Yarn dependencies
run: make yarndep
- name: Run Yarn lint
run: yarn lint
prettier:
name: Prettier formatting check
runs-on: ubuntu-latest
container:
image: smartcontract/builder:1.0.37
credentials:
username: ${{ secrets.DOCKER_READONLY_USERNAME }}
password: ${{ secrets.DOCKER_READONLY_PASSWORD }}
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Cache Yarn dependencies
uses: actions/cache@v2
with:
path: /usr/local/share/.cache/yarn
key: yarn-${{ env.CACHE_VERSION }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-${{ env.CACHE_VERSION }}
- name: Install Yarn dependencies
run: make yarndep
- name: Run Yarn lint
run: yarn prettier:check
prepublish_npm:
name: Prepublish NPM
runs-on: [self-hosted, sdlc-ghr-prod]
container:
image: smartcontract/builder:1.0.37
credentials:
username: ${{ secrets.DOCKER_READONLY_USERNAME }}
password: ${{ secrets.DOCKER_READONLY_PASSWORD }}
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Cache Yarn dependencies
uses: actions/cache@v2
with:
path: /usr/local/share/.cache/yarn
key: yarn-${{ env.CACHE_VERSION }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-${{ env.CACHE_VERSION }}
- name: Install Yarn dependencies
run: make yarndep
- name: Run prepublish NPM test
run: ./tools/ci/prepublish_npm_test
build-chainlink:
name: Build chainlink image
runs-on: [self-hosted, sdlc-ghr-prod]
strategy:
matrix:
dockerfile: [core/chainlink.Dockerfile]
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: '${{ secrets.GHA_AWS_ACCESS_KEY_ID }}'
aws-secret-access-key: '${{ secrets.GHA_AWS_SECRET_ACCESS_KEY }}'
aws-region: '${{ secrets.AWS_DEFAULT_REGION }}'
role-to-assume: '${{ secrets.GHA_AWS_ROLE_TO_ASSUME }}'
role-duration-seconds: 1200
role-session-name: 'temp-session'
role-skip-session-tagging: true
- name: Docker login to ECR
uses: aws-actions/amazon-ecr-login@v1
id: login-ecr
# https://github.com/docker/build-push-action/issues/20
- name: Get ecr password
id: get-ecr-password
run: |
aws ecr get-login-password \
| {
read PASSWORD
echo "::add-mask::$PASSWORD"
echo "::set-output name=password::$PASSWORD"
}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_READONLY_USERNAME }}
password: ${{ secrets.DOCKER_READONLY_PASSWORD }}
- name: Build image
uses: docker/build-push-action@v1
with:
registry: ${{ steps.login-ecr.outputs.registry }}
repository: ${{ secrets.ECR_REPO }}
username: AWS # temporary
password: ${{ steps.get-ecr-password.outputs.password }} # temporary
dockerfile: ${{ matrix.dockerfile }}
build_args: COMMIT_SHA=${{ github.sha }},ENVIRONMENT=release
tags: githubactions
add_git_labels: true
tag_with_ref: true
tag_with_sha: true
push: false