Skip to content

fix: adjust power net labels #23

fix: adjust power net labels

fix: adjust power net labels #23

name: Build Schematic
on:
pull_request:
types: [opened, synchronize]
paths:
- '**.kicad_sch'
jobs:
expose-pr-number:
name: Expose PR Number
runs-on: ubuntu-latest
steps:
- name: Expose PR ID
run: echo "${{ github.event.number }}" > pr-number.txt
- name: Expose commit SHA
run: echo "${{ github.event.pull_request.head.sha }}" > commit-sha.txt
- name: Upload PR ID
uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr-number.txt
- name: Upload commit SHA
uses: actions/upload-artifact@v4
with:
name: commit_sha
path: commit-sha.txt
build:
name: Reports and PDF Diffs
runs-on: ubuntu-latest
needs: expose-pr-number
steps:
- name: Checkout current branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get current user id
id: user
run: |
echo "uid=$(id -u)" >> $GITHUB_OUTPUT
echo "gid=$(id -g)" >> $GITHUB_OUTPUT
- name: Run ERC and generate PDFs
uses: addnab/docker-run-action@v3
with:
image: cloudypadmal/pslab-mini-kicad:1.0.0
options: >-
-v ${{ github.workspace }}:/workspace
-w /workspace
--user ${{ steps.user.outputs.uid }}:${{ steps.user.outputs.gid }}
run: |
export HOME=/workspace
mkdir -p reports/schematics
rm -rf parent-repo
echo "Running ERC ===============================================>"
> reports/erc-report.txt
for sch in $(find . -name '*.kicad_sch'); do
outfile="reports/erc_$(basename "$sch" .kicad_sch).txt"
kicad-cli sch erc "$sch" --output "$outfile"
echo "=== ERC Report for $(basename "$sch") ===" >> reports/erc-report.txt
cat "$outfile" >> reports/erc-report.txt
echo "" >> reports/erc-report.txt
rm -f "$outfile"
done
echo "Generating PDFs for schematics ============================>"
for sch in $(find . -name '*.kicad_sch'); do
outfile="reports/schematics/$(basename "$sch" .kicad_sch).pdf"
kicad-cli sch export pdf "$sch" --output "$outfile"
pdftoppm "$outfile" "reports/schematics/$(basename "$outfile" .pdf)-schematic" -png -singlefile
done
echo "Fetching parent repository ================================"
git clone https://github.com/fossasia/pslab-mini-hardware.git parent-repo --depth 1 --branch main
echo "Generating PDFs for parent schematics =====================>"
for sch in $(find parent-repo -name '*.kicad_sch'); do
outfile="reports/schematics/$(basename "$sch" .kicad_sch)-old.pdf"
kicad-cli sch export pdf "$sch" --output "$outfile"
done
echo "Compare schematics with parent repository ===================>"
for old_sch in $(find reports/schematics/ -name '*-old.pdf'); do
base_name="$(basename "$old_sch" -old.pdf)"
current_pdf="reports/schematics/${base_name}.pdf"
old_pdf="reports/schematics/${base_name}-old.pdf"
diff_pdf="reports/schematics/${base_name}-schematic-diff.pdf"
if [ -f "$old_pdf" ] && [ -f "$current_pdf" ]; then
xvfb-run diff-pdf --output-diff="$diff_pdf" -g --skip-identical "$old_pdf" "$current_pdf"
if gs -dBATCH -dNOPAUSE -dQUIET -sDEVICE=bbox "$diff_pdf" 2>&1 | grep -q "BoundingBox: 0 0 0 0"; then
echo "No differences found in $base_name"
rm -f "$diff_pdf"
else
echo "Creating PDF diff for $base_name"
pdftoppm "$diff_pdf" "reports/schematics/${base_name}-schematic-diff" -png -singlefile
fi
rm -rf "$old_pdf"
else
echo "No PDF found for ${base_name}"
fi
done
- name: Upload ERC reports
uses: actions/upload-artifact@v4
with:
name: erc-report
path: reports/erc-report.txt
- name: Upload schematics
uses: actions/upload-artifact@v4
with:
name: schematics
path: reports/schematics/*
- name: Build status from ERC report
run: |
errors=$(grep -oP 'Errors\s+\K[0-9]+' reports/erc-report.txt)
if [ "$errors" -ne 0 ]; then
echo "❌ ERC errors detected"
cat reports/erc-report.txt
exit 1
else
echo "✅ No ERC errors detected."
fi