Merge pull request #169 from Concordium/improvement-sc-tool #414
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: "cargo-concordium: Build and test" | |
# This job runs rustfmt and clippy linting, | |
# cargo check on cargo-concordium, | |
# and then it runs cargo test and ./target/debug/wasm-test | |
on: | |
push: | |
branches: main | |
pull_request: | |
branches: main | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
paths: | |
- 'cargo-concordium/**/*.rs' | |
- 'cargo-concordium/**/*.toml' | |
- 'rustfmt.toml' | |
- 'concordium-base' | |
workflow_dispatch: # allows manual trigger | |
env: | |
# from concordium/rustfmt:0.17 | |
RUST_FMT: nightly-2023-04-01-x86_64-unknown-linux-gnu | |
RUST_CLIPPY: 1.73 | |
jobs: | |
"lint_fmt": | |
name: ${{ matrix.build-dir }} lint:fmt | |
# Don't run on draft pull requests | |
if: ${{ !github.event.pull_request.draft }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
build-dir: | |
- 'cargo-concordium' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: ${{ env.RUST_FMT }} | |
override: true | |
components: rustfmt | |
- name: Format | |
working-directory: ${{ matrix.build-dir }} | |
run: | | |
cargo fmt -- --color=always --check | |
# For binaries we additionally commit the lock file. And we want to ensure | |
# that the file is up-to-date. | |
"lint_clippy_binaries": | |
name: ${{ matrix.build-dir }} lint:clippy | |
# Don't run on draft pull requests | |
if: ${{ !github.event.pull_request.draft }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
build-dir: | |
- 'cargo-concordium' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: ${{ env.RUST_CLIPPY }} | |
override: true | |
components: clippy | |
- name: Clippy | |
working-directory: ${{ matrix.build-dir }} | |
run: | | |
git config --global url."https://github.com/".insteadOf "git@github.com:" | |
cargo clippy --locked --color=always --tests --benches -- -Dclippy::all | |
"cargo-concordium_cargo_build-bench": | |
name: cargo-concordium cargo:build-bench | |
runs-on: ubuntu-latest | |
needs: | |
- lint_clippy_binaries | |
- lint_fmt | |
strategy: | |
matrix: | |
build-dir: | |
- 'cargo-concordium' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: ${{ env.RUST_CLIPPY }} | |
override: true | |
components: clippy | |
- name: Cargo check | |
working-directory: ${{ matrix.build-dir }} | |
run: cargo check --benches --tests | |
"cargo_test": | |
name: ${{ matrix.build-dir }} cargo:test | |
runs-on: ubuntu-latest | |
needs: | |
- cargo-concordium_cargo_build-bench | |
strategy: | |
matrix: | |
build-dir: | |
- 'cargo-concordium' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: ${{ env.RUST_CLIPPY }} | |
override: true | |
- name: Test | |
working-directory: ${{ matrix.build-dir }} | |
run: cargo test |