Skip to content

Commit

Permalink
add subweight
Browse files Browse the repository at this point in the history
  • Loading branch information
mordamax committed Jan 17, 2025
1 parent 2d4ea30 commit 496344c
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions .github/workflows/bench-all-runtimes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Bench all runtimes (frame-omni-bencher)
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,8 +29,7 @@ jobs:
- uses: actions/checkout@v4
- id: runtime
run: |
# only first two runtimes
RUNTIMES=$(jq '[.[] | select(.package != null)]' .github/workflows/runtimes-matrix.json)
RUNTIMES=$(jq '[.[] | select(.package != null)]' .github/workflows/runtimes-matrix.json | head -n 2)
RUNTIMES=$(echo $RUNTIMES | jq -c .)
echo "runtime=$RUNTIMES"
Expand Down Expand Up @@ -106,28 +106,44 @@ jobs:
app-id: ${{ secrets.CMD_BOT_APP_ID }}
private-key: ${{ secrets.CMD_BOT_APP_KEY }}

- name: Apply diff from artifacts folder
- name: Install subweight
run: cargo install subweight

- name: Apply diff and create PR
env:
GH_TOKEN: ${{ steps.generate_token.outputs.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 checkout -b "$BRANCH"
for file in patches/diff-*/diff-*.patch; do
if [ -f "$file" ]; then
echo "Applying $file"
git apply "$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"
SUBWEIGHT_OUTPUT=$(subweight compare commits \
--path-pattern "./**/weights/**/*.rs,./**/weights.rs" \
--method asymptotic \
--format markdown \
--no-color \
--change added changed \
--ignore-errors \
refs/remotes/origin/master "refs/heads/$BRANCH")
DEGRADATION_WARNING=""
PR_TITLE="Update weights weekly for $DATE"
gh pr create \
--title "$PR_TITLE" \
--body "Update weights weekly for $DATE\n\n${DEGRADATION_WARNING}\n\n<details><summary>Weight Changes Analysis</summary>\n\n\`\`\`\n${SUBWEIGHT_OUTPUT}\n\`\`\`\n\n</details>"

0 comments on commit 496344c

Please sign in to comment.