Skip to content

feat: Documentation and CI configuration for Solidity #79

feat: Documentation and CI configuration for Solidity

feat: Documentation and CI configuration for Solidity #79

Workflow file for this run

name: Rust
on:
merge_group:
push:
branches:
- "main"
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
env:
CARGO_TERM_COLOR: always
# Disable incremental compilation.
#
# Incremental compilation is useful as part of an edit-build-test-edit cycle,
# as it lets the compiler avoid recompiling code that hasn't changed. However,
# on CI, we're not making small edits; we're almost always building the entire
# project from scratch. Thus, incremental compilation on CI actually
# introduces *additional* overhead to support making future builds
# faster...but no future builds will ever occur in any given CI environment.
#
# See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
# for details.
CARGO_INCREMENTAL: 0
# Allow more retries for network requests in cargo (downloading crates) and
# rustup (installing toolchains). This should help to reduce flaky CI failures
# from transient network timeouts or other issues.
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
# Don't emit giant backtraces in the CI logs.
RUST_BACKTRACE: short
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- buildjet-16vcpu-ubuntu-2204
package:
- "aptos"
fail-fast: false
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
steps:
- uses: actions/checkout@v4
with:
repository: lurk-lab/ci-workflows
- uses: ./.github/actions/ci-env
- uses: actions/checkout@v4
- name: Setup CI
uses: ./.github/actions/setup
with:
pull_token: ${{ secrets.REPO_TOKEN }}
# make sure benches don't bit-rot
- name: build benches
run: |
cargo check --benches --features aptos
working-directory: ${{ github.workspace }}/${{ matrix.package }}/light-client
- name: Run cargo test in workspace
run: |
cargo nextest run --workspace --release --profile ci --all-features
working-directory: ${{ github.workspace }}/${{ matrix.package }}
- name: Doctests
run: |
cargo test --doc
env:
RUSTFLAGS: "--cfg tokio_unstable"
working-directory: ${{ github.workspace }}/${{ matrix.package }}
clippy:
runs-on: buildjet-16vcpu-ubuntu-2204
strategy:
matrix:
package:
- "aptos"
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
steps:
- uses: actions/checkout@v4
with:
repository: lurk-lab/ci-workflows
- uses: ./.github/actions/ci-env
- uses: actions/checkout@v4
- name: Setup CI
uses: ./.github/actions/setup
with:
pull_token: ${{ secrets.REPO_TOKEN }}
# See '.cargo/config' for list of enabled/disabled clippy lints
- name: rustfmt
run: cargo fmt --all --check
working-directory: ${{ github.workspace }}/${{ matrix.package }}
- name: cargo clippy
run: cargo xclippy -D warnings
working-directory: ${{ github.workspace }}/${{ matrix.package }}
solidity-unit-tests:
runs-on: buildjet-16vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v4
with:
repository: lurk-lab/ci-workflows
- uses: ./.github/actions/ci-env
# Setup Git auth to prevent double checkout, ven if this is done to times
- name: Set up git private repo access
shell: bash
run: |
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com/".insteadOf ssh://[email protected]
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com".insteadOf https://github.com
- uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.REPO_TOKEN }}
- name: Setup CI
uses: ./.github/actions/setup
with:
pull_token: ${{ secrets.REPO_TOKEN }}
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Check formatting
run: |
forge fmt --check
working-directory: ${{ github.workspace }}/aptos/solidity/contracts/
- name: Run Forge build
run: |
forge --version
forge build
working-directory: ${{ github.workspace }}/aptos/solidity/contracts/
- name: Run Forge tests
run: |
forge test
working-directory: ${{ github.workspace }}/aptos/solidity/contracts/
cycle-count-regression:
runs-on: warp-ubuntu-latest-x64-32x
steps:
- uses: actions/checkout@v4
with:
repository: lurk-lab/ci-workflows
- uses: ./.github/actions/ci-env
- uses: actions/checkout@v4
- name: Setup CI
uses: ./.github/actions/setup
with:
pull_token: ${{ secrets.REPO_TOKEN }}
- name: Get cycle counts for PR
id: get_cycles_pr
run: |
CYCLE_COUNTS='[]'
set -o pipefail
# TODO: Remove hardcoded test names
for test_name in "test_execute_inclusion" "test_execute_epoch_change" "test_execute_sig"; do
cargo nextest run --verbose --release --profile ci --features aptos --package aptos-lc --no-capture -E "test($test_name)" 2>&1 | tee out.txt
num_cycles=$(cat out.txt | grep -o 'finished execution clk = [0-9]\+' | awk -F'= ' '{ print $2 }')
CYCLE_COUNTS=$(echo $CYCLE_COUNTS | jq -c ". += [{\"${test_name}\": \"$num_cycles\"}]")
done
set +o pipefail
echo "CYCLE_COUNTS=$CYCLE_COUNTS" | tee -a "$GITHUB_OUTPUT"
working-directory: ${{ github.workspace }}/aptos/light-client
env:
RUST_LOG: debug
- uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
- name: Get cycle counts for base branch
id: regression-check
run: |
counter=0
CYCLE_COUNTS='${{ steps.get_cycles_pr.outputs.CYCLE_COUNTS }}'
echo "$CYCLE_COUNTS"
FAILING_TESTS=""
REGRESSION="false"
set -o pipefail
# TODO: Remove hardcoded test names
for test_name in "test_execute_inclusion" "test_execute_epoch_change" "test_execute_sig"; do
cargo nextest run --verbose --release --profile ci --features aptos --package aptos-lc --no-capture -E "test($test_name)" 2>&1 | tee out.txt
num_cycles_base=$(cat out.txt | grep -o 'finished execution clk = [0-9]\+' | awk -F'= ' '{ print $2 }')
num_cycles_pr=$(echo "$CYCLE_COUNTS" | jq ".[$counter] | to_entries | .[0].value")
echo "$test_name summary"
echo "Base = $num_cycles_base cycles, PR = ${num_cycles_pr:1:-1} cycles"
if [[ "$num_cycles_pr" > "$num_cycles_base" ]]; then
echo "Performance regression for test ${test_name}"
REGRESSION="true"
FAILING_TESTS+="\`${test_name}\`\n"
FAILING_TESTS+="Cycles before: ${num_cycles_base//\"/}\n"
FAILING_TESTS+="Cycles after: ${num_cycles_pr//\"/}\n"
fi
counter=$((counter + 1))
done
set +o pipefail
echo "regression=$REGRESSION" | tee -a $GITHUB_OUTPUT
echo "failing-tests<<EOF" >> $GITHUB_OUTPUT
echo -e "$FAILING_TESTS" | tee -a $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "WORKFLOW_URL=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | tee -a $GITHUB_ENV
working-directory: ${{ github.workspace }}/aptos/light-client
env:
RUST_LOG: debug
- uses: actions/checkout@v4
- name: Comment on failing run
if: steps.regression-check.outputs.regression == 'true' && github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Benchmark cycle count regression check failed :x:
${{ steps.regression-check.outputs.failing-tests }}
${{ env.WORKFLOW_URL }}
- uses: JasonEtco/create-an-issue@v2
if: steps.regression-check.outputs.regression == 'true' && github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_URL: ${{ env.WORKFLOW_URL }}
FAILING_TESTS: ${{ steps.regression-check.outputs.failing-tests }}
with:
update_existing: true
filename: .github/BENCH_CYCLE_REGRESSION.md