Skip to content

Commit

Permalink
common zkevm and types (scroll-tech#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lawliet-Chan authored May 23, 2022
1 parent d69c27a commit 1b1a9ec
Show file tree
Hide file tree
Showing 24 changed files with 7,214 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RUST_LOG=info
RUST_BACKTRACE=1
107 changes: 107 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Lint

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
SCCACHE_REGION: ap-northeast-1
SCCACHE_BUCKET: ff-building
SCCACHE_S3_USE_SSL: true
SCCACHE_S3_KEY_PREFIX: sccache-gh-action
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CARGO_INCREMENTAL: false

jobs:
fmt:
name: fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-11-17
override: true
components: rustfmt, clippy
- name: Cache cargo registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v2
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo target
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Setup sccache
run: |
cd $RUNNER_TEMP
export NAME="sccache-v0.2.15-x86_64-unknown-linux-musl"
curl -fsSOL https://github.com/mozilla/sccache/releases/download/v0.2.15/$NAME.tar.gz
tar xzf $NAME.tar.gz
mkdir -p ~/.cargo/bin
mv ./$NAME/sccache ~/.cargo/bin
chmod +x ~/.cargo/bin/sccache
printf "[build]\nrustc-wrapper = \"/home/runner/.cargo/bin/sccache\"" >> ~/.cargo/config
~/.cargo/bin/sccache -s
- name: Run cargo fmt
run: |
cargo build --release
cargo fmt --all -- --check
- name: Show sccache stats
run: ~/.cargo/bin/sccache -s

clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-11-17
override: true
components: rustfmt, clippy
- name: Cache cargo registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v2
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo target
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Setup sccache
run: |
cd $RUNNER_TEMP
export NAME="sccache-v0.2.15-x86_64-unknown-linux-musl"
curl -fsSOL https://github.com/mozilla/sccache/releases/download/v0.2.15/$NAME.tar.gz
tar xzf $NAME.tar.gz
mkdir -p ~/.cargo/bin
mv ./$NAME/sccache ~/.cargo/bin
chmod +x ~/.cargo/bin/sccache
printf "[build]\nrustc-wrapper = \"/home/runner/.cargo/bin/sccache\"" >> ~/.cargo/config
~/.cargo/bin/sccache -s
- name: Run cargo clippy
run: |
cargo build --release
cargo clippy --release -- -D warnings
- name: Show sccache stats
run: ~/.cargo/bin/sccache -s
75 changes: 75 additions & 0 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Unit Test

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
SCCACHE_REGION: ap-northeast-1
SCCACHE_BUCKET: ff-building
SCCACHE_S3_USE_SSL: true
SCCACHE_S3_KEY_PREFIX: sccache-gh-action
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CARGO_INCREMENTAL: false

jobs:
linux-test:
name: Linux Test on ${{ matrix.rust }}
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64]
rust: [nightly]
container:
image: ${{ matrix.arch }}/rust
env:
# Disable full debug symbol generation to speed up CI build and keep memory down
# "1" means line tables only, which is useful for panic tracebacks.
RUSTFLAGS: "-C debuginfo=1"
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Cache Cargo Index
uses: actions/cache@v2
with:
path: /github/home/.cargo/git
key: ${{ runner.os }}-${{ matrix.arch }}-index-cache-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Cargo Registry
uses: actions/cache@v2
with:
path: /github/home/.cargo/registry
key: ${{ runner.os }}-${{ matrix.arch }}-registry-cache-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Cargo Target
uses: actions/cache@v2
with:
path: /github/home/target
key: ${{ runner.os }}-${{ matrix.arch }}-target-cache-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
- name: Setup sccache
run: |
cd $RUNNER_TEMP
export NAME="sccache-v0.2.15-x86_64-unknown-linux-musl"
curl -fsSOL https://github.com/mozilla/sccache/releases/download/v0.2.15/$NAME.tar.gz
tar xzf $NAME.tar.gz
mkdir -p ~/.cargo/bin
mv ./$NAME/sccache ~/.cargo/bin
chmod +x ~/.cargo/bin/sccache
printf "[build]\nrustc-wrapper = \"/home/runner/.cargo/bin/sccache\"" >> ~/.cargo/config
~/.cargo/bin/sccache -s
- name: Setup Rust toolchain
run: |
rustup toolchain install ${{ matrix.rust }}
rustup default ${{ matrix.rust }}
rustup component add rustfmt
- name: Run tests
run: cargo test
- name: Show sccache stats
run: ~/.cargo/bin/sccache -s
env:
CARGO_HOME: "/github/home/.cargo"
CARGO_TARGET_DIR: "/github/home/target"
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
# will have compiled files and executables
/target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# for jetbrains
.idea
Loading

0 comments on commit 1b1a9ec

Please sign in to comment.