Skip to content

Tests

Tests #28

Workflow file for this run

name: Tests
on:
pull_request:
branches: [main]
push:
branches: ["main"]
tags: ["*"]
env:
CARGO_INCREMENTAL: 0 # this setting is automatically applied by rust-cache but documented here for explicitness
CARGO_NET_RETRY: 10
RUST_BACKTRACE: short
RUSTFLAGS: "-D warnings"
RUSTUP_MAX_RETRIES: 10
jobs:
build:
runs-on: oracles-20.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-build
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust install
uses: dtolnay/rust-toolchain@stable
- name: Install protoc
run: sudo apt-get install -y protobuf-compiler
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --all --tests
fmt:
needs: build
runs-on: oracles-20.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-fmt
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust install
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Install protoc
run: sudo apt-get install -y protobuf-compiler
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
run: cargo fmt -- --check
clippy:
needs: build
runs-on: oracles-20.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-clippy
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust install
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Install protoc
run: sudo apt-get install -y protobuf-compiler
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Clippy
run: cargo clippy --all-targets -- -Dclippy::all -D warnings
tests:
needs: build
runs-on: oracles-20.04
strategy:
fail-fast: false
matrix:
package: [boost-manager,file-store,ingest,iot-config,iot-packet-verifier,iot-verifier,mobile-config,mobile-packet-verifier,mobile-verifier,reward-scheduler,task-manager]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-tests-${{ matrix.package }}
cancel-in-progress: true
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust install
uses: dtolnay/rust-toolchain@stable
- name: Install protoc
run: sudo apt-get install -y protobuf-compiler
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run unit and integration tests
env:
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/postgres"
run: cargo test -p ${{ matrix.package }} -- --include-ignored