1313 description : " Optional suffix to override tag name generation"
1414 type : string
1515 required : false
16- action :
17- description : " Action with docker image"
18- type : string
19- default : " push"
20- required : false
2116 compilers :
2217 description : ' JSON of required compilers and their versions'
2318 type : string
2419 required : false
2520 default : ' [{ "zksolc": ["1.3.14", "1.3.16", "1.3.17", "1.3.1", "1.3.7", "1.3.18", "1.3.19", "1.3.21"] } , { "zkvyper": ["1.3.13"] }]'
26- jobs :
27- build-images :
28- name : Build and Push Docker Images
29- env :
30- IMAGE_TAG_SUFFIX : ${{ inputs.image_tag_suffix }}
31- runs-on : ${{ fromJSON('["matterlabs-ci-runner-high-performance", "matterlabs-ci-runner-arm"]')[contains(matrix.platforms, 'arm')] }}
32- strategy :
33- matrix :
34- components :
35- - contract-verifier
36- - verified-sources-fetcher
37- platforms :
38- - linux/amd64
21+ action :
22+ type : string
23+ default : non-push
24+ required : false
3925
26+ jobs :
27+ prepare-contracts :
28+ name : Prepare contracts
29+ runs-on : matterlabs-ci-runner-high-performance
4030 steps :
41- - uses : actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
31+ - uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
4232 with :
4333 submodules : " recursive"
4434
45- - name : setup-env
35+ - name : Prepare ENV
36+ shell : bash
4637 run : |
4738 echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
4839 echo CI=1 >> $GITHUB_ENV
4940 echo $(pwd)/bin >> $GITHUB_PATH
41+ echo $HOME/.local/bin >> $GITHUB_PATH
5042 echo CI=1 >> .env
5143 echo IN_DOCKER=1 >> .env
5244
5345 - name : Download contracts
46+ shell : bash
5447 run : |
5548 commit_sha=$(git submodule status contracts | awk '{print $1}' | tr -d '-')
5649 page=1
8073 tar -C ./contracts -zxf l2-contracts.tar.gz
8174 tar -C ./contracts -zxf system-contracts.tar.gz
8275
83- - name : pre-download compilers
76+ - name : Install Apt dependencies
8477 if : env.BUILD_CONTRACTS == 'true'
78+ shell : bash
79+ run : |
80+ sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config
81+
82+ - name : Install Node
83+ if : env.BUILD_CONTRACTS == 'true'
84+ uses : actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
85+ with :
86+ node-version : 20
87+ cache : ' npm'
88+
89+ - name : Install Yarn
90+ if : env.BUILD_CONTRACTS == 'true'
91+ run : npm install -g yarn
92+
93+ - name : Setup rust
94+ if : env.BUILD_CONTRACTS == 'true'
95+ uses : actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0
96+ with :
97+ toolchain : nightly-2024-08-01
98+
99+ - name : Install foundry-zksync
100+ if : env.BUILD_CONTRACTS == 'true'
101+ run : |
102+ mkdir ./foundry-zksync
103+ curl -LO https://github.com/matter-labs/foundry-zksync/releases/download/nightly-15bec2f861b3b4c71e58f85e2b2c9dd722585aa8/foundry_nightly_linux_amd64.tar.gz
104+ tar zxf foundry_nightly_linux_amd64.tar.gz -C ./foundry-zksync
105+ chmod +x ./foundry-zksync/forge ./foundry-zksync/cast
106+ echo "$PWD/foundry-zksync" >> $GITHUB_PATH
107+
108+ - name : Pre-download compilers
109+ if : env.BUILD_CONTRACTS == 'true'
110+ shell : bash
85111 run : |
86112 # Download needed versions of vyper compiler
87113 # Not sanitized due to unconventional path and tags
@@ -98,59 +124,116 @@ jobs:
98124 chmod +x "./hardhat-nodejs/compilers-v2/$compiler/${compiler}-v${version}"
99125 done
100126
101- - name : start-services
127+ - name : Install zkstack
128+ if : env.BUILD_CONTRACTS == 'true'
129+ run : |
130+ ./zkstack_cli/zkstackup/install --path ./zkstack_cli/zkstackup/zkstackup
131+ zkstackup --local || true
132+
133+ - name : build contracts
134+ if : env.BUILD_CONTRACTS == 'true'
135+ shell : bash
102136 run : |
103- echo "IMAGE_TAG_SUFFIX=${{ env.IMAGE_TAG_SUFFIX }}" >> .env
104- run_retried docker compose pull zk postgres
105- docker compose up -d zk postgres
106- ci_run pre_download_compilers.sh
107- ci_run sccache --start-server
137+ cp etc/tokens/{test,localhost}.json
138+ zkstack dev contracts
139+
140+ - name : Upload contracts
141+ uses : actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
142+ with :
143+ name : contacts-verifier
144+ path : |
145+ ./contracts
146+
147+ build-images :
148+ name : Build and Push Docker Images
149+ needs : prepare-contracts
150+ runs-on : ${{ fromJSON('["matterlabs-ci-runner-high-performance", "matterlabs-ci-runner-arm"]')[contains(matrix.platforms, 'arm')] }}
151+ strategy :
152+ matrix :
153+ components :
154+ - contract-verifier
155+ - verified-sources-fetcher
156+ platforms :
157+ - linux/amd64
158+
159+ steps :
160+ - uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
161+ with :
162+ submodules : " recursive"
108163
109- - name : init
164+ - name : Set up Docker Buildx
165+ uses : docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
166+
167+ - name : Setup env
168+ shell : bash
110169 run : |
111- ci_run git config --global --add safe.directory /usr/src/zksync
112- ci_run git config --global --add safe.directory /usr/src/zksync/sdk/binaryen
113- ci_run git config --global --add safe.directory /usr/src/zksync/contracts/system-contracts
114- ci_run git config --global --add safe.directory /usr/src/zksync/contracts
115- ci_run ./bin/zk || true
116- ci_run run_retried curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key
117-
118- - name : install zkstack
170+ echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
171+ echo CI=1 >> $GITHUB_ENV
172+ echo $(pwd)/bin >> $GITHUB_PATH
173+ echo CI=1 >> .env
174+ echo IN_DOCKER=1 >> .env
175+
176+ - name : Download setup key
177+ shell : bash
119178 run : |
120- ci_run ./zkstack_cli/zkstackup/install -g --path ./zkstack_cli/zkstackup/zkstackup || true
121- ci_run zkstackup -g --local
179+ if [ -f "/setup_2^26.key" ]; then
180+ cp '/setup_2^26.key' './setup_2^26.key'
181+ else
182+ run_retried curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key
183+ fi
122184
123- - name : build contracts
124- if : env.BUILD_CONTRACTS == 'true'
185+ - name : Set env vars
186+ shell : bash
125187 run : |
126- ci_run cp etc/tokens/{test,localhost}.json
127- ci_run zkstack dev contracts
188+ echo PLATFORM=$(echo ${{ matrix.platforms }} | tr '/' '-') >> $GITHUB_ENV
189+ echo IMAGE_TAG_SHA=$(git rev-parse --short HEAD) >> $GITHUB_ENV
190+ # Support for custom tag suffix
191+ if [ -n "${{ inputs.image_tag_suffix }}" ]; then
192+ echo IMAGE_TAG_SHA_TS="${{ inputs.image_tag_suffix }}" >> $GITHUB_ENV
193+ else
194+ echo IMAGE_TAG_SHA_TS=$(git rev-parse --short HEAD)-$(date +%s) >> $GITHUB_ENV
195+ fi
196+
197+ - name : Download contracts
198+ uses : actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
199+ with :
200+ name : contacts-verifier
201+ path : |
202+ ./contracts
128203
129- - name : Login to Docker registries
204+ - name : login to Docker registries
130205 if : ${{ inputs.action == 'push' }}
206+ shell : bash
131207 run : |
132- ci_run docker login -u ${{ secrets.DOCKERHUB_USER }} -p ${{ secrets.DOCKERHUB_TOKEN }}
133- ci_run gcloud auth configure-docker us-docker.pkg.dev -q
134-
135- - name : update-images
136- env :
137- DOCKER_ACTION : ${{ inputs.action }}
138- COMPONENT : ${{ matrix.components }}
139- PLATFORM : ${{ matrix.platforms }}
140- run : |
141- ci_run run_retried rustup default nightly-2024-05-07
142- platform=$(echo $PLATFORM | tr '/' '-')
143- ci_run zk docker $DOCKER_ACTION --custom-tag=${IMAGE_TAG_SUFFIX} --platform=${PLATFORM} $COMPONENT
144- - name : Show sccache stats
145- if : always()
208+ docker login -u ${{ secrets.DOCKERHUB_USER }} -p ${{ secrets.DOCKERHUB_TOKEN }}
209+ gcloud auth configure-docker us-docker.pkg.dev -q
210+
211+ - name : Build and push
212+ uses : docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0
213+ with :
214+ context : .
215+ load : true
216+ platforms : ${{ matrix.platforms }}
217+ file : docker/${{ matrix.components }}/Dockerfile
218+ build-args : |
219+ SCCACHE_GCS_BUCKET=matterlabs-infra-sccache-storage
220+ SCCACHE_GCS_SERVICE_ACCOUNT=gha-ci-runners@matterlabs-infra.iam.gserviceaccount.com
221+ SCCACHE_GCS_RW_MODE=READ_WRITE
222+ RUSTC_WRAPPER=sccache
223+ tags : |
224+ us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/${{ matrix.components }}:${{ env.IMAGE_TAG_SHA_TS }}-${{ env.PLATFORM }}
225+ matterlabs/${{ matrix.components }}:${{ env.IMAGE_TAG_SHA_TS }}-${{ env.PLATFORM }}
226+
227+ - name : Push docker image
228+ if : ${{ inputs.action == 'push' }}
146229 run : |
147- ci_run sccache --show-stats || true
148- ci_run cat /tmp/sccache_log.txt || true
230+ docker push us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/${{ matrix.components }}:${{ env.IMAGE_TAG_SHA_TS }}-${{ env.PLATFORM }}
231+ docker push matterlabs/${{ matrix.components }}:${{ env.IMAGE_TAG_SHA_TS }}-${{ env.PLATFORM }}
232+
149233
150234 create_manifest :
151235 name : Create release manifest
152- # TODO: After migraton switch to CI
153- runs-on : matterlabs-default-infra-runners
236+ runs-on : matterlabs-ci-runner
154237 needs : build-images
155238 if : ${{ inputs.action == 'push' }}
156239 strategy :
0 commit comments