ESP32-PaxCounter/.github/workflows/build.yml

270 lines
9.0 KiB
YAML
Raw Normal View History

2023-01-17 14:56:40 +01:00
name: PlatformIO CI/CD
2022-10-27 12:34:43 +02:00
on:
pull_request:
2022-11-22 15:53:30 +01:00
paths-ignore:
- 'docs/**'
- 'mkdocs.yml'
- 'LICENSE'
- 'README.md'
2022-10-27 12:34:43 +02:00
push:
2022-10-27 13:34:26 +02:00
branches:
- master
- build-workflow
2022-11-22 15:53:30 +01:00
paths-ignore:
- 'docs/**'
- 'mkdocs.yml'
- 'LICENSE'
- 'README.md'
2023-01-21 15:34:09 +01:00
schedule:
# do a build once a week at 06:07Z Sunday
- cron: '7 6 * * 0'
2023-01-18 10:19:29 +01:00
workflow_dispatch:
2023-01-21 15:46:03 +01:00
jobs:
build-for-all-boards:
name: Build code for all ESP32 boards
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
include:
- os: ubuntu-latest
path: ~/.cache/pip
platformio-path: ~/.platformio
board:
[
generic.h,
ebox.h,
eboxtube.h,
ecopower.h,
heltec.h,
heltecv2.h,
heltecv21.h,
ttgov1.h,
ttgov2.h,
ttgov21old.h,
ttgov21new.h,
ttgofox.h,
ttgobeam.h,
ttgobeam10.h,
ttgotdisplay.h,
ttgotwristband.h,
fipy.h,
lopy.h,
lopy4.h,
lolin32litelora.h,
lolin32lora.h,
lolin32lite.h,
wemos32oled.h,
wemos32matrix.h,
octopus32.h,
tinypico.h,
tinypicomatrix.h,
m5core.h,
m5fire.h,
olimexpoeiso.h,
]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Cache pip
uses: actions/cache@v3
with:
path: ${{ matrix.path }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v3
with:
path: ${{ matrix.platformio-path }}
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9.13"
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Copy of necessary files
run: |
cp platformio_orig.ini platformio.ini
cp src/loraconf_sample.h src/loraconf.h
cp src/ota_sample.conf src/ota.conf
cp src/paxcounter_orig.conf src/paxcounter.conf
- name: Clean
run: pio run -t clean -e ci
- name: Run PlatformIO CI for ${{ matrix.board }}
env:
CI_HALFILE: ${{ matrix.board }}
run: pio run -e ci
build-windows-macos:
name: Build code on platforms Windows and MAC
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
include:
- os: macos-latest
path: ~/Library/Caches/pip
platformio-path: ~/Library/Caches/platformio
- os: windows-latest
path: ~\AppData\Local\pip\Cache
platformio-path: ~\AppData\Local\platformio\Cache
board: [generic.h, ttgov21new.h]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Cache pip
uses: actions/cache@v3
with:
path: ${{ matrix.path }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v3
with:
path: ${{ matrix.platformio-path }}
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9.13"
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Copy of necessary files
run: |
cp platformio_orig.ini platformio.ini
cp src/loraconf_sample.h src/loraconf.h
cp src/ota_sample.conf src/ota.conf
cp src/paxcounter_orig.conf src/paxcounter.conf
- name: Clean
run: pio run -t clean -e ci
- name: Run PlatformIO CI for ${{ matrix.board }}
env:
CI_HALFILE: ${{ matrix.board }}
run: pio run -e ci
build-s3-usb-stick:
name: Build code for ESP32-S3 boards
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
path: ~/.cache/pip
platformio-path: ~/.platformio
- os: macos-latest
path: ~/Library/Caches/pip
platformio-path: ~/Library/Caches/platformio
- os: windows-latest
path: ~\AppData\Local\pip\Cache
platformio-path: ~\AppData\Local\platformio\Cache
board: [ttgotdongles3.h, ttgotdongledisplays3.h]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Cache pip
uses: actions/cache@v3
with:
path: ${{ matrix.path }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v3
with:
path: ${{ matrix.platformio-path }}
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9.13"
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Copy of necessary files
run: |
cp platformio_orig_s3.ini platformio.ini
cp src/loraconf_sample.h src/loraconf.h
cp src/ota_sample.conf src/ota.conf
cp src/paxcounter_orig.conf src/paxcounter.conf
- name: Clean
run: pio run -t clean -e ci
- name: Run PlatformIO CI for ${{ matrix.board }}
env:
CI_HALFILE: ${{ matrix.board }}
run: pio run -e ci
2023-01-20 22:15:55 +01:00
deploy-on-testboard:
2023-01-21 13:40:29 +01:00
name: Deploy code on testboard
2023-01-20 22:15:55 +01:00
runs-on: windows-latest
2023-01-17 14:02:13 +01:00
steps:
- uses: actions/checkout@v3
- name: Cache pip
uses: actions/cache@v3
with:
2023-01-20 22:15:55 +01:00
path: ~\AppData\Local\pip\Cache
2023-01-17 14:02:13 +01:00
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v3
with:
2023-01-20 22:15:55 +01:00
path: ~\AppData\Local\platformio\Cache
2023-01-17 14:02:13 +01:00
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9.13"
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
2023-01-21 15:10:45 +01:00
- name: Prepare config files for test
2023-01-17 14:02:13 +01:00
run: |
2023-01-18 13:52:35 +01:00
cp platformio_orig.ini platformio.ini
2023-01-17 14:02:13 +01:00
cp src/loraconf_sample.h src/loraconf.h
cp src/ota_sample.conf src/ota.conf
cp src/paxcounter_orig.conf src/paxcounter.conf
2023-01-21 15:34:09 +01:00
# apply test credentials to loraconf.h
2023-01-21 15:10:45 +01:00
sed -i "s/APPEUI\[8\] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};/${{ secrets.APPEUI }}/" "src/loraconf.h"
sed -i "s/APPKEY\[16\] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};/${{ secrets.APPKEY }}/" "src/loraconf.h"
2023-01-21 15:34:09 +01:00
# apply test credentials to ota.conf
sed -i "/OTA_WIFI_SSID/c OTA_WIFI_SSID = ${{ secrets.OTA_WIFI_SSID }}" "src/ota.conf"
sed -i "/OTA_WIFI_PASS/c OTA_WIFI_PASS = ${{ secrets.OTA_WIFI_PASS }}" "src/ota.conf"
sed -i "/PAXEXPRESS_USER/c PAXEXPRESS_USER = ${{ secrets.PAXEXPRESS_USER }}" "src/ota.conf"
sed -i "/PAXEXPRESS_REPO/c PAXEXPRESS_REPO = ${{ secrets.PAXEXPRESS_REPO }}" "src/ota.conf"
sed -i "/PAXEXPRESS_API_TOKEN/c PAXEXPRESS_API_TOKEN = ${{ secrets.PAXEXPRESS_API_TOKEN }}" "src/ota.conf"
2023-01-20 22:32:37 +01:00
- name: Build and deploy for testboard
2023-01-17 14:02:13 +01:00
env:
2023-01-21 14:30:38 +01:00
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }}
run: pio remote -a prenzlpi run -t upload -r
- name: Wait 120 seconds
run: sleep 120s
shell: bash
- name: Query testboard
2023-04-29 18:54:25 +02:00
uses: cyberman54/curl@v1.2
id: ttn
with:
#Get latest decoded payload message seen last 120 seconds from testboard
url: 'https://eu1.cloud.thethings.network/api/v3/as/applications/paxcounter-cicd/packages/storage/uplink_message?f_port=1&order=-received_at&last=120s&limit=1&type=uplink_message&field_mask=up.uplink_message.decoded_payload'
method: 'GET'
bearer-token: ${{ secrets.BEARER_TOKEN }}
headers: '{"Accept": "text/event-stream"}'
log-response: false
- name: Check testboard response
run:
2023-04-29 18:54:25 +02:00
echo ${{ fromJson(steps.ttn.outputs.response).data.result.uplink_message.decoded_payload.pax }}