Skip to content

Commit ee00e49

Browse files
committed
Refactor GitHub Actions workflows for build, documentation, and linting
- Consolidated build logic into reusable workflows (`task-build.yml` and `task-docs.yml`) to reduce duplication across multiple workflows. - Introduced `environments.json` to centralize the list of PlatformIO build environments, improving maintainability and clarity. - Updated `build.yml` and `build_and_docs_to_dev.yml` to utilize the new reusable workflows and environment definitions. - Enhanced `release.yml` to streamline the release process and integrate documentation generation. - Created reusable linting workflow (`task-lint.yml`) to standardize code formatting checks across the repository. - Simplified manual documentation workflow by leveraging the new reusable documentation workflow. - Improved artifact management and retention policies across workflows. - Updated dependencies and versions in workflows to ensure compatibility and performance.
1 parent 3266449 commit ee00e49

File tree

10 files changed

+1099
-344
lines changed

10 files changed

+1099
-344
lines changed

.github/workflows/README.md

Lines changed: 535 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/build.yml

Lines changed: 8 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -4,125 +4,17 @@ on: [push, pull_request]
44

55
jobs:
66
build:
7-
strategy:
8-
fail-fast: false
9-
matrix:
10-
environments:
11-
- "rfbridge"
12-
- "rfbridge-direct"
13-
- "esp32dev-all-test"
14-
- "esp32dev-rf"
15-
- "esp32dev-pilight-cc1101"
16-
- "esp32dev-somfy-cc1101"
17-
- "esp32dev-pilight-somfy-cc1101"
18-
- "esp32dev-weatherstation"
19-
- "esp32dev-gf-sun-inverter"
20-
- "esp32dev-ir"
21-
- "esp32dev-ble"
22-
- "esp32dev-ble-mqtt-undecoded"
23-
- "esp32dev-ble-aws"
24-
- "esp32feather-ble"
25-
- "esp32-lolin32lite-ble"
26-
- "esp32-olimex-gtw-ble-eth"
27-
- "esp32-olimex-gtw-ble-poe"
28-
- "esp32-olimex-gtw-ble-poe-iso"
29-
- "esp32-wt32-eth01-ble-eth"
30-
- "esp32-olimex-gtw-ble-wifi"
31-
- "esp32-m5stick-ble"
32-
- "esp32-m5stack-ble"
33-
- "esp32-m5tough-ble"
34-
- "esp32-m5stick-c-ble"
35-
- "esp32-m5stick-cp-ble"
36-
- "esp32s3-atomS3U"
37-
- "esp32-m5atom-matrix"
38-
- "esp32-m5atom-lite"
39-
- "esp32dev-rtl_433"
40-
- "esp32dev-rtl_433-fsk"
41-
- "esp32doitv1-aithinker-r01-sx1278"
42-
- "heltec-rtl_433"
43-
- "heltec-rtl_433-fsk"
44-
- "heltec-ble"
45-
- "lilygo-rtl_433"
46-
- "lilygo-rtl_433-fsk"
47-
- "lilygo-ble"
48-
- "esp32dev-multi_receiver"
49-
- "esp32dev-multi_receiver-pilight"
50-
- "tinypico-ble"
51-
- "ttgo-lora32-v1"
52-
- "ttgo-lora32-v21"
53-
- "ttgo-t-beam"
54-
- "heltec-wifi-lora-32"
55-
- "shelly-plus1"
56-
- "nodemcuv2-all-test"
57-
- "nodemcuv2-fastled-test"
58-
- "nodemcuv2-2g"
59-
- "nodemcuv2-ir"
60-
- "nodemcuv2-serial"
61-
- "avatto-bakeey-ir"
62-
- "nodemcuv2-rf"
63-
- "nodemcuv2-rf-cc1101"
64-
- "nodemcuv2-somfy-cc1101"
65-
- "manual-wifi-test"
66-
- "rf-wifi-gateway"
67-
- "nodemcuv2-rf2"
68-
- "nodemcuv2-rf2-cc1101"
69-
- "nodemcuv2-pilight"
70-
- "nodemcuv2-weatherstation"
71-
- "sonoff-basic"
72-
- "sonoff-basic-rfr3"
73-
- "esp32dev-ble-datatest"
74-
- "esp32s3-dev-c1-ble"
75-
- "esp32c3-dev-m1-ble"
76-
- "airm2m_core_esp32c3"
77-
- "esp32c3_lolin_mini"
78-
- "esp32c3-m5stamp"
79-
- "thingpulse-espgateway"
80-
- "theengs-bridge"
81-
- "esp32dev-ble-idf"
82-
- "theengs-bridge-v11"
83-
- "theengs-plug"
84-
- "esp32dev-ble-broker"
85-
- "esp32s3-m5stack-stamps3"
86-
- "esp32c3u-m5stamp"
87-
- "lilygo-t3-s3-rtl_433"
88-
- "lilygo-t3-s3-rtl_433-fsk"
89-
runs-on: ubuntu-latest
90-
name: Build with PlatformIO
91-
steps:
92-
- uses: actions/checkout@v4
93-
- name: Set up Python
94-
uses: actions/setup-python@v5
95-
with:
96-
python-version: '3.13'
97-
- name: Install uv
98-
uses: astral-sh/setup-uv@v6
99-
with:
100-
version: "latest"
101-
enable-cache: false
102-
- name: Install dependencies
103-
run: |
104-
uv pip install --system -U https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.18.zip
105-
- name: Extract ESP32 platform version from platformio.ini
106-
run: |
107-
ESP32_VERSION=$(grep 'esp32_platform\s*=' platformio.ini | cut -d'@' -f2 | tr -d '[:space:]')
108-
echo "ESP32_PLATFORM_VERSION=${ESP32_VERSION}" >> $GITHUB_ENV
109-
- name: Run PlatformIO
110-
env:
111-
PYTHONIOENCODING: utf-8
112-
PYTHONUTF8: '1'
113-
run: platformio run -e ${{ matrix.environments }}
114-
- name: Upload Assets
115-
uses: actions/upload-artifact@v4
116-
with:
117-
name: ${{ matrix.environments }}
118-
path: |
119-
.pio/build/*/firmware.bin
120-
.pio/build/*/partitions.bin
121-
retention-days: 7
7+
name: Build firmware
8+
uses: ./.github/workflows/task-build.yml
9+
with:
10+
python-version: '3.13'
11+
enable-dev-ota: false
12+
artifact-retention-days: 7
13+
prepare-for-deploy: false
12214

12315
documentation:
16+
name: Build documentation
12417
runs-on: ubuntu-latest
125-
name: Create the documentation
12618
steps:
12719
- uses: actions/checkout@v4
12820
- name: Set up Node.js
Lines changed: 43 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -1,173 +1,65 @@
11
name: Build binaries, docs and publish to dev folder
2+
23
on:
34
workflow_dispatch:
45
schedule:
56
- cron: '0 0 * * *'
7+
68
jobs:
7-
build:
8-
strategy:
9-
fail-fast: false
10-
matrix:
11-
environments:
12-
- "rfbridge"
13-
- "rfbridge-direct"
14-
- "theengs-bridge"
15-
- "theengs-bridge-v11"
16-
- "theengs-plug"
17-
- "esp32dev-all-test"
18-
- "esp32dev-rf"
19-
- "esp32dev-pilight"
20-
- "esp32dev-pilight-cc1101"
21-
- "esp32dev-somfy-cc1101"
22-
- "esp32dev-pilight-somfy-cc1101"
23-
- "esp32dev-weatherstation"
24-
- "esp32dev-gf-sun-inverter"
25-
- "esp32dev-ir"
26-
- "esp32dev-ble"
27-
- "esp32dev-ble-broker"
28-
- "esp32dev-ble-mqtt-undecoded"
29-
- "esp32dev-ble-aws"
30-
- "esp32feather-ble"
31-
- "esp32-lolin32lite-ble"
32-
- "esp32-olimex-gtw-ble-eth"
33-
- "esp32-olimex-gtw-ble-poe"
34-
- "esp32-olimex-gtw-ble-poe-iso"
35-
- "esp32-wt32-eth01-ble-eth"
36-
- "esp32-olimex-gtw-ble-wifi"
37-
- "esp32-m5stick-ble"
38-
- "esp32-m5stack-ble"
39-
- "esp32-m5tough-ble"
40-
- "esp32-m5stick-c-ble"
41-
- "esp32-m5stick-cp-ble"
42-
- "esp32-m5atom-matrix"
43-
- "esp32-m5atom-lite"
44-
- "esp32doitv1-aithinker-r01-sx1278"
45-
- "esp32dev-rtl_433"
46-
- "esp32dev-rtl_433-fsk"
47-
- "heltec-rtl_433"
48-
- "heltec-rtl_433-fsk"
49-
- "heltec-ble"
50-
- "lilygo-rtl_433"
51-
- "lilygo-rtl_433-fsk"
52-
- "lilygo-t3-s3-rtl_433"
53-
- "lilygo-t3-s3-rtl_433-fsk"
54-
- "lilygo-ble"
55-
- "esp32dev-multi_receiver"
56-
- "esp32dev-multi_receiver-pilight"
57-
- "tinypico-ble"
58-
- "ttgo-lora32-v1"
59-
- "ttgo-lora32-v21"
60-
- "ttgo-t-beam"
61-
- "heltec-wifi-lora-32"
62-
- "shelly-plus1"
63-
- "nodemcuv2-all-test"
64-
- "nodemcuv2-fastled-test"
65-
- "nodemcuv2-2g"
66-
- "nodemcuv2-ir"
67-
- "nodemcuv2-serial"
68-
- "avatto-bakeey-ir"
69-
- "nodemcuv2-rf"
70-
- "nodemcuv2-rf-cc1101"
71-
- "nodemcuv2-somfy-cc1101"
72-
- "manual-wifi-test"
73-
- "rf-wifi-gateway"
74-
- "nodemcuv2-rf2"
75-
- "nodemcuv2-rf2-cc1101"
76-
- "nodemcuv2-pilight"
77-
- "nodemcuv2-weatherstation"
78-
- "sonoff-basic"
79-
- "sonoff-basic-rfr3"
80-
- "esp32dev-ble-datatest"
81-
- "esp32s3-dev-c1-ble"
82-
- "esp32s3-m5stack-stamps3"
83-
- "esp32s3-atomS3U"
84-
- "esp32c3-dev-m1-ble"
85-
- "airm2m_core_esp32c3"
86-
- "esp32c3-dev-c2-ble"
87-
- "esp32c3-dev-c2-ble-no-serial"
88-
- "esp32c3_lolin_mini"
89-
- "esp32c3_lolin_mini_with_serial"
90-
- "esp32c3-m5stamp"
91-
- "esp32c3u-m5stamp"
92-
- "thingpulse-espgateway"
93-
- "esp32dev-ble-idf"
9+
prepare:
9410
runs-on: ubuntu-latest
9511
if: github.repository_owner == '1technophile'
96-
name: Build ${{ matrix.environments }}
12+
outputs:
13+
short-sha: ${{ steps.short-sha.outputs.sha }}
9714
steps:
9815
- uses: actions/checkout@v4
9916
- uses: benjlevesque/short-sha@v2.1
10017
id: short-sha
10118
with:
10219
length: 6
103-
- name: Set up Python
104-
uses: actions/setup-python@v5
105-
with:
106-
python-version: "3.13"
107-
- name: Install uv
108-
uses: astral-sh/setup-uv@v6
109-
with:
110-
version: "latest"
111-
enable-cache: false
112-
- name: Install dependencies
113-
run: |
114-
uv pip install --system -U https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.18.zip
115-
- name: Set sha tag
116-
run: |
117-
sed -i "s/version_tag/${{ steps.short-sha.outputs.sha }}/g" main/User_config.h scripts/latest_version_dev.json
118-
- name: Run PlatformIO
119-
env:
120-
PYTHONIOENCODING: utf-8
121-
PYTHONUTF8: '1'
122-
run: |
123-
export PLATFORMIO_BUILD_FLAGS="'-DDEVELOPMENTOTA=true'"
124-
platformio run -e ${{ matrix.environments }}
125-
- name: Prepare firmware artifacts
126-
run: |
127-
mkdir -p firmware
128-
cp .pio/build/${{ matrix.environments }}/firmware.bin firmware/${{ matrix.environments }}-firmware.bin
129-
if [ -f .pio/build/${{ matrix.environments }}/partitions.bin ]; then
130-
cp .pio/build/${{ matrix.environments }}/partitions.bin firmware/${{ matrix.environments }}-partitions.bin
131-
fi
132-
if [ -f .pio/build/${{ matrix.environments }}/bootloader.bin ]; then
133-
cp .pio/build/${{ matrix.environments }}/bootloader.bin firmware/${{ matrix.environments }}-bootloader.bin
134-
fi
135-
- name: Upload firmware
136-
uses: actions/upload-artifact@v4
137-
with:
138-
name: firmware-${{ matrix.environments }}
139-
path: firmware/
140-
retention-days: 1
20+
21+
build:
22+
needs: prepare
23+
name: Build development firmware
24+
uses: ./.github/workflows/task-build.yml
25+
with:
26+
python-version: '3.13'
27+
enable-dev-ota: true
28+
version-tag: ${{ needs.prepare.outputs.short-sha }}
29+
artifact-retention-days: 1
30+
artifact-name-prefix: 'firmware-'
31+
prepare-for-deploy: true
14132

14233
deploy:
143-
needs: build
34+
needs: [prepare, build]
14435
runs-on: ubuntu-latest
14536
if: github.repository_owner == '1technophile'
14637
name: Deploy binaries and docs
14738
steps:
14839
- uses: actions/checkout@v4
149-
- uses: benjlevesque/short-sha@v2.1
150-
id: short-sha
151-
with:
152-
length: 6
40+
15341
- name: Download all firmware artifacts
15442
uses: actions/download-artifact@v4
15543
with:
15644
pattern: firmware-*
15745
path: toDeploy
15846
merge-multiple: true
47+
15948
- name: Set up Python
16049
uses: actions/setup-python@v5
16150
with:
16251
python-version: "3.13"
52+
16353
- name: Install uv
16454
uses: astral-sh/setup-uv@v6
16555
with:
16656
version: "latest"
16757
enable-cache: false
58+
16859
- name: Install dependencies
16960
run: |
17061
uv pip install --system -U https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.18.zip
62+
17163
- name: Create library zips
17264
run: |
17365
# Install libraries for a representative environment to get libdeps
@@ -180,6 +72,7 @@ jobs:
18072
zip -r "${i%/}-libraries.zip" "$i"
18173
done
18274
mv *.zip ../../toDeploy/
75+
18376
- name: Prepare additional assets
18477
run: |
18578
cd toDeploy
@@ -189,33 +82,22 @@ jobs:
18982
# Zip source code
19083
zip -r toDeploy/OpenMQTTGateway_sources.zip main LICENSE.txt
19184
ls -lA toDeploy/
192-
- name: Set sha tag for docs
193-
run: |
194-
sed -i "s/version_tag/DEVELOPMENT SHA:${{ steps.short-sha.outputs.sha }} TEST ONLY/g" docs/.vuepress/config.js
195-
sed -i "s|base: '/'|base: '/dev/'|g" docs/.vuepress/config.js
196-
- name: Set up Node.js
197-
uses: actions/setup-node@v4
198-
with:
199-
node-version: "16.x"
200-
- name: Download Common Config
201-
run: |
202-
curl -o docs/.vuepress/public/commonConfig.js https://www.theengs.io/commonConfig.js
203-
- name: Build documentation
204-
run: |
205-
python ./scripts/gen_wu.py --dev
206-
npm install
207-
npm run docs:build
208-
- name: Deploy to GitHub Pages
209-
uses: peaceiris/actions-gh-pages@v3
210-
with:
211-
github_token: ${{ secrets.GITHUB_TOKEN }}
212-
publish_dir: ./docs/.vuepress/dist
213-
destination_dir: dev
214-
cname: docs.openmqttgateway.com
215-
- name: Running Page Speed Insights
216-
uses: jakepartusch/psi-action@v1.3
217-
id: psi
218-
with:
219-
url: "https://docs.openmqttgateway.com/dev/"
220-
threshold: 60
221-
key: ${{ secrets.APIKEY }}
85+
86+
documentation:
87+
needs: [prepare, build]
88+
name: Build and deploy development documentation
89+
uses: ./.github/workflows/task-docs.yml
90+
with:
91+
python-version: '3.11'
92+
node-version: '16.x'
93+
version-source: 'custom'
94+
custom-version: 'DEVELOPMENT SHA:${{ needs.prepare.outputs.short-sha }} TEST ONLY'
95+
base-path: '/dev/'
96+
destination-dir: 'dev'
97+
generate-webuploader: true
98+
webuploader-args: '--dev'
99+
run-pagespeed: true
100+
pagespeed-url: 'https://docs.openmqttgateway.com/dev/'
101+
secrets:
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
APIKEY: ${{ secrets.APIKEY }}

0 commit comments

Comments
 (0)