Skip to content

Commit

Permalink
ci: Migrate Gitlab tests to GitHub runner (#698)
Browse files Browse the repository at this point in the history
## fixes KILTprotocol/ticket#3345
Build docker image only when tests on gh passed
## 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: Antonio Antonino <antonio@kilt.io>
  • Loading branch information
ggera and ntn-x2 authored Aug 29, 2024
1 parent 60f670d commit 24d49b6
Show file tree
Hide file tree
Showing 15 changed files with 444 additions and 413 deletions.
289 changes: 289 additions & 0 deletions .github/workflows/check-code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@
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: Checkout repository
uses: actions/checkout@v4
with:
# We use different payloads depending on whether this is a `push` or a `pull_request` event
ref: ${{ github.event.head_commit.message || github.event.pull_request.head.sha }}

- 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
fail-fast: false

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

- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true

- 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 }}-${{ hashFiles('**/Cargo.lock') }}

- 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
env:
RUSTUP_NIGHTLY_VERSION: nightly-2023-10-02
needs: get-commit-head
if: ${{ !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-rust') }}

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

- name: Install nightly toolchain
run: rustup toolchain add ${{ env.RUSTUP_NIGHTLY_VERSION }}

- name: Run `cargo fmt`
# Latest nightly version matching the base rustc version (1.74.0)
run: cargo +${{ env.RUSTUP_NIGHTLY_VERSION }} 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
- cargo-clippy
# Run this job if the `clippy` step completed successfully or was skipped, as long as the commit does not explicitly skip integration tests as well.
if: ${{ always() && needs.cargo-clippy.result != 'failure' && !contains(needs.get-commit-head.outputs.headCommitMsg, 'ci-skip-integration-tests') }}

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

- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true

- 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: 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 }}-${{ hashFiles('**/Cargo.lock') }}

- 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
fail-fast: false

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

- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true

- 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 }}-${{ hashFiles('**/Cargo.lock') }}

- 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
fail-fast: false

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

- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true

- 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 }}-${{ hashFiles('**/Cargo.lock') }}

- 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
fail-fast: false

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

- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true

- 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: 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 }}-${{ hashFiles('**/Cargo.lock') }}

- 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
37 changes: 0 additions & 37 deletions .github/workflows/check-fmt.yml

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/docs-publish.yml

This file was deleted.

Loading

0 comments on commit 24d49b6

Please sign in to comment.