Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

CI refactoring #174

Merged
merged 1 commit into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions .github/templates/setup-worker/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: setup-worker
description: |
This action sets up a worker for use in other actions. It installs the
necessary dependencies for building the project.
inputs:
rust-components:
description: Comma-separated list of components to be additionally installed for a new rust toolchain
required: false

runs:
using: "composite"

steps:
- name: Setup Ubuntu dependencies
shell: bash
run: sudo apt update && sudo apt install -y git clang curl libssl-dev llvm libudev-dev cmake protobuf-compiler

- name: Install Rust nightly
shell: bash
run: |
rustup toolchain install nightly-2023-01-01
rustup default nightly-2023-01-01
rustup target add wasm32-unknown-unknown
rustup component add rustfmt
93 changes: 51 additions & 42 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,37 @@
name: Check Set-Up & Build
name: Check Build and Tests

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
check:
# The type of runner that the job will run on
runs-on: ubuntu-20.04
env:
NIGHTLY: nightly-2022-11-02 # Fix version to prevent cache misses with nightly changes

# Steps represent a sequence of tasks that will be executed as part of the job
lint:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Set-Up
run: sudo apt update && sudo apt install -y git clang curl libssl-dev llvm libudev-dev cmake protobuf-compiler

- name: Install Rust
uses: actions-rs/toolchain@v1
- name: Setup worker
uses: "./.github/templates/setup-worker"
with:
profile: minimal
toolchain: stable
rust-components: rustfmt

- name: Install Nightly
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.NIGHTLY }}
override: true
target: wasm32-unknown-unknown
components: rustfmt

# Fail fast: check formatting first as it doesn't require compilation
- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --check
run: cargo fmt --all -- --check

check:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup worker
uses: "./.github/templates/setup-worker"

- name: Cache Build artefacts
uses: actions/cache@v3
Expand All @@ -58,8 +42,8 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-release

- name: Check Build Trappist Runtime
run: |
Expand All @@ -69,12 +53,37 @@ jobs:
run: |
SKIP_WASM_BUILD=1 cargo check --release --no-default-features --features with-stout-runtime

- name: Check Build for Benchmarking Trappist Runtime
run: >
pushd node &&
cargo check --features=runtime-benchmarks,with-trappist-runtime --release
test:
needs: lint
runs-on: ubuntu-latest
steps:
# Tests with benchmarks require a lot of disk space
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
android: true
dotnet: false
haskell: false
large-packages: false
swap-storage: false

- uses: actions/checkout@v3

- name: Setup worker
uses: "./.github/templates/setup-worker"

- name: Cache Build artefacts
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-debug

- name: Check Build for Benchmarking stout Runtime
run: >
pushd node &&
cargo check --no-default-features --features=runtime-benchmarks,with-stout-runtime --release
- name: Run tests
run: |
cargo test --features runtime-benchmarks --jobs 2