Skip to content

Commit 5d26e45

Browse files
Merged branch main into RFID
2 parents 1147fa5 + 85f0f3c commit 5d26e45

25 files changed

+9643
-747
lines changed
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
name: KiCad CI
2+
3+
on:
4+
push:
5+
paths:
6+
- 'pmod/**'
7+
- '!pmod/assets/**'
8+
- '!pmod/template/**'
9+
pull_request:
10+
paths:
11+
- 'pmod/**'
12+
- '!pmod/assets/**'
13+
- '!pmod/template/**'
14+
workflow_dispatch:
15+
inputs:
16+
project_filter:
17+
description: 'Filter by specific project (optional)'
18+
required: false
19+
default: ''
20+
type: string
21+
22+
jobs:
23+
find-changed-projects:
24+
runs-on: ubuntu-latest
25+
outputs:
26+
projects: ${{ steps.filter-projects.outputs.projects }}
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0 # Fetch all history for proper diffing
32+
33+
- name: Find changed KiCad projects
34+
id: filter-projects
35+
run: |
36+
echo "Checking for changed files in pmod directory..."
37+
38+
# Get the list of changed files
39+
if [ "${{ github.event_name }}" == "push" ]; then
40+
# For push events, compare with previous commit
41+
if [ -n "${{ github.event.before }}" ]; then
42+
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} -- "pmod/")
43+
else
44+
# For initial push or force push, get all files
45+
CHANGED_FILES=$(git log -1 --name-only --oneline ${{ github.sha }} -- "pmod/")
46+
fi
47+
elif [ "${{ github.event_name }}" == "pull_request" ]; then
48+
# For PR events, compare with base branch
49+
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- "pmod/")
50+
else
51+
# For workflow_dispatch or other events, process all projects
52+
echo "Manual trigger - processing all projects"
53+
PROJECTS=$(find pmod -name "*.kicad_pro" -path "*/KiCad/*" | sed 's|/KiCad/.*\.kicad_pro||' | sort -u)
54+
if [ -n "${{ github.event.inputs.project_filter }}" ]; then
55+
echo "Filtering for project: ${{ github.event.inputs.project_filter }}"
56+
PROJECTS=$(echo "$PROJECTS" | grep "${{ github.event.inputs.project_filter }}" || true)
57+
fi
58+
if [ -n "$PROJECTS" ]; then
59+
# Convert to proper JSON array
60+
JSON_PROJECTS=$(echo "$PROJECTS" | jq -R -s -c 'split("\n") | map(select(. != ""))')
61+
echo "projects=$JSON_PROJECTS" >> $GITHUB_OUTPUT
62+
echo "Manual projects: $JSON_PROJECTS"
63+
else
64+
echo 'projects=[]' >> $GITHUB_OUTPUT
65+
fi
66+
exit 0
67+
fi
68+
69+
echo "Changed files:"
70+
echo "$CHANGED_FILES"
71+
72+
# If no changed files found, exit early
73+
if [ -z "$CHANGED_FILES" ]; then
74+
echo "No changed files found in pmod directory"
75+
echo 'projects=[]' >> $GITHUB_OUTPUT
76+
exit 0
77+
fi
78+
79+
# Extract unique project directories from changed files
80+
CHANGED_PROJECTS=()
81+
while IFS= read -r file; do
82+
if [[ "$file" =~ ^pmod/([^/]+)/ ]]; then
83+
PROJECT_NAME="${BASH_REMATCH[1]}"
84+
# Skip blacklisted directories
85+
if [[ "$PROJECT_NAME" != "assets" && "$PROJECT_NAME" != "template" ]]; then
86+
CHANGED_PROJECTS+=("pmod/$PROJECT_NAME")
87+
fi
88+
fi
89+
done <<< "$CHANGED_FILES"
90+
91+
# Remove duplicates and convert to JSON
92+
if [ ${#CHANGED_PROJECTS[@]} -gt 0 ]; then
93+
UNIQUE_PROJECTS=($(printf "%s\n" "${CHANGED_PROJECTS[@]}" | sort -u))
94+
# Create proper JSON array
95+
JSON_ARRAY="["
96+
for i in "${!UNIQUE_PROJECTS[@]}"; do
97+
if [ $i -gt 0 ]; then
98+
JSON_ARRAY+=","
99+
fi
100+
JSON_ARRAY+="\"${UNIQUE_PROJECTS[$i]}\""
101+
done
102+
JSON_ARRAY+="]"
103+
echo "Changed projects: $JSON_ARRAY"
104+
echo "projects=$JSON_ARRAY" >> $GITHUB_OUTPUT
105+
else
106+
echo "No changed projects found"
107+
echo 'projects=[]' >> $GITHUB_OUTPUT
108+
fi
109+
110+
kicad-checks:
111+
needs: find-changed-projects
112+
if: needs.find-changed-projects.outputs.projects != '[]'
113+
runs-on: ubuntu-latest
114+
strategy:
115+
matrix:
116+
project: ${{ fromJson(needs.find-changed-projects.outputs.projects) }}
117+
name: KiCad DRC and 3D Export - ${{ matrix.project }}
118+
steps:
119+
- name: Checkout
120+
uses: actions/checkout@v4
121+
122+
- name: Extract project name
123+
id: project-info
124+
run: |
125+
PROJECT_NAME=$(basename "${{ matrix.project }}")
126+
echo "project_name=$PROJECT_NAME" >> $GITHUB_OUTPUT
127+
echo "Processing project: ${{ matrix.project }}"
128+
echo "Project name: $PROJECT_NAME"
129+
130+
- name: Find project file
131+
id: project-file
132+
run: |
133+
KICAD_DIR="${{ matrix.project }}/KiCad"
134+
if [ -d "$KICAD_DIR" ]; then
135+
PROJECT_FILE=$(find "$KICAD_DIR" -name "*.kicad_pro" -exec basename {} .kicad_pro \; | head -1)
136+
if [ -n "$PROJECT_FILE" ]; then
137+
echo "project_file=$PROJECT_FILE" >> $GITHUB_OUTPUT
138+
echo "kicad_dir=$KICAD_DIR" >> $GITHUB_OUTPUT
139+
else
140+
echo "No KiCad project file found in $KICAD_DIR"
141+
exit 1
142+
fi
143+
else
144+
echo "KiCad directory not found: $KICAD_DIR"
145+
exit 1
146+
fi
147+
148+
- name: Create assets directory
149+
run: |
150+
mkdir -p "${{ matrix.project }}/assets"
151+
152+
- name: Run KiCad DRC (continue on error)
153+
uses: sparkengineering/kicad-action@v4
154+
with:
155+
kicad_pcb: "${{ steps.project-file.outputs.kicad_dir }}/${{ steps.project-file.outputs.project_file }}.kicad_pcb"
156+
pcb_drc: true
157+
continue-on-error: true
158+
159+
- name: Generate 3D render
160+
uses: sparkengineering/kicad-action@v4
161+
with:
162+
kicad_pcb: "${{ steps.project-file.outputs.kicad_dir }}/${{ steps.project-file.outputs.project_file }}.kicad_pcb"
163+
pcb_image: true
164+
pcb_image_path: "${{ matrix.project }}/assets/default.png"
165+
166+
- name: Upload DRC report if failed
167+
uses: actions/upload-artifact@v4
168+
if: ${{ failure() }}
169+
with:
170+
name: drc-report-${{ steps.project-info.outputs.project_name }}
171+
path: ${{ steps.project-file.outputs.kicad_dir }}/drc.rpt
172+
173+
- name: Upload 3D render
174+
uses: actions/upload-artifact@v4
175+
if: ${{ !cancelled() }}
176+
with:
177+
name: 3d-render-${{ steps.project-info.outputs.project_name }}
178+
path: ${{ matrix.project }}/assets/default.png

.github/workflows/full-check.yml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
name: KiCad Full Repository Check
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
force_all:
7+
description: 'Run on all projects (ignore changes)'
8+
required: false
9+
default: false
10+
type: boolean
11+
generate_renders:
12+
description: 'Generate 3D render images'
13+
required: false
14+
default: true
15+
type: boolean
16+
17+
jobs:
18+
find-all-projects:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
projects: ${{ steps.find-projects.outputs.projects }}
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Find all KiCad projects
27+
id: find-projects
28+
run: |
29+
echo "Finding all KiCad projects in repository..."
30+
31+
# Find all KiCad projects, excluding blacklisted directories
32+
PROJECTS=$(find pmod -name "*.kicad_pro" -path "*/KiCad/*" | sed 's|/KiCad/.*\.kicad_pro||' | sort -u)
33+
34+
# Filter out blacklisted directories
35+
FILTERED_PROJECTS=()
36+
while IFS= read -r project; do
37+
PROJECT_NAME=$(basename "$project")
38+
if [[ "$PROJECT_NAME" != "assets" && "$PROJECT_NAME" != "template" ]]; then
39+
FILTERED_PROJECTS+=("$project")
40+
fi
41+
done <<< "$PROJECTS"
42+
43+
# Convert to JSON array
44+
if [ ${#FILTERED_PROJECTS[@]} -gt 0 ]; then
45+
JSON_ARRAY="["
46+
for i in "${!FILTERED_PROJECTS[@]}"; do
47+
if [ $i -gt 0 ]; then
48+
JSON_ARRAY+=","
49+
fi
50+
JSON_ARRAY+="\"${FILTERED_PROJECTS[$i]}\""
51+
done
52+
JSON_ARRAY+="]"
53+
echo "Found projects: $JSON_ARRAY"
54+
echo "projects=$JSON_ARRAY" >> $GITHUB_OUTPUT
55+
else
56+
echo "No KiCad projects found"
57+
echo 'projects=[]' >> $GITHUB_OUTPUT
58+
fi
59+
60+
kicad-full-check:
61+
needs: find-all-projects
62+
if: needs.find-all-projects.outputs.projects != '[]'
63+
runs-on: ubuntu-latest
64+
strategy:
65+
matrix:
66+
project: ${{ fromJson(needs.find-all-projects.outputs.projects) }}
67+
name: KiCad Full Check - ${{ matrix.project }}
68+
steps:
69+
- name: Checkout
70+
uses: actions/checkout@v4
71+
72+
- name: Extract project name
73+
id: project-info
74+
run: |
75+
PROJECT_NAME=$(basename "${{ matrix.project }}")
76+
echo "project_name=$PROJECT_NAME" >> $GITHUB_OUTPUT
77+
echo "Processing project: ${{ matrix.project }}"
78+
echo "Project name: $PROJECT_NAME"
79+
echo "Generate renders: ${{ github.event.inputs.generate_renders }}"
80+
81+
- name: Find project file
82+
id: project-file
83+
run: |
84+
KICAD_DIR="${{ matrix.project }}/KiCad"
85+
if [ -d "$KICAD_DIR" ]; then
86+
PROJECT_FILE=$(find "$KICAD_DIR" -name "*.kicad_pro" -exec basename {} .kicad_pro \; | head -1)
87+
if [ -n "$PROJECT_FILE" ]; then
88+
echo "project_file=$PROJECT_FILE" >> $GITHUB_OUTPUT
89+
echo "kicad_dir=$KICAD_DIR" >> $GITHUB_OUTPUT
90+
echo "Found KiCad project: $PROJECT_FILE"
91+
else
92+
echo "No KiCad project file found in $KICAD_DIR"
93+
exit 1
94+
fi
95+
else
96+
echo "KiCad directory not found: $KICAD_DIR"
97+
exit 1
98+
fi
99+
100+
- name: Create assets directory
101+
if: ${{ github.event.inputs.generate_renders == 'true' }}
102+
run: |
103+
mkdir -p "${{ matrix.project }}/assets"
104+
echo "Created assets directory for ${{ matrix.project }}"
105+
106+
- name: Run KiCad DRC
107+
uses: sparkengineering/kicad-action@v4
108+
with:
109+
kicad_pcb: "${{ steps.project-file.outputs.kicad_dir }}/${{ steps.project-file.outputs.project_file }}.kicad_pcb"
110+
pcb_drc: true
111+
continue-on-error: true
112+
113+
- name: Generate 3D render
114+
if: ${{ github.event.inputs.generate_renders == 'true' }}
115+
uses: sparkengineering/kicad-action@v4
116+
with:
117+
kicad_pcb: "${{ steps.project-file.outputs.kicad_dir }}/${{ steps.project-file.outputs.project_file }}.kicad_pcb"
118+
pcb_image: true
119+
pcb_image_path: "${{ matrix.project }}/assets/default.png"
120+
121+
- name: Check if 3D render was created
122+
if: ${{ github.event.inputs.generate_renders == 'true' }}
123+
id: check-render
124+
run: |
125+
if [ -f "${{ matrix.project }}/assets/default.png" ]; then
126+
echo "3D render successfully created"
127+
echo "render_created=true" >> $GITHUB_OUTPUT
128+
else
129+
echo "3D render was not created"
130+
echo "render_created=false" >> $GITHUB_OUTPUT
131+
fi
132+
133+
- name: Upload DRC report
134+
uses: actions/upload-artifact@v4
135+
if: always()
136+
with:
137+
name: drc-report-${{ steps.project-info.outputs.project_name }}
138+
path: ${{ steps.project-file.outputs.kicad_dir }}/drc.rpt
139+
140+
- name: Upload 3D render
141+
if: ${{ github.event.inputs.generate_renders == 'true' && steps.check-render.outputs.render_created == 'true' }}
142+
uses: actions/upload-artifact@v4
143+
with:
144+
name: 3d-render-${{ steps.project-info.outputs.project_name }}
145+
path: ${{ matrix.project }}/assets/default.png
146+
147+
summary:
148+
needs: [find-all-projects, kicad-full-check]
149+
if: always()
150+
runs-on: ubuntu-latest
151+
name: Summary
152+
steps:
153+
- name: Print summary
154+
run: |
155+
echo "=== KiCad Full Repository Check Complete ==="
156+
echo "Total projects processed: ${{ fromJson(needs.find-all-projects.outputs.projects).length }}"
157+
echo "Generate renders: ${{ github.event.inputs.generate_renders }}"
158+
echo "All projects: ${{ needs.find-all-projects.outputs.projects }}"
159+
echo "============================================"

.github/workflows/test-ghpages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ jobs:
4040
run: pip install -r requirements.txt
4141

4242
- name: Build documentation
43-
run: mkdocs build --strict
43+
run: mkdocs build

0 commit comments

Comments
 (0)