Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
switch to swc compare files
Browse files Browse the repository at this point in the history
  • Loading branch information
s3krit committed Apr 5, 2023
1 parent ff1d4f3 commit b7e963a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/check-weights.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,38 @@ jobs:
shell: bash
run: |
scripts/ci/github/verify_updated_weights.sh ${{ matrix.runtime }}
# This job uses https://github.com/ggwpez/substrate-weight-compare to compare the weights of the current
# release with the last release, then adds them as a comment to the PR.
check_weight_changes:
strategy:
fail-fast: false
matrix:
runtime: [westend, kusama, polkadot, rococo]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
- name: Get latest release
run: |
# LAST_RELEASE=$(curl -s https://api.github.com/repos/paritytech/polkadot/releases/latest | jq -r .tag_name)
# TODO: remove this line and uncomment the one above before merging
LAST_RELEASE=v0.9.39
echo "LAST_RELEASE=$LAST_RELEASE" >> $GITHUB_ENV
- name: Checkout current sources
uses: actions/checkout@v3
with:
path: polkadot-current
- name: Checkout latest release sources
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ env.LAST_RELEASE }}
path: polkadot-latest
- name: Check weight changes
shell: bash
run: |
cargo install --git https://github.com/ggwpez/substrate-weight-compare swc
echo "${{ matrix.runtime }} changes:" > ./swc_output_${{ matrix.runtime }}.txt
echo '```' >> ./swc_output_${{ matrix.runtime }}.txt
scripts/ci/github/check_weights_swc.sh | tee -a ./swc_output_${{ matrix.runtime }}.txt
echo '```' >> ./swc_output_${{ matrix.runtime }}.txt
polkadot-current/scripts/ci/github/compare_weights.sh ${{ matrix.runtime }} polkadot-old polkadot-new > swc_output_${{ matrix.runtime }}.md
- name: Add comment
uses: thollander/actions-comment-pull-request@v2
with:
filePath: ./swc_output_${{ matrix.runtime }}.txt
filePath: ./swc_output_${{ matrix.runtime }}.md
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 13 additions & 7 deletions scripts/ci/github/check_weights_swc.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#!/bin/bash
#!/usr/bin/env bash
# Need to set globstar for ** magic
shopt -s globstar

RUNTIME=$1
# Get last release from github
# Remove before merging, and uncomment the line below
RELEASE="v0.9.38"
# RELEASE=$(curl -s https://api.github.com/repos/paritytech/polkadot/releases/latest | jq -r .tag_name)

swc compare commits --method asymptotic --path-pattern "./runtime/$RUNTIME/src/weights/**/*.rs" "$RELEASE"
OLD=$2
NEW=$3
echo -e "$RUNTIME changes since $LAST_RELEASE:\n"
echo '```'
swc compare files \
--old $(pwd)/$OLD/runtime/$RUNTIME/src/weights/**/*.rs \
--new $(pwd)/$NEW/runtime/$RUNTIME/src/weights/**/*.rs \
--method asymptotic \
--ignore-errors
echo '```'

0 comments on commit b7e963a

Please sign in to comment.