ci: refactoring and compiler cache for llvm builds #25
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Unit Tests | |
# Execute workflow for each PR and with each merge to the trunk | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: | |
- main | |
# Cancel the workflow if any new changes pushed to a feature branch or the trunk | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: false # for now, false (put jobs in queue) allowing multiple PR testing consequently | |
env: | |
VYPER_DOWNLOAD_URL: "https://github.com/vyperlang/vyper/releases/download" | |
VYPER_VERSION: "v0.3.10" | |
VYPER_DOWNLOAD_FILENAME: "vyper.0.3.10+commit.91361694" | |
CARGO_NET_GIT_FETCH_WITH_CLI: true | |
UNIT_TESTS_RESULTS_XML: unit-tests-results.xml | |
RUSTC_BOOTSTRAP: 1 # Use rustc in bootstrap mode allowing cargo2junit to use experimental --json feature | |
jobs: | |
# unit-tests-macos: | |
# strategy: | |
# matrix: | |
# include: | |
# - name: "MacOS x86" | |
# runner: macos-12-large | |
# - name: "MacOS arm64" | |
# runner: [self-hosted, macOS, ARM64] | |
# runs-on: ${{ matrix.runner }} | |
# name: ${{ matrix.name }} | |
# defaults: | |
# run: | |
# shell: zsh {0} # For MacOS hosts, .zprofile is pre-configured | |
# env: | |
# VYPER_DOWNLOAD_EXTENSION: ".darwin" | |
# steps: | |
# # TODO: This step should be done as part of github runners hooks | |
# # Users should always expect clean workspace when a new job starts | |
# # https://github.blog/changelog/2022-04-04-github-actions-job-management-hooks-for-self-hosted-runners/ | |
# - name: Cleanup workspace | |
# if: ${{ matrix.name }} == "MacOS ARM64" | |
# run: | | |
# setopt rmstarsilent # Do not query the user before executing rm * or rm path/*. | |
# setopt +o nomatch | |
# rm -rf ${{ github.workspace }}/* | |
# - name: Checkout source | |
# uses: actions/checkout@v4 | |
# - name: Prepare environment | |
# run: | | |
# brew install cmake ninja | |
# - name: Clone LLVM framework | |
# run: | | |
# cargo install compiler-llvm-builder | |
# zkevm-llvm clone | |
# - name: Build LLVM framework | |
# run: | | |
# zkevm-llvm build | |
# - name: Install vyper compiler | |
# run: | | |
# curl --location -o "${PWD}/vyper" \ | |
# "${VYPER_DOWNLOAD_URL}/${VYPER_VERSION}/${VYPER_DOWNLOAD_FILENAME}${VYPER_DOWNLOAD_EXTENSION}" | |
# chmod a+x "${PWD}/vyper" | |
# echo "${PWD}" >> "${GITHUB_PATH}" | |
# - name: Build zkvyper | |
# run: | | |
# cargo build --release | |
# echo "${PWD}/target/release" >> "${GITHUB_PATH}" | |
# - name: Install junit converter | |
# run: cargo install cargo2junit | |
# - name: Run unit tests | |
# run: | | |
# cargo test --verbose -- -Z unstable-options --format json | cargo2junit | tee "${UNIT_TESTS_RESULTS_XML}" | |
# - name: Upload test results | |
# if: always() | |
# uses: EnricoMi/publish-unit-test-result-action/composite@v2 | |
# with: | |
# check_name: ${{ matrix.name }} Unit Tests Results | |
# github_token: ${{ secrets.GITHUB_TOKEN }} | |
# files: ${{ env.UNIT_TESTS_RESULTS_XML }} | |
# action_fail_on_inconclusive: true | |
unit-tests-linux: | |
strategy: | |
matrix: | |
include: | |
- name: "Linux x86" | |
runner: matterlabs-ci-runner | |
target: "x86_64-unknown-linux-musl" | |
# TODO: uncomment and parametrize VYPER_DOWNLOAD_EXTENSION when arm64 linux vyper executable is available | |
# Linux ARM64 is not supported yet due to lack of Vyper executable for Linux arm64 | |
# - name: "Linux arm64" | |
# runner: matterlabs-ci-runner-arm | |
# target: "aarch64-unknown-linux-musl" | |
# rustflags: "-C link-arg=-Wl,-Bstatic -C link-arg=-lc -C link-arg=-L/usr/lib/llvm-15/lib/clang/15.0.7/lib/linux/ -C link-arg=-lclang_rt.builtins-aarch64" | |
runs-on: ${{ matrix.runner }} | |
name: ${{ matrix.name }} | |
container: | |
image: matterlabs/llvm_runner_jammy:latest | |
credentials: | |
username: ${{ secrets.DOCKERHUB_USER }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
env: | |
RUSTFLAGS: ${{ matrix.rustflags }} | |
VYPER_DOWNLOAD_EXTENSION: ".linux" | |
CCACHE_BASEDIR: ${{ github.workspace }} | |
CCACHE_NOHASHDIR: true | |
CCACHE_COMPILERCHECK: content | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
- run: apt update # Only for Docker jobs | |
# ensure the ccache for each PR is separate so they don't interfere with each other | |
- name: Ccache for PRs | |
uses: hendrikmuhs/[email protected] | |
if: ${{ github.event.number != '' }} | |
with: | |
key: ${{ matrix.preset }}-PR-${{ github.event.number }} | |
restore-keys: | | |
${{ matrix.preset }}-PR-${{ github.event.number }} | |
${{ matrix.preset }}-no-PR | |
max-size: "2G" | |
verbose: 2 | |
- name: Ccache for everything but PRs | |
uses: hendrikmuhs/[email protected] | |
if: ${{ github.event.number == '' }} | |
with: | |
key: ${{ matrix.preset }}-no-PR | |
restore-keys: | | |
${{ matrix.preset }}-no-PR | |
max-size: "2G" | |
verbose: 2 | |
- name: Prepare environment | |
run: | | |
rustup target add ${{ matrix.target }} | |
- name: Clone LLVM framework | |
run: | | |
set -x | |
cargo install compiler-llvm-builder --target ${{ matrix.target }} | |
zkevm-llvm clone | |
zkevm-llvm build --extra-args '\-DCMAKE_C_COMPILER_LAUNCHER=ccache' '\-DCMAKE_CXX_COMPILER_LAUNCHER=ccache' | |
# - name: Install vyper compiler | |
# run: | | |
# curl --location -o "${PWD}/vyper" \ | |
# "${VYPER_DOWNLOAD_URL}/${VYPER_VERSION}/${VYPER_DOWNLOAD_FILENAME}${VYPER_DOWNLOAD_EXTENSION}" | |
# chmod a+x "${PWD}/vyper" | |
# echo "${PWD}" >> "${GITHUB_PATH}" | |
# - name: Build LLVM framework | |
# uses: nick-fields/retry@v2 | |
# with: | |
# timeout_minutes: 60 | |
# max_attempts: 2 # protection mechanism for sporadic dependencies download failure | |
# command: zkevm-llvm build | |
# - name: Build zkvyper | |
# run: | | |
# cargo build --release --target ${{ matrix.target }} | |
# echo "${PWD}/target/${{ matrix.target }}/release" >> "${GITHUB_PATH}" | |
# - name: Install junit converter | |
# run: cargo install cargo2junit | |
# - name: Run unit tests | |
# run: | | |
# cargo test --verbose --target ${{ matrix.target }} -- -Z unstable-options --format json | \ | |
# cargo2junit | tee "${UNIT_TESTS_RESULTS_XML}" | |
# - name: Upload test results | |
# if: always() | |
# uses: EnricoMi/publish-unit-test-result-action@v2 | |
# with: | |
# check_name: ${{ matrix.name }} Unit Tests Results | |
# github_token: ${{ secrets.GITHUB_TOKEN }} | |
# files: ${{ env.UNIT_TESTS_RESULTS_XML }} | |
# action_fail_on_inconclusive: true | |
# unit-tests-windows: | |
# name: "Windows" | |
# runs-on: windows-2022-github-hosted-16core | |
# env: | |
# LIBSTDCPP_SOURCE_PATH: "C:/a/_temp/msys64/mingw64/lib/libstdc++.a" | |
# VYPER_DOWNLOAD_EXTENSION: ".windows.exe" | |
# MINGW64_DOWNLOAD_URL: "https://repo.msys2.org/mingw/mingw64" | |
# MINGW64_DOWNLOAD_FILENAME: "mingw-w64-x86_64-cmake-3.27.7-3-any.pkg.tar.zst" | |
# defaults: | |
# run: | |
# shell: msys2 {0} | |
# steps: | |
# - name: Checkout source | |
# uses: actions/checkout@v4 | |
# - name: Prepare msys2 | |
# uses: msys2/setup-msys2@v2 | |
# - name: Prepare env | |
# run: | | |
# pacman-key --refresh | |
# pacman -Sy | |
# curl -LO "$MINGW64_DOWNLOAD_URL/$MINGW64_DOWNLOAD_FILENAME" | |
# pacman --noconfirm -U "$MINGW64_DOWNLOAD_FILENAME" | |
# pacman --noconfirm -S --needed --overwrite \ | |
# base-devel \ | |
# git \ | |
# ninja \ | |
# mingw-w64-x86_64-clang \ | |
# mingw-w64-x86_64-lld \ | |
# mingw-w64-x86_64-rust \ | |
# mingw-w64-x86_64-gcc-libs \ | |
# mingw-w64-x86_64-gcc | |
# - name: Install vyper compiler | |
# run: | | |
# curl --location -o vyper.exe \ | |
# "${VYPER_DOWNLOAD_URL}/${VYPER_VERSION}/${VYPER_DOWNLOAD_FILENAME}${VYPER_DOWNLOAD_EXTENSION}" | |
# - name: Build LLVM framework | |
# run: | | |
# cargo install compiler-llvm-builder | |
# export PATH="${PATH}:/c/Users/runneradmin/.cargo/bin/" | |
# zkevm-llvm clone | |
# zkevm-llvm build | |
# - name: Build compiler | |
# run: | | |
# cargo build --release | |
# - name: Install junit converter | |
# run: cargo install cargo2junit | |
# - name: Run unit tests | |
# run: | | |
# export PATH="$PWD/target/release:$PWD:$PATH:/c/Users/runneradmin/.cargo/bin/" | |
# cargo test --verbose -- -Z unstable-options --format json | cargo2junit | tee "${UNIT_TESTS_RESULTS_XML}" | |
# - name: Upload test results | |
# if: always() | |
# uses: EnricoMi/publish-unit-test-result-action/composite@v2 | |
# with: | |
# check_name: Windows Unit Tests Results | |
# github_token: ${{ secrets.GITHUB_TOKEN }} | |
# files: ${{ env.UNIT_TESTS_RESULTS_XML }} | |
# action_fail_on_inconclusive: true |