-
Notifications
You must be signed in to change notification settings - Fork 7
246 lines (239 loc) · 9.68 KB
/
circleci.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
name: CI Checks
run-name: ci checks
# Dockefile for the self-hosted runner:
# https://github.com/celo-org/infrastructure/blob/master/terraform/root-modules/gcp/integration-tests-gke/files/github-arc/Dockerfile-monorepo
on:
push:
branches:
- main
paths-ignore:
- '**/*.md'
pull_request:
branches:
- main
paths-ignore:
- '**/*.md'
concurrency:
group: circle-ci-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash --login -eo pipefail {0}
env:
# Increment these to force cache rebuilding
NODE_MODULE_CACHE_VERSION: 3
NODE_OPTIONS: '--max-old-space-size=4096'
TERM: dumb
GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.parallel=false -Dorg.gradle.configureondemand=true -Dorg.gradle.jvmargs="-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError"'
# Git Tag for contract release to use
RELEASE_TAG: ganache-v7-core-contracts.v9
# RELEASE_TAG: core-contracts.v9
# CELO_BLOCKCHAIN_BRANCH_TO_TEST: master
CELO_BLOCKCHAIN_BRANCH_TO_TEST: release/1.7.x
jobs:
install-dependencies:
name: Install + Build +
outputs:
package-json-checksum: ${{ steps.node-checksums.outputs.PACKAGE_JSON_CHECKSUM }}
# Propagate more outputs if you need https://github.com/tj-actions/changed-files#outputs
# Adding a initial comma so ',<path>' matches also for the first file
all_modified_files: ',${{ steps.changed-files.outputs.all_modified_files }}'
# runs-on: ubuntu-latest
runs-on: ['self-hosted', 'org', '8-cpu']
container:
image: us-west1-docker.pkg.dev/devopsre/actions-runner-controller/celo-monorepo:node18
timeout-minutes: 30
steps:
- name: Restore .git cache
uses: actions/cache@v3
id: cache_git
with:
path: .git
key: git-${{ github.ref }}
restore-keys: |
git-
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Verify setup for incremental testing
run: |
set -euo pipefail
set -v
# To get the "main" branch mapping
git checkout main
git checkout ${GITHUB_SHA}
# Verify that following commands work, they are later called in the incremental testing script
# Their output does not matter here, the fact that they finish successfully does.
git rev-parse --abbrev-ref HEAD
git fetch --all --tags
- name: Calculate node cache keys
id: node-checksums
run: |
find . -maxdepth 5 -type f -name 'package.json' -not -path "*node_modules*" -print0 | sort -z | xargs -0 cat > $RUNNER_TEMP/package.checksum
echo "PACKAGE_JSON_CHECKSUM=$(md5sum $RUNNER_TEMP/package.checksum | cut -f1 -d' ')"
echo "PACKAGE_JSON_CHECKSUM=$(md5sum $RUNNER_TEMP/package.checksum | cut -f1 -d' ')" >> "$GITHUB_OUTPUT"
- name: Restore node cache
uses: actions/cache@v3
id: cache_node
with:
# We need to cache all the artifacts generated by yarn install+build
# Update this list also in .github/actions/sync-workspace/action.yml with exactly the same list
path: |
node_modules
packages/**/node_modules
key: node-${{ runner.os }}-${{ runner.arch }}-${{ env.NODE_MODULE_CACHE_VERSION }}-${{ hashFiles('**/yarn.lock') }}-${{ steps.node-checksums.outputs.PACKAGE_JSON_CHECKSUM }}
restore-keys: |
node-${{ runner.os }}-${{ runner.arch }}-${{ env.NODE_MODULE_CACHE_VERSION }}-
# We use cache to share the build artifacts between jobs (gh artifacts are too slow...)
# For more context check https://github.com/actions/upload-artifact/issues/199
- name: Restore build artifacts cache
uses: actions/cache@v3
id: cache_build_artifacts
with:
# We need to cache all the artifacts generated by yarn install+build
# Update this list also in .github/actions/sync-workspace/action.yml with exactly the same list
path: |
packages/**/lib
packages/**/dist
packages/**/build
key: code-${{ github.sha }}
restore-keys: |
code-${{ github.sha }}
- name: Install yarn dependencies
run: git config --global url."https://".insteadOf ssh:// && yarn install
if: steps.cache_node.outputs.cache-hit != 'true'
- name: Run yarn postinstall if cache hitted
run: yarn run postinstall
if: steps.cache_node.outputs.cache-hit == 'true'
- name: Fail if any file changed on git
run: |
# This fails if there is any change
if ! git diff-index HEAD --; then
echo "Git changes detected while building. If this is unexpected, bump NODE_MODULE_CACHE_VERSION in .github/workflows/circleci.yml"
exit 1
fi
- name: Build packages
run: yarn build --ignore docs --include-dependencies
- name: Check licenses
if: steps.cache_node.outputs.cache-hit != 'true'
run: |
yarn check-licenses
lint-checks:
name: Lint code
runs-on: ['self-hosted', 'org', '8-cpu']
container:
image: us-west1-docker.pkg.dev/devopsre/actions-runner-controller/celo-monorepo:node18
timeout-minutes: 30
needs: install-dependencies
steps:
# Restore .git cache as we need to checkout the local composite action to run it:
# https://github.com/orgs/community/discussions/11771
- uses: actions/cache/restore@v3
id: cache_git
with:
path: .git
key: git-${{ github.ref }}
- uses: actions/checkout@v3
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
package-json-checksum: ${{ needs.install-dependencies.outputs.package-json-checksum }}
- run: yarn run prettify:diff
- run: yarn run lint
- name: Detect files changed in PR, and expose as output
id: changed-files
uses: tj-actions/changed-files@v37
with:
# Using comma as separator to be able to easily match full paths (using ,<path>)
separator: ','
# Checking if changed in the last 100 commits in PRs
fetch_depth: '150'
- run: echo ",${{ steps.changed-files.outputs.all_modified_files }}"
- name: Has Changeset
id: changeset
run: yarn changeset status --since origin/main
general_test:
name: General (identity + encrypted-backup) test
runs-on: ['self-hosted', 'org', '8-cpu']
container:
image: us-west1-docker.pkg.dev/devopsre/actions-runner-controller/celo-monorepo:node18
needs: install-dependencies
steps:
- uses: actions/cache/restore@v3
id: cache_git
with:
path: .git
key: git-${{ github.ref }}
- uses: actions/checkout@v3
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
package-json-checksum: ${{ needs.install-dependencies.outputs.package-json-checksum }}
- name: Run Encrypted Backup tests
run: |
yarn --cwd=packages/sdk/encrypted-backup test
- name: Run Identity Tests
run: |
yarn --cwd=packages/sdk/identity test
- name: Upload Jest Test Results
uses: actions/upload-artifact@v3
with:
name: Jest Test Results
path: test-results/jest
combiner-test:
name: Combiner test
runs-on: ['self-hosted', 'org', '8-cpu']
container:
image: us-west1-docker.pkg.dev/devopsre/actions-runner-controller/celo-monorepo:node18
timeout-minutes: 30
needs: install-dependencies
if: |
github.base_ref == 'main' || contains(github.base_ref, 'staging') || contains(github.base_ref, 'production') ||
contains(needs.install-dependencies.outputs.all_modified_files, 'packages/phone-number-privacy/combiner') ||
contains(needs.install-dependencies.outputs.all_modified_files, ',package.json') ||
contains(needs.install-dependencies.outputs.all_modified_files, ',yarn.lock') ||
false
steps:
- uses: actions/cache/restore@v3
id: cache_git
with:
path: .git
key: git-${{ github.ref }}
- uses: actions/checkout@v3
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
package-json-checksum: ${{ needs.install-dependencies.outputs.package-json-checksum }}
- name: Run Tests for combiner
run: |
yarn --cwd=packages/phone-number-privacy/combiner test:coverage
odis-test:
name: ODIS (signer + common) test
needs: install-dependencies
runs-on: ['self-hosted', 'org', '8-cpu']
container:
image: us-west1-docker.pkg.dev/devopsre/actions-runner-controller/celo-monorepo:node18
timeout-minutes: 30
if: |
github.base_ref == 'main' || contains(github.base_ref, 'staging') || contains(github.base_ref, 'production') ||
contains(needs.install-dependencies.outputs.all_modified_files, 'packages/phone-number-privacy') ||
contains(needs.install-dependencies.outputs.all_modified_files, ',package.json') ||
contains(needs.install-dependencies.outputs.all_modified_files, ',yarn.lock') ||
false
steps:
- uses: actions/cache/restore@v3
id: cache_git
with:
path: .git
key: git-${{ github.ref }}
- uses: actions/checkout@v3
- name: Sync workspace
uses: ./.github/actions/sync-workspace
with:
package-json-checksum: ${{ needs.install-dependencies.outputs.package-json-checksum }}
- name: Run Tests for common package
run: |
yarn --cwd=packages/phone-number-privacy/common test:coverage
- name: Run Tests for signer
run: |
yarn --cwd=packages/phone-number-privacy/signer test:coverage