More balanced task distribution among shards #473
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################################## | |
# | |
# Workflow for generating the metadata. It's triggered | |
# on each pull request commit, ignoring paths that don't | |
# affect the metadata (mostly the Substrate specifics). | |
# | |
# It generates the metadata by running the node and | |
# invoking subxt metadata command. If the generated file | |
# is different than the already present one | |
# (config/subxt/metadata.scale), the Github bot commits | |
# and pushes to the current PR branch. | |
# | |
########################################################## | |
name: Generate metadata | |
on: | |
pull_request: | |
paths-ignore: | |
- 'docker/**' | |
- 'docs/**' | |
- 'infra/**' | |
- 'js/**' | |
- '**/*.md' | |
- 'tester/**' | |
- 'scripts/**' | |
- 'tc-subxt/**' | |
- 'chronicle/**' | |
- 'tss/**' | |
- 'lib/**' | |
jobs: | |
generate: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install deps | |
run: sudo apt-get update && sudo apt-get install -y musl-tools protobuf-compiler | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
submodules: recursive | |
- name: Install rust toolchain | |
run : rustup show | |
- name: Install subxt | |
uses: actions-rs/cargo@v1 | |
with: | |
command: install | |
args: --version 0.33.0 subxt-cli | |
- name: Rust cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Build timechain-node | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release -p timechain-node | |
# Runs the node (saves the PID), generates the metadata | |
# and kills the process afterwards. | |
- name: Generate metadata | |
run: | | |
./target/release/timechain-node --dev & | |
NODE_PID=$! | |
sleep 15 | |
subxt metadata --url ws://127.0.0.1:9944 -f bytes > config/subxt/metadata.scale-new | |
kill -9 $NODE_PID | |
# Calculates the diff and outputs the updated flag. | |
- name: Get diff | |
id: diff | |
run: | | |
set +e | |
diff config/subxt/metadata.scale-new config/subxt/metadata.scale | |
CODE=$? | |
set -e | |
if [ $CODE -eq 0 ]; then | |
echo NO DIFF | |
echo "updated=false" >> $GITHUB_OUTPUT | |
else | |
mv config/subxt/metadata.scale-new config/subxt/metadata.scale | |
echo "updated=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Checkout PR | |
if: steps.diff.outputs.updated == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh pr checkout ${{ github.event.pull_request.number }} | |
# Github bot commits the change and pushes to the PR branch | |
# NOTE: only if the updated flag from step "Get diff" is true | |
- name: Commit & Push changes | |
if: steps.diff.outputs.updated == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "Github Bot" | |
git commit -am "Update metadata" | |
git push |