From 983bebb6ea18965e04cfb4fc019a89c6d42b1976 Mon Sep 17 00:00:00 2001 From: Tim Huyeng Date: Tue, 1 Nov 2022 11:20:17 +0100 Subject: [PATCH 1/4] working on board ci --- .github/workflows/build.yml | 11 ++++++++--- build.py | 10 +++++++++- platformio_orig.ini | 13 ++++++++++--- src/main.cpp | 2 +- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 53185297..07ac8f98 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,7 @@ on: push: branches: - master - - development + workflow_dispatch: jobs: build: @@ -23,6 +23,7 @@ jobs: - os: windows-latest path: ~\AppData\Local\pip\Cache platformio-path: ~\AppData\Local\platformio\Cache + board: [heltecv2.h,heltecv21.h,ttgov21new.h] runs-on: ${{ matrix.os }} steps: @@ -53,5 +54,9 @@ jobs: 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: Run PlatformIO - run: pio run + - name: Clean + run: pio run -t clean -e ci + - name: Run PlatformIO Test + env: + CI_HALFILE: ${{ matrix.board }} + run: pio run -e ci diff --git a/build.py b/build.py index 94b53ff9..1ab79cbd 100644 --- a/build.py +++ b/build.py @@ -27,7 +27,15 @@ haldir = os.path.join (srcdir, "hal") # check if hal file is present in source directory halconfig = config.get("board", "halfile") -halconfigfile = os.path.join (haldir, halconfig) + +# check if hal file is not set by ENV CI_HALFILE +if not os.getenv("CI_HALFILE"): + halconfigfile = os.path.join (haldir, halconfig) +else: + # if set, use ENV CI_HALFILE + print("CI_HALFILE ENV FOUND") + halconfigfile = os.path.join (haldir,os.getenv("CI_HALFILE")) + if os.path.isfile(halconfigfile) and os.access(halconfigfile, os.R_OK): print("Parsing hardware configuration from " + halconfigfile) else: diff --git a/platformio_orig.ini b/platformio_orig.ini index 3eb41b62..e2005bc5 100644 --- a/platformio_orig.ini +++ b/platformio_orig.ini @@ -82,7 +82,7 @@ lib_deps_basic = https://github.com/SukkoPera/Arduino-Rokkit-Hash.git bblanchon/ArduinoJson @ ^6 makuna/RTC @ ^2.3.5 - spacehuhn/SimpleButton + spacehuhn/SimpleButton lewisxhe/XPowersLib @ ^0.1.4 256dpi/MQTT @ ^2.5.0 lib_deps_all = @@ -94,7 +94,6 @@ lib_deps_all = ${common.lib_deps_sensors} ${common.lib_deps_ledmatrix} build_flags_basic = - -include "src/hal/${board.halfile}" -include "src/paxcounter.conf" '-DCORE_DEBUG_LEVEL=${common.debug_level}' '-DLOG_LOCAL_LEVEL=${common.debug_level}' @@ -115,7 +114,9 @@ upload_speed = ${common.upload_speed} ;upload_port = COM12 platform = ${common.platform_espressif32} lib_deps = ${common.lib_deps_all} -build_flags = ${common.build_flags_all} +build_flags = + -include "src/hal/${board.halfile}" + ${common.build_flags_all} upload_protocol = ${common.upload_protocol} extra_scripts = ${common.extra_scripts} monitor_speed = ${common.monitor_speed} @@ -131,3 +132,9 @@ upload_protocol = esptool upload_protocol = esptool platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git + +[env:ci] +build_flags = + -include "src/hal/${sysenv.CI_HALFILE}" ; set by CI + ${common.build_flags_all} +upload_protocol = esptool \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 380120ee..00a8bf2e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -276,7 +276,7 @@ void setup() { libpax_default_config(&configuration); // configure WIFI sniffing - strcpy(configuration.wifi_my_country, WIFI_MY_COUNTRY); + strcpy(configuration.wifi_my_country_str, WIFI_MY_COUNTRY); configuration.wificounter = cfg.wifiscan; configuration.wifi_channel_map = WIFI_CHANNEL_ALL; configuration.wifi_channel_switch_interval = cfg.wifichancycle; From 06286fafa7234c1e45e318a39d8bdbd22ae6496f Mon Sep 17 00:00:00 2001 From: Tim Huyeng Date: Tue, 1 Nov 2022 11:21:12 +0100 Subject: [PATCH 2/4] added branch for testing --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 07ac8f98..91ed248a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - build-workflow workflow_dispatch: jobs: From fe156d006d63c87c99c773838f3be09b20e2c12c Mon Sep 17 00:00:00 2001 From: Tim Huyeng Date: Tue, 1 Nov 2022 11:33:27 +0100 Subject: [PATCH 3/4] reduce to ubuntu-os, fixed release build name using the correct halconfig --- .github/workflows/build.yml | 5 +++-- build.py | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91ed248a..b103b3d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,8 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest] + # os: [ubuntu-latest, windows-latest, macos-latest] include: - os: ubuntu-latest path: ~/.cache/pip @@ -57,7 +58,7 @@ jobs: cp src/paxcounter_orig.conf src/paxcounter.conf - name: Clean run: pio run -t clean -e ci - - name: Run PlatformIO Test + - name: Run PlatformIO CI for ${{ matrix.board }} env: CI_HALFILE: ${{ matrix.board }} run: pio run -e ci diff --git a/build.py b/build.py index 1ab79cbd..5d5e4cb2 100644 --- a/build.py +++ b/build.py @@ -28,13 +28,14 @@ haldir = os.path.join (srcdir, "hal") # check if hal file is present in source directory halconfig = config.get("board", "halfile") -# check if hal file is not set by ENV CI_HALFILE -if not os.getenv("CI_HALFILE"): - halconfigfile = os.path.join (haldir, halconfig) -else: +# check if hal file is set by ENV CI_HALFILE +if os.getenv("CI_HALFILE"): # if set, use ENV CI_HALFILE print("CI_HALFILE ENV FOUND") - halconfigfile = os.path.join (haldir,os.getenv("CI_HALFILE")) + # override halconfig + halconfig = os.getenv("CI_HALFILE") + +halconfigfile = os.path.join (haldir, halconfig) if os.path.isfile(halconfigfile) and os.access(halconfigfile, os.R_OK): print("Parsing hardware configuration from " + halconfigfile) From 0267e09ff8b36a9322ef9f29e5975d42cf18e86c Mon Sep 17 00:00:00 2001 From: Tim Huyeng Date: Tue, 1 Nov 2022 11:37:18 +0100 Subject: [PATCH 4/4] remvoed whitespaces, added all boards to workflow --- .github/workflows/build.yml | 55 +++++++++++++++++++++++++++++-------- build.py | 10 +++---- src/paxcounter_orig.conf | 4 +-- 3 files changed, 50 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b103b3d0..0e47212a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,8 +4,8 @@ on: pull_request: push: branches: - - master - - build-workflow + - master + - build-workflow workflow_dispatch: jobs: @@ -16,16 +16,47 @@ jobs: os: [ubuntu-latest] # 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: [heltecv2.h,heltecv21.h,ttgov21new.h] + - 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: + [ + generic.h, + ebox.h, + eboxtube.h, + ecopower.h, + heltec.h, + heltecv2.h, + heltecv21.h, + ttgov1.h, + ttgov2.h, + ttgov21old.httgov21new.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: diff --git a/build.py b/build.py index 5d5e4cb2..e6bd6b50 100644 --- a/build.py +++ b/build.py @@ -107,10 +107,10 @@ env.Replace(PAXEXPRESS_API_TOKEN=apitoken) # get runtime credentials and put them to compiler directive env.Append(BUILD_FLAGS=[ - u'-DWIFI_SSID=\\"' + mykeys["OTA_WIFI_SSID"] + '\\"', - u'-DWIFI_PASS=\\"' + mykeys["OTA_WIFI_PASS"] + '\\"', - u'-DPAXEXPRESS_USER=\\"' + mykeys["PAXEXPRESS_USER"] + '\\"', - u'-DPAXEXPRESS_REPO=\\"' + mykeys["PAXEXPRESS_REPO"] + '\\"', + u'-DWIFI_SSID=\\"' + mykeys["OTA_WIFI_SSID"] + '\\"', + u'-DWIFI_PASS=\\"' + mykeys["OTA_WIFI_PASS"] + '\\"', + u'-DPAXEXPRESS_USER=\\"' + mykeys["PAXEXPRESS_USER"] + '\\"', + u'-DPAXEXPRESS_REPO=\\"' + mykeys["PAXEXPRESS_REPO"] + '\\"', u'-DPAXEXPRESS_PACKAGE=\\"' + package + '\\"', u'-DARDUINO_LMIC_PROJECT_CONFIG_H=' + lmicconfig, u'-I \"' + srcdir + '\"' @@ -136,7 +136,7 @@ def publish_paxexpress(source, target, env): } r = None - + try: r = requests.put(url, data=open(firmware_path, "rb"), diff --git a/src/paxcounter_orig.conf b/src/paxcounter_orig.conf index 5249a6f0..ce9a42c3 100644 --- a/src/paxcounter_orig.conf +++ b/src/paxcounter_orig.conf @@ -97,7 +97,7 @@ #define RCMDPORT 2 // remote commands #define STATUSPORT 2 // remote command results #define CONFIGPORT 3 // config query results -#define GPSPORT 4 // gps - NOTE: set to 1 to send combined GPS+COUNTERPORT payload +#define GPSPORT 4 // gps - NOTE: set to 1 to send combined GPS+COUNTERPORT payload #define BUTTONPORT 5 // button pressed signal #define RESERVEDPORT 6 // reserved (unused) #define BMEPORT 7 // BME680 sensor @@ -126,4 +126,4 @@ #define MQTT_PASSWD "public" #define MQTT_RETRYSEC 20 // retry reconnect every 20 seconds #define MQTT_KEEPALIVE 10 // keep alive interval in seconds -//#define MQTT_CLIENTNAME "my_paxcounter" // generated by default +//#define MQTT_CLIENTNAME "my_paxcounter" // generated by default \ No newline at end of file