Skip to content

Commit

Permalink
[FEAT] add nextest / project generation test / typos check for CI (#216)
Browse files Browse the repository at this point in the history
* [FEAT] use nextest for CI

* [FEAT] clean CI

* [FIX] matrix mode setup for CI

* [FIX] RELEASE_FLAG for windows

* [FIX] RELEASE_FLAG for windows second try

* [FIX] RELEASE_FLAG for windows third try

* [FIX] RELEASE_FLAG for windows fourth try

* [FEAT] add project generation test again

* [FEAT] add typos check to CI
  • Loading branch information
makeecat authored Jan 12, 2025
1 parent 357698a commit 6c54917
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .config/_typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[default.extend-words]
mis = "mis"
ratatui = "ratatui"
13 changes: 13 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://nexte.st/docs/configuration/test-groups/?h=group
[test-groups]
# resource-limited = { max-threads = 4 }
serial-integration = { max-threads = 1 }

# [[profile.default.overrides]]
# filter = 'test(resource_limited::)'
# test-group = 'resource-limited'

[[profile.default.overrides]]
filter = 'package(cu-vlp16) + package(cu-hesai) + package(cu-livox)'
#platform = 'cfg(unix)'
test-group = 'serial-integration'
107 changes: 81 additions & 26 deletions .github/workflows/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ name: "CI/CD"

on:
push:
branches: [ "master" ]
branches: ["master"]
pull_request:
branches: [ "master" ]
branches: ["master"]

env:
CARGO_TERM_COLOR: always

jobs:
build-debug:
name: Build Debug
build-debug-release:
name: Build

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
os: [ubuntu-latest, macos-latest, windows-latest]
mode: [debug, release]

steps:
- uses: actions/checkout@v4
Expand All @@ -33,7 +35,7 @@ jobs:

# Fail cheaply and early if the code is not even formatted correctly.
- name: Cargo fmt check
run: cargo fmt --all -- --check
run: cargo +stable fmt --all -- --check

## System dependencies
# Install dependencies only on Linux
Expand All @@ -49,28 +51,43 @@ jobs:
Expand-Archive -Path npcap-sdk.zip -DestinationPath $env:USERPROFILE\npcap-sdk
Remove-Item npcap-sdk.zip
winget install --id DaiyuuNobori.Win10Pcap --disable-interactivity --accept-source-agreements --accept-package-agreements
- name: Set Library and Include Paths (Windows)
if: runner.os == 'Windows'
run: |
$npcapLibDir = "$env:USERPROFILE\npcap-sdk\Lib\x64"
Add-Content -Path $env:GITHUB_ENV -Value "LIB=$npcapLibDir"
# Run debug builds and tests
- name: Run clippy in debug
run: cargo clippy --workspace --all-targets -- --deny warnings
- name: Build in debug
run: cargo build --workspace --features macro_debug
- name: Run tests
run: cargo test --workspace
- name: Set Release Flag (Linux / MacOS)
if: runner.os != 'Windows'
run: echo "RELEASE_FLAG=$([[ '${{ matrix.mode }}' == 'release' ]] && echo '--release' || echo '')" >> $GITHUB_ENV

- name: Set Release Flag (Windows)
if: runner.os == 'Windows' && matrix.mode == 'release'
run: |
Add-Content -Path $env:GITHUB_ENV -Value "RELEASE_FLAG=--release"
build-release:
name: Build Release
# Run clippy and build in debug / release
- name: Run clippy in debug / release
run: cargo +stable clippy $RELEASE_FLAG --workspace --all-targets -- --deny warnings
- name: Run clippy in debug / release with mock and macro_debug
run: cargo +stable clippy $RELEASE_FLAG --workspace --all-targets --features mock,macro_debug -- --deny warnings
- name: Run clippy in debug /release with perf-ui, image and kornia
run: cargo +stable clippy $RELEASE_FLAG --workspace --all-targets --features perf-ui,image,kornia -- --deny warnings
- name: Run doctests in debug
if: matrix.mode == 'debug'
run: cargo +stable test --doc --workspace
- name: Run build in debug / release
run: cargo +stable build $RELEASE_FLAG --workspace --all-targets --all-features

test-debug-release:
name: Test
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
os: [ubuntu-latest, macos-latest, windows-latest]
mode: [debug, release]

steps:
- uses: actions/checkout@v4
Expand All @@ -85,29 +102,67 @@ jobs:
if: runner.os == 'Windows'
uses: Cyberboss/install-winget@v1

# Fail cheaply and early if the code is not even formatted correctly.
- name: Cargo fmt check
run: cargo fmt --all -- --check

## System dependencies
# Install dependencies only on Linux
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libudev-dev libpcap-dev

# Those are needed for the integration tests on Windows
- name: Download Npcap SDK (Windows)
if: runner.os == 'Windows'
run: |
Invoke-WebRequest -Uri https://npcap.com/dist/npcap-sdk-1.13.zip -OutFile npcap-sdk.zip
Expand-Archive -Path npcap-sdk.zip -DestinationPath $env:USERPROFILE\npcap-sdk
Remove-Item npcap-sdk.zip
winget install --id DaiyuuNobori.Win10Pcap --disable-interactivity --accept-source-agreements --accept-package-agreements
- name: Set Library and Include Paths (Windows)
if: runner.os == 'Windows'
run: |
$npcapLibDir = "$env:USERPROFILE\npcap-sdk\Lib\x64"
Add-Content -Path $env:GITHUB_ENV -Value "LIB=$npcapLibDir"
# Run release builds and tests
- name: Run clippy in release
run: cargo clippy --release --workspace --all-targets -- --deny warnings
- name: Build in release
run: cargo build --release --workspace --features macro_debug
- name: Install latest nextest
uses: taiki-e/install-action@nextest

- name: Set Release Flag (Linux / MacOS)
if: runner.os != 'Windows'
run: echo "RELEASE_FLAG=$([[ '${{ matrix.mode }}' == 'release' ]] && echo '--release' || echo '')" >> $GITHUB_ENV

- name: Set Release Flag (Windows)
if: runner.os == 'Windows' && matrix.mode == 'release'
run: |
Add-Content -Path $env:GITHUB_ENV -Value "RELEASE_FLAG=--release"
# Run test in debug / release
- name: Run test in debug / release
run: cargo +stable nextest run $RELEASE_FLAG --all-targets --workspace
- name: Run test in debug / release with mock and macro_debug
run: cargo +stable nextest run $RELEASE_FLAG --all-targets --workspace --features mock,macro_debug
- name: Run test in debug / release with perf-ui, image and kornia
run: cargo +stable nextest run $RELEASE_FLAG --all-targets --workspace --features perf-ui,image,kornia
- name: Run test in debug / release with all features
run: cargo +stable nextest run $RELEASE_FLAG --all-targets --workspace --all-features

- name: Install cargo-generate
run: cargo +stable install cargo-generate

- name: Generate new project
run: |
cd templates
cargo +stable generate -p cu_full --name test_project --destination . -d copper_source=local --silent
- name: Build generated project
run: |
cd templates/test_project
cargo +stable build $RELEASE_FLAG
typos:
name: Typos Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/typos@master
with:
config: ./.config/_typos.toml

0 comments on commit 6c54917

Please sign in to comment.