Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update chain specs periodically through the CI #939

Merged
merged 49 commits into from
Apr 8, 2022
Merged
Changes from 21 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
688bccd
Update chain specs periodically through the CI
tomaka Apr 6, 2022
576e809
Upload as artifact instead
tomaka Apr 6, 2022
00c9ed8
More work
tomaka Apr 6, 2022
a9fff36
Run it when pushing
tomaka Apr 6, 2022
cd05aed
Don't put quotes around chain ID
tomaka Apr 6, 2022
bd27275
Fix paths
tomaka Apr 6, 2022
769ed74
Don't fail-fast
tomaka Apr 6, 2022
0296d0f
Fix jq call
tomaka Apr 6, 2022
b4c909e
Try create a PR
tomaka Apr 6, 2022
82bbd5a
More tweaks
tomaka Apr 6, 2022
51f11e7
Tweak
tomaka Apr 6, 2022
c62d73c
Forgot to checkout
tomaka Apr 6, 2022
42c6850
Don't upload everything lol
tomaka Apr 6, 2022
6a8fdee
Change branch name
tomaka Apr 6, 2022
6c728b6
Tweaks
tomaka Apr 6, 2022
bb6e248
Flag to cp
tomaka Apr 6, 2022
1432427
Comment
tomaka Apr 6, 2022
a4c7b96
Fix cp
tomaka Apr 6, 2022
ffc97f4
Do the extension separately
tomaka Apr 6, 2022
99a0373
Tweak PR body
tomaka Apr 6, 2022
91254ab
Small comment
tomaka Apr 6, 2022
b63faa5
Update checkpoints in chain specifications (#946)
github-actions[bot] Apr 7, 2022
17d29f0
Empty commit to retrigger the PR
tomaka Apr 7, 2022
858ac5c
Use main branch
tomaka Apr 7, 2022
28b1829
Checkout main branch
tomaka Apr 7, 2022
70b2404
Retrigger workflow
tomaka Apr 7, 2022
970b6d2
Retrigger workflow
tomaka Apr 7, 2022
0ce5777
Use different token
tomaka Apr 8, 2022
da8479b
Merge branch 'main' into tka-update-chain-specs-ci
tomaka Apr 8, 2022
9a45661
Retrigger action
tomaka Apr 8, 2022
0b9dac5
Try this
tomaka Apr 8, 2022
c2cec75
Retrigger action
tomaka Apr 8, 2022
f3c34c8
Try generate token on the fly
tomaka Apr 8, 2022
84da0bb
Try passing nothing
tomaka Apr 8, 2022
6d63b5c
Retrigger action
tomaka Apr 8, 2022
186805d
Restore the secrets
tomaka Apr 8, 2022
3343dcd
Pin version
tomaka Apr 8, 2022
24ed8b5
Revert "Pin version"
tomaka Apr 8, 2022
f3a147b
Retrigger action
tomaka Apr 8, 2022
7b5ee6f
Retrigger action
tomaka Apr 8, 2022
6de0b75
Retrigger action
tomaka Apr 8, 2022
7072bc8
Retrigger action
tomaka Apr 8, 2022
e91d2ff
Retrigger action
tomaka Apr 8, 2022
a660d5a
Retrigger action
tomaka Apr 8, 2022
773e444
Retrigger action
tomaka Apr 8, 2022
b8f6bd5
Retrigger action
tomaka Apr 8, 2022
ccff4d0
Use GH_TOKEN 🤷
tomaka Apr 8, 2022
e9587ba
Adjust PR body
tomaka Apr 8, 2022
62a2c6e
Remove testing code
tomaka Apr 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/update-chain-specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: chain-specs-periodic-update

on:
push:
branches: [ tka-update-chain-specs-ci ] # TODO: remove before merging, I'm just testing
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When approved, I'll remove this line before merging. It's there just so that I can test if it work.

schedule:
- cron: '0 8 * * *' # every day at 8am


jobs:
download-spec:
runs-on: ubuntu-latest

strategy:
matrix:
# This starts one parallel job for each of these addresses.
rpc-node-address: [
"wss://rpc.polkadot.io",
"wss://kusama-rpc.polkadot.io",
"wss://westend-rpc.polkadot.io",
"wss://rococo-rpc.polkadot.io"
]
fail-fast: false # Don't automatically cancel the jobs of the other RPC nodes if one fails

steps:
- uses: actions/checkout@v3
with:
path: repo
- run: |
curl -L -O https://github.com/vi/websocat/releases/download/v1.9.0/websocat_linux64
chmod +x websocat_linux64
- run: |
echo '{"id":1,"jsonrpc":"2.0","method":"sync_state_genSyncSpec","params":[true]}' |
./websocat_linux64 -n1 -B 99999999 ${{ matrix.rpc-node-address }} |
jq .result > chain_spec.json
- id: get-chain-id # Reads the `id` field in the newly-downloaded chain spec
run: echo "::set-output name=id::`jq -r .id ./chain_spec.json`"
- run: | # Overwrite the `lightSyncState` field of the existing chain spec with the value of spec that's been downloaded.
tmp=$(mktemp)
output=./repo/packages/connect/src/connector/specs/${{ steps.get-chain-id.outputs.id }}.json
jq --slurpfile downloaded ./chain_spec.json '.lightSyncState = $downloaded[0].lightSyncState' "$output" > "$tmp"
mv "$tmp" "$output"
- run: | # Do the same as the previous step, but for the chain spec of the extension. This is done separately in case the spec is not the same with the one in `connect`
tmp=$(mktemp)
output=./repo/projects/extension/public/assets/${{ steps.get-chain-id.outputs.id }}.json
jq --slurpfile downloaded ./chain_spec.json '.lightSyncState = $downloaded[0].lightSyncState' "$output" > "$tmp"
mv "$tmp" "$output"
- uses: actions/upload-artifact@v3
with:
name: chain-spec-${{ steps.get-chain-id.outputs.id }}
# Note that passing `repo/**` maintains paths under `repo`. This is a bit of magic by the upload-artifact action.
path: |
repo/**/${{ steps.get-chain-id.outputs.id }}.json

create-pr:
runs-on: ubuntu-latest
if: ${{ always() }} # Run this job even if one of the steps of download-spec has failed
needs: download-spec

steps:
- uses: actions/checkout@v3
with:
path: repo
- uses: actions/download-artifact@v3
with:
# Since we're not passing a name, this automatically downloads *all* artifacts
# Unfortunately, this creates intermediary directories.
path: .
- run: cp -r ./chain-spec-*/* ./repo
- uses: peter-evans/create-pull-request@v4
with:
path: repo
branch: automatic-checkpoints-update
title: Update checkpoints in chain specifications
# Note that the `download-spec` job above fails if the downloaded specification doesn't
# correspond to an existing file. It is therefore impossible that the pull request
# accidentally adds new specifications.
body: >
This pull request has been automatically generated by downloading chain
specifications from various JSON-RPC endpoints and extracting their checkpoints.
commit-message: Update checkpoints in chain specifications
delete-branch: true