-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (93 loc) · 2.92 KB
/
metadata.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
##########################################################
#
# 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