Skip to content

Continuous Integration #18

Continuous Integration

Continuous Integration #18

Workflow file for this run

##############################
# #
# Copyright (c) xTekC. #
# Licensed under MPL-2.0. #
# See LICENSE for details. #
# #
##############################
name: Continuous Integration
on:
pull_request:
push:
branches:
- main
- staging # for bors
- trying # for bors
schedule:
- cron: "0 0 * * 0"
jobs:
build:
name: Build on ${{ matrix.build.OS }} (${{ matrix.build.TARGET }})
runs-on: ${{ matrix.build.OS }}
strategy:
fail-fast: false
matrix:
build:
- {
OS: ubuntu-latest,
TOOLCHAIN: stable,
TARGET: riscv64gc-unknown-linux-gnu,
}
- {
OS: ubuntu-latest,
TOOLCHAIN: stable,
TARGET: aarch64-linux-android,
}
- {
OS: ubuntu-latest,
TOOLCHAIN: stable,
TARGET: aarch64-unknown-linux-gnu,
}
- {
OS: ubuntu-latest,
TOOLCHAIN: stable,
TARGET: aarch64-unknown-linux-musl,
}
- {
OS: ubuntu-latest,
TOOLCHAIN: stable,
TARGET: x86_64-unknown-linux-gnu,
}
- {
OS: ubuntu-latest,
TOOLCHAIN: stable,
TARGET: x86_64-unknown-linux-musl,
}
- {
OS: ubuntu-latest,
TOOLCHAIN: stable,
TARGET: x86_64-unknown-freebsd,
}
- {
OS: ubuntu-latest,
TOOLCHAIN: stable,
TARGET: x86_64-unknown-netbsd,
}
- {
OS: macos-latest,
TOOLCHAIN: stable,
TARGET: aarch64-apple-darwin,
}
- { OS: macos-latest,
TOOLCHAIN: stable,
TARGET: x86_64-apple-darwin,
}
- {
OS: windows-latest,
TOOLCHAIN: stable,
TARGET: aarch64-pc-windows-msvc,
}
- {
OS: windows-latest,
TOOLCHAIN: stable,
TARGET: x86_64-pc-windows-gnu,
}
- {
OS: windows-latest,
TOOLCHAIN: stable,
TARGET: x86_64-pc-windows-msvc,
}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.build.TOOLCHAIN }}
- name: Install target
run: rustup target add ${{ matrix.build.TARGET }}
- name: Build for ${{ matrix.build.TARGET }}
if: ${{ matrix.build.TARGET != 'riscv64gc-unknown-linux-gnu' && matrix.build.TARGET != 'aarch64-linux-android' && matrix.build.TARGET != 'aarch64-unknown-linux-gnu' && matrix.build.TARGET != 'aarch64-unknown-linux-musl' && matrix.build.TARGET != 'x86_64-unknown-freebsd' && matrix.build.TARGET != 'x86_64-unknown-netbsd' }}
run: |
cargo build --locked --target ${{ matrix.build.TARGET }} --verbose
- name: Build (with cross) for ${{ matrix.build.TARGET }}
if: ${{ matrix.build.TARGET == 'riscv64gc-unknown-linux-gnu' || matrix.build.TARGET == 'aarch64-linux-android' || matrix.build.TARGET == 'aarch64-unknown-linux-gnu' || matrix.build.TARGET == 'aarch64-unknown-linux-musl' || matrix.build.TARGET == 'x86_64-unknown-freebsd' || matrix.build.TARGET == 'x86_64-unknown-netbsd' }}
run: |
cargo install cross --git https://github.com/cross-rs/cross
cross build --locked --target ${{ matrix.build.TARGET }} --verbose
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
# - name: Install cargo-llvm-cov
# uses: taiki-e/install-action@cargo-llvm-cov
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test
# - name: Generate code coverage
# run: cargo llvm-cov --lcov --output-path lcov.info
# env:
# NO_COLOR: 1
# OUT_DIR: target
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# name: code-coverage-report
# files: lcov.info
# fail_ci_if_error: true
# verbose: true
# token: ${{ secrets.CODECOV_TOKEN }}
# config_file: config/codecov.yml
lint:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
if: github.event_name != 'pull_request'
uses: actions/checkout@v3
- name: Checkout the repository
if: github.event_name == 'pull_request'
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Run rustfmt
run: cargo fmt --all -- --check
# env:
# RUSTFMT_CONFIG_PATH: ./config/rustfmt.toml
- name: Run clippy
run: cargo clippy --tests -- -D warnings
# env:
# CLIPPY_CONFIG_PATH: ./config/clippy.toml
# - name: Run cargo-deny
# uses: EmbarkStudios/cargo-deny-action@v1
# with:
# command: check licenses sources
# env:
# CARGO_DENY_CONFIG_PATH: ./config/deny.toml
- name: Run cargo-audit
run: |
cargo install cargo-audit
cargo audit
env:
CARGO_AUDIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Run committed
# uses: crate-ci/committed@master
# with:
# args: "-vv"
# commits: "HEAD"
# env:
# COMMITTED_CONFIG_PATH: ./config/committed.toml
# - name: Run lychee
# uses: lycheeverse/lychee-action@v1
# with:
# args: -v *.md
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Run codespell
# uses: codespell-project/actions-codespell@master
# with:
# check_filenames: true
# check_hidden: true
# ignore_words_file: config/.codespellignore
# skip: target,.git
# - name: Run cargo-msrv
# shell: bash
# run: |
# curl -s 'https://api.github.com/repos/foresterre/cargo-msrv/releases' | \
# jq -r "[.[] | select(.prerelease == false)][0].assets[] | \
# select(.name | ascii_downcase | test(\"linux.*x86_64|x86_64.*linux\")).browser_download_url" | \
# wget -qi -
# tar -xvf cargo-msrv*.tar* -C ~/.cargo/bin/ cargo-msrv
# printf "%s" "Checking MSRV for $package..."
# cargo msrv --output-format json verify | tail -n 1 | jq --exit-status '.success'