Skip to content

Continuous Integration #1745

Continuous Integration

Continuous Integration #1745

Workflow file for this run

name: Continuous Integration
on:
push:
branches: [main]
paths-ignore:
- "**.md"
- "**.yml"
- "**.yaml"
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
branches: [main]
paths-ignore:
- "**.md"
- "**.yml"
- "**.yaml"
merge_group:
types: [checks_requested]
env:
CARGO_TERM_COLOR: always
jobs:
fmt:
name: Code Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v4
- name: Use Rust nightly with rustfmt
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt -- --config group_imports=StdExternalCrate,imports_granularity=Module --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v4
- name: Use Rust stable with clippy
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- run: cargo clippy --no-deps --all-features --all-targets -- -D warnings -D clippy::expect_used -D clippy::unwrap_used -D clippy::unimplemented
# Create tests and code coverage archives using llvm-cov.
build-test-artifacts:
runs-on: ubuntu-latest
needs: [fmt, clippy]
strategy:
matrix:
clarity_version: [1, 2, 3]
name: Clarity::V${{ matrix.clarity_version }} Artifacts
steps:
- name: Checkout PR
uses: actions/checkout@v4
- name: Use Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Create archive of test binaries
run: |
cargo llvm-cov nextest-archive \
--features test-clarity-v${{ matrix.clarity_version }} \
--workspace \
--archive-file nextest-archive-v${{ matrix.clarity_version }}.tar.zst
- name: Upload test binaries
uses: actions/upload-artifact@v4
with:
name: nextest-archive-v${{ matrix.clarity_version }}
path: nextest-archive-v${{ matrix.clarity_version }}.tar.zst
if-no-files-found: error
- name: Upload standard.wasm file
uses: actions/upload-artifact@v4
with:
name: standard-v${{ matrix.clarity_version }}.wasm
path: ${{github.workspace}}/clar2wasm/src/standard/standard.wasm
if-no-files-found: error
# Run the tests and generates coverage reports
# using the precompiled data from the build-test-artifacts job.
run-tests:
runs-on: ubuntu-latest
needs: build-test-artifacts
strategy:
fail-fast: false
matrix:
clarity_version: [1, 2, 3]
name: Clarity::V${{ matrix.clarity_version }} Tests
steps:
- name: Checkout PR
uses: actions/checkout@v4
- name: Use Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Download standard.wasm file
uses: actions/download-artifact@v4
with:
name: standard-v${{ matrix.clarity_version }}.wasm
path: ${{github.workspace}}/clar2wasm/src/standard/
- name: Download archive
uses: actions/download-artifact@v4
with:
name: nextest-archive-v${{ matrix.clarity_version }}
- name: Run tests and output coverage
shell: bash
run: |
cargo llvm-cov nextest \
--archive-file nextest-archive-v${{ matrix.clarity_version }}.tar.zst \
--codecov \
--output-path codecov-v${{ matrix.clarity_version }}.json
- name: Upload codecov.json
uses: actions/upload-artifact@v4
with:
name: code-coverage-v${{ matrix.clarity_version }}
path: codecov-v${{ matrix.clarity_version }}.json
if-no-files-found: error
# Code coverage
codecov:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: run-tests
strategy:
fail-fast: false
matrix:
clarity_version: [1, 2, 3]
name: Clarity::V${{ matrix.clarity_version }} Code Coverage
steps:
- name: Download codecov.json
uses: actions/download-artifact@v4
with:
name: code-coverage-v${{ matrix.clarity_version }}
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v4
with:
files: codecov-v${{ matrix.clarity_version }}.json
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
# Compile boot contracts with a release version.
compile-boot-contracts:
name: Compile boot-contracts
runs-on: ubuntu-latest
needs: [fmt, clippy]
defaults:
run:
working-directory: ./clar2wasm
steps:
- name: Checkout PR
uses: actions/checkout@v4
- name: Use Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Setup wasm-tools
uses: bytecodealliance/actions/wasm-tools/setup@v1
- name: Compile boot-contracts
run: |
cargo build --release
bash ./scripts/boot-contracts-compile.sh