From c7e80a3bb45d2d079487f63908a3fd33ace77717 Mon Sep 17 00:00:00 2001 From: akasaka Date: Sun, 20 Oct 2024 10:02:03 +0900 Subject: [PATCH] Fixing CI --- .env.example | 4 ++-- .github/actions/prepare_pio.yml | 20 -------------------- .github/actions/prepare_pio/action.yml | 19 +++++++++++++++++++ .github/workflows/main.yml | 16 +++++++++++++--- helper/aquestalk-detect.py | 12 ++++++++---- src/service/prefs.cpp | 6 ++++++ 6 files changed, 48 insertions(+), 29 deletions(-) delete mode 100644 .github/actions/prepare_pio.yml create mode 100644 .github/actions/prepare_pio/action.yml diff --git a/.env.example b/.env.example index 9ed89f4..b0ad761 100644 --- a/.env.example +++ b/.env.example @@ -8,10 +8,10 @@ ADMIN_PASS=\"plasma\" # OpenWeatherMap configuration WEATHER_LAT=\"43.0642\" WEATHER_LON=\"141.3469\" -WEATHER_API_KEY=\"your OpenWeatherMap API Key\" +WEATHER_API_KEY=\"your_OpenWeatherMap_API_Key\" # Wordnik configuration -WORDNIK_API_KEY=\"your Wordnik API key\" +WORDNIK_API_KEY=\"your_Wordnik_API_key\" # AquesTalk configuration AQUESTALK_LICENSE_KEY=\"XXX-XXX-XXX\" diff --git a/.github/actions/prepare_pio.yml b/.github/actions/prepare_pio.yml deleted file mode 100644 index 630baa5..0000000 --- a/.github/actions/prepare_pio.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Prepare PIO environment - -on: [workflow_call] - -jobs: - prepare_pio: - name: Set up PIO environment - runs-on: ubuntu-latest - steps: - - uses: actions/cache@v4 - with: - path: | - ~/.cache/pip - ~/.platformio/.cache - key: ${{ runner.os }}-pio - - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - name: Install PlatformIO Core - run: pip install --upgrade platformio \ No newline at end of file diff --git a/.github/actions/prepare_pio/action.yml b/.github/actions/prepare_pio/action.yml new file mode 100644 index 0000000..bcb3042 --- /dev/null +++ b/.github/actions/prepare_pio/action.yml @@ -0,0 +1,19 @@ +name: Prepare PIO environment + +on: [workflow_call] + +runs: + using: "composite" + steps: + - uses: actions/cache@v4 + with: + path: | + ~/.cache/pip + ~/.platformio/.cache + key: pisos-pio + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install PlatformIO Core + shell: bash + run: pip install --upgrade platformio \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e13fbc0..b7a5991 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,7 @@ name: Build production version on: push: - branches: [main] + branches: [main, develop] jobs: build-everything: @@ -13,23 +13,33 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + submodules: recursive - name: Prepare environment uses: ./.github/actions/prepare_pio + - name: Download AquesTalk + run: | + wget https://www.a-quest.com/archive/package/aquestalk-esp32_0243.zip -O /tmp/aquestalk.zip + unzip /tmp/aquestalk.zip -d /tmp + mv /tmp/aquestalk-esp32/src/esp32/libaquestalk.a ./lib/nonfree-aquestalk/libaquestalk.a + mv /tmp/aquestalk-esp32/src/aquestalk.h ./lib/nonfree-aquestalk/aquestalk.h + - name: Create env file + run: cp ./.env.example ./.env - name: Build all targets run: pio run continue-on-error: true # TODO make this more graceful - name: Upload firmware images uses: actions/upload-artifact@v4 with: - name: filesystem path: ./.pio/build/*/firmware.bin + name: firmwares.zip if-no-files-found: error - name: Delete WIP tunes - run: rm ./music/wip_*.pomf + run: rm ./data/music/wip_*.pomf - name: Create LittleFS image run: pio run --target buildfs --environment music-pomf - name: Upload filesystem image uses: actions/upload-artifact@v4 with: path: ./.pio/build/music-pomf/littlefs.bin + name: filesystem.zip if-no-files-found: error \ No newline at end of file diff --git a/helper/aquestalk-detect.py b/helper/aquestalk-detect.py index e0dd6ff..c803b8c 100644 --- a/helper/aquestalk-detect.py +++ b/helper/aquestalk-detect.py @@ -1,8 +1,12 @@ -from os.path import isfile +from os.path import isfile, join, abspath +from os import getcwd Import("env") -if isfile("./lib/nonfree-aquestalk/libaquestalk.a"): - print("Found a copy of AquesTalk") - env.Append(BUILD_FLAGS=["-LD:lib/nonfree-aquestalk", "-laquestalk", "-DLIBAQUESTALK_FOUND"]) +DIR_PATH=abspath(join(getcwd(), "lib/nonfree-aquestalk")).replace("\\", "/") +LIB_PATH=join(DIR_PATH, "libaquestalk.a") + +if isfile(LIB_PATH): + print("Found a copy of AquesTalk:", LIB_PATH) + env.Append(BUILD_FLAGS=["-L"+DIR_PATH, "-laquestalk", "-DLIBAQUESTALK_FOUND"]) else: print("No AquesTalk library found") \ No newline at end of file diff --git a/src/service/prefs.cpp b/src/service/prefs.cpp index 5f52811..54d04f4 100644 --- a/src/service/prefs.cpp +++ b/src/service/prefs.cpp @@ -35,6 +35,12 @@ inline void init_store_if_needed() { prefs_set_int(PREFS_KEY_HOURLY_CHIME_MELODY, 2); prefs_set_bool(PREFS_KEY_VOICE_SPEAK_ON_HEADPAT, true); prefs_set_bool(PREFS_KEY_WEATHER_OVERLAY, true); + #ifdef WORDNIK_API_KEY + prefs_set_string(PREFS_KEY_WORDNIK_APIKEY, String(WORDNIK_API_KEY)); + #endif + #ifdef WEATHER_API_KEY + prefs_set_string(PREFS_KEY_WEATHER_APIKEY, String(WEATHER_API_KEY)); + #endif prefs_set_bool(PREFS_KEY_INITIAL_SETTING_DONE, true); }