From 70b5a6889235e1a7d03c3e27e8eb3f10b7225a2d Mon Sep 17 00:00:00 2001 From: Thomas Versteeg Date: Tue, 31 Oct 2023 21:10:56 +0100 Subject: [PATCH 1/3] Add CI for testing --- .github/workflows/test.yaml | 75 +++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..1c978d06 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,75 @@ +name: test + +on: + push: + paths-ignore: + - "doc/**" + - ".vscode/**" + - "html/**" + - "data/**" + - "promo/**" + - "py/**" + - "**.md" + +jobs: + # Check for formatting + rustfmt: + name: Formatter check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + components: rustfmt + override: true + + - run: rustup component add rustfmt + - uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + # Run test check on Linux, macOS, and Windows + test: + name: Test + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-22.04, ubuntu-20.04, macOS-13, macOS-12, macOS-11, windows-latest] + steps: + # Checkout the branch being tested + - uses: actions/checkout@v4 + + # Install rust stable + - uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + + # Cache the built dependencies + - uses: Swatinem/rust-cache@v2.7.1 + with: + save-if: ${{ github.event_name == 'push' }} + + # Install the required dependencies on Ubuntu + - name: Install test dependencies + run: sudo apt-get install clang cmake speech-dispatcher libspeechd-dev pkg-config libssl-dev alsa librust-alsa-sys-dev + if: ${{ contains(matrix.os, 'ubuntu') }} + + # Test for Ubuntu 20.04 + - name: Test + run: cargo test --all --features speech_dispatcher_0_9 + if: matrix.os == 'ubuntu-20.04' + + # Test for Ubuntu 22.04 + - name: Test + run: cargo test --all --features speech_dispatcher_0_11 + if: matrix.os == 'ubuntu-22.04' + + # Test for windows and mac + - name: Test + run: cargo test --all + if: ${{ !contains(matrix.os, 'ubuntu') }} From ab6519d199b565b997efacc0641f12ad3c33de3c Mon Sep 17 00:00:00 2001 From: Thomas Versteeg Date: Wed, 1 Nov 2023 20:08:29 +0100 Subject: [PATCH 2/3] Lint cargo clippy in CI --- .github/workflows/test.yaml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1c978d06..8af26c74 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,14 +11,19 @@ on: - "py/**" - "**.md" +# Make sure CI fails on all warnings, including Clippy lints +env: + RUSTFLAGS: "-Dwarnings" + jobs: - # Check for formatting - rustfmt: - name: Formatter check + # Check for formatting and clippy + lint: + name: Lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + # Setup Rust toolchain - uses: actions-rs/toolchain@v1 with: profile: minimal @@ -26,12 +31,22 @@ jobs: components: rustfmt override: true - - run: rustup component add rustfmt + # Install the required dependencies + - name: Install test dependencies + run: sudo apt-get install clang cmake speech-dispatcher libspeechd-dev pkg-config libssl-dev alsa librust-alsa-sys-dev + + # Cargo fmt - uses: actions-rs/cargo@v1 with: command: fmt args: --all -- --check + # Cargo clippy + - uses: actions-rs/cargo@v1 + with: + command: clippy + args: --all-targets --all-features + # Run test check on Linux, macOS, and Windows test: name: Test From bb480cd4771a6b07872f5de35ffd4be1e1749549 Mon Sep 17 00:00:00 2001 From: Thomas Versteeg Date: Wed, 22 Nov 2023 16:08:31 +0100 Subject: [PATCH 3/3] Fixed: Only test speech_dispatcher_0_11 feature for Clippy in CI --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8af26c74..2964c08b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -45,7 +45,7 @@ jobs: - uses: actions-rs/cargo@v1 with: command: clippy - args: --all-targets --all-features + args: --all-targets --features speech_dispatcher_0_11 # Run test check on Linux, macOS, and Windows test: