Skip to content

Commit 3e42c96

Browse files
CI: Build MakeCode with and without docker on each commit. (#274)
1 parent 2d364a1 commit 3e42c96

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

.github/workflows/makecode.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Build MakeCode
2+
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.
5+
on:
6+
push:
7+
branches: '*'
8+
9+
jobs:
10+
build-makecode:
11+
strategy:
12+
matrix:
13+
# One job builds with the local toolchain, the other with Docker
14+
pxt-flags: ["PXT_NODOCKER=1", ""]
15+
fail-fast: false
16+
name: Build MakeCode ${{ matrix.pxt-flags && '(nodocker)' }}
17+
runs-on: ubuntu-22.04
18+
steps:
19+
- name: Setup Python 3.7
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: '3.7'
23+
- name: Setup arm-none-eabi-gcc v10.3
24+
if: ${{ matrix.pxt-flags }}
25+
uses: carlosperate/arm-none-eabi-gcc-action@v1
26+
with:
27+
release: 10.3-2021.10
28+
- name: Install Yotta, Ninja v1.10 & CMake v3.22 via PyPI
29+
if: ${{ matrix.pxt-flags }}
30+
# MarkupSafe < 2.0 needed for Yotta
31+
run: python -m pip install MarkupSafe==1.1.1 ninja==1.10.2.2 cmake==3.22.1 yotta
32+
- name: Install srecord
33+
if: ${{ matrix.pxt-flags }}
34+
run: |
35+
sudo apt update
36+
sudo apt install srecord
37+
- name: Setup Node.js v16
38+
uses: actions/setup-node@v3
39+
with:
40+
node-version: 16.x
41+
- name: Clone the pxt-microbit repo
42+
uses: actions/checkout@v3
43+
with:
44+
repository: 'microsoft/pxt-microbit'
45+
- name: Install MakeCode dependencies
46+
run: |
47+
npm install -g pxt
48+
npm install
49+
# Running from pxt-microbit main branch, so use latest release of these packages
50+
npm install pxt-core@latest pxt-common-packages@latest
51+
- name: Edit pxtarget.json to use this repository and commit
52+
shell: bash
53+
run: |
54+
python - << EOF
55+
import json, collections
56+
57+
def msg_exit(msg):
58+
print('{}\nThe GH Actions workflow Python script needs to be updated.'.format(msg))
59+
exit(1)
60+
61+
with open('pxtarget.json', 'r') as f:
62+
pxt_target = json.loads(f.read(), object_pairs_hook=collections.OrderedDict)
63+
64+
try:
65+
mbcodal = pxt_target['variants']['mbcodal']
66+
mbdal = pxt_target['variants']['mbdal']
67+
if mbdal['compileService'] != {}:
68+
msg_exit("Unexpected variants.mbdal.compileService value.")
69+
if mbcodal['compileService']['codalTarget']['url'] != "https://github.com/lancaster-university/codal-microbit-v2":
70+
msg_exit("Unexpected variants.mbcodal.compileService.codalTarget.url value.")
71+
# Just need to check this exists, we don't care about the value
72+
_ = mbcodal['compileService']['codalTarget']['branch']
73+
except KeyError as e:
74+
msg_exit('The pxt-microbit/pxtarget.json structure has changed and expected keys are not found.')
75+
else:
76+
mbdal['compileService'] = { 'dockerArgs' : ['--env', 'YOTTA_GITHUB_AUTHTOKEN=${{ secrets.YOTTA_GITHUB_AUTHTOKEN }}'] }
77+
mbcodal['compileService']['codalTarget']['url'] = mbcodal['compileService']['codalTarget']['url'].replace(
78+
'lancaster-university/codal-microbit-v2', '${GITHUB_REPOSITORY}'
79+
)
80+
mbcodal['compileService']['codalTarget']['branch'] = '${GITHUB_SHA}'
81+
82+
with open('pxtarget.json', 'w') as f:
83+
f.write(json.dumps(pxt_target, indent=4))
84+
EOF
85+
git diff pxtarget.json
86+
- name: Build MakeCode targets
87+
# Because pxt runs docker with "--user build" it doesn't have write access to some mounted files,
88+
# so we need to force all files created by the pxt cli to have write/execute rights for everyone
89+
run: |
90+
chmod -R a+rwx .
91+
umask 0000
92+
${{ matrix.pxt-flags }} pxt buildtarget --local
93+
env:
94+
YOTTA_GITHUB_AUTHTOKEN: ${{ secrets.YOTTA_GITHUB_AUTHTOKEN }}

0 commit comments

Comments
 (0)