Skip to content

Commit a4c2b30

Browse files
ci: Also build MakeCode & MicroPython on PRs. (#473)
1 parent 78fc713 commit a4c2b30

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

.github/workflows/makecode.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: Build MakeCode
22

3-
# MakeCode has to git clone/checkout this repo commit SHA, so only run this
4-
# workflow on pushes, as PRs generate a "merge commit" that is not clonable.
53
on:
64
push:
75
branches: '*'
6+
pull_request:
7+
branches: '*'
88

99
jobs:
1010
build-makecode:
@@ -50,6 +50,20 @@ jobs:
5050
run: |
5151
npm install -g pxt
5252
npm install
53+
# MakeCode has to git clone/checkout this repo commit SHA, the GITHUB_SHA env
54+
# variable from a PR represents the "merge commit" of that PR against main,
55+
# and so that commit is not reachable by MakeCode because it's not pushed anywhere
56+
- name: Set CODAL_MICROBIT_V2_SHA
57+
run: |
58+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
59+
CODAL_MICROBIT_V2_SHA=$(jq -r .pull_request.head.sha < $GITHUB_EVENT_PATH)
60+
else
61+
CODAL_MICROBIT_V2_SHA=${GITHUB_SHA}
62+
fi
63+
echo "CODAL_MICROBIT_V2_SHA=$CODAL_MICROBIT_V2_SHA" >> $GITHUB_ENV
64+
echo "CODAL_MICROBIT_V2_SHA=$CODAL_MICROBIT_V2_SHA"
65+
env:
66+
GITHUB_EVENT_PATH: ${{ github.event_path }}
5367
- name: Edit pxtarget.json to use this repository and commit
5468
shell: bash
5569
run: |
@@ -79,7 +93,7 @@ jobs:
7993
mbcodal['compileService']['codalTarget']['url'] = mbcodal['compileService']['codalTarget']['url'].replace(
8094
'lancaster-university/codal-microbit-v2', '${GITHUB_REPOSITORY}'
8195
)
82-
mbcodal['compileService']['codalTarget']['branch'] = '${GITHUB_SHA}'
96+
mbcodal['compileService']['codalTarget']['branch'] = '${{ env.CODAL_MICROBIT_V2_SHA }}'
8397
8498
with open('pxtarget.json', 'w') as f:
8599
f.write(json.dumps(pxt_target, indent=4))

.github/workflows/micropython.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: Build MicroPython
22

3-
# MicroPython has to git clone/checkout this repo commit SHA, so only run this
4-
# workflow on pushes, as PRs generate a "merge commit" that is not clonable.
53
on:
64
push:
75
branches: '*'
6+
pull_request:
7+
branches: '*'
88

99
jobs:
1010
build-micropython:
@@ -16,6 +16,12 @@ jobs:
1616
with:
1717
repository: 'microbit-foundation/micropython-microbit-v2'
1818
submodules: 'true'
19+
- name: Manually clone microbit-v2-samples in the lib/codal/libraries folder
20+
uses: actions/checkout@v4
21+
with:
22+
path: lib/codal/libraries/codal-microbit-v2
23+
fetch-depth: '0'
24+
submodules: 'recursive'
1925
- name: Setup arm-none-eabi-gcc v10.3
2026
uses: carlosperate/arm-none-eabi-gcc-action@v1
2127
with:

0 commit comments

Comments
 (0)