chore: Update CI configuration #1445
Workflow file for this run
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: Tests | |
on: | |
merge_group: | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: argumentcomputer/ci-workflows | |
- uses: ./.github/actions/ci-env | |
- uses: ./.github/actions/install-deps | |
with: | |
packages: opam | |
- uses: actions/checkout@v4 | |
with: | |
path: build | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: taiki-e/install-action@nextest | |
- uses: taiki-e/install-action@wasm-pack | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 23 | |
- uses: actions/checkout@v4 | |
with: | |
repository: lurk-lab/lurkscript | |
path: lurkscript | |
ref: 'remove-set-panic-hook' | |
token: ${{ secrets.REPO_TOKEN }} | |
- name: Install Lurkscript | |
run: | | |
mkdir ci-bin | |
cd ci-bin | |
CI_BINDIR="$(pwd)" | |
echo "$CI_BINDIR" >> $GITHUB_PATH | |
export PATH="$PATH:$CI_BINDIR" | |
cd ../lurkscript | |
npm install -g pnpm | |
pnpm config set global-bin-dir "$CI_BINDIR" | |
pnpm install | |
pnpm -r build | |
pnpm install-cli | |
- uses: Swatinem/rust-cache@v2 | |
- name: Linux Tests | |
run: | | |
cd build | |
cargo nextest run --profile ci --cargo-profile dev-ci --workspace --run-ignored all --features loam | |
clippy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: argumentcomputer/ci-workflows | |
- uses: ./.github/actions/ci-env | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- name: Check Rustfmt Code Style | |
run: cargo fmt --all --check | |
- name: check *everything* compiles | |
run: cargo check --all-targets --all-features --workspace --examples --tests --benches | |
# See '.cargo/config' for list of enabled/disabled clippy lints | |
- name: Check clippy warnings | |
run: cargo xclippy -D warnings | |
- name: Doctests | |
run: cargo test --doc --workspace | |
# TODO: Uncomment once https://github.com/EmbarkStudios/cargo-deny-action/issues/67 is released | |
# - name: Cargo-deny | |
# uses: EmbarkStudios/cargo-deny-action@v1 | |
bench-regression: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: argumentcomputer/ci-workflows | |
- uses: ./.github/actions/ci-env | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- uses: taiki-e/install-action@nextest | |
- name: Set env | |
run: | | |
echo "TESTS=fib_e2e" | tee -a $GITHUB_ENV | |
echo "LOAM_FIB_ARG=50000" | tee -a $GITHUB_ENV | |
- name: Get benchmark for PR | |
id: bench_pr | |
run: | | |
BENCH_RESULTS='[]' | |
for test_name in ${{ env.TESTS }}; do | |
cargo nextest run -E "test($test_name)" --release --nocapture --run-ignored all | tee out.txt 2>&1 | |
BENCH=$(grep 'Total time' out.txt | awk -F'= ' '{ print $2 }') | |
BENCH_RESULTS=$(echo $BENCH_RESULTS | jq -c ". += [{\"${test_name}\": \"$BENCH\"}]") | |
done | |
echo "BENCH_RESULTS=$BENCH_RESULTS" | tee -a "$GITHUB_OUTPUT" | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.base_ref }} | |
- name: Get bench for base branch | |
id: regression-check | |
continue-on-error: false | |
run: | | |
counter=0 | |
BENCH_RESULTS='${{ steps.bench_pr.outputs.BENCH_RESULTS }}' | |
echo "$BENCH_RESULTS" | |
SLOW_TESTS="" | |
REGRESSION="false" | |
for test_name in ${{ env.TESTS }}; do | |
cargo nextest run -E "test($test_name)" --release --nocapture --run-ignored all | tee out.txt 2>&1 | |
BENCH_BASE=$(grep 'Total time' out.txt | awk -F'= ' '{ print $2 }') | |
BENCH_PR=$(echo "$BENCH_RESULTS" | jq ".[$counter] | to_entries | .[0].value" | sed 's/"//g') | |
echo "$test_name summary" | |
echo "Base = $BENCH_BASE, PR = $BENCH_PR" | |
if [[ -z $BENCH_BASE || -z $BENCH_PR ]]; then | |
exit 1 | |
fi | |
BENCH_BASE_NUM=${BENCH_BASE%% *} | |
BENCH_PR_NUM=${BENCH_PR%% *} | |
# 10% slowdown threshold | |
REGRESSION_THRESHOLD=$(echo "$BENCH_BASE_NUM * 1.10" | bc) | |
if (( $(echo "$BENCH_PR_NUM >= $REGRESSION_THRESHOLD" | bc -l) )); then | |
echo "Performance regression for test ${test_name}" | |
REGRESSION="true" | |
SLOW_TESTS+="\`${test_name}\`\n" | |
SLOW_TESTS+="Bench result before: $BENCH_BASE\n" | |
SLOW_TESTS+="Bench result after: $BENCH_PR\n" | |
fi | |
counter=$((counter + 1)) | |
done | |
echo "regression=$REGRESSION" | tee -a $GITHUB_OUTPUT | |
echo "slow-tests<<EOF" >> $GITHUB_OUTPUT | |
echo -e "$SLOW_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 | |
- 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 regression check failed :x: | |
${{ steps.regression-check.outputs.slow-tests }} | |
[Workflow URL](${{ env.WORKFLOW_URL }}) | |
- uses: JasonEtco/create-an-issue@v2 | |
if: steps.regression-check.outputs.regression == 'true' && github.event_name == 'merge_group' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
WORKFLOW_URL: ${{ env.WORKFLOW_URL }} | |
SLOW_TESTS: ${{ steps.regression-check.outputs.slow-tests }} | |
with: | |
update_existing: true | |
filename: .github/BENCH_REGRESSION.md | |