-
Notifications
You must be signed in to change notification settings - Fork 1
233 lines (211 loc) · 6.91 KB
/
build-test.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 & test
on:
push:
branches: main
paths:
- '**.py'
- '**.go'
- '**.js'
- '**.ts'
- 'ORIGINALVOXEL-3.obj'
- .github/workflows/build-test.yml
- requirements.txt
- package.json
pull_request:
paths:
- '**.py'
- '**.go'
- '**.js'
- '**.ts'
- 'ORIGINALVOXEL-3.obj'
- .github/workflows/build-test.yml
- requirements.txt
- package.json
workflow_dispatch:
inputs:
jobs:
build-test-go-versions:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.18]
test-path:
- ./tutorials/conversion_obj_step
- ./tutorials/conversion_obj_stl
- ./tutorials/get_mass_volume
- ./samples/convert_file
- ./samples/file_density
- ./samples/file_mass
- ./samples/file_volume
- ./samples/file_center_of_mass
- ./samples/file_surface_area
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Set up Go ${{ matrix.go-version }}
uses: actions/[email protected]
with:
go-version: ${{ matrix.go-version }}
- name: Run scripts
shell: bash
run: |
FILE=$(find ${{ matrix.test-path }} -name "*.go")
go run $FILE
env:
KITTYCAD_API_TOKEN: ${{secrets.KITTYCAD_API_TOKEN}}
build-test-python-versions:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
test-path:
- ./tutorials/conversion_obj_step
- ./tutorials/conversion_obj_stl
- ./tutorials/get_mass_volume
- ./tutorials/getting_started
- ./tutorials/modeling_websocket
- ./tutorials/beginner_tutorial
- ./tutorials/websocket_tutorial
- ./samples/convert_file
- ./samples/file_density
- ./samples/file_mass
- ./samples/file_volume
- ./samples/file_center_of_mass
- ./samples/file_surface_area
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
shell: bash
run: |
pip install -r requirements.txt
- name: Run scripts
shell: bash
run: |
p=${{ matrix.test-path }}
for f in $(find "$p" -name "*.*.*" | sed 's/.*[0-9]*_\(.*\)\.part/\1/' | sort -u | uniq);
do
cd "$p";
cat $(ls *$f.part | sort -g) > "$f";
cd -;
done
FILE=$(find ${{ matrix.test-path }} -name "*.py")
python $FILE
env:
KITTYCAD_API_TOKEN: ${{secrets.KITTYCAD_API_TOKEN}}
build-test-js-versions:
runs-on: ubuntu-latest
strategy:
matrix:
node: [16, 18]
test-path:
- ./tutorials/beginner_tutorial
- ./samples/convert_file
- ./samples/file_density
- ./samples/file_mass
- ./samples/file_volume
- ./samples/file_center_of_mass
- ./samples/file_surface_area
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Set up node ${{ matrix.python-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'yarn'
- run: yarn install
- name: Run scripts
shell: bash
run: |
FILE=$(find ${{ matrix.test-path }} -name "*.js")
node $FILE
env:
KITTYCAD_TOKEN: ${{secrets.KITTYCAD_API_TOKEN}}
commit-script-outputs:
# Using the python script to commit the output of the scripts
# The go scripts should have the same output
# This implicitly makes python the source of truth for the outputs
needs: [build-test-python-versions]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
lfs: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
shell: bash
run: |
pip install -r requirements.txt
- name: remove previous outputs
shell: bash
run: |
rm -rf tutorials/**/*output.{stl,obj,step,json}
rm -rf samples/**/*output.{stl,obj,step,json}
- name: test outputs
run: |
files=( "./tutorials/conversion_obj_step"
"./tutorials/conversion_obj_stl"
"./tutorials/get_mass_volume"
"./tutorials/getting_started"
"./samples/convert_file"
"./samples/file_density"
"./samples/file_mass"
"./samples/file_volume"
"./samples/file_center_of_mass"
"./samples/file_surface_area"
)
for FILE in "${files[@]}"
do
FULL_FILE=$(find $FILE -name "*.py")
python $FULL_FILE
mv output.* $FILE
OUTPUT_FILE=$(find $FILE -name output.*)
if [[ $OUTPUT_FILE == *.step ]]
# current date is added to step file, meaning there will always be a diff, clamping this to a consistent date to prevent this
then
sed -i 's/20..-..-..T..:..:../2022-00-00T00:00:00/g' $OUTPUT_FILE
fi
if [ $(find $FILE -maxdepth 2 -name 'output.*' -print -quit ) ]; then
echo "$FILE output was created."
else
echo "better luck next time $FILE output was NOT created"
exit 1
fi
echo "done $FILE"
done
echo "all done"
env:
KITTYCAD_API_TOKEN: ${{secrets.KITTYCAD_API_TOKEN}}
- name: stage outputs
run: |
git add "tutorials/**/*output.*"
git add "samples/**/*output.*"
- name: git status
run: git status
- name: Check for modified files
id: git-check
run: echo ::set-output name=modified::$(if git diff-index --ignore-submodules --quiet HEAD --; then echo "false"; else echo "true"; fi)
- name: Commit changes, if any
if: steps.git-check.outputs.modified == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git fetch origin
git commit -am "Updating script outputs"
git push origin ${{github.event.pull_request.head.ref }}