Skip to content

Snapshot v0.2.69

Snapshot v0.2.69 #204

Workflow file for this run

name: Build MakeCode
# MakeCode has to git clone/checkout this repo commit SHA, so only run this
# workflow on pushes, as PRs generate a "merge commit" that is not clonable.
on:
push:
branches: '*'
jobs:
build-makecode:
strategy:
matrix:
# One job builds with the local toolchain, the other with Docker
pxt-flags: ["PXT_NODOCKER=1", ""]
fail-fast: false
name: Build MakeCode ${{ matrix.pxt-flags && '(nodocker)' }}
runs-on: ubuntu-22.04
steps:
- name: Setup Python 3.9
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Setup arm-none-eabi-gcc v10.3
if: ${{ matrix.pxt-flags }}
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: 10.3-2021.10
- name: Install Yotta, Ninja v1.10 & CMake v3.22 via PyPI
if: ${{ matrix.pxt-flags }}
run: |
# Newer pip needed to install newer wheels type for cmsis-pack-manager
python -m pip install --upgrade pip
# project-generator==0.8.17 and MarkupSafe < 2.0 needed for Yotta
python -m pip install project-generator==0.8.17 MarkupSafe==1.1.1
python -m pip install ninja==1.10.2.2 cmake==3.22.1 yotta
- name: Install srecord
if: ${{ matrix.pxt-flags }}
run: |
sudo apt update
sudo apt install srecord
- name: Setup Node.js v16
uses: actions/setup-node@v4
with:
node-version: 16.x
- name: Clone the pxt-microbit repo
uses: actions/checkout@v4
with:
repository: 'microsoft/pxt-microbit'
- name: Install MakeCode dependencies
run: |
npm install -g pxt
npm install
- name: Edit pxtarget.json to use this repository and commit
shell: bash
run: |
python - << EOF
import json, collections
def msg_exit(msg):
print('{}\nThe GH Actions workflow Python script needs to be updated.'.format(msg))
exit(1)
with open('pxtarget.json', 'r') as f:
pxt_target = json.loads(f.read(), object_pairs_hook=collections.OrderedDict)
try:
mbcodal = pxt_target['variants']['mbcodal']
mbdal = pxt_target['variants']['mbdal']
if mbdal['compileService'] != {}:
msg_exit("Unexpected variants.mbdal.compileService value.")
if mbcodal['compileService']['codalTarget']['url'] != "https://github.com/lancaster-university/codal-microbit-v2":
msg_exit("Unexpected variants.mbcodal.compileService.codalTarget.url value.")
# Just need to check this exists, we don't care about the value
_ = mbcodal['compileService']['codalTarget']['branch']
except KeyError as e:
msg_exit('The pxt-microbit/pxtarget.json structure has changed and expected keys are not found.')
else:
mbdal['compileService'] = { 'dockerArgs' : ['--env', 'YOTTA_GITHUB_AUTHTOKEN=${{ secrets.YOTTA_GITHUB_AUTHTOKEN }}'] }
mbcodal['compileService']['codalTarget']['url'] = mbcodal['compileService']['codalTarget']['url'].replace(
'lancaster-university/codal-microbit-v2', '${GITHUB_REPOSITORY}'
)
mbcodal['compileService']['codalTarget']['branch'] = '${GITHUB_SHA}'
with open('pxtarget.json', 'w') as f:
f.write(json.dumps(pxt_target, indent=4))
EOF
git diff pxtarget.json
# https://github.com/microsoft/pxt-microbit/issues/5721
# https://docs.docker.com/engine/deprecated/#pushing-and-pulling-with-image-manifest-v2-schema-1
# https://stackoverflow.com/a/51357915/775259
- name: Workaround for issue with pext/yotta:latest docker image type being deprecated
run: |
echo "[Service]" > docker-service-override.conf
echo 'Environment="DOCKER_ENABLE_DEPRECATED_PULL_SCHEMA_1_IMAGE=1"' >> docker-service-override.conf
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo mv docker-service-override.conf /etc/systemd/system/docker.service.d/docker-service-override.conf
sudo systemctl daemon-reload
sudo systemctl restart docker
- name: Build MakeCode targets
# Because pxt runs docker with "--user build" it doesn't have write access to some mounted files,
# so we need to force all files created by the pxt cli to have write/execute rights for everyone
run: |
chmod -R a+rwx .
umask 0000
${{ matrix.pxt-flags }} pxt buildtarget --local
env:
YOTTA_GITHUB_AUTHTOKEN: ${{ secrets.YOTTA_GITHUB_AUTHTOKEN }}