Skip to content

Commit

Permalink
ci: change flow for download contracts (matter-labs#1230)
Browse files Browse the repository at this point in the history
## What ❔
Workflow changes for download releases from era-contracts

## Why ❔
For reduce CI time

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [x] Tests for the changes have been added / updated.
- [x] Documentation comments have been added / updated.
- [x] Code has been formatted via `zk fmt` and `zk lint`.
- [x] Spellcheck has been run via `zk spellcheck`.
- [x] Linkcheck has been run via `zk linkcheck`.
  • Loading branch information
otani88 authored Feb 26, 2024
1 parent 11c8ff7 commit 7d53618
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 113 deletions.
83 changes: 0 additions & 83 deletions .github/workflows/build-contracts.yml

This file was deleted.

67 changes: 61 additions & 6 deletions .github/workflows/build-core-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ on:
type: string
default: "push"
required: false
compilers:
description: 'JSON of required compilers and their versions'
type: string
required: false
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"] }]'
jobs:
build-images:
name: Build and Push Docker Images
Expand Down Expand Up @@ -51,10 +56,52 @@ jobs:
echo IN_DOCKER=1 >> .env
- name: Download contracts
uses: actions/download-artifact@v4
with:
name: contracts
path: ./contracts/
run: |
commit_sha=$(git submodule status contracts | awk '{print $1}' | tr -d '-')
page=1
filtered_tag=""
while [ true ]; do
echo "Page: $page"
tags=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/matter-labs/era-contracts/tags?per_page=100&page=${page}" | jq .)
if [ $(jq length <<<"$tags") -eq 0 ]; then
echo "No tag found on all pages."
echo "BUILD_CONTRACTS=true" >> "$GITHUB_ENV"
exit 0
fi
filtered_tag=$(jq -r --arg commit_sha "$commit_sha" 'map(select(.commit.sha == $commit_sha)) | .[].name' <<<"$tags")
if [[ ! -z "$filtered_tag" ]]; then
echo "BUILD_CONTRACTS=false" >> "$GITHUB_ENV"
break
fi
((page++))
done
echo "Contracts tag is: ${filtered_tag}"
mkdir -p ./contracts
curl -s -LO https://github.com/matter-labs/era-contracts/releases/download/${filtered_tag}/l1-contracts.tar.gz
curl -s -LO https://github.com/matter-labs/era-contracts/releases/download/${filtered_tag}/l2-contracts.tar.gz
curl -s -LO https://github.com/matter-labs/era-contracts/releases/download/${filtered_tag}/system-contracts.tar.gz
tar -C ./contracts -zxf l1-contracts.tar.gz
tar -C ./contracts -zxf l2-contracts.tar.gz
tar -C ./contracts -zxf system-contracts.tar.gz
- name: pre-download compilers
if: env.BUILD_CONTRACTS == 'true'
run: |
# Download needed versions of vyper compiler
# Not sanitized due to unconventional path and tags
mkdir -p ./hardhat-nodejs/compilers-v2/vyper/linux
wget -nv -O ./hardhat-nodejs/compilers-v2/vyper/linux/0.3.10 https://github.com/vyperlang/vyper/releases/download/v0.3.10/vyper.0.3.10+commit.91361694.linux
wget -nv -O ./hardhat-nodejs/compilers-v2/vyper/linux/0.3.3 https://github.com/vyperlang/vyper/releases/download/v0.3.3/vyper.0.3.3+commit.48e326f0.linux
chmod +x ./hardhat-nodejs/compilers-v2/vyper/linux/0.3.10
chmod +x ./hardhat-nodejs/compilers-v2/vyper/linux/0.3.3
COMPILERS_JSON='${{ inputs.compilers }}'
echo "$COMPILERS_JSON" | jq -r '.[] | to_entries[] | .key as $compiler | .value[] | "\(.),\($compiler)"' | while IFS=, read -r version compiler; do
mkdir -p "./hardhat-nodejs/compilers-v2/$compiler"
wget -nv -O "./hardhat-nodejs/compilers-v2/$compiler/${compiler}-v${version}" "https://github.com/matter-labs/${compiler}-bin/releases/download/v${version}/${compiler}-linux-amd64-musl-v${version}"
chmod +x "./hardhat-nodejs/compilers-v2/$compiler/${compiler}-v${version}"
done
- name: start-services
run: |
Expand All @@ -73,6 +120,15 @@ jobs:
ci_run yarn zk build
ci_run curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key
- name: build contracts
if: env.BUILD_CONTRACTS == 'true'
run: |
ci_run zk run yarn
ci_run cp etc/tokens/{test,localhost}.json
ci_run zk compiler all
ci_run zk contract build
ci_run zk f yarn run l2-contracts build
- name: Login to Docker registries
if: ${{ inputs.action == 'push' }}
run: |
Expand Down Expand Up @@ -114,8 +170,7 @@ jobs:
IMAGE_TAG_SUFFIX: ${{ inputs.image_tag_suffix }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
with:
submodules: "recursive"

- name: login to Docker registries
run: |
docker login -u ${{ secrets.DOCKERHUB_USER }} -p ${{ secrets.DOCKERHUB_TOKEN }}
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/build-docker-from-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jobs:
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
with:
submodules: "recursive"

- name: Generate output with git tag
id: set
Expand All @@ -49,14 +48,9 @@ jobs:
run: |
./prover/extract-setup-data-keys.sh >> $GITHUB_OUTPUT
build-contracts:
name: Build contracts
if: contains(github.ref_name, 'core')
uses: ./.github/workflows/build-contracts.yml

build-push-core-images:
name: Build and push image
needs: [setup, build-contracts]
needs: [setup]
uses: ./.github/workflows/build-core-template.yml
if: contains(github.ref_name, 'core')
secrets:
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,9 @@ jobs:
name: CI for Common Components (prover or core)
uses: ./.github/workflows/ci-common-reusable.yml

build-contracts:
name: Build contracts
needs: changed_files
if: ${{ (needs.changed_files.outputs.core == 'true' || needs.changed_files.outputs.all == 'true') && !contains(github.ref_name, 'release-please--branches') }}
uses: ./.github/workflows/build-contracts.yml

build-core-images:
name: Build core images
needs: build-contracts
needs: changed_files
if: ${{ (needs.changed_files.outputs.core == 'true' || needs.changed_files.outputs.all == 'true') && !contains(github.ref_name, 'release-please--branches') }}
uses: ./.github/workflows/build-core-template.yml
with:
Expand Down Expand Up @@ -139,7 +133,7 @@ jobs:
name: Github Status Check
runs-on: ubuntu-latest
if: always() && !cancelled()
needs: [ci-for-core-lint, ci-for-core, ci-for-prover, ci-for-docs, build-contracts, build-core-images, build-prover-images]
needs: [ci-for-core-lint, ci-for-core, ci-for-prover, ci-for-docs, build-core-images, build-prover-images]
steps:
- name: Status
run: |
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/release-test-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: "recursive"

- name: Get all test, doc and src files that have changed
id: changed-files-yaml
Expand All @@ -47,8 +46,6 @@ jobs:
prover_fri_gpu_key_id: ${{ steps.extract-prover-fri-setup-key-ids.outputs.gpu_short_commit_sha }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
with:
submodules: "recursive"

- name: Generate image tag suffix
id: generate-tag-suffix
Expand All @@ -62,15 +59,10 @@ jobs:
run: |
./prover/extract-setup-data-keys.sh >> $GITHUB_OUTPUT
build-contracts:
name: Build contracts
needs: changed_files
if: needs.changed_files.outputs.core == 'true' || needs.changed_files.outputs.all == 'true'
uses: ./.github/workflows/build-contracts.yml
build-push-core-images:
name: Build and push images
needs: [setup, build-contracts]
needs: [setup, changed_files]
uses: ./.github/workflows/build-core-template.yml
if: needs.changed_files.outputs.core == 'true' || needs.changed_files.outputs.all == 'true'
with:
Expand Down

0 comments on commit 7d53618

Please sign in to comment.