Skip to content

Commit cc822e0

Browse files
authored
Merge pull request #7499 from MicroDev1/ci
Use composite action for fetching submodules
2 parents 7522522 + fc0bd6b commit cc822e0

File tree

4 files changed

+119
-135
lines changed

4 files changed

+119
-135
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: 'Fetch Submodules'
2+
3+
inputs:
4+
submodules:
5+
description: 'The submodules to cache'
6+
required: false
7+
default: '["extmod/ulab", "lib/", "tools/"]'
8+
type: string
9+
10+
cache:
11+
description: 'The cache action to use'
12+
required: false
13+
default: 'restore'
14+
type: choice
15+
options:
16+
- cache
17+
- restore
18+
19+
version:
20+
description: 'Whether to generate CP version'
21+
required: false
22+
default: false
23+
type: boolean
24+
25+
outputs:
26+
frozen:
27+
description: 'Whether frozen submodules were fetched'
28+
value: ${{ steps.cp-deps.outputs.frozen_tags }}
29+
30+
version:
31+
description: 'The CP version'
32+
value: ${{ steps.cp-version.outputs.cp-version }}
33+
34+
runs:
35+
using: "composite"
36+
steps:
37+
- name: Create submodule status
38+
id: create-submodule-status
39+
run: |
40+
git submodule status ${{ join(fromJSON(inputs.submodules), ' ') }} >> submodule_status
41+
echo $(cut -d ' ' -f 2 submodule_status) | echo "submodules=[\"$(sed "s/ /\", \"/g")\"]" >> $GITHUB_OUTPUT
42+
shell: bash
43+
44+
- name: Cache submodules
45+
if: ${{ inputs.cache == 'cache' }}
46+
uses: actions/cache@v3
47+
with:
48+
path: ".git/modules/\n${{ join(fromJSON(steps.create-submodule-status.outputs.submodules), '\n') }}"
49+
key: submodules-common-${{ hashFiles('submodule_status') }}
50+
enableCrossOsArchive: true
51+
52+
- name: Restore submodules
53+
if: ${{ inputs.cache == 'restore' }}
54+
uses: actions/cache/restore@v3
55+
with:
56+
path: ".git/modules/\n${{ join(fromJSON(steps.create-submodule-status.outputs.submodules), '\n') }}"
57+
key: submodules-common-${{ hashFiles('submodule_status') }}
58+
enableCrossOsArchive: true
59+
60+
- name: Remove submodule status
61+
run: rm submodule_status
62+
shell: bash
63+
64+
- name: CircuitPython dependencies
65+
id: cp-deps
66+
run: python tools/ci_fetch_deps.py ${{ matrix.board || github.job }}
67+
shell: bash
68+
69+
- name: CircuitPython version
70+
id: cp-version
71+
if: ${{ inputs.version == 'true' }}
72+
run: |
73+
echo "::group::Fetch history and tags"
74+
git fetch --no-recurse-submodules --shallow-since="2021-07-01" --tags https://github.com/adafruit/circuitpython HEAD
75+
git fetch --no-recurse-submodules --shallow-since="2021-07-01" origin $GITHUB_SHA
76+
git repack -d
77+
echo "::endgroup::"
78+
CP_VERSION=$(tools/describe)
79+
echo "$CP_VERSION"
80+
echo "CP_VERSION=$CP_VERSION" >> $GITHUB_ENV
81+
echo "cp-version=$CP_VERSION" >> $GITHUB_OUTPUT
82+
shell: bash

.github/workflows/build.yml

Lines changed: 28 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ 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-
2219
jobs:
2320
test:
2421
runs-on: ubuntu-20.04
@@ -28,7 +25,7 @@ jobs:
2825
boards-arm: ${{ steps.set-matrix.outputs.boards-arm }}
2926
boards-espressif: ${{ steps.set-matrix.outputs.boards-espressif }}
3027
boards-riscv: ${{ steps.set-matrix.outputs.boards-riscv }}
31-
cp-version: ${{ steps.cp-version.outputs.cp-version }}
28+
cp-version: ${{ steps.set-up-submodules.outputs.version }}
3229
steps:
3330
- name: Dump GitHub context
3431
run: echo "$GITHUB_CONTEXT"
@@ -45,28 +42,12 @@ jobs:
4542
python-version: "3.x"
4643
- name: Duplicate USB VID/PID check
4744
run: python3 -u -m tools.ci_check_duplicate_usb_vid_pid
48-
- name: Create submodule status
49-
run: git submodule status ${{ join(fromJSON(env.CACHE_SUBMODULES), ' ') }} >> submodule_status
50-
- name: Cache submodules
51-
uses: actions/cache@v3
45+
- name: Set up submodules
46+
id: set-up-submodules
47+
uses: ./.github/actions/fetch_submodules
5248
with:
53-
path: ".git/modules/\n${{ join(fromJSON(env.CACHE_SUBMODULES), '\n') }}"
54-
key: submodules-common-${{ hashFiles('submodule_status') }}
55-
- name: CircuitPython dependencies
56-
run: |
57-
python tools/ci_fetch_deps.py ${{ github.job }}
58-
echo "::group::Fetch history and tags"
59-
git fetch --no-recurse-submodules --shallow-since="2021-07-01" --tags https://github.com/adafruit/circuitpython HEAD
60-
git fetch --no-recurse-submodules --shallow-since="2021-07-01" origin $GITHUB_SHA
61-
git repack -d
62-
echo "::endgroup::"
63-
- name: CircuitPython version
64-
id: cp-version
65-
run: |
66-
CP_VERSION=$(tools/describe)
67-
echo "$CP_VERSION"
68-
echo "CP_VERSION=$CP_VERSION" >> $GITHUB_ENV
69-
echo "cp-version=$CP_VERSION" >> $GITHUB_OUTPUT
49+
cache: "cache"
50+
version: true
7051
- name: Install dependencies
7152
run: |
7253
sudo apt-get update
@@ -202,17 +183,8 @@ jobs:
202183
uses: actions/setup-python@v4
203184
with:
204185
python-version: "3.x"
205-
- name: Create submodule status
206-
run: git submodule status ${{ join(fromJSON(env.CACHE_SUBMODULES), ' ') }} >> submodule_status
207-
- name: Restore submodules
208-
uses: actions/cache/restore@v3
209-
with:
210-
path: ".git/modules/\n${{ join(fromJSON(env.CACHE_SUBMODULES), '\n') }}"
211-
key: submodules-common-${{ hashFiles('submodule_status') }}
212-
- name: CircuitPython dependencies
213-
run: python tools/ci_fetch_deps.py ${{ github.job }}
214-
- name: CircuitPython version
215-
run: tools/describe
186+
- name: Set up submodules
187+
uses: ./.github/actions/fetch_submodules
216188
- name: Versions
217189
run: |
218190
gcc --version
@@ -260,21 +232,12 @@ jobs:
260232
with:
261233
submodules: false
262234
fetch-depth: 1
263-
- name: Create submodule status
264-
run: git submodule status ${{ join(fromJSON(env.CACHE_SUBMODULES), ' ') }} >> submodule_status
265-
- name: Restore submodules
266-
uses: actions/cache/restore@v3
267-
with:
268-
path: ".git/modules/\n${{ join(fromJSON(env.CACHE_SUBMODULES), '\n') }}"
269-
key: submodules-common-${{ hashFiles('submodule_status') }}
270-
- name: CircuitPython dependencies
271-
run: python tools/ci_fetch_deps.py ${{ github.job }}
272-
- name: CircuitPython version
273-
run: tools/describe
274235
- name: Set up python
275236
uses: actions/setup-python@v4
276237
with:
277238
python-version: "3.x"
239+
- name: Set up submodules
240+
uses: ./.github/actions/fetch_submodules
278241
- name: Install dependencies
279242
run: |
280243
sudo apt-get update
@@ -343,16 +306,9 @@ jobs:
343306
uses: actions/setup-python@v4
344307
with:
345308
python-version: "3.x"
346-
- name: Create submodule status
347-
run: git submodule status ${{ join(fromJSON(env.CACHE_SUBMODULES), ' ') }} >> submodule_status
348-
- name: Restore submodules
349-
uses: actions/cache/restore@v3
350-
with:
351-
path: ".git/modules/\n${{ join(fromJSON(env.CACHE_SUBMODULES), '\n') }}"
352-
key: submodules-common-${{ hashFiles('submodule_status') }}
353-
- name: CircuitPython dependencies
354-
id: cp-deps
355-
run: python tools/ci_fetch_deps.py ${{ matrix.board }}
309+
- name: Set up submodules
310+
id: set-up-submodules
311+
uses: ./.github/actions/fetch_submodules
356312
- name: Install dependencies
357313
run: |
358314
sudo apt-get install -y gettext mtools
@@ -379,7 +335,7 @@ jobs:
379335
python3 --version
380336
mkfs.fat --version || true
381337
- name: Build mpy-cross
382-
if: ${{ steps.cp-deps.outputs.frozen_tags == 'True' }}
338+
if: ${{ steps.set-up-submodules.outputs.frozen == 'True' }}
383339
run: make -C mpy-cross -j2
384340
- name: Setup build failure matcher
385341
run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/workflows/match-build-fail.json"
@@ -425,16 +381,9 @@ jobs:
425381
uses: actions/setup-python@v4
426382
with:
427383
python-version: "3.x"
428-
- name: Create submodule status
429-
run: git submodule status ${{ join(fromJSON(env.CACHE_SUBMODULES), ' ') }} >> submodule_status
430-
- name: Restore submodules
431-
uses: actions/cache/restore@v3
432-
with:
433-
path: ".git/modules/\n${{ join(fromJSON(env.CACHE_SUBMODULES), '\n') }}"
434-
key: submodules-common-${{ hashFiles('submodule_status') }}
435-
- name: CircuitPython dependencies
436-
id: cp-deps
437-
run: python tools/ci_fetch_deps.py ${{ matrix.board }}
384+
- name: Set up submodules
385+
id: set-up-submodules
386+
uses: ./.github/actions/fetch_submodules
438387
- uses: carlosperate/arm-none-eabi-gcc-action@v1
439388
with:
440389
release: '10-2020-q4'
@@ -448,7 +397,7 @@ jobs:
448397
arm-none-eabi-gcc --version
449398
python3 --version
450399
- name: Build mpy-cross
451-
if: ${{ steps.cp-deps.outputs.frozen_tags == 'True' }}
400+
if: ${{ steps.set-up-submodules.outputs.frozen == 'True' }}
452401
run: make -C mpy-cross -j2
453402
- name: Setup build failure matcher
454403
run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/workflows/match-build-fail.json"
@@ -474,7 +423,6 @@ jobs:
474423
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
475424

476425

477-
478426
build-espressif:
479427
runs-on: ubuntu-22.04
480428
needs: test
@@ -498,13 +446,6 @@ jobs:
498446
uses: actions/setup-python@v4
499447
with:
500448
python-version: "3.10"
501-
- name: Create submodule status
502-
run: git submodule status ${{ join(fromJSON(env.CACHE_SUBMODULES), ' ') }} >> submodule_status
503-
- name: Restore submodules
504-
uses: actions/cache/restore@v3
505-
with:
506-
path: ".git/modules/\n${{ join(fromJSON(env.CACHE_SUBMODULES), '\n') }}"
507-
key: submodules-common-${{ hashFiles('submodule_status') }}
508449
- name: Get IDF commit
509450
id: idf-commit
510451
run: |
@@ -518,19 +459,13 @@ jobs:
518459
.git/modules/ports/espressif/esp-idf
519460
ports/espressif/esp-idf
520461
key: submodules-idf-${{ steps.idf-commit.outputs.commit }}
521-
- name: CircuitPython dependencies
522-
id: cp-deps
523-
run: python tools/ci_fetch_deps.py ${{ matrix.board }}
524-
- name: CircuitPython version
525-
run: tools/describe
526462
- name: Cache IDF tools
527463
uses: actions/cache@v3
528464
with:
529465
path: ${{ env.IDF_TOOLS_PATH }}
530466
key: ${{ runner.os }}-Python-${{ steps.setup-python.outputs.python-version }}-tools-idf-${{ steps.idf-commit.outputs.commit }}
531-
- name: Clone IDF submodules
532-
run: git submodule update --init --depth=1
533-
working-directory: ${{ env.IDF_PATH }}
467+
- name: Initialize IDF submodules
468+
run: git submodule update --init --depth=1 --recursive $IDF_PATH
534469
- name: Install IDF tools
535470
run: |
536471
echo "Installing ESP-IDF tools"
@@ -539,6 +474,9 @@ jobs:
539474
echo "Installing Python environment and packages"
540475
$IDF_PATH/tools/idf_tools.py --non-interactive install-python-env
541476
rm -rf $IDF_TOOLS_PATH/dist
477+
- name: Set up submodules
478+
id: set-up-submodules
479+
uses: ./.github/actions/fetch_submodules
542480
- name: Install dependencies
543481
run: |
544482
source $IDF_PATH/export.sh
@@ -552,7 +490,7 @@ jobs:
552490
ninja --version
553491
cmake --version
554492
- name: Build mpy-cross
555-
if: ${{ steps.cp-deps.outputs.frozen_tags == 'True' }}
493+
if: ${{ steps.set-up-submodules.outputs.frozen == 'True' }}
556494
run: make -C mpy-cross -j2
557495
- name: Setup build failure matcher
558496
run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/workflows/match-build-fail.json"
@@ -600,16 +538,9 @@ jobs:
600538
uses: actions/setup-python@v4
601539
with:
602540
python-version: "3.x"
603-
- name: Create submodule status
604-
run: git submodule status ${{ join(fromJSON(env.CACHE_SUBMODULES), ' ') }} >> submodule_status
605-
- name: Restore submodules
606-
uses: actions/cache/restore@v3
607-
with:
608-
path: ".git/modules/\n${{ join(fromJSON(env.CACHE_SUBMODULES), '\n') }}"
609-
key: submodules-common-${{ hashFiles('submodule_status') }}
610-
- name: CircuitPython dependencies
611-
id: cp-deps
612-
run: python tools/ci_fetch_deps.py ${{ matrix.board }}
541+
- name: Set up submodules
542+
id: set-up-submodules
543+
uses: ./.github/actions/fetch_submodules
613544
- name: Install dependencies
614545
run: |
615546
sudo apt-get install -y gettext
@@ -622,7 +553,7 @@ jobs:
622553
riscv64-unknown-elf-gcc --version
623554
python3 --version
624555
- name: Build mpy-cross
625-
if: ${{ steps.cp-deps.outputs.frozen_tags == 'True' }}
556+
if: ${{ steps.set-up-submodules.outputs.frozen == 'True' }}
626557
run: make -C mpy-cross -j2
627558
- name: Setup build failure matcher
628559
run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/workflows/match-build-fail.json"

.github/workflows/create_website_pr.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,10 @@ jobs:
2525
uses: actions/setup-python@v4
2626
with:
2727
python-version: "3.x"
28-
- name: CircuitPython dependencies
29-
run: |
30-
python tools/ci_fetch_deps.py ${{ github.job }}
31-
echo "::group::Fetch history and tags"
32-
git fetch --no-recurse-submodules --shallow-since="2021-07-01" --tags https://github.com/adafruit/circuitpython HEAD
33-
git fetch --no-recurse-submodules --shallow-since="2021-07-01" origin $GITHUB_SHA
34-
git repack -d
35-
echo "::endgroup::"
36-
- name: CircuitPython version
37-
run: |
38-
CP_VERSION=$(tools/describe)
39-
echo "$CP_VERSION"
40-
echo "CP_VERSION=$CP_VERSION" >> $GITHUB_ENV
28+
- name: Set up submodules
29+
uses: ./.github/actions/fetch_submodules
30+
with:
31+
version: true
4132
- name: Install dependencies
4233
run: pip install -r requirements-dev.txt
4334
- name: Versions

.github/workflows/ports_windows.yml

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ concurrency:
1919
cancel-in-progress: true
2020

2121
jobs:
22-
build:
22+
windows:
2323
runs-on: windows-2022
2424
defaults:
2525
run:
@@ -75,31 +75,11 @@ jobs:
7575
with:
7676
submodules: false
7777
fetch-depth: 1
78-
- name: Create submodule status
79-
run: git submodule status extmod/ulab lib/ tools/ >> submodule_status
80-
- name: Restore submodules
81-
uses: actions/cache/restore@v3
78+
79+
- name: Set up submodules
80+
uses: ./.github/actions/fetch_submodules
8281
with:
83-
path: |
84-
.git/modules/
85-
extmod/ulab
86-
lib/
87-
tools/
88-
key: submodules-common-${{ hashFiles('submodule_status') }}
89-
enableCrossOsArchive: true
90-
- name: CircuitPython dependencies
91-
run: |
92-
python tools/ci_fetch_deps.py windows
93-
echo "::group::Fetch history and tags"
94-
git fetch --no-recurse-submodules --shallow-since="2021-07-01" --tags https://github.com/adafruit/circuitpython HEAD
95-
git fetch --no-recurse-submodules --shallow-since="2021-07-01" origin $GITHUB_SHA
96-
git repack -d
97-
echo "::endgroup::"
98-
- name: CircuitPython version
99-
run: |
100-
CP_VERSION=$(tools/describe)
101-
echo "$CP_VERSION"
102-
echo "CP_VERSION=$CP_VERSION" >> $GITHUB_ENV
82+
version: true
10383

10484
- name: build mpy-cross
10585
run: make -j2 -C mpy-cross

0 commit comments

Comments
 (0)