From 3643dad3547878e4b0db4a3cecef4ab23397e18b Mon Sep 17 00:00:00 2001 From: Michael Neale Date: Thu, 20 Nov 2025 08:57:31 +1100 Subject: [PATCH 1/5] trying out running tests --- .github/workflows/README.md | 74 +++++++++++++++ .github/workflows/ci.yml | 151 ++++++++++++++++++++++++++++++ .github/workflows/quick-check.yml | 53 +++++++++++ 3 files changed, 278 insertions(+) create mode 100644 .github/workflows/README.md create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/quick-check.yml diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 00000000..482cb514 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,74 @@ +# GitHub Actions Workflows + +This directory contains the CI/CD workflows for the g3 project. + +## Workflows + +### 1. CI (`ci.yml`) +**Triggers:** Push to `main` or `develop` branches, Pull Requests + +**Jobs:** +- **Test**: Runs tests on Ubuntu, macOS, and Windows + - Format checking (`cargo fmt`) + - Linting with Clippy (`cargo clippy`) + - Build verification + - Unit and integration tests + - Documentation tests + +- **Build**: Creates release builds for all platforms + - Uploads build artifacts for download + +- **Coverage**: Generates code coverage reports + - Uses `cargo-tarpaulin` + - Uploads to Codecov (optional) + +### 2. Quick Check (`quick-check.yml`) +**Triggers:** Push to any branch except `main`, Pull Requests + +**Jobs:** +- **Quick Check**: Fast verification on Ubuntu only + - Format checking + - Clippy linting + - Build check + - Run tests + +This workflow is designed for rapid feedback during development. + +## System Dependencies + +The workflows automatically install required system dependencies: + +**Ubuntu:** +- `libx11-dev` +- `libxdo-dev` +- `libxcb-shape0-dev` +- `libxcb-xfixes0-dev` + +**macOS:** No additional dependencies required + +**Windows:** No additional dependencies required + +## Caching + +All workflows use GitHub Actions cache to speed up builds: +- Cargo registry +- Cargo git index +- Build artifacts (`target/` directory) + +## Artifacts + +The CI workflow produces downloadable artifacts: +- `g3-ubuntu-latest`: Linux binaries +- `g3-macos-latest`: macOS binaries +- `g3-windows-latest`: Windows binaries + +## Adding Badges to README + +Add these badges to your main README.md: + +```markdown +[![CI](https://github.com/YOUR_USERNAME/g3/actions/workflows/ci.yml/badge.svg)](https://github.com/YOUR_USERNAME/g3/actions/workflows/ci.yml) +[![Quick Check](https://github.com/YOUR_USERNAME/g3/actions/workflows/quick-check.yml/badge.svg)](https://github.com/YOUR_USERNAME/g3/actions/workflows/quick-check.yml) +``` + +Replace `YOUR_USERNAME` with your GitHub username or organization name. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..98d9f261 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,151 @@ +name: CI + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main, develop ] + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + +jobs: + test: + name: Test + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + rust: [stable] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ matrix.rust }} + components: rustfmt, clippy + + - name: Cache cargo registry + uses: actions/cache@v4 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-registry- + + - name: Cache cargo index + uses: actions/cache@v4 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-git- + + - name: Cache cargo build + uses: actions/cache@v4 + with: + path: target + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-build-target- + + - name: Install system dependencies (Ubuntu) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y libx11-dev libxdo-dev libxcb-shape0-dev libxcb-xfixes0-dev + + - name: Check formatting + run: cargo fmt --all -- --check + + - name: Run clippy + run: cargo clippy --all-targets --all-features -- -D warnings + continue-on-error: true + + - name: Build + run: cargo build --workspace --verbose + + - name: Run tests + run: cargo test --workspace --lib --tests --verbose + + - name: Run doc tests + run: cargo test --workspace --doc --verbose + continue-on-error: true + + build: + name: Build Release + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-release- + + - name: Install system dependencies (Ubuntu) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y libx11-dev libxdo-dev libxcb-shape0-dev libxcb-xfixes0-dev + + - name: Build release + run: cargo build --workspace --release --verbose + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: g3-${{ matrix.os }} + path: | + target/release/g3${{ runner.os == 'Windows' && '.exe' || '' }} + target/release/g3-console${{ runner.os == 'Windows' && '.exe' || '' }} + if-no-files-found: ignore + + coverage: + name: Code Coverage + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y libx11-dev libxdo-dev libxcb-shape0-dev libxcb-xfixes0-dev + + - name: Install tarpaulin + run: cargo install cargo-tarpaulin + + - name: Generate coverage + run: cargo tarpaulin --workspace --out xml --output-dir coverage --verbose + continue-on-error: true + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + files: ./coverage/cobertura.xml + flags: unittests + name: codecov-umbrella + fail_ci_if_error: false diff --git a/.github/workflows/quick-check.yml b/.github/workflows/quick-check.yml new file mode 100644 index 00000000..14e5b023 --- /dev/null +++ b/.github/workflows/quick-check.yml @@ -0,0 +1,53 @@ +name: Quick Check + +on: + push: + branches-ignore: + - main + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + quick-check: + name: Quick Check + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + + - name: Cache cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-quick-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-quick- + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y libx11-dev libxdo-dev libxcb-shape0-dev libxcb-xfixes0-dev + + - name: Check formatting + run: cargo fmt --all -- --check + + - name: Run clippy + run: cargo clippy --workspace --all-targets -- -D warnings + continue-on-error: true + + - name: Check build + run: cargo check --workspace --all-targets + + - name: Run tests + run: cargo test --workspace --lib --tests From 69ae894de84bf082465150d0268a1d6837d0e803 Mon Sep 17 00:00:00 2001 From: Michael Neale Date: Thu, 20 Nov 2025 09:04:15 +1100 Subject: [PATCH 2/5] cleaning up CI --- .github/workflows/README.md | 74 ------------------ .github/workflows/ci.yml | 126 ++---------------------------- .github/workflows/quick-check.yml | 53 ------------- 3 files changed, 7 insertions(+), 246 deletions(-) delete mode 100644 .github/workflows/README.md delete mode 100644 .github/workflows/quick-check.yml diff --git a/.github/workflows/README.md b/.github/workflows/README.md deleted file mode 100644 index 482cb514..00000000 --- a/.github/workflows/README.md +++ /dev/null @@ -1,74 +0,0 @@ -# GitHub Actions Workflows - -This directory contains the CI/CD workflows for the g3 project. - -## Workflows - -### 1. CI (`ci.yml`) -**Triggers:** Push to `main` or `develop` branches, Pull Requests - -**Jobs:** -- **Test**: Runs tests on Ubuntu, macOS, and Windows - - Format checking (`cargo fmt`) - - Linting with Clippy (`cargo clippy`) - - Build verification - - Unit and integration tests - - Documentation tests - -- **Build**: Creates release builds for all platforms - - Uploads build artifacts for download - -- **Coverage**: Generates code coverage reports - - Uses `cargo-tarpaulin` - - Uploads to Codecov (optional) - -### 2. Quick Check (`quick-check.yml`) -**Triggers:** Push to any branch except `main`, Pull Requests - -**Jobs:** -- **Quick Check**: Fast verification on Ubuntu only - - Format checking - - Clippy linting - - Build check - - Run tests - -This workflow is designed for rapid feedback during development. - -## System Dependencies - -The workflows automatically install required system dependencies: - -**Ubuntu:** -- `libx11-dev` -- `libxdo-dev` -- `libxcb-shape0-dev` -- `libxcb-xfixes0-dev` - -**macOS:** No additional dependencies required - -**Windows:** No additional dependencies required - -## Caching - -All workflows use GitHub Actions cache to speed up builds: -- Cargo registry -- Cargo git index -- Build artifacts (`target/` directory) - -## Artifacts - -The CI workflow produces downloadable artifacts: -- `g3-ubuntu-latest`: Linux binaries -- `g3-macos-latest`: macOS binaries -- `g3-windows-latest`: Windows binaries - -## Adding Badges to README - -Add these badges to your main README.md: - -```markdown -[![CI](https://github.com/YOUR_USERNAME/g3/actions/workflows/ci.yml/badge.svg)](https://github.com/YOUR_USERNAME/g3/actions/workflows/ci.yml) -[![Quick Check](https://github.com/YOUR_USERNAME/g3/actions/workflows/quick-check.yml/badge.svg)](https://github.com/YOUR_USERNAME/g3/actions/workflows/quick-check.yml) -``` - -Replace `YOUR_USERNAME` with your GitHub username or organization name. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98d9f261..6b48954b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,92 +2,19 @@ name: CI on: push: - branches: [ main, develop ] pull_request: - branches: [ main, develop ] - -env: - CARGO_TERM_COLOR: always - RUST_BACKTRACE: 1 jobs: test: - name: Test - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - rust: [stable] - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ matrix.rust }} - components: rustfmt, clippy - - - name: Cache cargo registry - uses: actions/cache@v4 - with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-registry- - - - name: Cache cargo index - uses: actions/cache@v4 - with: - path: ~/.cargo/git - key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-git- - - - name: Cache cargo build - uses: actions/cache@v4 - with: - path: target - key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-build-target- - - - name: Install system dependencies (Ubuntu) - if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install -y libx11-dev libxdo-dev libxcb-shape0-dev libxcb-xfixes0-dev - - - name: Check formatting - run: cargo fmt --all -- --check - - - name: Run clippy - run: cargo clippy --all-targets --all-features -- -D warnings - continue-on-error: true - - - name: Build - run: cargo build --workspace --verbose - - - name: Run tests - run: cargo test --workspace --lib --tests --verbose - - - name: Run doc tests - run: cargo test --workspace --doc --verbose - continue-on-error: true - - build: - name: Build Release runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] steps: - - name: Checkout code - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Install Rust toolchain + - name: Install Rust uses: dtolnay/rust-toolchain@stable - name: Cache cargo @@ -97,9 +24,7 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-release- + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Install system dependencies (Ubuntu) if: runner.os == 'Linux' @@ -107,45 +32,8 @@ jobs: sudo apt-get update sudo apt-get install -y libx11-dev libxdo-dev libxcb-shape0-dev libxcb-xfixes0-dev - - name: Build release - run: cargo build --workspace --release --verbose - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: g3-${{ matrix.os }} - path: | - target/release/g3${{ runner.os == 'Windows' && '.exe' || '' }} - target/release/g3-console${{ runner.os == 'Windows' && '.exe' || '' }} - if-no-files-found: ignore - - coverage: - name: Code Coverage - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - - - name: Install system dependencies - run: | - sudo apt-get update - sudo apt-get install -y libx11-dev libxdo-dev libxcb-shape0-dev libxcb-xfixes0-dev - - - name: Install tarpaulin - run: cargo install cargo-tarpaulin - - - name: Generate coverage - run: cargo tarpaulin --workspace --out xml --output-dir coverage --verbose - continue-on-error: true + - name: Build + run: cargo build --workspace - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - with: - files: ./coverage/cobertura.xml - flags: unittests - name: codecov-umbrella - fail_ci_if_error: false + - name: Run tests + run: cargo test --workspace --lib --tests diff --git a/.github/workflows/quick-check.yml b/.github/workflows/quick-check.yml deleted file mode 100644 index 14e5b023..00000000 --- a/.github/workflows/quick-check.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Quick Check - -on: - push: - branches-ignore: - - main - pull_request: - -env: - CARGO_TERM_COLOR: always - -jobs: - quick-check: - name: Quick Check - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt, clippy - - - name: Cache cargo - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-quick-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-quick- - - - name: Install system dependencies - run: | - sudo apt-get update - sudo apt-get install -y libx11-dev libxdo-dev libxcb-shape0-dev libxcb-xfixes0-dev - - - name: Check formatting - run: cargo fmt --all -- --check - - - name: Run clippy - run: cargo clippy --workspace --all-targets -- -D warnings - continue-on-error: true - - - name: Check build - run: cargo check --workspace --all-targets - - - name: Run tests - run: cargo test --workspace --lib --tests From 40f9ea5eb301455ff77accfb1e78c3404ebb7eff Mon Sep 17 00:00:00 2001 From: Michael Neale Date: Thu, 20 Nov 2025 09:08:51 +1100 Subject: [PATCH 3/5] tighten platforms --- .github/workflows/ci.yml | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b48954b..b286400b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,12 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + include: + - os: ubuntu-latest + arch: x86_64 + - os: ubuntu-latest + arch: aarch64 + - os: macos-latest steps: - uses: actions/checkout@v4 @@ -17,6 +22,10 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable + - name: Set up QEMU (for aarch64 on Linux) + if: matrix.arch == 'aarch64' && runner.os == 'Linux' + uses: docker/setup-qemu-action@v3 + - name: Cache cargo uses: actions/cache@v4 with: @@ -24,16 +33,33 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-${{ matrix.arch || 'x86_64' }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Install system dependencies (Ubuntu) - if: runner.os == 'Linux' + if: runner.os == 'Linux' && matrix.arch != 'aarch64' run: | sudo apt-get update sudo apt-get install -y libx11-dev libxdo-dev libxcb-shape0-dev libxcb-xfixes0-dev - - name: Build + - name: Build and test (Linux aarch64) + if: matrix.arch == 'aarch64' && runner.os == 'Linux' + uses: uraimo/run-on-arch-action@v2 + with: + arch: aarch64 + distro: ubuntu22.04 + install: | + apt-get update + apt-get install -y curl build-essential libx11-dev libxdo-dev libxcb-shape0-dev libxcb-xfixes0-dev + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + run: | + . $HOME/.cargo/env + cargo build --workspace + cargo test --workspace --lib --tests + + - name: Build (Linux x86_64 / macOS) + if: matrix.arch != 'aarch64' run: cargo build --workspace - - name: Run tests + - name: Run tests (Linux x86_64 / macOS) + if: matrix.arch != 'aarch64' run: cargo test --workspace --lib --tests From 04ceefd5e25ee0741b37092b0a07d97e2fd99615 Mon Sep 17 00:00:00 2001 From: Michael Neale Date: Thu, 20 Nov 2025 09:10:32 +1100 Subject: [PATCH 4/5] deps --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b286400b..2604f91e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: if: runner.os == 'Linux' && matrix.arch != 'aarch64' run: | sudo apt-get update - sudo apt-get install -y libx11-dev libxdo-dev libxcb-shape0-dev libxcb-xfixes0-dev + sudo apt-get install -y libx11-dev libxdo-dev libxcb-shape0-dev libxcb-xfixes0-dev libxtst-dev - name: Build and test (Linux aarch64) if: matrix.arch == 'aarch64' && runner.os == 'Linux' @@ -49,7 +49,7 @@ jobs: distro: ubuntu22.04 install: | apt-get update - apt-get install -y curl build-essential libx11-dev libxdo-dev libxcb-shape0-dev libxcb-xfixes0-dev + apt-get install -y curl build-essential libx11-dev libxdo-dev libxcb-shape0-dev libxcb-xfixes0-dev libxtst-dev curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y run: | . $HOME/.cargo/env From 95e5a59720409e48ee5bbf2d275f56fe84f4092a Mon Sep 17 00:00:00 2001 From: Michael Neale Date: Thu, 20 Nov 2025 09:16:08 +1100 Subject: [PATCH 5/5] linux build specifics --- .github/workflows/ci.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2604f91e..36bcd890 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,13 +53,21 @@ jobs: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y run: | . $HOME/.cargo/env - cargo build --workspace - cargo test --workspace --lib --tests + cargo build --workspace --exclude g3-computer-control + cargo test --workspace --exclude g3-computer-control --lib --tests - - name: Build (Linux x86_64 / macOS) - if: matrix.arch != 'aarch64' + - name: Build (Linux x86_64) + if: matrix.arch != 'aarch64' && runner.os == 'Linux' + run: cargo build --workspace --exclude g3-computer-control + + - name: Run tests (Linux x86_64) + if: matrix.arch != 'aarch64' && runner.os == 'Linux' + run: cargo test --workspace --exclude g3-computer-control --lib --tests + + - name: Build (macOS) + if: runner.os == 'macOS' run: cargo build --workspace - - name: Run tests (Linux x86_64 / macOS) - if: matrix.arch != 'aarch64' + - name: Run tests (macOS) + if: runner.os == 'macOS' run: cargo test --workspace --lib --tests