Skip to content

Commit

Permalink
ci: support eravm and evm execution targets (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonbaliasnikov authored Aug 9, 2024
1 parent 09fe768 commit 67cfdbf
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ccache-regen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
ccache-regen:
runs-on: [ci-runner-compiler, Linux]
container:
image: ghcr.io/matter-labs/llvm_runner/ubuntu22-llvm17:latest
image: ghcr.io/matter-labs/zksync-llvm-runner:latest
options: -m 110g
steps:

Expand Down
22 changes: 10 additions & 12 deletions .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ jobs:
run-with-sanitizers:
runs-on: [ci-runner-compiler, Linux]
container:
image: ghcr.io/matter-labs/llvm_runner/ubuntu22-llvm17:latest
image: ghcr.io/matter-labs/zksync-llvm-runner:latest
options: -m 110g
env:
TARGET: x86_64-unknown-linux-gnu
RUSTC_BOOTSTRAP: 1
steps:

- name: Checkout compiler-tester
Expand All @@ -49,33 +50,30 @@ jobs:
sanitizer: ${{ inputs.llvm-sanitizer }}
enable-assertions: true

- name: Install rustc nightly
run: |
rustup install nightly-${TARGET}
rustup component add rust-src --toolchain nightly-${TARGET}
- name: Build compiler-tester
env:
RUSTFLAGS: "-Z sanitizer=${{ inputs.rust-sanitizer }}"
run: cargo +nightly build --release --target ${TARGET} -Zbuild-std --bin 'compiler-tester'
run: |
rustup component add rust-src --toolchain "$(rustc --version | cut -d ' ' -f2)-${TARGET}"
cargo build --target ${TARGET} -Zbuild-std --bin 'compiler-tester'
- name: Build zksolc and zkvyper
env:
CARGO_CHECKOUT_DIR: /usr/local/cargo/git/checkouts
RUSTFLAGS: "-Z sanitizer=${{ inputs.rust-sanitizer }}"
run: |
cargo +nightly build --release --target ${TARGET} -Zbuild-std \
cargo build --target ${TARGET} -Zbuild-std \
--manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-solidity-*/*/Cargo.toml \
--target-dir './target-zksolc/'
cargo +nightly build --release --target ${TARGET} -Zbuild-std \
cargo build --target ${TARGET} -Zbuild-std \
--manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-vyper-*/*/Cargo.toml \
--target-dir './target-zkvyper/'
- name: Run tests with sanitizers
run: |
set -x
./target/${TARGET}/release/compiler-tester \
--zksolc "./target-zksolc/${TARGET}/release/zksolc" \
--zkvyper "./target-zkvyper/${TARGET}/release/zkvyper" \
./target/${TARGET}/debug/compiler-tester \
--zksolc "./target-zksolc/${TARGET}/debug/zksolc" \
--zkvyper "./target-zkvyper/${TARGET}/debug/zkvyper" \
--path '${{ inputs.path }}'
--mode '${{ inputs.mode }}'
44 changes: 42 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,13 @@ jobs:
cargo-check:
runs-on: [ci-runner-compiler, Linux]
container:
image: ghcr.io/matter-labs/llvm_runner/ubuntu22-llvm17:latest
image: ghcr.io/matter-labs/zksync-llvm-runner:latest
steps:
- uses: actions/checkout@v4

- name: Build LLVM
uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1
with:
enable-tests: true
enable-assertions: true
ccache-key-type: static

Expand All @@ -61,22 +60,62 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}


# Define target for integration tests and benchmarks
# based on PR title labels
target-machine:
runs-on: ubuntu-latest
outputs:
evm: ${{ steps.evm.outputs.machine }}
eravm: ${{ steps.eravm.outputs.machine }}
default: ${{ steps.default.outputs.machine }}
steps:

- name: Check for EraVM target
id: eravm
if: contains(github.event.pull_request.title, '(EraVM)')
run: echo "machine=EraVM" | tee -a "${GITHUB_OUTPUT}"

- name: Check for EVM target
id: evm
if: contains(github.event.pull_request.title, '(EVM)')
run: echo "machine=EVM" | tee -a "${GITHUB_OUTPUT}"

- name: Check for default target
id: default
shell: bash -ex {0}
run: |
if [[ "${{ join(steps.*.outputs.*) }}" == "" ]]; then
echo "machine=default" | tee -a "${GITHUB_OUTPUT}"
fi
# Integration tests workflow call from the era-compiler-ci repository
# This is a common part of the integration tests workflow for all repositories
# If you would like to make a change to the integration tests workflow, please do it in the era-compiler-ci repository
integration-tests:
needs: target-machine
uses: matter-labs/era-compiler-ci/.github/workflows/integration-tests.yaml@v1
secrets: inherit
strategy:
fail-fast: false
matrix:
target: ${{ needs.target-machine.outputs.* }}
with:
compiler-tester-repo: ${{ github.event.pull_request.head.repo.full_name }} # required to properly test forks
ccache-key-type: static
target-machine: ${{ matrix.target }}

# Benchmarks workflow call from the era-compiler-ci repository
# This is a common part of the benchmarks workflow for all repositories
# If you would like to make a change to the benchmarks workflow, please do it in the era-compiler-ci repository
benchmarks:
needs: target-machine
uses: matter-labs/era-compiler-ci/.github/workflows/benchmarks.yml@v1
secrets: inherit
strategy:
fail-fast: false
matrix:
target: ${{ needs.target-machine.outputs.* }}
with:
compiler_tester_reference_branch: ${{ github.event.inputs.compiler_tester_reference_branch || 'main' }}
compiler_tester_candidate_branch: ${{ github.event.inputs.compiler_tester_candidate_branch || '' }}
Expand All @@ -86,6 +125,7 @@ jobs:
compiler_llvm_benchmark_path: ${{ github.event.inputs.compiler_llvm_benchmark_path || '' }}
compiler-tester-repo: ${{ github.event.pull_request.head.repo.full_name }}
ccache-key-type: static
target-machine: ${{ matrix.target }}

# Special job that allows some of the jobs to be skipped or failed
# requiring others to be successful
Expand Down
10 changes: 6 additions & 4 deletions solidity_adapter/src/index/test_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ impl TryFrom<&Path> for TestFile {
let mut file = fs::File::open(value)?;

let mut data = String::new();
file.read_to_string(&mut data)
.map_err(|error| anyhow::anyhow!("Failed to read test file (2, {:?}): {}", file, error))?;
file.read_to_string(&mut data).map_err(|error| {
anyhow::anyhow!("Failed to read test file (2, {:?}): {}", file, error)
})?;

let hash = Self::md5(data.as_str());

Expand All @@ -72,8 +73,9 @@ impl TestFile {
.ok_or_else(|| anyhow::anyhow!("Test file hash is None: {:?}", path))?;
let mut file = fs::File::open(path)?;
let mut data = String::new();
file.read_to_string(&mut data)
.map_err(|error| anyhow::anyhow!("Failed to read test file (3, {:?}): {}", file, error))?;
file.read_to_string(&mut data).map_err(|error| {
anyhow::anyhow!("Failed to read test file (3, {:?}): {}", file, error)
})?;
let actual_hash = Self::md5(data.as_str());
Ok(!saved_hash.eq(&actual_hash))
}
Expand Down
5 changes: 3 additions & 2 deletions solidity_adapter/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ impl TryFrom<&Path> for Test {
let mut file = fs::File::open(path)?;

let mut data = String::new();
file.read_to_string(&mut data)
.map_err(|error| anyhow::anyhow!("Failed to read test file (1, {:?}): {}", file, error))?;
file.read_to_string(&mut data).map_err(|error| {
anyhow::anyhow!("Failed to read test file (1, {:?}): {}", file, error)
})?;

let comment_start = if path
.extension()
Expand Down

0 comments on commit 67cfdbf

Please sign in to comment.