Skip to content

feat: env and bind built-ins #1368

feat: env and bind built-ins

feat: env and bind built-ins #1368

Workflow file for this run

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: warp-ubuntu-latest-x64-16x
steps:
- name: Set up git private repo access
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
echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" | tee -a $GITHUB_ENV
- 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
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
- name: Linux Tests
run: |
cargo nextest run --profile ci --cargo-profile dev-ci --workspace --run-ignored all --features loam
clippy:
runs-on: ubuntu-latest
steps:
- name: Set up git private repo access
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
echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" | tee -a $GITHUB_ENV
- 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: warp-ubuntu-latest-x64-32x
steps:
- name: Set up git private repo access
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
echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" | tee -a $GITHUB_ENV
- 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