Files
Akhil Velagapudi 58549fb924 [DIO-301] Add pcb vendor, pcb build --offline (#72)
* Update Cargo.lock

Signed-off-by: akhilles <akhilvelagapudi@gmail.com>

* Add pcb vendor

Signed-off-by: akhilles <akhilvelagapudi@gmail.com>

* Copy pcb.toml to release if it exists

Signed-off-by: akhilles <akhilvelagapudi@gmail.com>

* Use vendor dir in resolver

Add --offline support to build, layout.
Standardize behavior of find_workspace_root. Most of the callsites would
fallback on parent dir of target .zen file. We should just do that
universally to reduce conditional code paths.

Add an option to the resolve to not use the vendor dir in case that's
useful in some cases.

Signed-off-by: akhilles <akhilvelagapudi@gmail.com>

* Drop vendor alias

Signed-off-by: akhilles <akhilvelagapudi@gmail.com>

* Only support pcb vendor in pcb.toml workspaces

Attempting to resolve a common workspace root from multiple zen files in
a dir without pcb.toml just got way too complicated. We can add support
for this in the future if needed.

Signed-off-by: akhilles <akhilvelagapudi@gmail.com>

* Canonicalize zen_path

Signed-off-by: akhilles <akhilvelagapudi@gmail.com>

---------

Signed-off-by: akhilles <akhilvelagapudi@gmail.com>
2025-08-15 12:07:51 -07:00

149 lines
4.6 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-latest
- name: macOS
runs-on: macos-latest
- name: macOS 14
runs-on: macos-14
- name: Ubuntu
runs-on: ubuntu-latest
container:
image: kicad/kicad:9.0.3 # Keep in sync with KICAD_VERSION
options: --user root
steps:
- uses: actions/checkout@v3
- 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: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- 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: Test CLI (E2E)
env:
RUST_LOG: info,pcb::release=debug,pcb::bom=debug
run: |
# Test BOM generation on example project
cargo run -- bom examples/PhaseDriver/PhaseDriver.zen -f json
# Test simple workspace (no pcb.toml)
cargo run -- bom test-workspaces/simple/boards/TestBoard.zen
cargo run -- release test-workspaces/simple/boards/TestBoard.zen
# 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: Test stdlib builds
shell: bash
run: |
# Save current directory
ORIGINAL_DIR=$(pwd)
# Clone the stdlib repository
git clone https://github.com/diodeinc/stdlib.git /tmp/stdlib
# Find all .star and .zen files and build them
cd /tmp/stdlib
find . -name "*.star" -o -name "*.zen" | while read -r file; do
echo "Building $file..."
if ! (cd "$ORIGINAL_DIR" && cargo run -p pcb -- build "/tmp/stdlib/$file"); then
echo "Failed to build $file"
exit 1
fi
done
echo "All stdlib files built successfully!"