Skip to content

ci: add unit tests workflow #2

ci: add unit tests workflow

ci: add unit tests workflow #2

Workflow file for this run

name: Unit Tests
# Execute workflow for each PR and with each merge to the trunk
on:
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_VERSION: "v0.3.10"
VYPER_DOWNLOAD_URL: "https://github.com/vyperlang/vyper/releases/download"
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_FILENAME: "vyper.0.3.10+commit.91361694.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
setopt +o nomatch
rm -rf ${{ github.workspace }}/*
- name: Checkout source
uses: actions/checkout@v4
- name: Prepare environment
run: |
brew install cmake ninja
- name: Build LLVM framework
run: |
cargo install compiler-llvm-builder
zkevm-llvm clone
zkevm-llvm build
- name: Install vyper compiler
run: |
curl --verbose \
--location -o "${PWD}/vyper" "${VYPER_DOWNLOAD_URL}/${VYPER_VERSION}/${VYPER_DOWNLOAD_FILENAME}" && \
chmod a+x "${PWD}/vyper"
echo "${PWD}" >> "${GITHUB_PATH}"
- name: Build zkvyper
run: |
cargo build -vv --release
echo "${PWD}/target/release" >> "${GITHUB_PATH}"
- name: Run unit tests
run: |
cargo install cargo2junit
cargo test -- -Z unstable-options --format json | cargo2junit > "${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"
- 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_FILENAME: "vyper.0.3.10+commit.91361694.linux"
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Prepare environment
run: |
rustup target add ${{ matrix.target }}
- name: Install vyper compiler
run: |
curl --verbose \
--location -o "${PWD}/vyper" "${VYPER_DOWNLOAD_URL}/${VYPER_VERSION}/${VYPER_DOWNLOAD_FILENAME}" && \
chmod a+x "${PWD}/vyper"
echo "${PWD}" >> "${GITHUB_PATH}"
- name: Build LLVM framework
run: |
cargo install compiler-llvm-builder --target ${{ matrix.target }}
zkevm-llvm clone
zkevm-llvm build
- name: Build zkvyper
run: |
cargo build -vv --release --target ${{ matrix.target }}
echo "${PWD}/target/${{ matrix.target }}/release" >> "${GITHUB_PATH}"
- name: Run unit tests
run: |
cargo install cargo2junit
cargo test --verbose --target ${{ matrix.target }} -- -Z unstable-options --format json | cargo2junit > "${UNIT_TESTS_RESULTS_XML}"
cat "${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_FILENAME: "vyper.0.3.10+commit.91361694.windows.exe"
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 https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-cmake-3.27.7-3-any.pkg.tar.zst
pacman --noconfirm -U mingw-w64-x86_64-cmake-3.27.7-3-any.pkg.tar.zst
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 --verbose --location -o vyper.exe "${VYPER_DOWNLOAD_URL}/${VYPER_VERSION}/${VYPER_DOWNLOAD_FILENAME}"
- 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 -vv --release
- name: Run unit tests
run: |
cargo install cargo2junit
export PATH="$PWD/target/release:$PWD:$PATH:/c/Users/runneradmin/.cargo/bin/"
cargo test --verbose -- -Z unstable-options --format json | cargo2junit > "${UNIT_TESTS_RESULTS_XML}"
cat "${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