Files

203 lines
6.6 KiB
YAML

name: Build and Test
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_PROFILE_TEST_DEBUG: 0
KICAD_VERSION: 10.0.5
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: read
jobs:
lint:
name: Lint and Check
runs-on: blacksmith-16vcpu-ubuntu-2404
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
with:
components: rustfmt, clippy
cache-bin: false
- name: Check formatting
run: cargo fmt --all -- --check
- name: Check stdlib .zen formatting
run: cargo run -p pcbc -- fmt --check lib/std
- name: Run Clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
test:
name: Test (${{ matrix.config.name }})
runs-on: ${{ matrix.config.runs-on }}
container: ${{ matrix.config.container }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
config:
- name: Windows
runs-on: blacksmith-16vcpu-windows-2025
- name: macOS
runs-on: blacksmith-6vcpu-macos-15
- name: Ubuntu
runs-on: blacksmith-16vcpu-ubuntu-2404
container:
image: ghcr.io/diodeinc/kicad:10.0.5
options: --user root
steps:
- name: Enable Windows long paths
if: runner.os == 'Windows'
run: git config --global core.longpaths true
- name: Cache APT packages (Ubuntu)
if: matrix.config.name == 'Ubuntu'
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: /tmp/apt-cache/archives
key: apt-${{ runner.os }}-${{ runner.arch }}-debian-trixie-${{ env.KICAD_VERSION }}-ca-certificates-curl-build-essential-pkg-config
restore-keys: |
apt-${{ runner.os }}-${{ runner.arch }}-debian-trixie-${{ env.KICAD_VERSION }}-
- name: Install Dependencies (Ubuntu)
if: matrix.config.name == 'Ubuntu'
run: |
apt_cache_dir=/tmp/apt-cache/archives
mkdir -p "$apt_cache_dir/partial"
apt-get -o Dir::Cache::archives="$apt_cache_dir/" update
apt-get -o Dir::Cache::archives="$apt_cache_dir/" install -y --no-install-recommends ca-certificates curl build-essential pkg-config
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Cache KiCad (macOS)
if: contains(matrix.config.name, 'macOS')
id: cache-kicad-mac
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
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
brew uninstall --cask kicad 2>/dev/null || true
rm -rf /Applications/KiCad 2>/dev/null || true
brew install --cask kicad
- name: Cache KiCad (Windows)
if: matrix.config.name == 'Windows'
id: cache-kicad-windows
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: C:\Program Files\KiCad\10.0
key: ${{ runner.os }}-kicad-${{ env.KICAD_VERSION }}
- name: Install KiCad (Windows)
if: matrix.config.name == 'Windows' && steps.cache-kicad-windows.outputs.cache-hit != 'true'
shell: pwsh
run: |
$release = Invoke-RestMethod `
-Uri "https://api.github.com/repos/KiCad/kicad-source-mirror/releases/tags/${env:KICAD_VERSION}"
$asset = $release.assets |
Where-Object { $_.name -like "kicad-$env:KICAD_VERSION*-x86_64.exe" } |
Select-Object -First 1
if (-not $asset) {
throw "No KiCad Windows installer found for release tag $env:KICAD_VERSION"
}
$installer = Join-Path $env:RUNNER_TEMP $asset.name
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $installer
Start-Process -FilePath $installer -ArgumentList '/S', '/allusers' -Wait
- name: Verify KiCad installation (Windows)
if: matrix.config.name == 'Windows'
shell: pwsh
run: |
if (-not (Test-Path "C:\Program Files\KiCad\10.0\bin\kicad-cli.exe")) {
throw "KiCad CLI was not restored or installed"
}
- name: Install Rust (Windows)
if: runner.os == 'Windows'
uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
with:
rustflags: ""
cache-bin: false
- name: Install Rust
if: runner.os != 'Windows'
uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
with:
cache-bin: false
- name: Install nextest
uses: taiki-e/install-action@1ed6d7be6168f6c9046541087ff549b6bc581fdf # v2.87.2
with:
tool: nextest
- name: Test All (Workspace)
env:
RUST_LOG: debug
RUST_BACKTRACE: full
run: cargo nextest run --workspace --profile ci --locked
- name: Run doctests
env:
RUST_LOG: debug
RUST_BACKTRACE: full
run: cargo test --doc --workspace --locked
python-tests:
name: Python Tests
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 10
defaults:
run:
working-directory: crates/pcb-layout/src/scripts
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
- run: uv sync --locked
working-directory: .
- run: uv run --locked ty check
working-directory: .
- run: uv run --locked ruff check .
- run: uv run --locked ruff format --check .
- run: uv run --locked pytest lens/tests -v
check_readme:
name: Check README Sync
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check README sync
run: bin/embed-readme --check README.md