Skip to content

Commit 87dc84a

Browse files
committed
more ci docs build changes
- some refactoring - add doc build tools to search pattern - build all if trigger event is not a pr
1 parent e91fb24 commit 87dc84a

File tree

2 files changed

+49
-39
lines changed

2 files changed

+49
-39
lines changed

.github/workflows/build.yml

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,23 @@ jobs:
1616
test:
1717
runs-on: ubuntu-20.04
1818
outputs:
19-
docs-build: ${{ steps.set-matrix.outputs.docs-build }}
20-
arm-boards: ${{ steps.set-matrix.outputs.arm-boards }}
21-
riscv-boards: ${{ steps.set-matrix.outputs.riscv-boards }}
22-
espressif-boards: ${{ steps.set-matrix.outputs.espressif-boards }}
19+
build-doc: ${{ steps.set-matrix.outputs.build-doc }}
20+
boards-arm: ${{ steps.set-matrix.outputs.boards-arm }}
21+
boards-riscv: ${{ steps.set-matrix.outputs.boards-riscv }}
22+
boards-espressif: ${{ steps.set-matrix.outputs.boards-espressif }}
2323
steps:
2424
- name: Dump GitHub context
2525
env:
2626
GITHUB_CONTEXT: ${{ toJson(github) }}
2727
run: echo "$GITHUB_CONTEXT"
2828
- uses: actions/[email protected]
2929
with:
30-
submodules: true
30+
submodules: false
3131
fetch-depth: 0
32-
- run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
32+
- name: Populate selected submodules
33+
run: git submodule update --init extmod/ lib/ tools/
34+
- name: Fetch tags
35+
run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
3336
- name: CircuitPython version
3437
run: |
3538
git describe --dirty --tags
@@ -38,7 +41,7 @@ jobs:
3841
uses: actions/setup-python@v1
3942
with:
4043
python-version: 3.8
41-
- name: Install deps
44+
- name: Install dependencies
4245
run: |
4346
sudo apt-get update
4447
sudo apt-get install -y eatmydata
@@ -109,11 +112,11 @@ jobs:
109112
zip -9r circuitpython-stubs.zip circuitpython-stubs
110113
[ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp circuitpython-stubs/dist/*.tar.gz s3://adafruit-circuit-python/bin/stubs/circuitpython-stubs-${{ env.CP_VERSION }}.zip --no-progress --region us-east-1
111114
- name: "Get changes"
115+
if: github.event_name == 'pull_request'
112116
uses: dorny/paths-filter@v2
113117
id: filter
114118
with:
115119
list-files: json
116-
base: ${{ github.ref }}
117120
filters: |
118121
changed:
119122
- '**'
@@ -134,9 +137,12 @@ jobs:
134137
run: echo "$GITHUB_CONTEXT"
135138
- uses: actions/[email protected]
136139
with:
137-
submodules: true
140+
submodules: false
138141
fetch-depth: 0
139-
- run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
142+
- name: Populate selected submodules
143+
run: git submodule update --init extmod/ lib/ tools/
144+
- name: Fetch tags
145+
run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
140146
- name: CircuitPython version
141147
run: |
142148
git describe --dirty --tags
@@ -185,15 +191,16 @@ jobs:
185191
build-doc:
186192
runs-on: ubuntu-20.04
187193
needs: test
188-
if: ${{ needs.test.outputs.docs-build == 'True' }}
194+
if: ${{ needs.test.outputs.build-doc == 'True' }}
189195
steps:
190196
- uses: actions/[email protected]
191197
with:
192198
submodules: false
193199
fetch-depth: 0
194200
- name: Populate selected submodules
195-
run: git submodule update --init extmod/ulab
196-
- run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
201+
run: git submodule update --init extmod/
202+
- name: Fetch tags
203+
run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
197204
- name: CircuitPython version
198205
run: |
199206
git describe --dirty --tags
@@ -202,7 +209,7 @@ jobs:
202209
uses: actions/setup-python@v1
203210
with:
204211
python-version: 3.8
205-
- name: Install deps
212+
- name: Install dependencies
206213
run: |
207214
sudo apt-get update
208215
sudo apt-get install -y eatmydata
@@ -244,8 +251,8 @@ jobs:
244251
strategy:
245252
fail-fast: false
246253
matrix:
247-
board: ${{ fromJSON(needs.test.outputs.arm-boards) }}
248-
if: ${{ needs.test.outputs.arm-boards != '[]' }}
254+
board: ${{ fromJSON(needs.test.outputs.boards-arm) }}
255+
if: ${{ needs.test.outputs.boards-arm != '[]' }}
249256
steps:
250257
- name: Set up Python 3.8
251258
uses: actions/setup-python@v1
@@ -255,8 +262,9 @@ jobs:
255262
with:
256263
submodules: true
257264
fetch-depth: 0
258-
- run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
259-
- name: Install deps
265+
- name: Fetch tags
266+
run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
267+
- name: Install dependencies
260268
run: |
261269
sudo apt-get install -y gettext
262270
pip install -r requirements-ci.txt -r requirements-dev.txt
@@ -295,8 +303,8 @@ jobs:
295303
strategy:
296304
fail-fast: false
297305
matrix:
298-
board: ${{ fromJSON(needs.test.outputs.riscv-boards) }}
299-
if: ${{ needs.test.outputs.riscv-boards != '[]' }}
306+
board: ${{ fromJSON(needs.test.outputs.boards-riscv) }}
307+
if: ${{ needs.test.outputs.boards-riscv != '[]' }}
300308
steps:
301309
- name: Set up Python 3.8
302310
uses: actions/setup-python@v1
@@ -306,8 +314,9 @@ jobs:
306314
with:
307315
submodules: true
308316
fetch-depth: 0
309-
- run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
310-
- name: Install deps
317+
- name: Fetch tags
318+
run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
319+
- name: Install dependencies
311320
run: |
312321
sudo apt-get install -y gettext
313322
pip install -r requirements-ci.txt -r requirements-dev.txt
@@ -346,8 +355,8 @@ jobs:
346355
strategy:
347356
fail-fast: false
348357
matrix:
349-
board: ${{ fromJSON(needs.test.outputs.espressif-boards) }}
350-
if: ${{ needs.test.outputs.espressif-boards != '[]' }}
358+
board: ${{ fromJSON(needs.test.outputs.boards-espressif) }}
359+
if: ${{ needs.test.outputs.boards-espressif != '[]' }}
351360
steps:
352361
- name: Set up Python 3.8
353362
uses: actions/setup-python@v1
@@ -357,7 +366,8 @@ jobs:
357366
with:
358367
submodules: true
359368
fetch-depth: 0
360-
- run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
369+
- name: Fetch tags
370+
run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
361371
- name: CircuitPython version
362372
run: git describe --dirty --tags
363373
- uses: actions/cache@v2
@@ -380,7 +390,7 @@ jobs:
380390
env:
381391
IDF_PATH: ${{ github.workspace }}/ports/espressif/esp-idf
382392
IDF_TOOLS_PATH: ${{ github.workspace }}/.idf_tools
383-
- name: Install deps
393+
- name: Install dependencies
384394
run: |
385395
source $IDF_PATH/export.sh
386396
sudo apt-get install -y gettext ninja-build

tools/ci_set_matrix.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@
3333
"stm": "arm",
3434
}
3535

36-
changed_files = json.loads(os.environ["CHANGED_FILES"])
37-
print("changed_files")
38-
print(changed_files)
36+
changed_files = {}
37+
try:
38+
changed_files = json.loads(os.environ["CHANGED_FILES"])
39+
except json.decoder.JSONDecodeError as exc:
40+
if exc.msg != "Expecting value":
41+
raise
3942

4043

4144
def set_boards_to_build(build_all):
@@ -59,8 +62,8 @@ def set_boards_to_build(build_all):
5962

6063
if not build_all:
6164
boards_to_build = set()
62-
board_pattern = re.compile(r"ports\/\w+\/boards\/(\w+)\/")
63-
port_pattern = re.compile(r"ports\/(\w+)\/")
65+
board_pattern = re.compile(r"^ports\/\w+\/boards\/(\w+)\/")
66+
port_pattern = re.compile(r"^ports\/(\w+)\/")
6467
for p in changed_files:
6568
# See if it is board specific
6669
board_matches = board_pattern.search(p)
@@ -90,14 +93,14 @@ def set_boards_to_build(build_all):
9093

9194
# Set the step outputs for each architecture
9295
for arch in arch_to_boards:
93-
print("::set-output name=" + arch + "-boards::" + json.dumps(sorted(arch_to_boards[arch])))
96+
print("::set-output name=boards-" + arch + "::" + json.dumps(sorted(arch_to_boards[arch])))
9497

9598

9699
def set_docs_to_build(build_all):
97100
doc_match = build_all
98101
if not build_all:
99102
doc_pattern = re.compile(
100-
r"extmod\/ulab\/code|ports\/\w+\/bindings|shared-bindings|\.(?:md|MD|rst|RST)$"
103+
r"^(?:docs|(?:(?:extmod\/ulab|ports\/\w+\/bindings|shared-bindings)\S+\.c|conf\.py|tools\/extract_pyi\.py|requirements-doc\.txt)$)|(?:-stubs|\.(?:md|MD|rst|RST))$"
101104
)
102105
for p in changed_files:
103106
if doc_pattern.search(p):
@@ -106,15 +109,12 @@ def set_docs_to_build(build_all):
106109

107110
# Set the step outputs
108111
print("Building docs:", doc_match)
109-
print("::set-output name=docs-build::" + str(doc_match))
112+
print("::set-output name=build-doc::" + str(doc_match))
110113

111114

112115
def check_changed_files():
113-
if not changed_files or (
114-
os.environ.get("GITHUB_EVENT_NAME", "") == "push"
115-
and os.environ.get("GITHUB_REPOSITORY", "") == "adafruit/circuitpython"
116-
):
117-
print("Building all docs/boards because of adafruit/circuitpython branch")
116+
if not changed_files:
117+
print("Building all docs/boards")
118118
return True
119119
else:
120120
print("Adding docs/boards to build based on changed files")

0 commit comments

Comments
 (0)