ci: Migrate Gitlab tests to GitHub runner #4
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
name: Check codebase | |
on: | |
pull_request: | |
push: | |
branches: | |
- develop | |
- master | |
- 'refs/tags/[0-9]+.[0-9]+.[0-9]+*' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
get-commit-head: | |
name: Get HEAD commit message | |
runs-on: ubuntu-latest | |
outputs: | |
headCommitMsg: ${{ steps.get-head-commit-message.outputs.headCommitMsg }} | |
steps: | |
- name: Get HEAD commit message | |
id: get-head-commit-message | |
run: echo "headCommitMsg=$(git show -s --format=%s)" >> $GITHUB_OUTPUT | |
cargo-clippy: | |
name: Run Clippy checks | |
runs-on: ubuntu-latest | |
needs: get-commit-head | |
if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} | |
strategy: | |
matrix: | |
features: | |
- | |
- --all-features | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Cargo cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }} | |
- name: Run `cargo clippy` | |
run: | | |
docker run --rm \ | |
-v "${GITHUB_WORKSPACE}:/workspace" \ | |
-v "${HOME}/.cargo:/root/.cargo" \ | |
-w /workspace \ | |
-e SKIP_WASM_BUILD=1 \ | |
paritytech/ci-unified:bullseye-1.74.0 \ | |
bash -c "cargo clippy --all-targets --locked ${{ matrix.features }} -- -D warnings" | |
cargo-fmt: | |
name: Check formatting | |
runs-on: ubuntu-latest | |
container: | |
image: paritytech/ci-unified:bullseye-1.74.0 | |
needs: get-commit-head | |
if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Rust toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
# Latest 1.74 nightly release | |
toolchain: nightly-2023-10-01 | |
components: rustfmt | |
- name: Run `cargo fmt` | |
run: cargo fmt -- --check | |
- name: Run `taplo` | |
run: taplo fmt --check | |
integration-tests: | |
name: Run Chopsticks tests | |
runs-on: ubuntu-latest | |
env: | |
working-dir: ./integration-tests/chopsticks | |
CI: true | |
PEREGRINE_WASM_OVERRIDE: ../../target/debug/wbuild/peregrine-runtime/peregrine_runtime.wasm | |
defaults: | |
run: | |
working-directory: ${{ env.working-dir }} | |
needs: get-commit-head | |
if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-integration-tests') }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: "${{ env.working-dir }}/.nvmrc" | |
- name: Install dependencies | |
run: yarn --immutable | |
- name: Check TS | |
run: yarn ts-check | |
- name: Check lints | |
run: yarn lint | |
- name: Build Peregrine runtime | |
run: cargo build -p peregrine-runtime | |
- name: Run Chopsticks tests | |
run: yarn test:CI | |
cargo-test: | |
name: Run Cargo tests | |
runs-on: ubuntu-latest | |
needs: cargo-clippy | |
strategy: | |
matrix: | |
features: | |
- | |
- --all-features | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Cargo cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ github.job }}-${{ github.ref }}-${{ matrix.features }} | |
- name: Run `cargo test` | |
run: | | |
docker run --rm \ | |
-v "${GITHUB_WORKSPACE}:/workspace" \ | |
-v "${HOME}/.cargo:/root/.cargo" \ | |
-w /workspace \ | |
-e SKIP_WASM_BUILD=1 \ | |
paritytech/ci-unified:bullseye-1.74.0 \ | |
bash -c "cargo test --all-targets --locked ${{ matrix.features }}" | |
cargo-doc: | |
name: Check Rustdoc | |
runs-on: ubuntu-latest | |
needs: cargo-clippy | |
strategy: | |
matrix: | |
features: | |
- | |
- --all-features | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Cargo cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ github.job }}-${{ github.ref }} | |
- name: Run `cargo doc` | |
run: | | |
docker run --rm \ | |
-v "${GITHUB_WORKSPACE}:/workspace" \ | |
-v "${HOME}/.cargo:/root/.cargo" \ | |
-w /workspace \ | |
-e RUSTDOCFLAGS='-D warnings' \ | |
-e SKIP_WASM_BUILD=1 \ | |
paritytech/ci-unified:bullseye-1.74.0 \ | |
bash -c "cargo doc --no-deps --locked ${{ matrix.features }}" | |
try-runtime: | |
name: Run try-runtime | |
runs-on: ubuntu-latest | |
needs: cargo-clippy | |
env: | |
TRY_RUNTIME_CLI_VERSION_TAG: v0.7.0 | |
container: | |
image: paritytech/ci-unified:bullseye-1.74.0 | |
strategy: | |
matrix: | |
runtime: | |
- peregrine | |
- spiritnet | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Cargo cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ github.job }}-${{ github.ref }} | |
- name: Install try-runtime | |
run: | | |
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 | |
./try-runtime --version | |
- name: Build runtime | |
run: cargo build --release --locked -p ${{ matrix.runtime }}-runtime --features try-runtime | |
- name: Run `try-runtime` | |
run: | | |
./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 |