Skip to content

Commit

Permalink
ci: caching (#657)
Browse files Browse the repository at this point in the history
## fixes KILTprotocol/ticket#3345
Breaks up the on `gitlab-ci.yml` & adds one more stage release.
- [x] Migrate few jobs from gitlab to Github
- [x]  Enable caching
## Metadata Diff to Develop Branch

<details>
<summary>Peregrine Diff</summary>

```
```

</details>

<details>
<summary>Spiritnet Diff</summary>

```
```

</details>

## Checklist:

- [ ] I have verified that the code works
- [ ] No panics! (checked arithmetic ops, no indexing `array[3]` use
`get(3)`, ...)
- [ ] I have verified that the code is easy to understand
  - [ ] If not, I have left a well-balanced amount of inline comments
- [ ] I have [left the code in a better
state](https://deviq.com/principles/boy-scout-rule)
- [ ] I have documented the changes (where applicable)
* Either PR or Ticket to update [the
Docs](https://github.com/KILTprotocol/docs)
    * Link the PR/Ticket here

---------

Co-authored-by: Chris Chinchilla <[email protected]>
  • Loading branch information
ggera and ChrisChinchilla authored Aug 13, 2024
1 parent 880c74e commit a4561c5
Show file tree
Hide file tree
Showing 12 changed files with 429 additions and 317 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/check-fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Check fmt

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

jobs:
get-head-commit-msg:
runs-on: ubuntu-latest
outputs:
head-commit-msg: ${{ steps.step-head-commit.outputs.headCommitMsg }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Get Head Commit Message
id: step-head-commit
run: echo "headCommitMsg=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"

check-fmt:
runs-on: ubuntu-latest
needs: get-head-commit-msg
if: ${{ !contains(needs.get-head-commit-msg.outputs.head-commit-msg, 'ci-skip-rust') }}
container:
image: paritytech/ci-unified:bullseye-1.74.0
steps:
- uses: actions/checkout@v4

- name: Run cargo fmt
run: cargo fmt -- --check

- name: Run taplo
run: taplo fmt --check
39 changes: 39 additions & 0 deletions .github/workflows/docs-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and Deploy Chain docs

on:
push:
branches:
- develop
- 'refs/tags/[0-9]+.[0-9]+.[0-9]+*'

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true

- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and Deploy in Container
run: |
docker run --rm \
-v "${GITHUB_WORKSPACE}:/workspace" \
-v "${HOME}/.cargo:/root/.cargo" \
-w /workspace \
paritytech/ci-unified:bullseye-1.74.0 \
bash -c "
RUSTDOCFLAGS='-D warnings' cargo doc --all-features --no-deps --locked && \
chown -R $(id -u):$(id -g) target/doc"
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages-${{ github.ref_name }}
folder: target/doc
55 changes: 55 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Integration tests

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

jobs:
get-head-commit-msg:
runs-on: ubuntu-latest
outputs:
head-commit-msg: ${{ steps.step-head-commit.outputs.headCommitMsg }}

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Get Head Commit Message
id: step-head-commit
run: echo "headCommitMsg=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"

integration-tests:
runs-on: ubuntu-latest
needs: get-head-commit-msg
if: ${{ !contains(needs.get-head-commit-msg.outputs.head-commit-msg, 'ci-skip-integration-tests') }}
env:
working-dir: ./integration-tests/chopsticks
CI: "true"
defaults:
run:
working-directory: ${{ env.working-dir }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version-file: "${{ env.working-dir }}/.nvmrc"

- name: Install dependencies
run: yarn --immutable

- name: Type Checking
run: yarn ts-check

- name: Linting
run: yarn lint

- name: Test Suite
run: yarn test:CI

81 changes: 81 additions & 0 deletions .github/workflows/srtool-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Srtool build

on:
push:
branches:
- develop
- master
- 'refs/tags/[0-9]+.[0-9]+.[0-9]+*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

env:
SUBWASM_VERSION: v0.21.3

jobs:
build-wasm:
runs-on: ubuntu-latest

strategy:
matrix:
runtime: [peregrine, spiritnet]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Srtool build
id: srtool_build
uses: chevdor/[email protected]
env:
PARACHAIN_PALLET_ID: "0x50"
AUTHORIZE_UPGRADE_PREFIX: "0x02"
AUTHORIZE_UPGRADE_CHECK_VERSION: "true"
with:
chain: ${{ matrix.runtime }}
runtime_dir: runtimes/${{ matrix.runtime }}

- name: Summary
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq | tee ${{ matrix.runtime }}-srtool-digest.json
echo "Compressed Runtime: ${{ steps.srtool_build.outputs.wasm_compressed }}"
- name: Install subwasm
run: |
wget https://github.com/chevdor/subwasm/releases/download/${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_${{ env.SUBWASM_VERSION }}.deb
sudo dpkg -i subwasm_linux_amd64_${{ env.SUBWASM_VERSION }}.deb
subwasm --version
- name: Show Runtime information
shell: bash
run: |
subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }}
subwasm info --json ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.runtime }}-compressed-info.json
- name: Extract the metadata
shell: bash
run: |
subwasm meta ${{ steps.srtool_build.outputs.wasm_compressed }}
subwasm meta --format=json+scale ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.runtime }}-metadata.json
- name: Check the metadata diff
shell: bash
run: |
subwasm get -o ${{ matrix.runtime }}-live.wasm wss://${{ matrix.runtime }}.kilt.io
subwasm diff --no-color ${{ matrix.runtime }}-live.wasm ${{ steps.srtool_build.outputs.wasm_compressed }} || \
echo "Subwasm call failed, check the logs. This is likely because ${{ matrix.runtime }} is not known by subwasm" | \
tee ${{ matrix.runtime }}-diff.txt
- name: Archive Subwasm results
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.runtime }}-runtime
path: |
${{ matrix.runtime }}-compressed-info.json
${{ matrix.runtime }}-metadata.json
${{ matrix.runtime }}-diff.txt
${{ steps.srtool_build.outputs.wasm_compressed }}
${{ matrix.runtime }}-srtool-digest.json
65 changes: 65 additions & 0 deletions .github/workflows/try-runtime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Try-runtime

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

env:
TRY_RUNTIME_CLI_VERSION_TAG: v0.7.0
CARGO_HOME: ./.cargo

jobs:
get-head-commit-msg:
runs-on: ubuntu-latest
outputs:
head-commit-msg: ${{ steps.step-head-commit.outputs.headCommitMsg }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Get Head Commit Message
id: step-head-commit
run: echo "headCommitMsg=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"


test-try-runtime:
strategy:
matrix:
runtime: [peregrine, spiritnet]
runs-on: ubuntu-latest
needs: get-head-commit-msg
if: ${{ !contains(needs.get-head-commit-msg.outputs.head-commit-msg, 'ci-skip-rust') }}
container:
image: paritytech/ci-unified:bullseye-1.74.0
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up caching for Cargo
uses: actions/cache@v4
with:
path: ${{ secrets.CARGO_CACHE_PATH }}
key: cargo-try-runtime-${{ matrix.runtime }}-${{ github.ref_name }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-try-runtime-${{ matrix.runtime }}-${{ github.ref_name }}-
- name: Run try-runtime
run: |
echo "Running ${{ matrix.runtime }} runtime migration check"
echo "---------- Downloading try-runtime CLI ----------"
curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/${{ env.TRY_RUNTIME_CLI_VERSION_TAG }}/try-runtime-x86_64-unknown-linux-musl -o try-runtime
chmod +x ./try-runtime
echo "Using try-runtime-cli version:"
./try-runtime --version
echo "---------- Building ${{ matrix.runtime }} runtime ----------"
cargo build --release --locked -p ${{ matrix.runtime }}-runtime --features try-runtime
echo "---------- Executing on-runtime-upgrade for ${{ matrix.runtime }} ----------"
./try-runtime --runtime ./target/release/wbuild/${{ matrix.runtime }}-runtime/${{ matrix.runtime }}_runtime.compact.compressed.wasm \
on-runtime-upgrade --disable-spec-version-check --checks=all live --uri wss://${{ matrix.runtime }}.kilt.io
Loading

0 comments on commit a4561c5

Please sign in to comment.