mirror of
https://github.com/diodeinc/pcb.git
synced 2026-09-14 20:17:19 +08:00
422c5fdb84
Also use actions/checkout for faster cloning. Signed-off-by: akhilles <akhilvelagapudi@gmail.com>
134 lines
4.0 KiB
YAML
134 lines
4.0 KiB
YAML
name: Build and Test
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
KICAD_VERSION: 9.0.3 # Update container image below when changing this
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build_and_test:
|
|
name: Build and Test (${{ matrix.config.name }})
|
|
runs-on: ${{ matrix.config.runs-on }}
|
|
container: ${{ matrix.config.container }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
config:
|
|
- name: Windows
|
|
runs-on: windows-large
|
|
- name: macOS
|
|
runs-on: macos-15-xlarge
|
|
- name: Ubuntu
|
|
runs-on: ubuntu-large
|
|
container:
|
|
image: kicad/kicad:9.0.3 # Keep in sync with KICAD_VERSION
|
|
options: --user root
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: Install Dependencies (Ubuntu)
|
|
if: matrix.config.name == 'Ubuntu'
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y curl build-essential pkg-config libssl-dev
|
|
|
|
- name: Cache KiCad (macOS)
|
|
if: contains(matrix.config.name, 'macOS')
|
|
id: cache-kicad-mac
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: /Applications/KiCad
|
|
key: ${{ runner.os }}-kicad-${{ env.KICAD_VERSION }}
|
|
|
|
- name: Install KiCad (macOS)
|
|
if: contains(matrix.config.name, 'macOS') && steps.cache-kicad-mac.outputs.cache-hit != 'true'
|
|
run: |
|
|
brew update
|
|
# Uninstall existing KiCad if present to avoid conflicts
|
|
brew uninstall --cask kicad 2>/dev/null || true
|
|
# Remove any remaining KiCad installation
|
|
rm -rf /Applications/KiCad 2>/dev/null || true
|
|
# Install KiCad fresh
|
|
brew install --cask kicad
|
|
|
|
- name: Cache KiCad (Windows)
|
|
if: matrix.config.name == 'Windows'
|
|
id: cache-kicad-windows
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: C:\Program Files\KiCad
|
|
key: ${{ runner.os }}-kicad-${{ env.KICAD_VERSION }}
|
|
|
|
- name: Install KiCad (Windows)
|
|
if: matrix.config.name == 'Windows' && steps.cache-kicad-windows.outputs.cache-hit != 'true'
|
|
run: |
|
|
choco install kicad --version ${{ env.KICAD_VERSION }} -y
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: rustfmt, clippy
|
|
|
|
- name: Cache Cargo
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
# Only save cache from main branch to prevent cache proliferation
|
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
|
|
- name: Build All (Workspace)
|
|
run: cargo build --verbose --workspace
|
|
|
|
- name: Check formatting
|
|
run: cargo fmt --all -- --check
|
|
|
|
- name: Run Clippy
|
|
run: cargo clippy --workspace -- -D warnings
|
|
|
|
- name: Test All (Workspace)
|
|
env:
|
|
RUST_LOG: debug
|
|
RUST_BACKTRACE: full
|
|
run: cargo test --verbose --workspace
|
|
|
|
- name: Run slow tests
|
|
env:
|
|
RUST_LOG: debug
|
|
RUST_BACKTRACE: full
|
|
run: cargo test --verbose -p pcb -- --ignored
|
|
|
|
- name: Test CLI (E2E)
|
|
env:
|
|
RUST_LOG: info,pcb::release=debug,pcb::bom=debug
|
|
run: |
|
|
# Test workspace with pcb.toml and workspace-relative loads
|
|
cargo run -- bom test-workspaces/with-pcb-toml/boards/WorkspaceTestBoard.zen
|
|
cargo run -- release test-workspaces/with-pcb-toml/boards/WorkspaceTestBoard.zen
|
|
cargo run -- vendor test-workspaces/with-pcb-toml
|
|
cargo run -- build test-workspaces/with-pcb-toml/boards --offline
|
|
|
|
- name: Checkout stdlib
|
|
uses: actions/checkout@v5
|
|
with:
|
|
repository: diodeinc/stdlib
|
|
path: stdlib
|
|
|
|
- name: Test stdlib builds
|
|
shell: bash
|
|
run: |
|
|
# Save path to pcb binary
|
|
PCB_BIN="$(pwd)/target/debug/pcb"
|
|
|
|
# Find and build all .zen files
|
|
find stdlib -name "*.zen" -exec "$PCB_BIN" build {} +
|
|
|
|
echo "All stdlib files built successfully!"
|