Skip to content

Commit f36c862

Browse files
committed
refactor stuff in ci
1 parent 3b2fe15 commit f36c862

File tree

1 file changed

+46
-54
lines changed

1 file changed

+46
-54
lines changed

.github/workflows/build.yml

Lines changed: 46 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ concurrency:
1616
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1717
cancel-in-progress: true
1818

19+
env:
20+
CACHE_SUBMODULES: "['extmod/ulab', 'lib/', 'tools/']"
21+
1922
jobs:
2023
test:
2124
runs-on: ubuntu-20.04
@@ -43,15 +46,11 @@ jobs:
4346
- name: Duplicate USB VID/PID check
4447
run: python3 -u -m tools.ci_check_duplicate_usb_vid_pid
4548
- name: Create submodule status
46-
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
49+
run: git submodule status ${{ join(fromJSON(env.CACHE_SUBMODULES), ' ') }} >> submodule_status
4750
- name: Cache submodules
4851
uses: actions/cache@v3
4952
with:
50-
path: |
51-
.git/modules/
52-
extmod/ulab
53-
lib/
54-
tools/
53+
path: ".git/modules/\n${{ join(fromJSON(env.CACHE_SUBMODULES), '\n') }}"
5554
key: submodules-common-${{ hashFiles('submodule_status') }}
5655
- name: CircuitPython dependencies
5756
run: |
@@ -137,7 +136,9 @@ jobs:
137136
name: mpy-cross.static-x64-windows
138137
path: mpy-cross/mpy-cross.static.exe
139138
- name: Upload to S3
140-
if: (github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
139+
if: >-
140+
(github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') ||
141+
(github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
141142
env:
142143
AWS_PAGER: ''
143144
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
@@ -184,7 +185,11 @@ jobs:
184185
mpy-cross-mac:
185186
runs-on: macos-11
186187
needs: test
187-
if: ${{ needs.test.outputs.boards-aarch != '[]' || needs.test.outputs.boards-arm != '[]' || needs.scheduler.test.boards-espressif != '[]' || needs.scheduler.test.boards-riscv != '[]' }}
188+
if: >-
189+
needs.test.outputs.boards-aarch != '[]' ||
190+
needs.test.outputs.boards-arm != '[]' ||
191+
needs.test.outputs.boards-espressif != '[]' ||
192+
needs.test.outputs.boards-riscv != '[]'
188193
env:
189194
CP_VERSION: ${{ needs.test.outputs.cp-version }}
190195
steps:
@@ -198,15 +203,11 @@ jobs:
198203
with:
199204
python-version: "3.x"
200205
- name: Create submodule status
201-
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
206+
run: git submodule status ${{ join(fromJSON(env.CACHE_SUBMODULES), ' ') }} >> submodule_status
202207
- name: Restore submodules
203208
uses: actions/cache/restore@v3
204209
with:
205-
path: |
206-
.git/modules/
207-
extmod/ulab
208-
lib/
209-
tools/
210+
path: ".git/modules/\n${{ join(fromJSON(env.CACHE_SUBMODULES), '\n') }}"
210211
key: submodules-common-${{ hashFiles('submodule_status') }}
211212
- name: CircuitPython dependencies
212213
run: python tools/ci_fetch_deps.py ${{ github.job }}
@@ -260,15 +261,11 @@ jobs:
260261
submodules: false
261262
fetch-depth: 1
262263
- name: Create submodule status
263-
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
264+
run: git submodule status ${{ join(fromJSON(env.CACHE_SUBMODULES), ' ') }} >> submodule_status
264265
- name: Restore submodules
265266
uses: actions/cache/restore@v3
266267
with:
267-
path: |
268-
.git/modules/
269-
extmod/ulab
270-
lib/
271-
tools/
268+
path: ".git/modules/\n${{ join(fromJSON(env.CACHE_SUBMODULES), '\n') }}"
272269
key: submodules-common-${{ hashFiles('submodule_status') }}
273270
- name: CircuitPython dependencies
274271
run: python tools/ci_fetch_deps.py ${{ github.job }}
@@ -304,7 +301,9 @@ jobs:
304301
name: docs
305302
path: _build/latex
306303
- name: Upload to S3
307-
if: (github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
304+
if: >-
305+
(github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') ||
306+
(github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
308307
env:
309308
AWS_PAGER: ''
310309
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
@@ -345,15 +344,11 @@ jobs:
345344
with:
346345
python-version: "3.x"
347346
- name: Create submodule status
348-
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
347+
run: git submodule status ${{ join(fromJSON(env.CACHE_SUBMODULES), ' ') }} >> submodule_status
349348
- name: Restore submodules
350349
uses: actions/cache/restore@v3
351350
with:
352-
path: |
353-
.git/modules/
354-
extmod/ulab
355-
lib/
356-
tools/
351+
path: ".git/modules/\n${{ join(fromJSON(env.CACHE_SUBMODULES), '\n') }}"
357352
key: submodules-common-${{ hashFiles('submodule_status') }}
358353
- name: CircuitPython dependencies
359354
id: cp-deps
@@ -398,14 +393,16 @@ jobs:
398393
name: ${{ matrix.board }}
399394
path: bin/${{ matrix.board }}
400395
- name: Upload to S3
396+
if: >-
397+
(github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') ||
398+
(github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
401399
run: |
402400
pip install awscli
403-
"[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1"
401+
[ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1
404402
env:
405403
AWS_PAGER: ''
406404
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
407405
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
408-
if: (github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
409406

410407

411408
build-arm:
@@ -429,15 +426,11 @@ jobs:
429426
with:
430427
python-version: "3.x"
431428
- name: Create submodule status
432-
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
429+
run: git submodule status ${{ join(fromJSON(env.CACHE_SUBMODULES), ' ') }} >> submodule_status
433430
- name: Restore submodules
434431
uses: actions/cache/restore@v3
435432
with:
436-
path: |
437-
.git/modules/
438-
extmod/ulab
439-
lib/
440-
tools/
433+
path: ".git/modules/\n${{ join(fromJSON(env.CACHE_SUBMODULES), '\n') }}"
441434
key: submodules-common-${{ hashFiles('submodule_status') }}
442435
- name: CircuitPython dependencies
443436
id: cp-deps
@@ -469,14 +462,17 @@ jobs:
469462
name: ${{ matrix.board }}
470463
path: bin/${{ matrix.board }}
471464
- name: Upload to S3
465+
if: >-
466+
(github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') ||
467+
(github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
472468
run: |
473469
pip install awscli
474-
"[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1"
470+
[ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1
475471
env:
476472
AWS_PAGER: ''
477473
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
478474
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
479-
if: (github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
475+
480476

481477

482478
build-espressif:
@@ -503,15 +499,11 @@ jobs:
503499
with:
504500
python-version: "3.10"
505501
- name: Create submodule status
506-
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
502+
run: git submodule status ${{ join(fromJSON(env.CACHE_SUBMODULES), ' ') }} >> submodule_status
507503
- name: Restore submodules
508504
uses: actions/cache/restore@v3
509505
with:
510-
path: |
511-
.git/modules/
512-
extmod/ulab
513-
lib/
514-
tools/
506+
path: ".git/modules/\n${{ join(fromJSON(env.CACHE_SUBMODULES), '\n') }}"
515507
key: submodules-common-${{ hashFiles('submodule_status') }}
516508
- name: Get IDF commit
517509
id: idf-commit
@@ -535,7 +527,7 @@ jobs:
535527
uses: actions/cache@v3
536528
with:
537529
path: ${{ env.IDF_TOOLS_PATH }}
538-
key: ${{ runner.os }}-idf-tools-${{ steps.idf-commit.outputs.commit }}-${{ steps.setup-python.outputs.python-version }}
530+
key: ${{ runner.os }}-Python-${{ steps.setup-python.outputs.python-version }}-tools-idf-${{ steps.idf-commit.outputs.commit }}
539531
- name: Clone IDF submodules
540532
run: git submodule update --init --depth=1
541533
working-directory: ${{ env.IDF_PATH }}
@@ -576,14 +568,16 @@ jobs:
576568
name: ${{ matrix.board }}
577569
path: bin/${{ matrix.board }}
578570
- name: Upload to S3
571+
if: >-
572+
(github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') ||
573+
(github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
579574
run: |
580575
pip install awscli
581-
"[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1"
576+
[ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1
582577
env:
583578
AWS_PAGER: ''
584579
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
585580
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
586-
if: (github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
587581

588582

589583
build-riscv:
@@ -607,15 +601,11 @@ jobs:
607601
with:
608602
python-version: "3.x"
609603
- name: Create submodule status
610-
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
604+
run: git submodule status ${{ join(fromJSON(env.CACHE_SUBMODULES), ' ') }} >> submodule_status
611605
- name: Restore submodules
612606
uses: actions/cache/restore@v3
613607
with:
614-
path: |
615-
.git/modules/
616-
extmod/ulab
617-
lib/
618-
tools/
608+
path: ".git/modules/\n${{ join(fromJSON(env.CACHE_SUBMODULES), '\n') }}"
619609
key: submodules-common-${{ hashFiles('submodule_status') }}
620610
- name: CircuitPython dependencies
621611
id: cp-deps
@@ -646,11 +636,13 @@ jobs:
646636
name: ${{ matrix.board }}
647637
path: bin/${{ matrix.board }}
648638
- name: Upload to S3
639+
if: >-
640+
(github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') ||
641+
(github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
649642
run: |
650643
pip install awscli
651-
"[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1"
644+
[ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1
652645
env:
653646
AWS_PAGER: ''
654647
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
655648
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
656-
if: (github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))

0 commit comments

Comments
 (0)