-
Notifications
You must be signed in to change notification settings - Fork 0
233 lines (204 loc) · 8.12 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: "Build manufacturing files"
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches:
- "**"
paths:
- '**.kicad_sch'
- '**.kicad_pcb'
- 'footprints.pretty/*'
- 'footprints_project_specific.pretty/*'
- 'libraries/*'
- '.github/workflows/ci.yml'
- 'config.kibot.yaml'
- 'bom.ini'
# Ignore the push event when creating tags
tags-ignore:
- 'v?[0-9]+.[0-9]+.[0-9]+'
release:
types:
- published
env:
SCHEMATIC_FILE: lm399_burnin_board.kicad_sch
PCB_FILE: lm399_burnin_board.kicad_pcb
KIBOT_CONFIG: config.kibot.yaml
jobs:
tests:
name: Run tests
runs-on: ubuntu-latest
outputs:
revision: ${{ steps.extract_sch_revision.outputs.value }}
basename: ${{ steps.repo-basename.outputs.value }}
steps:
- name: Download repository
uses: actions/checkout@v4
- name: Parse repository name
id: repo-basename
run: |
echo "value=$(basename ${{ github.repository }})" >> $GITHUB_OUTPUT
shell: bash
- name: Extract schematic revision
id: extract_sch_revision
run: |
echo "value=$(perl -0777 -ne "print /\(title_block.+\(rev \"(.+?)\"\)/sg" ${{ env.SCHEMATIC_FILE }})" >>${GITHUB_OUTPUT}
shell: bash
- name: Extract PCB revision
id: extract_pcb_revision
run: |
echo "value=$(perl -0777 -ne "print /\(title_block.+\(rev \"(.+?)\"\)/sg" ${{ env.PCB_FILE }})" >>${GITHUB_OUTPUT}
shell: bash
- name: Test if the revision number was extracted
if: steps.extract_sch_revision.outputs.value == ''
run: |
echo "::error::Failed to extract revision number from schematic file: ${{ env.SCHEMATIC_FILE }}"
exit 1
shell: bash
- name: Test schematic revision == pcb revision
if: steps.extract_sch_revision.outputs.value != steps.extract_pcb_revision.outputs.value
run: |
echo "::error::Revision number of the schematic (${{ steps.extract_sch_revision.outputs.value }}) does not match PCB (${{ steps.extract_pcb_revision.outputs.value }}) revision."
exit 1
shell: bash
- name: Test for correct git tag
if: github.ref_type == 'tag' && github.ref_name != steps.extract_sch_revision.outputs.value
run: |
echo "::error::Revision number of the schematic/PCB (${{ steps.extract_sch_revision.outputs.value }}) does not match the Github tag (${{ github.ref_name }})."
exit 1
shell: bash
ERC:
name: Run ERC
runs-on: ubuntu-latest
needs: tests
steps:
- name: Download repository
uses: actions/checkout@v4
with:
submodules: true
- name: Run ERC
uses: INTI-CMNB/KiBot@v2_dk8
with:
config: ${{ env.KIBOT_CONFIG }}
schema: ${{ env.SCHEMATIC_FILE }}
dir: generated
skip: run_drc
targets: __NONE__ # Only run preflights
- name: Upload results
uses: actions/upload-artifact@v4
with:
name: ERC_Output
path: generated
retention-days: 7
DRC:
name: Run DRC
runs-on: ubuntu-latest
needs: ERC
steps:
- name: Download repository
uses: actions/checkout@v4
with:
submodules: true
- name: Run DRC
uses: INTI-CMNB/KiBot@v2_dk8
with:
config: ${{ env.KIBOT_CONFIG }}
board: ${{ env.PCB_FILE }}
dir: generated
skip: run_erc
targets: __NONE__ # Only run preflights
- name: Upload results
uses: actions/upload-artifact@v4
with:
name: DRC_Output
path: generated
retention-days: 7
fabrication_output:
name: 'Produce fabrication outputs'
runs-on: ubuntu-latest
needs: [ERC, DRC]
strategy:
matrix:
variant: [ 'default', ]
steps:
- name: Download repository
uses: actions/checkout@v4
with:
submodules: true
- uses: INTI-CMNB/KiBot@v2_dk8
with:
config: ${{ env.KIBOT_CONFIG }}
schema: ${{ env.SCHEMATIC_FILE }}
board: ${{ env.PCB_FILE }}
skip: run_erc,run_drc
variant: ${{ matrix.variant }}
verbose: 0 # use 3 for debugging
- name: Upload bill of materials files as artifact
uses: actions/upload-artifact@v4
with:
name: manufacturing_files-bom-${{ matrix.variant }}
path: bom_files_compressed
retention-days: 7
- name: Upload schematic files as artifact
uses: actions/upload-artifact@v4
with:
name: manufacturing_files-schematics-${{ matrix.variant }}
path: schematics
retention-days: 7
- name: Upload Gerber files as artifact
uses: actions/upload-artifact@v4
with:
name: manufacturing_files-gerber-${{ matrix.variant }}
path: gerber_files_compressed
retention-days: 7
release:
name: 'Upload manufacturing files to release'
runs-on: ubuntu-latest
needs: [tests, fabrication_output]
if: github.event.action == 'published'
strategy:
matrix:
variant: [ 'default', ]
steps:
- name: Download manufacturing files artifact
uses: actions/download-artifact@v4
with:
path: manufacturing_files
pattern: manufacturing_files-*
merge-multiple: true
- name: Display structure of downloaded files
run: ls -R
working-directory: ./manufacturing_files
shell: bash
- name: Append BOM (bill of materials) as asset
if: github.event.action == 'published'
run: |
mv "./manufacturing_files/bom_(${{ matrix.variant }}).zip" ${{ needs.tests.outputs.basename }}_bom_${{ needs.tests.outputs.revision }}_${{ matrix.variant }}.zip
gh release upload ${{ github.ref_name }} ${{ needs.tests.outputs.basename }}_bom_${{ needs.tests.outputs.revision }}_${{ matrix.variant }}.zip#"Bill of materials for the ${{ matrix.variant }} variant (zip)" --repo ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
- name: Append schematics as asset
if: github.event.action == 'published'
run: |
mv "./manufacturing_files/$(basename ${{ env.SCHEMATIC_FILE }} .kicad_sch)_schematics_${{ needs.tests.outputs.revision }}_(${{ matrix.variant }}).pdf" ${{ needs.tests.outputs.basename }}_schematics_${{ needs.tests.outputs.revision }}_${{ matrix.variant }}.pdf
gh release upload ${{ github.ref_name }} ${{ needs.tests.outputs.basename }}_schematics_${{ needs.tests.outputs.revision }}_${{ matrix.variant }}.pdf#"Schematics for the ${{ matrix.variant }} variant (pdf)" --repo ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
- name: Append position files as asset
if: github.event.action == 'published'
run: |
mv "./manufacturing_files/pos_(${{ matrix.variant }}).zip" ${{ needs.tests.outputs.basename }}_position_${{ needs.tests.outputs.revision }}_${{ matrix.variant }}.zip
gh release upload ${{ github.ref_name }} ${{ needs.tests.outputs.basename }}_position_${{ needs.tests.outputs.revision }}_${{ matrix.variant }}.zip#"Pick & Place position files for the ${{ matrix.variant }} variant (zip)" --repo ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
- name: Append Gerber files as asset
if: github.event.action == 'published' && matrix.variant == 'default'
run: |
mv "./manufacturing_files/gerbers_(${{ matrix.variant }}).zip" ${{ needs.tests.outputs.basename }}_gerber_${{ needs.tests.outputs.revision }}_all.zip
gh release upload ${{ github.ref_name }} ${{ needs.tests.outputs.basename }}_gerber_${{ needs.tests.outputs.revision }}_all.zip#"Gerber files for all variants (zip)" --repo ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash