-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
388 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
name: Build production files for a specific PCB | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
name: | ||
description: "Name of the folder containing the PCB files. The generated production files will be at 'release/<name>'." | ||
required: true | ||
type: string | ||
overwrite: | ||
description: "Overwrite existing production files for this board" | ||
required: false | ||
type: boolean | ||
default: false | ||
sch_file: | ||
description: "Main .kicad_sch file name, defaults to '<name>.kicad_sch'" | ||
required: false | ||
type: string | ||
pcb_file: | ||
description: "Main .kicad_pcb file name, defaults to '<name>.kicad_pcb'" | ||
required: false | ||
type: string | ||
version: | ||
description: "Version number to include in info file" | ||
required: false | ||
type: string | ||
default: "v1.0" | ||
fabrication: | ||
description: "Manufacturer/fabrication provider name to include in info file" | ||
required: false | ||
type: string | ||
n_layers: | ||
description: "Number of layers to include in info file (note, gerbers are generated for every layer regardless of this setting)" | ||
required: false | ||
type: number | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
init: | ||
name: Initialise directory in release/ folder and check files exist | ||
runs-on: ubuntu-24.04 | ||
|
||
outputs: | ||
release_dir: ${{ steps.format.outputs.release_dir }} | ||
sch_location: ${{ steps.format.outputs.sch_location }} | ||
pcb_location: ${{ steps.format.outputs.pcb_location }} | ||
|
||
steps: | ||
- name: Checkout to latest commit | ||
uses: actions/checkout@v4 | ||
|
||
- name: Format names | ||
id: format | ||
env: | ||
NAME: ${{ inputs.name }} | ||
SCH_FILE: ${{ inputs.sch_file }} | ||
PCB_FILE: ${{ inputs.pcb_file }} | ||
run: | | ||
echo "release_dir=\"release/${NAME}\"" >> "$GITHUB_OUTPUT" | ||
echo "sch_location=\"${NAME}/${SCH_FILE}\"" >> "$GITHUB_OUTPUT" | ||
echo "pcb_location=\"${NAME}/${PCB_FILE}\"" >> "$GITHUB_OUTPUT" | ||
- name: Check schematic exists | ||
env: | ||
SCH_LOCATION: ${{ steps.format.outputs.sch_location }} | ||
run: test -f "$SCH_LOCATION" | ||
|
||
- name: Check PCB exists | ||
env: | ||
PCB_LOCATION: ${{ steps.format.outputs.pcb_location }} | ||
run: test -f "$PCB_LOCATION" | ||
|
||
- name: Check for existing release directory | ||
if: inputs.overwrite == 'false' | ||
env: | ||
RELEASE_DIR: ${{ steps.format.outputs.release_dir }} | ||
run: test ! -e "$RELEASE_DIR" | ||
|
||
- name: Setup release directory | ||
env: | ||
RELEASE_DIR: ${{ steps.format.outputs.release_dir }} | ||
run: | | ||
rm -f "$RELEASE_DIR" | ||
mkdir -p "$RELEASE_DIR" | ||
gen_files: | ||
name: Generate gerbers, schematic PDF and interactive BOM | ||
runs-on: ubuntu-24.04 | ||
needs: init | ||
|
||
permissions: | ||
contents: write | ||
|
||
container: | ||
image: maartin0/kicadutils | ||
|
||
steps: | ||
- name: Checkout to latest commit | ||
uses: actions/checkout@v4 | ||
|
||
- name: Add version to info | ||
if: inputs.version != '' | ||
env: | ||
RELEASE_DIR: ${{ needs.init.outputs.release_dir }} | ||
VERSION: ${{ inputs.version }} | ||
run: echo "version=${VERSION}" >> "${RELEASE_DIR}/info" | ||
|
||
- name: Add fabrication to info | ||
if: inputs.fabrication != '' | ||
env: | ||
RELEASE_DIR: ${{ needs.init.outputs.release_dir }} | ||
FABRICATION: ${{ inputs.fabrication }} | ||
run: echo "fabrication=${FABRICATION}" >> "${RELEASE_DIR}/info" | ||
|
||
- name: Add layers to info | ||
if: inputs.n_layers != '' | ||
env: | ||
RELEASE_DIR: ${{ needs.init.outputs.release_dir }} | ||
LAYERS: ${{ inputs.n_layers }} | ||
run: echo "layers=${LAYERS}" >> "${RELEASE_DIR}/info" | ||
|
||
- name: Generate gerbers | ||
run: | | ||
echo "TODO" | ||
- name: Generate schematic PDF | ||
run: | | ||
echo "TODO" | ||
- name: Generate interactive BOM | ||
run: | | ||
echo "TODO" | ||
- name: Commit changes | ||
env: | ||
NAME: ${{ inputs.name }} | ||
run: | | ||
git add release/ | ||
git config --global user.name 'github-actions' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git commit -m "Automatically generate $NAME production files" | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Test all projects | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
|
||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
defaults: | ||
run: | ||
shell: "bash" # We're using the bash-specific set -o pipefail | ||
|
||
jobs: | ||
test_erc_drc: | ||
name: Run KiCad ERC(s) and DRC(s) | ||
runs-on: ubuntu-24.04 | ||
container: | ||
image: maartin0/kicadutils | ||
|
||
steps: | ||
- name: Checkout to latest commit | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run ERC(s) | ||
run: | | ||
set -eo pipefail | ||
find . -name "*.kicad_sch" -print0 | xargs -0 -n1 sh -c './bin/test/erc.sh "$0" || exit 255' | ||
- name: Run DRC(s) | ||
run: | | ||
set -eo pipefail | ||
find . -name "*.kicad_pcb" -print0 | xargs -0 -n1 sh -c './bin/test/drc.sh "$0" || exit 255' | ||
test_relative: | ||
name: Check for non-relative paths | ||
runs-on: ubuntu-24.04 | ||
|
||
steps: | ||
- name: Check for non-relative paths | ||
run: | | ||
set -eo pipefail | ||
find . -name "*-lib-table" -print0 | xargs -0 -n1 sh -c './bin/test/relative.sh "$0" || exit 255' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Test changed files | ||
|
||
on: [push, pull_request] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
changes: | ||
name: Get changed files | ||
runs-on: ubuntu-24.04 | ||
|
||
steps: | ||
- name: Checkout to latest commit | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@v45 | ||
|
||
outputs: | ||
changed: ${{ steps.changed-files.outputs.any_changed }} | ||
all_changed_files: ${{ steps.changed-files.outputs.all_changed_files }} | ||
|
||
test_erc_drc: | ||
name: Run KiCad ERC(s) and DRC(s) | ||
runs-on: ubuntu-24.04 | ||
needs: changes | ||
if: needs.changes.outputs.changed == 'true' | ||
container: | ||
image: maartin0/kicadutils | ||
|
||
steps: | ||
- name: Checkout to latest commit | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run ERC(s) | ||
env: | ||
ALL_CHANGED_FILES: ${{ needs.changes.outputs.all_changed_files }} | ||
run: | | ||
for file in "${ALL_CHANGED_FILES}"; do | ||
if echo "$file" | grep ".kicad_sch$" >/dev/null; then | ||
./bin/test/erc.sh "$file" | ||
fi | ||
done | ||
- name: Run DRC(s) | ||
env: | ||
ALL_CHANGED_FILES: ${{ needs.changes.outputs.all_changed_files }} | ||
run: | | ||
for file in "${ALL_CHANGED_FILES}"; do | ||
if echo "$file" | grep ".kicad_pcb$" >/dev/null; then | ||
./bin/test/drc.sh "$file" | ||
fi | ||
done | ||
test_relative: | ||
name: Check for non-relative paths | ||
runs-on: ubuntu-24.04 | ||
needs: changes | ||
if: needs.changes.outputs.changed == 'true' | ||
|
||
steps: | ||
- name: Check for non-relative paths | ||
env: | ||
ALL_CHANGED_FILES: ${{ needs.changes.outputs.all_changed_files }} | ||
run: | | ||
for file in "${ALL_CHANGED_FILES}"; do | ||
if echo "$file" | grep "\-lib-table$" >/dev/null; then | ||
./bin/test/relative.sh "$file" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM ubuntu:24.04 | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y software-properties-common zip unzip python3 python3-pip nodejs npm git | ||
RUN add-apt-repository -y ppa:kicad/kicad-9.0-releases | ||
RUN apt-get update | ||
RUN apt-get install -y kicad | ||
RUN python3 -m pip install InteractiveHtmlBom --break-system-packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
if ! [ -f "Dockerfile" ]; then | ||
echo "Error: Make sure you're running this in the same directory as the Dockerfile" | ||
exit 1 | ||
fi | ||
|
||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: $0 <username>/<package name>" | ||
exit 1 | ||
fi | ||
|
||
docker build -t "$1" . | ||
docker push "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
log="$(date +"drc-log-%Y.%m.%d-%H.%M.%S.json")" | ||
|
||
cleanup() { | ||
rm -f "$log" | ||
} | ||
|
||
die() { | ||
echo "$*" | ||
cleanup | ||
exit 1 | ||
} | ||
|
||
path="$1" | ||
|
||
if ! [ -f "$path" ]; then | ||
die "'$path' does not exist" | ||
fi | ||
|
||
ext="$(basename "$path" | sed 's/^.*\.\(.*\)$/\1/')" | ||
|
||
if [ "$ext" != "kicad_pcb" ]; then | ||
die "File extension must be 'kicad_pcb'" | ||
fi | ||
|
||
if ! kicad-cli pcb drc "$path" --output "$log" --severity-error --exit-code-violations; then | ||
cat "$log" | ||
die "Non-zero DRC errors" | ||
fi | ||
|
||
cleanup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
log="$(date +"erc-log-%Y.%m.%d-%H.%M.%S.json")" | ||
|
||
cleanup() { | ||
rm -f "$log" | ||
} | ||
|
||
die() { | ||
echo "$*" | ||
cleanup | ||
exit 1 | ||
} | ||
|
||
path="$1" | ||
|
||
if ! [ -f "$path" ]; then | ||
die "'$path' does not exist" | ||
fi | ||
|
||
ext="$(basename "$path" | sed 's/^.*\.\(.*\)$/\1/')" | ||
|
||
if [ "$ext" != "kicad_sch" ]; then | ||
die "File extension must be 'kicad_sch'" | ||
fi | ||
|
||
if ! kicad-cli sch erc "$path" --output "$log" --severity-error --exit-code-violations; then | ||
cat "$log" | ||
die "Non-zero ERC errors" | ||
fi | ||
|
||
cleanup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
log="$(date +"rel-log-%Y.%m.%d-%H.%M.%S.json")" | ||
|
||
cleanup() { | ||
rm -f "$log" | ||
} | ||
|
||
die() { | ||
if [ -n "$*" ]; then | ||
echo "$*" | ||
fi | ||
cleanup | ||
exit 1 | ||
} | ||
|
||
path="$1" | ||
|
||
if ! [ -f "$path" ]; then | ||
die "'$path' does not exist" | ||
fi | ||
|
||
if ! echo "$path" | grep "\-lib-table$" >/dev/null; then | ||
die "expected filename ending in '-lib-table'" | ||
fi | ||
|
||
if grep "^ *(lib.*(uri \"[^\$]" "$path" > "$log"; then | ||
echo "'$path' appears to not use a relative path:" | ||
cat "$log" | ||
die | ||
fi | ||
|
||
cleanup |