Sierra emu #9
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: Committer-CI | |
on: | |
push: | |
branches: | |
- main | |
- main-v[0-9].** | |
tags: | |
- v[0-9].** | |
paths: | |
- '.github/workflows/committer_ci.yml' | |
- 'Cargo.toml' | |
- 'Cargo.lock' | |
- 'crates/committer_cli/**' | |
- 'crates/starknet_committer/**' | |
- 'crates/starknet_patricia/**' | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- auto_merge_enabled | |
- edited | |
paths: | |
- '.github/workflows/committer_ci.yml' | |
- 'Cargo.toml' | |
- 'Cargo.lock' | |
- 'crates/committer_cli/**' | |
- 'crates/starknet_committer/**' | |
- 'crates/starknet_patricia/**' | |
# 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: | |
run-regression-tests: | |
runs-on: starkware-ubuntu-latest-small | |
if: ${{ github.event_name == 'pull_request' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/install_rust | |
- uses: Swatinem/rust-cache@v2 | |
- id: auth | |
uses: "google-github-actions/auth@v2" | |
with: | |
credentials_json: ${{ secrets.COMMITER_PRODUCTS_EXT_WRITER_JSON }} | |
- uses: 'google-github-actions/setup-gcloud@v2' | |
- run: echo "BENCH_INPUT_FILES_PREFIX=$(cat ./crates/committer_cli/src/tests/flow_test_files_prefix)" >> $GITHUB_ENV | |
- run: gcloud storage cp -r gs://committer-testing-artifacts/$BENCH_INPUT_FILES_PREFIX/* ./crates/committer_cli/test_inputs | |
- run: cargo test -p committer_cli --release -- --include-ignored test_regression | |
benchmarking: | |
runs-on: starkware-ubuntu-latest-small | |
if: ${{ github.event_name == 'pull_request' }} | |
steps: | |
# Checkout the base branch to get the old code. | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.base_ref }} | |
- uses: Swatinem/rust-cache@v2 | |
# Download the old benchmark inputs. | |
- id: auth | |
uses: "google-github-actions/auth@v2" | |
with: | |
credentials_json: ${{ secrets.COMMITER_PRODUCTS_EXT_WRITER_JSON }} | |
- uses: 'google-github-actions/setup-gcloud@v2' | |
- run: echo "OLD_BENCH_INPUT_FILES_PREFIX=$(cat ./crates/committer_cli/src/tests/flow_test_files_prefix)" >> $GITHUB_ENV | |
- run: gcloud storage cp -r gs://committer-testing-artifacts/$OLD_BENCH_INPUT_FILES_PREFIX/* ./crates/committer_cli/test_inputs | |
# List the existing benchmarks. | |
- run: | | |
cargo bench -p committer_cli -- --list | grep ': benchmark$' | sed -e "s/: benchmark$//" > benchmarks_list.txt | |
# Benchmark the old code. | |
- run: cargo bench -p committer_cli | |
# Backup the downloaded files to avoid re-downloading them if they didn't change (overwritten by checkout). | |
- run: mv ./crates/committer_cli/test_inputs/tree_flow_inputs.json ./crates/committer_cli/test_inputs/tree_flow_inputs.json_bu | |
- run: mv ./crates/committer_cli/test_inputs/committer_flow_inputs.json ./crates/committer_cli/test_inputs/committer_flow_inputs.json_bu | |
# Checkout the new code. | |
- uses: actions/checkout@v4 | |
with: | |
clean: false | |
- run: echo "NEW_BENCH_INPUT_FILES_PREFIX=$(cat ./crates/committer_cli/src/tests/flow_test_files_prefix)" >> $GITHUB_ENV | |
# Input files didn't change. | |
- if: env.OLD_BENCH_INPUT_FILES_PREFIX == env.NEW_BENCH_INPUT_FILES_PREFIX | |
run: | | |
mv ./crates/committer_cli/test_inputs/tree_flow_inputs.json_bu ./crates/committer_cli/test_inputs/tree_flow_inputs.json | |
mv ./crates/committer_cli/test_inputs/committer_flow_inputs.json_bu ./crates/committer_cli/test_inputs/committer_flow_inputs.json | |
# Input files did change, download new inputs. | |
- if: env.OLD_BENCH_INPUT_FILES_PREFIX != env.NEW_BENCH_INPUT_FILES_PREFIX | |
run: | | |
gcloud storage cp -r gs://committer-testing-artifacts/$NEW_BENCH_INPUT_FILES_PREFIX/* ./crates/committer_cli/test_inputs | |
# Benchmark the new code, splitting the benchmarks, and prepare the results for posting a comment. | |
- run: bash ./crates/committer_cli/benches/bench_split_and_prepare_post.sh benchmarks_list.txt bench_new.txt | |
- run: echo BENCHES_RESULT=$(cat bench_new.txt) >> $GITHUB_ENV | |
# Post comment in case of performance regression or improvement. | |
- run: npm install fs | |
- if: contains(env.BENCHES_RESULT, 'regressed') || contains(env.BENCHES_RESULT, 'improved') | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs') | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: fs.readFileSync('bench_new.txt', 'utf8'), | |
}) | |
gcs-push: | |
runs-on: starkware-ubuntu-20-04-medium | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/install_rust | |
- uses: Swatinem/rust-cache@v2 | |
# Commit hash on pull request event would be the head commit of the branch. | |
- name: Get commit hash prefix for PR update | |
if: ${{ github.event_name == 'pull_request' }} | |
env: | |
COMMIT_SHA: ${{ github.event.pull_request.head.sha }} | |
run: echo "SHORT_HASH=${COMMIT_SHA:0:7}" >> $GITHUB_ENV | |
# On push event (to main, for example) we should take the commit post-push. | |
- name: Get commit hash prefix for merge | |
if: ${{ github.event_name != 'pull_request' }} | |
env: | |
COMMIT_SHA: ${{ github.event.after }} | |
run: echo "SHORT_HASH=${COMMIT_SHA:0:7}" >> $GITHUB_ENV | |
- name: Build CLI binary | |
run: ./build_native_in_docker.sh cargo build -p committer_cli -r --bin committer_cli --target-dir CLI_TARGET | |
- id: auth | |
uses: "google-github-actions/auth@v2" | |
with: | |
credentials_json: ${{ secrets.COMMITER_PRODUCTS_EXT_WRITER_JSON }} | |
- name: Upload binary to GCP | |
id: upload_file | |
uses: "google-github-actions/upload-cloud-storage@v2" | |
with: | |
path: "CLI_TARGET/release/committer_cli" | |
destination: "committer-products-external/${{ env.SHORT_HASH }}/release/" |