Skip to content

Commit

Permalink
feat: add docs, shared actions and workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
antonbaliasnikov committed May 15, 2024
1 parent 6ac5e26 commit 03c65d2
Show file tree
Hide file tree
Showing 13 changed files with 719 additions and 2 deletions.
39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Bug report
about: Use this template for reporting issues
title: ''
labels: bug
assignees: ''
---

### 🐛 Bug Report

#### 📝 Description

Provide a clear and concise description of the bug.

#### 🔄 Reproduction Steps

Steps to reproduce the behaviour

#### 🤔 Expected Behavior

Describe what you expected to happen.

#### 😯 Current Behavior

Describe what actually happened.

#### 🖥️ Environment

Any relevant environment details.

#### 📋 Additional Context

Add any other context about the problem here. If applicable, add screenshots to help explain.

#### 📎 Log Output

```
Paste any relevant log output here.
```
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Feature request
about: Use this template for requesting features
title: ''
labels: feat
assignees: ''
---

### 🌟 Feature Request

#### 📝 Description

Provide a clear and concise description of the feature you'd like to see.

#### 🤔 Rationale

Explain why this feature is important and how it benefits the project.

#### 📋 Additional Context

Add any other context or information about the feature request here.
112 changes: 112 additions & 0 deletions .github/actions/build-llvm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# The general action to build ZKsync LLVM framework.
# It is universal for all platforms: Linux, MacOS and Windows.

name: 'Build LLVM'
description: 'Builds backend LLVM framework'
inputs:
clone-llvm:
description: 'Whether to clone LLVM repository.'
required: false
default: 'true'
enable-tests:
description: "Enable tests."
required: false
default: 'false'
enable-assertions:
description: "Enable assertions."
required: false
default: 'true'
extra-args:
description: 'Extra CMake arguments to compile LLVM.'
required: false
default: ''
builder-extra-args:
description: 'Extra LLVM builder arguments to compile LLVM.'
required: false
default: ''
build-type:
description: 'LLVM build type: debug | release'
required: false
default: 'release'
target-env:
description: 'Target environment (gnu or musl).'
required: false
default: 'gnu'
llvm-builder-version:
description: 'Version of the LLVM builder to use.'
required: false
default: '1.0.25'
ccache-key:
description: 'Github Actions cache key for CCache.'
required: false
default: ''
runs:
using: "composite"
steps:

# Ninja build tool is not available on MacOS x64 runners by default. See:
# https://github.com/actions/runner-images/issues/514
- name: Install Ninja on MacOS x64
if: runner.os == 'macOS' && runner.arch == 'X64'
shell: 'bash'
run: HOMEBREW_NO_AUTO_UPDATE=1 brew install ninja

- name: Install LLVM builder
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
run: cargo install compiler-llvm-builder@${{ inputs.llvm-builder-version }}

- name: Clone LLVM framework
if: inputs.clone-llvm == 'true'
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
run: zksync-llvm clone --target-env ${{ inputs.target-env }}

- name: Define ccache key
if: inputs.ccache-key == ''
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}"
# CCache action requires `apt update`
# to be executed before it for Linux Docker jobs. See:
# https://github.com/hendrikmuhs/ccache-action?tab=readme-ov-file#usage
- name: Prepare ccache installation
if: runner.os == 'Linux'
shell: 'bash'
run: apt update

- name: Set up compiler cache
uses: hendrikmuhs/[email protected]
env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_NOHASHDIR: "true"
CCACHE_COMPILERCHECK: "content"
with:
key: ${{ inputs.ccache-key == '' && steps.ccache-key.outputs.key || inputs.ccache-key }}
restore-keys: ${{ inputs.ccache-key == '' && steps.ccache-key.outputs.key || inputs.ccache-key }}
append-timestamp: false
max-size: "2G"
verbose: 2
save: true # ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/') }}

# CCACHE_BASEDIR, CCACHE_NOHASHDIR, and CCACHE_COMPILERCHECK
# are allowing to cache compiler output across different
# directories and compiler versions. See:
# https://ccache.dev/manual/3.7.12.html#_compiling_in_different_directories
- name: Build LLVM
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_NOHASHDIR: "true"
CCACHE_COMPILERCHECK: "content"
LIBSTDCPP_SOURCE_PATH: "C:/a/_temp/msys64/mingw64/lib/libstdc++.a"
run: |
set -x
[ "${{ inputs.build-type }}" = "debug" ] && DEBUG_ARG="--debug"
[ "${{ inputs.enable-tests }}" = "true" ] && ENABLE_TESTS="--enable-tests"
[ "${{ inputs.enable-assertions }}" = "true" ] && ENABLE_ASSERTIONS="--enable-assertions"
[ "${{ inputs.extra-args }}" != "" ] && EXTRA_ARGS="--extra-args ${{ inputs.extra-args }}"
zksync-llvm build --target-env ${{ inputs.target-env }} \
--use-ccache ${{ inputs.builder-extra-args }} ${DEBUG_ARG} ${ENABLE_TESTS} ${ENABLE_ASSERTIONS} ${EXTRA_ARGS}
23 changes: 23 additions & 0 deletions .github/actions/prepare-msys/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'Install msys2'
description: 'Prepares msys2 for Windows builds.'
runs:
using: composite
steps:
- name: Setup msys2
uses: msys2/setup-msys2@v2
with:
path-type: inherit # Important to correctly update PATH
install: >-
base-devel
git
ninja
mingw-w64-x86_64-clang
mingw-w64-x86_64-lld
mingw-w64-x86_64-rust
mingw-w64-x86_64-cmake
mingw-w64-x86_64-gcc
mingw-w64-x86_64-gcc-libs
- name: Prepare env
shell: 'msys2 {0}'
run: echo "/c/Users/runneradmin/.cargo/bin" >> "${GITHUB_PATH}"
18 changes: 18 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# What ❔

<!-- What are the changes this PR brings about? -->
<!-- Example: This PR adds a PR template to the repo. -->
<!-- (For bigger PRs adding more context is appreciated) -->

## Why ❔

<!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? -->
<!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. -->

## Checklist

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

- [ ] PR title corresponds to the body of PR.
- [ ] Documentation comments have been added / updated.
156 changes: 156 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: Benchmarks

on:
workflow_call:
inputs:
llvm_build_type:
type: string
description: "LLVM build type: debug | release"
required: true
default: "release"
compiler_tester_reference_branch:
type: string
description: "compiler-tester branch to use as a benchmark reference"
required: true
default: "main"
compiler_tester_candidate_branch:
type: string
description: "compiler-tester branch to use as a benchmark candidate"
required: true
default: "main"
compiler_llvm_reference_branch:
type: string
description: "compiler-llvm branch to use as a benchmark reference"
required: true
default: "main"
compiler_llvm_candidate_branch:
type: string
description: "compiler-llvm branch to use as a benchmark candidate"
required: true
default: "main"
compiler_llvm_benchmark_mode:
type: string
description: "Mode filter for compiler-llvm benchmarks"
required: false
default: "^M^B3"
compiler_llvm_benchmark_path:
type: string
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

jobs:
benchmarks:
strategy:
fail-fast: false
matrix:
type: ["reference", "candidate"]
name: ${{ matrix.type }}
runs-on: matterlabs-ci-runner
container:
image: matterlabs/llvm_runner:ubuntu22-llvm17-latest
options: -m 110g
steps:
- name: Define branches
id: define-branches
run: |
if [ "${{ matrix.type }}" = "candidate" ]; then
echo "compiler-tester-branch=${{ inputs.compiler_tester_candidate_branch || github.head_ref }}" | tee -a "${GITHUB_OUTPUT}"
echo "llvm-branch=${{ inputs.compiler_llvm_candidate_branch || '' }}" | tee -a "${GITHUB_OUTPUT}"
else
echo "compiler-tester-branch=${{ inputs.compiler_tester_reference_branch || github.event.repository.default_branch }}" | tee -a "${GITHUB_OUTPUT}"
echo "llvm-branch=${{ inputs.compiler_llvm_reference_branch || '' }}" | tee -a "${GITHUB_OUTPUT}"
fi
- name: Checkout compiler-tester
uses: actions/checkout@v4
with:
repository: matter-labs/era-compiler-tester
ref: ${{ steps.define-branches.outputs.compiler-tester-branch }}
submodules: recursive

- name: Checkout LLVM
if: steps.define-branches.outputs.llvm-branch != ''
uses: actions/checkout@v4
with:
repository: matter-labs/era-compiler-llvm
ref: ${{ steps.define-branches.outputs.llvm-branch }}
path: llvm

- name: Build LLVM
uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@aba-cpr-1691-set-up-a-pipeline-to-apply-all-ci-changes-to-all-repos
with:
clone-llvm: ${{ steps.define-branches.outputs.llvm-branch == '' && 'true' || 'false' }}

- name: Build compiler-tester
run: cargo build --verbose --release --bin 'compiler-tester'

- name: Build compilers
env:
CARGO_CHECKOUT_DIR: /usr/local/cargo/git/checkouts
run: |
cargo build --verbose --release \
--manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-solidity-*/*/Cargo.toml \
--target-dir './target-zksolc/'
cargo build --verbose --release \
--manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-vyper-*/*/Cargo.toml \
--target-dir './target-zkvyper/'
- 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' }} \
--benchmark=${{ matrix.type }}.json
- uses: actions/upload-artifact@v4
with:
name: compiler-llvm-${{ matrix.type }}-benchmark
path: ${{ matrix.type }}.json

analysis:
name: "Benchmark comparison"
runs-on: matterlabs-ci-runner
permissions:
pull-requests: write
container:
image: matterlabs/llvm_runner:ubuntu22-llvm17-latest
needs: benchmarks
steps:
- 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 }}
submodules: recursive

- uses: actions/download-artifact@v4
with:
pattern: compiler-llvm-*
merge-multiple: true

- name: Comparing the LLVM framework benchmark results
run: |
cargo run --release --bin benchmark-analyzer -- \
--reference reference.json --candidate candidate.json --output-file result.txt
- name: Posting the LLVM benchmark results to the summary
run: |
printf "Benchmark results:\n" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat result.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat $GITHUB_STEP_SUMMARY > result.txt
- name: Posting the LLVM benchmark results to a PR comment
if: github.event_name == 'pull_request'
uses: mshick/add-pr-comment@v2
with:
message-path: result.txt
14 changes: 14 additions & 0 deletions .github/workflows/cargo-license.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Cargo license check

on: workflow_call

jobs:
cargo-deny:
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Check licenses
uses: EmbarkStudios/cargo-deny-action@v1
Loading

0 comments on commit 03c65d2

Please sign in to comment.