Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 96 additions & 96 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,100 +74,100 @@ jobs:
# 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


# TODO: Uncomment once the github token works correctly with `JasonEtco/create-an-issue@v2`
# bench-regression:
# enabled:
# 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
Loading