use the contract executor #5
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: Main-CI-Flow | |
on: | |
push: | |
branches: | |
- main | |
- main-v[0-9].** | |
tags: | |
- v[0-9].** | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- auto_merge_enabled | |
- edited | |
# On PR events, cancel existing CI runs on this same PR for this workflow. | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
jobs: | |
commitlint: | |
runs-on: starkware-ubuntu-latest-small | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install commitlint | |
run: npm install --global @commitlint/cli @commitlint/config-conventional | |
- name: Validate PR commits with commitlint | |
if: github.event_name == 'pull_request' && !(contains(github.event.pull_request.title, 'merge-main') || contains(github.event.pull_request.title, 'merge main')) | |
env: | |
BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
run: commitlint --from "$BASE_SHA" --to "$HEAD_SHA" --verbose | |
- name: Validate PR title with commitlint | |
if: github.event_name != 'merge_group' && github.event_name != 'push' && !(contains(github.event.pull_request.title, 'merge-main') || contains(github.event.pull_request.title, 'merge main')) | |
env: | |
TITLE: ${{ github.event.pull_request.title }} | |
run: echo "$TITLE" | commitlint --verbose | |
format: | |
runs-on: starkware-ubuntu-20-04-medium | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master # TODO(Nimrod, 15/8/2024): Use stable toolchain. | |
with: | |
components: rustfmt | |
toolchain: nightly-2024-04-29 | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
prefix-key: "v0-rust-ubuntu-20.04" | |
- run: scripts/rust_fmt.sh --check | |
clippy: | |
runs-on: starkware-ubuntu-20-04-medium | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: Noelware/[email protected] | |
- uses: ./.github/actions/install_rust | |
with: | |
components: clippy | |
- name: Set up Native Dependencies | |
uses: ./.github/actions/setup-native-deps | |
id: native-deps | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
prefix-key: "v0-rust-ubuntu-20.04" | |
# Setup pypy and link to the location expected by .cargo/config.toml. | |
- uses: actions/setup-python@v5 | |
id: setup-pypy | |
with: | |
python-version: 'pypy3.9' | |
- run: ln -s '${{ steps.setup-pypy.outputs.python-path }}' /usr/local/bin/pypy3.9 | |
- env: | |
LD_LIBRARY_PATH: ${{ steps.setup-pypy.outputs.pythonLocation }}/bin | |
run: echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV | |
- run: scripts/clippy.sh | |
doc: | |
runs-on: starkware-ubuntu-latest-small | |
env: | |
RUSTDOCFLAGS: "-D warnings" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/install_rust | |
- name: Set up Native Dependencies | |
uses: ./.github/actions/setup-native-deps | |
id: native-deps | |
- uses: Swatinem/rust-cache@v2 | |
- uses: Noelware/[email protected] | |
with: | |
version: ${{env.PROTOC_VERSION}} | |
- run: cargo doc --workspace -r --document-private-items --no-deps | |
run-workspace-tests: | |
runs-on: starkware-ubuntu-latest-small | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/install_rust | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo test -p workspace_tests | |
run-tests: | |
runs-on: starkware-ubuntu-20-04-medium | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Fetch the entire history. | |
fetch-depth: 0 | |
- uses: ./.github/actions/install_rust | |
- name: Set up Native Dependencies | |
uses: ./.github/actions/setup-native-deps | |
id: native-deps | |
- uses: Noelware/[email protected] | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
prefix-key: "v0-rust-ubuntu-20.04" | |
# Setup pypy and link to the location expected by .cargo/config.toml. | |
- uses: actions/setup-python@v5 | |
id: setup-pypy | |
with: | |
python-version: 'pypy3.9' | |
- run: ln -s '${{ steps.setup-pypy.outputs.python-path }}' /usr/local/bin/pypy3.9 | |
- env: | |
LD_LIBRARY_PATH: ${{ env.Python3_ROOT_DIR }}/bin | |
run: echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV | |
- name: "Run tests pull request" | |
if: github.event_name == 'pull_request' | |
run: | | |
python3 -m venv ci | |
ci/bin/pip install -r scripts/requirements.txt | |
ci/bin/python scripts/run_tests.py --changes_only --commit_id ${{ github.event.pull_request.base.sha }} | |
env: | |
SEED: 0 | |
- name: "Run tests on push" | |
if: github.event_name == 'push' | |
# TODO: Better support for running tests on push. | |
run: | | |
python3 -m venv ci | |
ci/bin/pip install -r scripts/requirements.txt | |
ci/bin/python scripts/run_tests.py | |
env: | |
SEED: 0 | |
taplo: | |
runs-on: starkware-ubuntu-latest-small | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/install_rust | |
- uses: Swatinem/rust-cache@v2 | |
- uses: baptiste0928/cargo-install@v3 | |
with: | |
crate: taplo-cli | |
version: '0.9.0' | |
locked: true | |
- run: scripts/taplo.sh | |
machete: | |
runs-on: starkware-ubuntu-latest-small | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run Machete (detect unused dependencies) | |
uses: bnjbvr/cargo-machete@main | |
check: | |
runs-on: starkware-ubuntu-latest-small | |
env: | |
RUSTDOCFLAGS: "-D warnings" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/install_rust | |
- name: Set up Native Dependencies | |
uses: ./.github/actions/setup-native-deps | |
id: native-deps | |
- uses: Swatinem/rust-cache@v2 | |
- uses: Noelware/[email protected] | |
with: | |
version: ${{env.PROTOC_VERSION}} | |
- run: cargo check --workspace -r --all-features | |
merge-gatekeeper: | |
runs-on: starkware-ubuntu-latest-small | |
# Restrict permissions of the GITHUB_TOKEN. | |
# Docs: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs | |
permissions: | |
checks: read | |
statuses: read | |
steps: | |
- name: Run Merge Gatekeeper on pull request | |
if: github.event_name == 'pull_request' | |
uses: upsidr/merge-gatekeeper@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
timeout: 1200 | |
interval: 30 | |
ignored: "code-review/reviewable" | |
- name: Run Merge Gatekeeper on Merge Queue || push | |
if: github.event_name == 'merge_group' || github.event_name == 'push' | |
uses: upsidr/merge-gatekeeper@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
ref: ${{github.ref}} | |
timeout: 1200 | |
interval: 30 | |
ignored: "code-review/reviewable" | |
codecov: | |
runs-on: starkware-ubuntu-latest-medium | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/install_rust | |
- name: Set-Up | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y clang llvm libudev-dev | |
- uses: Noelware/[email protected] | |
with: | |
version: ${{env.PROTOC_VERSION}} | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- uses: Swatinem/rust-cache@v2 | |
- run: npm install -g [email protected] | |
- name: Coverage | |
run: cargo llvm-cov --codecov -r --output-path codecov.json | |
env: | |
SEED: 0 | |
- name: Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
verbose: true | |
fail_ci_if_error: true | |
version: "v0.1.15" |