Skip to content

Commit 434c235

Browse files
committed
multiple ci enhancements
- selectively fetch submodule tags - conditionally build mpy-cross - remove frozen from submodule cache
1 parent 6bc0274 commit 434c235

File tree

3 files changed

+60
-35
lines changed

3 files changed

+60
-35
lines changed

.github/workflows/build.yml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,13 @@ jobs:
4343
- name: Duplicate USB VID/PID check
4444
run: python3 -u -m tools.ci_check_duplicate_usb_vid_pid
4545
- name: Create submodule status
46-
run: git submodule status extmod/ulab frozen/ lib/ tools/ >> submodule_status
46+
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
4747
- name: Cache submodules
4848
uses: actions/cache@v3
4949
with:
5050
path: |
5151
.git/modules/
5252
extmod/ulab
53-
frozen/
5453
lib/
5554
tools/
5655
key: submodules-common-${{ hashFiles('submodule_status') }}
@@ -198,14 +197,13 @@ jobs:
198197
with:
199198
python-version: "3.x"
200199
- name: Create submodule status
201-
run: git submodule status extmod/ulab frozen/ lib/ tools/ >> submodule_status
200+
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
202201
- name: Restore submodules
203202
uses: actions/cache/restore@v3
204203
with:
205204
path: |
206205
.git/modules/
207206
extmod/ulab
208-
frozen/
209207
lib/
210208
tools/
211209
key: submodules-common-${{ hashFiles('submodule_status') }}
@@ -265,14 +263,13 @@ jobs:
265263
submodules: false
266264
fetch-depth: 1
267265
- name: Create submodule status
268-
run: git submodule status extmod/ulab frozen/ lib/ tools/ >> submodule_status
266+
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
269267
- name: Restore submodules
270268
uses: actions/cache/restore@v3
271269
with:
272270
path: |
273271
.git/modules/
274272
extmod/ulab
275-
frozen/
276273
lib/
277274
tools/
278275
key: submodules-common-${{ hashFiles('submodule_status') }}
@@ -350,18 +347,18 @@ jobs:
350347
with:
351348
python-version: "3.x"
352349
- name: Create submodule status
353-
run: git submodule status extmod/ulab frozen/ lib/ tools/ >> submodule_status
350+
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
354351
- name: Restore submodules
355352
uses: actions/cache/restore@v3
356353
with:
357354
path: |
358355
.git/modules/
359356
extmod/ulab
360-
frozen/
361357
lib/
362358
tools/
363359
key: submodules-common-${{ hashFiles('submodule_status') }}
364360
- name: CircuitPython dependencies
361+
id: cp-deps
365362
run: python tools/ci_fetch_deps.py ${{ matrix.board }}
366363
- uses: carlosperate/arm-none-eabi-gcc-action@v1
367364
with:
@@ -375,11 +372,12 @@ jobs:
375372
gcc --version
376373
arm-none-eabi-gcc --version
377374
python3 --version
378-
- name: mpy-cross
375+
- name: Build mpy-cross
376+
if: ${{ steps.cp-deps.outputs.frozen_tags == 'True' }}
379377
run: make -C mpy-cross -j2
380378
- name: Setup build failure matcher
381379
run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/workflows/match-build-fail.json"
382-
- name: build
380+
- name: Build
383381
run: python3 -u build_release_files.py
384382
working-directory: tools
385383
env:
@@ -418,18 +416,18 @@ jobs:
418416
with:
419417
python-version: "3.x"
420418
- name: Create submodule status
421-
run: git submodule status extmod/ulab frozen/ lib/ tools/ >> submodule_status
419+
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
422420
- name: Restore submodules
423421
uses: actions/cache/restore@v3
424422
with:
425423
path: |
426424
.git/modules/
427425
extmod/ulab
428-
frozen/
429426
lib/
430427
tools/
431428
key: submodules-common-${{ hashFiles('submodule_status') }}
432429
- name: CircuitPython dependencies
430+
id: cp-deps
433431
run: python tools/ci_fetch_deps.py ${{ matrix.board }}
434432
- name: Install dependencies
435433
run: |
@@ -442,11 +440,12 @@ jobs:
442440
gcc --version
443441
riscv64-unknown-elf-gcc --version
444442
python3 --version
445-
- name: mpy-cross
443+
- name: Build mpy-cross
444+
if: ${{ steps.cp-deps.outputs.frozen_tags == 'True' }}
446445
run: make -C mpy-cross -j2
447446
- name: Setup build failure matcher
448447
run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/workflows/match-build-fail.json"
449-
- name: build
448+
- name: Build
450449
run: python3 -u build_release_files.py
451450
working-directory: tools
452451
env:
@@ -486,18 +485,18 @@ jobs:
486485
with:
487486
python-version: "3.10"
488487
- name: Create submodule status
489-
run: git submodule status extmod/ulab frozen/ lib/ tools/ >> submodule_status
488+
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
490489
- name: Restore submodules
491490
uses: actions/cache/restore@v3
492491
with:
493492
path: |
494493
.git/modules/
495494
extmod/ulab
496-
frozen/
497495
lib/
498496
tools/
499497
key: submodules-common-${{ hashFiles('submodule_status') }}
500498
- name: CircuitPython dependencies
499+
id: cp-deps
501500
run: python tools/ci_fetch_deps.py ${{ matrix.board }}
502501
- name: CircuitPython version
503502
run: tools/describe
@@ -541,11 +540,12 @@ jobs:
541540
env:
542541
IDF_PATH: ${{ github.workspace }}/ports/espressif/esp-idf
543542
IDF_TOOLS_PATH: ${{ github.workspace }}/.idf_tools
544-
- name: mpy-cross
543+
- name: Build mpy-cross
544+
if: ${{ steps.cp-deps.outputs.frozen_tags == 'True' }}
545545
run: make -C mpy-cross -j2
546546
- name: Setup build failure matcher
547547
run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/workflows/match-build-fail.json"
548-
- name: build
548+
- name: Build
549549
run: |
550550
source $IDF_PATH/export.sh
551551
python3 -u build_release_files.py
@@ -589,18 +589,18 @@ jobs:
589589
with:
590590
python-version: "3.x"
591591
- name: Create submodule status
592-
run: git submodule status extmod/ulab frozen/ lib/ tools/ >> submodule_status
592+
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
593593
- name: Restore submodules
594594
uses: actions/cache/restore@v3
595595
with:
596596
path: |
597597
.git/modules/
598598
extmod/ulab
599-
frozen/
600599
lib/
601600
tools/
602601
key: submodules-common-${{ hashFiles('submodule_status') }}
603602
- name: CircuitPython dependencies
603+
id: cp-deps
604604
run: python tools/ci_fetch_deps.py ${{ matrix.board }}
605605
- name: Install dependencies
606606
run: |
@@ -627,11 +627,12 @@ jobs:
627627
arm-none-eabi-gcc --version
628628
python3 --version
629629
mkfs.fat --version || true
630-
- name: mpy-cross
630+
- name: Build mpy-cross
631+
if: ${{ steps.cp-deps.outputs.frozen_tags == 'True' }}
631632
run: make -C mpy-cross -j2
632633
- name: Setup build failure matcher
633634
run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/workflows/match-build-fail.json"
634-
- name: build
635+
- name: Build
635636
run: python3 -u build_release_files.py
636637
working-directory: tools
637638
env:

.github/workflows/ports_windows.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
pull_request:
66
paths:
7-
- '.github/workflows/*.yml'
7+
- '.github/workflows/ports_windows.yml'
88
- 'extmod/**'
99
- 'lib/**'
1010
- 'mpy-cross/**'
@@ -77,14 +77,13 @@ jobs:
7777
submodules: false
7878
fetch-depth: 1
7979
- name: Create submodule status
80-
run: git submodule status extmod/ulab frozen/ lib/ tools/ >> submodule_status
80+
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
8181
- name: Restore submodules
8282
uses: actions/cache/restore@v3
8383
with:
8484
path: |
8585
.git/modules/
8686
extmod/ulab
87-
frozen/
8887
lib/
8988
tools/
9089
key: submodules-common-${{ hashFiles('submodule_status') }}

tools/ci_fetch_deps.py

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import pathlib
2-
import shlex
3-
import subprocess
1+
import os
42
import sys
53
import time
4+
import shlex
5+
import pathlib
6+
import subprocess
67

78
# Target will be a board, "test", "docs", "mpy-cross-mac", or "windows"
89
TARGET = sys.argv[1]
@@ -58,13 +59,21 @@ def run(title, command, check=True):
5859
print("Duration:", time.monotonic() - start, flush=True)
5960

6061

62+
def set_output(name, value):
63+
if "GITHUB_OUTPUT" in os.environ:
64+
with open(os.environ["GITHUB_OUTPUT"], "at") as f:
65+
print(f"{name}={value}", file=f)
66+
else:
67+
print(f"Would set GitHub actions output {name} to '{value}'")
68+
69+
6170
def main():
6271
submodules = []
72+
submodules_tags = []
73+
6374
print("Target:", TARGET)
6475

65-
if TARGET == "scheduler":
66-
submodules = ["extmod/ulab", "lib/", "tools/", "frozen/"]
67-
elif TARGET == "mpy-cross-tests":
76+
if TARGET == "test":
6877
submodules = ["extmod/ulab", "lib/", "tools/"]
6978
elif TARGET == "build-doc":
7079
# used in .readthedocs.yml to generate RTD
@@ -98,13 +107,29 @@ def main():
98107
if lib_folder.count("/") > 1:
99108
lib_folder = lib_folder.split("/", maxsplit=2)
100109
lib_folder = "/".join(lib_folder[:2])
101-
submodules.append(lib_folder)
110+
submodules_tags.append(lib_folder)
102111

103-
print("Submodule paths:", submodules)
112+
print("Submodule tags[Y]:", submodules_tags)
113+
print("Submodule tags[N]:", submodules)
114+
115+
if submodules_tags:
116+
run(
117+
"Init the submodules with tags",
118+
f"git submodule update --init {' '.join(submodules_tags)}",
119+
)
104120

105121
if submodules:
106-
submodules = " ".join(submodules)
107-
run("Init the required submodules", f"git submodule update --init --depth=1 {submodules}")
122+
run(
123+
"Init the submodules without tags",
124+
f"git submodule update --init --depth=1 {' '.join(submodules)}",
125+
)
126+
127+
for submodule in submodules_tags:
128+
if submodule.startswith("frozen"):
129+
set_output("frozen_tags", True)
130+
break
131+
else:
132+
set_output("frozen_tags", False)
108133

109134

110135
if __name__ == "__main__":

0 commit comments

Comments
 (0)