Skip to content

Commit

Permalink
go
Browse files Browse the repository at this point in the history
add subweight
remove cmd bot app
threshold 2
  • Loading branch information
mordamax committed Jan 19, 2025
1 parent 2d4ea30 commit 459d0df
Showing 1 changed file with 63 additions and 25 deletions.
88 changes: 63 additions & 25 deletions .github/workflows/bench-all-runtimes.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Bench all runtimes (frame-omni-bencher)
name: Bench all runtimes

on:
# schedule:
# - cron: '0 1 * * 0' # weekly on Sunday night 01:00 UTC
workflow_dispatch:
# workflow_dispatch:
pull_request:

permissions: # allow the action to create a PR
contents: write
Expand All @@ -28,7 +29,6 @@ jobs:
- uses: actions/checkout@v4
- id: runtime
run: |
# only first two runtimes
RUNTIMES=$(jq '[.[] | select(.package != null)]' .github/workflows/runtimes-matrix.json)
RUNTIMES=$(echo $RUNTIMES | jq -c .)
Expand All @@ -38,7 +38,10 @@ jobs:
run-frame-omni-bencher:
runs-on: ${{ needs.preflight.outputs.RUNNER_WEIGHTS }}
needs: [preflight, runtime-matrix]
timeout-minutes: 1440 # 24 hours per runtime
# 24 hours per runtime.
# Max it takes 14hr for westend to recalculate, but due to limited runners,
# sometimes it can take longer.
timeout-minutes: 1440
strategy:
fail-fast: false # keep running other workflows even if one fails, to see the logs of all possible failures
matrix:
Expand Down Expand Up @@ -77,7 +80,11 @@ jobs:
echo "$CMD_OUTPUT" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
fi
git diff HEAD > diff-${{ matrix.runtime.name }}.patch
# Create patch that includes both modifications and new files
git add -A
git diff --staged > diff-${{ matrix.runtime.name }}.patch
git reset
- name: Upload diff
uses: actions/upload-artifact@v4
Expand All @@ -100,34 +107,65 @@ jobs:
with:
path: patches

- uses: actions/create-github-app-token@v1
id: generate_token
with:
app-id: ${{ secrets.CMD_BOT_APP_ID }}
private-key: ${{ secrets.CMD_BOT_APP_KEY }}
- name: Install subweight
run: cargo install subweight

- name: Apply diff from artifacts folder
- name: Apply diff and create PR
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# scan all patch files in the patches directory
DATE=$(date +'%Y-%m-%d-%s')
BRANCH="update-weights-weekly-$DATE"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git switch -c "$BRANCH"
for file in patches/diff-*/diff-*.patch; do
if [ -f "$file" ]; then
if [ -f "$file" ] && [ -s "$file" ]; then
echo "Applying $file"
git apply "$file"
git apply "$file" || echo "Failed to apply $file"
else
echo "Skipping empty or non-existent patch file: $file"
fi
done
DATE=$(date +'%Y-%m-%d-%s')
BRANCH="update-weights-weekly-$DATE"
rm -rf patches
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -b "$BRANCH"
git status
git add .
git commit -m "Update all weights weekly for $DATE"
git push --set-upstream origin "$BRANCH"
git status
gh pr create --title "Update weights weekly for $DATE" --body "Update weights weekly for $DATE"
git fetch
SUBWEIGHT_OUTPUT_RAW=$(subweight compare commits \
--path-pattern "./**/weights/**/*.rs,./**/weights.rs" \
--method asymptotic \
--format markdown \
--no-color \
--change added changed \
--ignore-errors \
--threshold 2 \
origin/master refs/heads/$BRANCH)
# Properly escape the markdown content and format the PR body
SUBWEIGHT_OUTPUT=$(cat << EOF
Auto-update weights for $DATE
<details>
<summary>Subweight Output</summary>
$SUBWEIGHT_OUTPUT_RAW
</details>
EOF
)
PR_TITLE="Auto-update weights for $DATE"
gh pr create \
--title "$PR_TITLE" \
--head "$BRANCH" \
--base "master" \
--label "R0-silent" \
--draft \
--body "$SUBWEIGHT_OUTPUT"

0 comments on commit 459d0df

Please sign in to comment.