Skip to content

nf34-ci

nf34-ci #118

Workflow file for this run

name: nf34-ci
on:
pull_request:
paths:
- "34-cellular-modbus-client/**"
- ".github/workflows/nf34-ci.yml"
workflow_dispatch: # allow the job to be run manually
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 4 * * 1' # 4am every Monday
jobs:
nf34-test:
env:
APP_DIR: 34-cellular-modbus-client
PROJECT_DIR: 34-cellular-modbus-client/firmware
runs-on: NF34
steps:
- uses: actions/checkout@v3
with:
sparse-checkout: |
.github
34-cellular-modbus-client
"${{ env.APP_DIR }}" # does not work
# - name: Setup Python version
# uses: actions/setup-python@v4
# with:
# python-version: '3.11'
# fails with
# Version 3.11 was not found in the local cache
# Error: The version '3.11' with architecture 'arm64' was not found for Ubuntu 22.04.
# The list of all available versions can be found here: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
#
# see: https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#using-setup-python-with-a-self-hosted-runner
# Instead we use the system version of python which has been set to 3.11.4
- name: Create and start virtual environment
run: |
python3 -m venv venv
source venv/bin/activate
- name: Build PlatformIO Project
# NF34_PORT_xxx are defined in the `.env` file in the actions runner service on the self hosted runner
run: |
source venv/bin/activate
pip3 install cffi platformio
echo $PLATFORMIO_BUILD_FLAGS
pio --version
pio remote -a "$PLATFORMIO_AGENT" run -d "$PROJECT_DIR" -t clean
# cannot use --force-remote to build on the agent's pio installation because environment variables are not propagated
# used to have -t clean -t upload which worked with --force-remote, but not with a local build
pio remote -a "$PLATFORMIO_AGENT" run -d "$PROJECT_DIR" --upload-port "$NF34_PORT_STLINK" -t upload
- name: Install Test script dependencies
run: |
source venv/bin/activate
pip3 install -r ${{ env.APP_DIR }}/requirements.txt
- name: Run NF34 test script
run: |
source venv/bin/activate
cd ${{ env.APP_DIR }}
# configuration of the test script provided by the environment variables on the runner
python3 test.py --serial-port $NF34_PORT_MODBUS