From 71989039e3ca14ce5e321d8ed5356b431c751b3e Mon Sep 17 00:00:00 2001 From: Anton Baliasnikov Date: Tue, 21 May 2024 15:37:46 +0100 Subject: [PATCH 1/5] feat: support custom solc for tests and benchmarks --- .github/actions/build-llvm/action.yml | 14 ++++-- .github/workflows/benchmarks.yml | 57 +++++++++++++++++----- .github/workflows/integration-tests.yaml | 61 +++++++++++++++++++++--- 3 files changed, 111 insertions(+), 21 deletions(-) diff --git a/.github/actions/build-llvm/action.yml b/.github/actions/build-llvm/action.yml index ae0e9af..157f8a3 100644 --- a/.github/actions/build-llvm/action.yml +++ b/.github/actions/build-llvm/action.yml @@ -40,6 +40,10 @@ inputs: description: 'Github Actions cache key for CCache.' required: false default: '' + ccache-key-type: + description: 'Type of ccache key: `static` - rotate each month, or `dynamic` - rotate with each update of `LLVM.lock`.' + required: false + default: 'dynamic' runs: using: "composite" steps: @@ -65,9 +69,13 @@ runs: shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }} id: ccache-key run: | - LLVM_BRANCH="$(git -C ./llvm rev-parse --abbrev-ref HEAD)" - LLVM_SHORT_SHA="$(git -C ./llvm rev-parse --short HEAD)" - echo "key=llvm-${LLVM_BRANCH}-${LLVM_SHORT_SHA}-${{ runner.os }}-${{ runner.arch }}" | tee -a "${GITHUB_OUTPUT}" + if [ ${{ inputs.ccache-key-type}} = static ]; then + echo "key=llvm-$(date +'%Y-%m')" | tee -a "${GITHUB_OUTPUT}" + else + LLVM_BRANCH="$(git -C ./llvm rev-parse --abbrev-ref HEAD)" + LLVM_SHORT_SHA="$(git -C ./llvm rev-parse --short HEAD)" + echo "key=llvm-${LLVM_BRANCH}-${LLVM_SHORT_SHA}-${{ runner.os }}-${{ runner.arch }}" | tee -a "${GITHUB_OUTPUT}" + fi # CCache action requires `apt update` # to be executed before it for Linux Docker jobs. See: diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index aa9e944..b83915f 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -6,7 +6,7 @@ on: llvm_build_type: type: string description: "LLVM build type: debug | release" - required: true + required: false default: "release" compiler_tester_reference_branch: type: string @@ -38,11 +38,26 @@ on: description: "Path filter for compiler-llvm benchmarks" required: false default: "" - - -concurrency: - group: ${{ github.repository_id }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + ccache-key-type: + type: string + required: false + default: 'dynamic' + description: 'Type of ccache key: `static` - rotate each month, or `dynamic` - rotate with each update of `LLVM.lock`.' + compiler-tester-repo: + type: string + required: false + default: 'matter-labs/era-compiler-tester' + description: 'Compiler tester repository to use. Required for forks testing.' + compiler-llvm-repo: + type: string + required: false + default: 'matter-labs/era-compiler-llvm' + description: 'Compiler LLVM repository to use. Required for forks testing.' + custom-solc-run-id: + type: string + required: false + default: '' + description: 'run id of custom zksync solc artifact to download.' jobs: benchmarks: @@ -70,7 +85,7 @@ jobs: - name: Checkout compiler-tester uses: actions/checkout@v4 with: - repository: matter-labs/era-compiler-tester + repository: ${{ inputs.compiler-tester-repo }} ref: ${{ steps.define-branches.outputs.compiler-tester-branch }} submodules: recursive @@ -78,14 +93,19 @@ jobs: if: steps.define-branches.outputs.llvm-branch != '' uses: actions/checkout@v4 with: - repository: matter-labs/era-compiler-llvm + repository: ${{ inputs.compiler-llvm-repo }} ref: ${{ steps.define-branches.outputs.llvm-branch }} path: llvm + # An issue prevents to correctly use the same version of composite actions from `workflow_call` + # https://github.com/actions/toolkit/issues/1264 + # for now, it will always be taken from the latest main - name: Build LLVM uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@main with: clone-llvm: ${{ steps.define-branches.outputs.llvm-branch == '' && 'true' || 'false' }} + enable-assertions: true + ccache-key-type: ${{ inputs.ccache-key-type }} - name: Build compiler-tester run: cargo build --verbose --release --bin 'compiler-tester' @@ -101,13 +121,28 @@ jobs: --manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-vyper-*/*/Cargo.toml \ --target-dir './target-zkvyper/' + - name: Download custom solc + if: inputs.custom-solc-run-id != '' && matrix.type == 'candidate' + uses: actions/download-artifact@v4 + with: + path: ./solc-bin/ + run-id: ${{ inputs.custom-solc-run-id }} + merge-multiple: true + + - name: Prepare custom solc + if: inputs.custom-solc-run-id != '' && matrix.type == 'candidate' + run: | + chmod a+x ./solc-bin/solc* + echo "Testing with custom solc from run ${{ inputs.custom-solc-run-id }}" + echo $(./solc-bin/solc* --version) + - name: Run benchmarks run: | ./target/release/compiler-tester \ --zksolc './target-zksolc/release/zksolc' \ --zkvyper './target-zkvyper/release/zkvyper' \ --path=${{ inputs.compiler_llvm_benchmark_path || '' }} \ - --mode=${{ inputs.compiler_llvm_benchmark_mode || '^M^B3' }} \ + --mode='${{ inputs.compiler_llvm_benchmark_mode || '^M^B3' }}' \ --benchmark=${{ matrix.type }}.json - uses: actions/upload-artifact@v4 @@ -127,8 +162,8 @@ jobs: - name: Checking out the compiler-tester repository uses: actions/checkout@v4 with: - repository: matter-labs/era-compiler-tester - ref: ${{ inputs.compiler_tester_candidate_branch || github.event.repository.default_branch }} + repository: ${{ inputs.compiler-tester-repo }} + ref: ${{ inputs.compiler_tester_candidate_branch || 'main' }} submodules: recursive - uses: actions/download-artifact@v4 diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index e3ac316..c028d15 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -11,10 +11,36 @@ on: type: string required: true description: 'LLVM revision to use.' - -concurrency: - group: ${{ github.repository_id }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + path: + type: string + required: false + default: '' + description: 'Path filter for integration tests execution. For example: `tests/solidity/`.' + extra-args: + type: string + required: false + default: '' + description: 'Extra arguments for era-compiler-tester.' + custom-solc-run-id: + type: string + required: false + default: '' + description: 'run id of custom zksync solc artifact to download.' + ccache-key-type: + type: string + required: false + default: 'dynamic' + description: 'Type of ccache key: `static` - rotate each month, or `dynamic` - rotate with each update of `LLVM.lock`.' + compiler-tester-repo: + type: string + required: false + default: 'matter-labs/era-compiler-tester' + description: 'Compiler tester repository to use. Required for forks testing.' + compiler-llvm-repo: + type: string + required: false + default: 'matter-labs/era-compiler-llvm' + description: 'Compiler LLVM repository to use. Required for forks testing.' jobs: run-integration-tests: @@ -28,7 +54,7 @@ jobs: - name: Checkout compiler-tester uses: actions/checkout@v4 with: - repository: matter-labs/era-compiler-tester + repository: ${{ inputs.compiler-tester-repo }} ref: ${{ inputs.compiler-tester-ref || '' }} submodules: recursive @@ -36,10 +62,13 @@ jobs: if: inputs.llvm-ref != '' uses: actions/checkout@v4 with: - repository: matter-labs/era-compiler-llvm + repository: ${{ inputs.compiler-llvm-repo }} ref: ${{ inputs.llvm-ref }} path: llvm + # An issue prevents to correctly use the same version of composite actions from `workflow_call` + # https://github.com/actions/toolkit/issues/1264 + # for now, it will always be taken from the latest main - name: Build LLVM uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@main with: @@ -47,6 +76,7 @@ jobs: enable-tests: true enable-assertions: true clone-llvm: ${{ inputs.llvm-ref == '' && 'true' || 'false' }} + ccache-key-type: ${{ inputs.ccache-key-type }} - name: Build compiler-tester run: cargo build --verbose --release --bin 'compiler-tester' @@ -62,11 +92,28 @@ jobs: --manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-vyper-*/*/Cargo.toml \ --target-dir './target-zkvyper/' + - name: Download custom solc + if: inputs.custom-solc-run-id != '' + uses: actions/download-artifact@v4 + with: + path: ./solc-bin/ + run-id: ${{ inputs.custom-solc-run-id }} + merge-multiple: true + + - name: Prepare custom solc + if: inputs.custom-solc-run-id != '' + run: | + chmod a+x ./solc-bin/solc* + echo "Testing with custom solc from run ${{ inputs.custom-solc-run-id }}" + echo $(./solc-bin/solc* --version) + - name: Run integration tests run: | + set -x ./target/release/compiler-tester \ --zksolc './target-zksolc/release/zksolc' \ - --zkvyper './target-zkvyper/release/zkvyper' + --zkvyper './target-zkvyper/release/zkvyper' \ + --path '${{ inputs.path }}' ${{ inputs.extra-args }} - name: Send Slack notification uses: 8398a7/action-slack@v3 From 1cc1045d9d07134ca1f230767771fdc5f91d3644 Mon Sep 17 00:00:00 2001 From: Anton Baliasnikov Date: Tue, 21 May 2024 17:26:34 +0100 Subject: [PATCH 2/5] chore: add boost support --- .github/actions/prepare-msys/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/prepare-msys/action.yml b/.github/actions/prepare-msys/action.yml index 8c1e878..7d1d908 100644 --- a/.github/actions/prepare-msys/action.yml +++ b/.github/actions/prepare-msys/action.yml @@ -17,6 +17,7 @@ runs: mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-libs + mingw-w64-x86_64-boost - name: Prepare env shell: 'msys2 {0}' From 8c25ed395e5ec09b32051e5235153068a0fffc2e Mon Sep 17 00:00:00 2001 From: Anton Baliasnikov Date: Tue, 21 May 2024 19:12:08 +0100 Subject: [PATCH 3/5] test --- .github/actions/prepare-msys/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/actions/prepare-msys/action.yml b/.github/actions/prepare-msys/action.yml index 7d1d908..8c1e878 100644 --- a/.github/actions/prepare-msys/action.yml +++ b/.github/actions/prepare-msys/action.yml @@ -17,7 +17,6 @@ runs: mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-libs - mingw-w64-x86_64-boost - name: Prepare env shell: 'msys2 {0}' From 7c6a8422a5076e1545bd648e85353ca8b8289565 Mon Sep 17 00:00:00 2001 From: Anton Baliasnikov Date: Tue, 21 May 2024 19:27:56 +0100 Subject: [PATCH 4/5] test --- .github/actions/prepare-msys/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/prepare-msys/action.yml b/.github/actions/prepare-msys/action.yml index 8c1e878..ee4c036 100644 --- a/.github/actions/prepare-msys/action.yml +++ b/.github/actions/prepare-msys/action.yml @@ -7,6 +7,7 @@ runs: uses: msys2/setup-msys2@v2 with: path-type: inherit # Important to correctly update PATH + update: true install: >- base-devel git @@ -17,6 +18,7 @@ runs: mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-libs + mingw-w64-x86_64-boost - name: Prepare env shell: 'msys2 {0}' From 161d55a69e73180e2c3ebb6e96ba748f54dc6ca5 Mon Sep 17 00:00:00 2001 From: Anton Baliasnikov Date: Tue, 21 May 2024 19:50:49 +0100 Subject: [PATCH 5/5] test --- .github/actions/prepare-msys/action.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/actions/prepare-msys/action.yml b/.github/actions/prepare-msys/action.yml index ee4c036..8c1e878 100644 --- a/.github/actions/prepare-msys/action.yml +++ b/.github/actions/prepare-msys/action.yml @@ -7,7 +7,6 @@ runs: uses: msys2/setup-msys2@v2 with: path-type: inherit # Important to correctly update PATH - update: true install: >- base-devel git @@ -18,7 +17,6 @@ runs: mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-libs - mingw-w64-x86_64-boost - name: Prepare env shell: 'msys2 {0}'