Updates and add Forgejo CI action

This commit is contained in:
Djuri Baars 2024-12-19 17:04:16 +01:00
parent f80c314247
commit 99c34d029f
7 changed files with 151 additions and 15 deletions

View file

@ -0,0 +1,139 @@
name: "BTClock CI"
on:
push:
tags:
- "*"
workflow_dispatch:
jobs:
build:
runs-on: docker
container:
image: ghcr.io/catthehacker/ubuntu:js-22.04
permissions:
contents: write
checks: write
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: yarn
cache-dependency-path: "**/yarn.lock"
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
~/data/node_modules
.pio
data/node_modules
key: ${{ runner.os }}-pio
- uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: "pip"
- name: Get current date
id: dateAndTime
shell: bash
run: echo "dateAndTime=$(date +'%Y-%m-%d-%H:%M')" >> $GITHUB_OUTPUT
- name: Install PlatformIO Core
shell: bash
run: pip install --upgrade platformio
- name: Run unit tests
shell: bash
run: mkdir -p junit-reports && pio test -e native_test_only --junit-output-path junit-reports/
- name: Build BTClock firmware
shell: bash
run: pio run
- name: Build BTClock filesystem
shell: bash
run: pio run --target buildfs
- name: Copy bootloader to output folder
run: cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin .pio
- name: Upload artifacts
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with:
include-hidden-files: true
retention-days: 1
name: prepared-outputs
path: .pio/**/*.bin
merge:
runs-on: docker
container:
image: ghcr.io/catthehacker/ubuntu:js-22.04
permissions:
contents: write
checks: write
needs: build
continue-on-error: true
strategy:
matrix:
chip:
- name: lolin_s2_mini
version: esp32s2
- name: lolin_s3_mini
version: esp32s3
- name: orangeclock
version: esp32s3
epd_variant: [213epd, 29epd]
exclude:
- chip: orangeclock
epd_variant: 213epd
steps:
- uses: https://code.forgejo.org/forgejo/download-artifact@v4
with:
name: prepared-outputs
path: .pio
- name: Install esptools.py
run: pip install --upgrade esptool
- name: Create merged firmware binary
run: mkdir -p ${{ matrix.chip.name }}_${{ matrix.epd_variant }} && esptool.py --chip ${{ matrix.chip.version }} merge_bin -o ${{ matrix.chip.name }}_${{ matrix.epd_variant }}/${{ matrix.chip.name }}_${{ matrix.epd_variant }}.bin --flash_mode dio 0x0000 .pio/build/${{ matrix.chip.name }}_${{ matrix.epd_variant }}/bootloader.bin 0x8000 .pio/build/${{ matrix.chip.name }}_${{ matrix.epd_variant }}/partitions.bin 0xe000 .pio/boot_app0.bin 0x10000 .pio/build/${{ matrix.chip.name }}_${{ matrix.epd_variant }}/firmware.bin 0x369000 .pio/build/${{ matrix.chip.name }}_${{ matrix.epd_variant }}/littlefs.bin
- name: Create checksum for firmware
shell: bash
run: shasum -a 256 .pio/build/${{ matrix.chip.name }}_${{ matrix.epd_variant }}/firmware.bin | awk '{print $1}' > ${{ matrix.chip.name }}_${{ matrix.epd_variant }}/${{ matrix.chip.name }}_${{ matrix.epd_variant }}_firmware.bin.sha256
- name: Create checksum for merged binary
run: shasum -a 256 ${{ matrix.chip.name }}_${{ matrix.epd_variant }}/${{ matrix.chip.name }}_${{ matrix.epd_variant }}.bin | awk '{print $1}' > ${{ matrix.chip.name }}_${{ matrix.epd_variant }}/${{ matrix.chip.name }}_${{ matrix.epd_variant }}.sha256
- name: Upload artifacts
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with:
name: build-${{ matrix.chip.name }}-${{ matrix.epd_variant }}
path: |
${{ matrix.chip.name }}_${{ matrix.epd_variant }}/*.bin
${{ matrix.chip.name }}_${{ matrix.epd_variant }}/*.sha256
release:
runs-on: docker
permissions:
contents: write
checks: write
needs: merge
steps:
- name: Download matrix outputs
uses: https://code.forgejo.org/forgejo/download-artifact@v4
with:
pattern: build-*
merge-multiple: false
path: temp
- name: Copy files
run: |
mkdir -p release
find temp -type f \( -name "*.bin" -o -name "*.sha256" \) -exec cp -f {} release/ \;
- name: Create release
uses: https://code.forgejo.org/actions/forgejo-release@v2.4.0
with:
url: "https://git.btclock.dev"
repo: "${{ github.repository }}"
direction: upload
tag: "${{ github.ref_name }}"
sha: "${{ github.sha }}"
release-dir: release
token: ${{ secrets.TOKEN }}
override: ${{ github.ref_type != 'tag' && github.ref_name != 'main' }}
prerelease: ${{ github.ref_type != 'tag' && github.ref_name != 'main' }}
release-notes-assistant: false

View file

@ -24,12 +24,11 @@ build_flags =
!python scripts/git_rev.py !python scripts/git_rev.py
-DLAST_BUILD_TIME=$UNIX_TIME -DLAST_BUILD_TIME=$UNIX_TIME
lib_deps = lib_deps =
zinggjm/GxEPD2@^1.5.6 zinggjm/GxEPD2@^1.6.1
https://github.com/tzapu/WiFiManager.git#v2.0.17 https://github.com/tzapu/WiFiManager.git#v2.0.17
bblanchon/ArduinoJson@^7.0.3 bblanchon/ArduinoJson@^7.2.1
mathieucarbou/ESP Async WebServer mathieucarbou/ESP Async WebServer@^3.0.6
gilmaimon/ArduinoWebsockets@^0.5.3 fastled/FastLED@^3.9.6
fastled/FastLED@^3.6.0
[env:lolin_s2_mini] [env:lolin_s2_mini]
extends = btclock_base extends = btclock_base
board = lolin_s2_mini board = lolin_s2_mini

View file

@ -90,7 +90,6 @@ void setupWifi()
randomSeed(seed); randomSeed(seed);
// WiFi.begin(, "); // WiFi.begin(, ");
WiFi.setAutoConnect(true);
WiFi.setAutoReconnect(true); WiFi.setAutoReconnect(true);
WiFiManager wm; WiFiManager wm;
@ -181,7 +180,6 @@ void wakeModemSleep()
void enableWiFi() void enableWiFi()
{ {
adc_power_on();
delay(200); delay(200);
WiFi.disconnect(false); // Reconnect the network WiFi.disconnect(false); // Reconnect the network
@ -206,7 +204,6 @@ void enableWiFi()
void disableWiFi() void disableWiFi()
{ {
adc_power_off();
WiFi.disconnect(true); // Disconnect from the network WiFi.disconnect(true); // Disconnect from the network
WiFi.mode(WIFI_OFF); // Switch WiFi off WiFi.mode(WIFI_OFF); // Switch WiFi off
Serial.println(""); Serial.println("");

View file

@ -3,11 +3,11 @@
#include <Arduino.h> #include <Arduino.h>
#include <Preferences.h> #include <Preferences.h>
#include "shared.hpp" #include "shared.hpp"
#include "driver/adc.h"
#include <WiFiManager.h> #include <WiFiManager.h>
#include <base64.h> #include <base64.h>
#include "epd.hpp" #include "epd.hpp"
#include <ArduinoOTA.h> #include <ArduinoOTA.h>
#include <esp_adc/adc_oneshot.h>
void enableWiFi(); void enableWiFi();
void disableWiFi(); void disableWiFi();

View file

@ -1,7 +1,7 @@
#include <Arduino.h> #include <Arduino.h>
#include <WebServer.h> #include <WebServer.h>
#include <WiFiClientSecure.h> #include <WiFiClient.h>
#include <HTTPClient.h> #include <HTTPClient.h>
#include "shared.hpp" #include "shared.hpp"
#include "epd.hpp" #include "epd.hpp"
@ -29,7 +29,7 @@ typedef void (*MethodPtr)(String, char);
MethodPtr methods[] = {nullptr, updateRow1, updateRow2, updateRow3}; MethodPtr methods[] = {nullptr, updateRow1, updateRow2, updateRow3};
WiFiClientSecure client; WiFiClient client;
uint currentPrice = 0; uint currentPrice = 0;
String currentBlock = ""; String currentBlock = "";
String currentFees = ""; String currentFees = "";
@ -71,7 +71,7 @@ void setup()
setupWebserver(); setupWebserver();
setupOTA(); setupOTA();
} }
client.setInsecure(); // client.setInsecure();
#ifndef IS_ORANGECLOCK #ifndef IS_ORANGECLOCK
digitalWrite(LED_BUILTIN, LOW); digitalWrite(LED_BUILTIN, LOW);
@ -103,7 +103,7 @@ void loop()
return; return;
} }
client.setInsecure(); // client.setInsecure();
// //

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <Arduino.h> #include <Arduino.h>
#include <WiFiClientSecure.h> #include <WiFiClient.h>
#include <Preferences.h> #include <Preferences.h>
#include <GxEPD2.h> #include <GxEPD2.h>
#include <GxEPD2_BW.h> #include <GxEPD2_BW.h>
@ -92,7 +92,7 @@ const int LINE_DATE = 100;
#define CURRENCY_AUD "AUD" #define CURRENCY_AUD "AUD"
#define CURRENCY_JPY "JPY" #define CURRENCY_JPY "JPY"
extern WiFiClientSecure client; extern WiFiClient client;
extern GxEPD2_BW<EPD_CLASS, EPD_CLASS::HEIGHT> display; extern GxEPD2_BW<EPD_CLASS, EPD_CLASS::HEIGHT> display;
extern Preferences preferences; extern Preferences preferences;
extern bool isUpdating; extern bool isUpdating;

View file

@ -4,6 +4,7 @@
#include <Arduino.h> #include <Arduino.h>
#include <ArduinoJson.hpp> #include <ArduinoJson.hpp>
#include "shared.hpp" #include "shared.hpp"
#include <esp_mac.h>
namespace ArduinoJson { namespace ArduinoJson {
template <> template <>