Skip to content

Commit 76d4b3d

Browse files
committed
Cleanup tests
1 parent 1a93715 commit 76d4b3d

41 files changed

Lines changed: 55 additions & 2275 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci-cd.yml

Lines changed: 31 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
jobs:
1818
# Stage 1: Branch Development Pipeline
1919
branch-pipeline:
20-
name: Branch Pipeline (Unit Test + Compile + Coverage + SonarQube)
20+
name: Branch Pipeline (Compile + SonarQube)
2121
runs-on: ubuntu-latest
2222
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref != 'refs/heads/main')
2323
steps:
@@ -44,19 +44,19 @@ jobs:
4444
- name: Install dependencies
4545
run: |
4646
pip install --upgrade platformio
47-
pip install gcovr==7.2
4847
sudo apt-get install build-essential bc jq
4948
50-
- name: Run unit tests (native)
51-
run: pio test -e native -f test_ota_simple -f test_wifi_simple -f test_utils_simple -f test_constants_simple
5249
53-
- name: Compile project
54-
run: pio run -e ttgo-lora32-v1-release
50+
- name: Compile project (ttgo-lora32-v1)
51+
run: pio run -e ttgo-lora32-v1
52+
53+
- name: Compile project (minimal)
54+
run: pio run -e minimal
5555

5656
- name: Check flash size limit
5757
run: |
5858
# Get build output and extract flash usage
59-
pio run -e ttgo-lora32-v1-release 2>&1 | tee build_output.log
59+
pio run -e ttgo-lora32-v1 2>&1 | tee build_output.log
6060
6161
# Extract flash usage from build output
6262
FLASH_USED=$(grep -oP 'Flash:.*used \K\d+' build_output.log | tail -n 1)
@@ -91,22 +91,16 @@ jobs:
9191
with:
9292
name: build-artifacts-branch-${{ github.sha }}
9393
path: |
94-
.pio/build/ttgo-lora32-v1-release/firmware.map
95-
.pio/build/ttgo-lora32-v1-release/firmware.elf
94+
.pio/build/ttgo-lora32-v1/firmware.map
95+
.pio/build/ttgo-lora32-v1/firmware.elf
96+
.pio/build/minimal/firmware.map
97+
.pio/build/minimal/firmware.elf
9698
retention-days: 30
9799
if: always()
98100

99101
- name: Generate Compilation DB
100102
run: pio run -t compiledb
101103

102-
- name: Generate coverage report
103-
run: |
104-
gcovr \
105-
--root . \
106-
--exclude '\.pio/libdeps/' \
107-
--exclude 'tests/.*' \
108-
--sonarqube \
109-
--output coverage.xml
110104

111105
- name: SonarQube Scan
112106
uses: SonarSource/sonarqube-scan-action@v5
@@ -115,11 +109,10 @@ jobs:
115109
with:
116110
args: >
117111
--define sonar.cfamily.compile-commands="compile_commands.json"
118-
--define sonar.coverageReportPaths="coverage.xml"
119112
120113
# Stage 2: Main Branch Pipeline
121114
main-pipeline:
122-
name: Main Pipeline (Unit Test + Compile + Coverage + SonarQube)
115+
name: Main Pipeline (Compile + SonarQube)
123116
runs-on: ubuntu-latest
124117
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
125118
steps:
@@ -146,19 +139,18 @@ jobs:
146139
- name: Install dependencies
147140
run: |
148141
pip install --upgrade platformio
149-
pip install gcovr==7.2
150142
sudo apt-get install build-essential bc jq
151143
152-
- name: Run unit tests (native)
153-
run: pio test -e native -f test_ota_simple -f test_wifi_simple -f test_utils_simple -f test_constants_simple
144+
- name: Compile project (ttgo-lora32-v1)
145+
run: pio run -e ttgo-lora32-v1
154146

155-
- name: Compile project
156-
run: pio run -e ttgo-lora32-v1-release
147+
- name: Compile project (minimal)
148+
run: pio run -e minimal
157149

158150
- name: Check flash size limit
159151
run: |
160152
# Get build output and extract flash usage
161-
pio run -e ttgo-lora32-v1-release 2>&1 | tee build_output.log
153+
pio run -e ttgo-lora32-v1 2>&1 | tee build_output.log
162154
163155
# Extract flash usage from build output
164156
FLASH_USED=$(grep -oP 'Flash:.*used \K\d+' build_output.log | tail -n 1)
@@ -193,31 +185,23 @@ jobs:
193185
with:
194186
name: build-artifacts-main-${{ github.sha }}
195187
path: |
196-
.pio/build/ttgo-lora32-v1-release/firmware.map
197-
.pio/build/ttgo-lora32-v1-release/firmware.elf
188+
.pio/build/ttgo-lora32-v1/firmware.map
189+
.pio/build/ttgo-lora32-v1/firmware.elf
190+
.pio/build/minimal/firmware.map
191+
.pio/build/minimal/firmware.elf
198192
retention-days: 30
199193
if: always()
200194

201195
- name: Generate Compilation DB
202196
run: pio run -t compiledb
203197

204-
- name: Generate coverage report
205-
run: |
206-
gcovr \
207-
--root . \
208-
--exclude '\.pio/libdeps/' \
209-
--exclude 'tests/.*' \
210-
--sonarqube \
211-
--output coverage.xml
212-
213198
- name: SonarQube Scan
214199
uses: SonarSource/sonarqube-scan-action@v5
215200
env:
216201
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
217202
with:
218203
args: >
219204
--define sonar.cfamily.compile-commands="compile_commands.json"
220-
--define sonar.coverageReportPaths="coverage.xml"
221205
222206
# Stage 3: Release Pipeline
223207
release-pipeline:
@@ -283,16 +267,17 @@ jobs:
283267
pip install --upgrade platformio
284268
sudo apt-get install build-essential bc jq
285269
286-
- name: Run unit tests (native)
287-
run: pio test -e native -f test_ota_simple -f test_wifi_simple -f test_utils_simple -f test_constants_simple
288270
289-
- name: Compile with updated firmware version
290-
run: pio run -e ttgo-lora32-v1-release
271+
- name: Compile with updated firmware version (ttgo-lora32-v1)
272+
run: pio run -e ttgo-lora32-v1
273+
274+
- name: Compile with updated firmware version (minimal)
275+
run: pio run -e minimal
291276

292277
- name: Check flash size limit
293278
run: |
294279
# Get build output and extract flash usage
295-
pio run -e ttgo-lora32-v1-release 2>&1 | tee build_output.log
280+
pio run -e ttgo-lora32-v1 2>&1 | tee build_output.log
296281
297282
# Extract flash usage from build output
298283
FLASH_USED=$(grep -oP 'Flash:.*used \K\d+' build_output.log | tail -n 1)
@@ -325,10 +310,10 @@ jobs:
325310
- name: Create release artifacts
326311
run: |
327312
mkdir -p artifacts
328-
cp .pio/build/ttgo-lora32-v1-release/firmware.bin artifacts/firmware-${{ steps.validate-tag.outputs.tag_name }}.bin
329-
cp .pio/build/ttgo-lora32-v1-release/firmware.elf artifacts/firmware-${{ steps.validate-tag.outputs.tag_name }}.elf
330-
cp .pio/build/ttgo-lora32-v1-release/firmware.map artifacts/firmware-${{ steps.validate-tag.outputs.tag_name }}.map
331-
cp .pio/build/ttgo-lora32-v1-release/partitions.bin artifacts/partitions-${{ steps.validate-tag.outputs.tag_name }}.bin
313+
cp .pio/build/ttgo-lora32-v1/firmware.bin artifacts/firmware-${{ steps.validate-tag.outputs.tag_name }}.bin
314+
cp .pio/build/ttgo-lora32-v1/firmware.elf artifacts/firmware-${{ steps.validate-tag.outputs.tag_name }}.elf
315+
cp .pio/build/ttgo-lora32-v1/firmware.map artifacts/firmware-${{ steps.validate-tag.outputs.tag_name }}.map
316+
cp .pio/build/ttgo-lora32-v1/partitions.bin artifacts/partitions-${{ steps.validate-tag.outputs.tag_name }}.bin
332317
333318
# Create a manifest file with build info
334319
cat > artifacts/build-info-${{ steps.validate-tag.outputs.tag_name }}.json << EOF

.github/workflows/size-baseline.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ jobs:
3838
3939
- name: Build release and capture artifacts
4040
run: |
41-
# Clean build with verbose output - use release environment for size baseline
42-
pio run -e ttgo-lora32-v1-release -v > ci-build-release.log 2>&1 || RELEASE_BUILD_FAILED=1
41+
# Clean build with verbose output - use ttgo-lora32-v1 environment for size baseline
42+
pio run -e ttgo-lora32-v1 -v be ci-build-release.log 21 || RELEASE_BUILD_FAILED=1
4343
4444
# Create baseline artifacts directory
4545
mkdir -p ci-baseline-artifacts
@@ -48,14 +48,14 @@ jobs:
4848
cp ci-build-release.log ci-baseline-artifacts/
4949
5050
# Copy generated files if they exist
51-
if [ -f ".pio/build/ttgo-lora32-v1-release/firmware.elf" ]; then
52-
cp .pio/build/ttgo-lora32-v1-release/firmware.elf ci-baseline-artifacts/release-firmware.elf
51+
if [ -f ".pio/build/ttgo-lora32-v1/firmware.elf" ]; then
52+
cp .pio/build/ttgo-lora32-v1/firmware.elf ci-baseline-artifacts/release-firmware.elf
5353
else
5454
echo "WARNING: release firmware.elf not found" >> ci-baseline-artifacts/build-warnings.txt
5555
fi
5656
57-
if [ -f ".pio/build/ttgo-lora32-v1-release/firmware.map" ]; then
58-
cp .pio/build/ttgo-lora32-v1-release/firmware.map ci-baseline-artifacts/release-firmware.map
57+
if [ -f ".pio/build/ttgo-lora32-v1/firmware.map" ]; then
58+
cp .pio/build/ttgo-lora32-v1/firmware.map ci-baseline-artifacts/release-firmware.map
5959
else
6060
echo "WARNING: release firmware.map not found" >> ci-baseline-artifacts/build-warnings.txt
6161
fi
@@ -71,7 +71,7 @@ jobs:
7171
echo "" >> ci-baseline-artifacts/ci-memory-usage.txt
7272
7373
# Extract RAM and Flash usage from build log
74-
echo "RELEASE BUILD (ttgo-lora32-v1-release):" >> ci-baseline-artifacts/ci-memory-usage.txt
74+
echo "TTGO-LORA32-V1 BUILD (ttgo-lora32-v1):" >> ci-baseline-artifacts/ci-memory-usage.txt
7575
echo "========================================" >> ci-baseline-artifacts/ci-memory-usage.txt
7676
if grep -q "RAM:\|Flash:" ci-build-release.log; then
7777
grep -A 2 -B 2 "RAM:\|Flash:" ci-build-release.log >> ci-baseline-artifacts/ci-memory-usage.txt
@@ -91,27 +91,27 @@ jobs:
9191
9292
- name: Build debug and capture artifacts
9393
run: |
94-
# Build debug environment for comparison
95-
pio run -e ttgo-lora32-v1-debug -v > ci-build-debug.log 2>&1 || DEBUG_BUILD_FAILED=1
94+
# Build minimal environment for comparison
95+
pio run -e minimal -v be ci-build-debug.log 21 || DEBUG_BUILD_FAILED=1
9696
9797
# Copy debug build log
9898
cp ci-build-debug.log ci-baseline-artifacts/
9999
100100
# Copy debug generated files if they exist
101-
if [ -f ".pio/build/ttgo-lora32-v1-debug/firmware.elf" ]; then
102-
cp .pio/build/ttgo-lora32-v1-debug/firmware.elf ci-baseline-artifacts/debug-firmware.elf
101+
if [ -f ".pio/build/minimal/firmware.elf" ]; then
102+
cp .pio/build/minimal/firmware.elf ci-baseline-artifacts/debug-firmware.elf
103103
else
104104
echo "WARNING: debug firmware.elf not found" >> ci-baseline-artifacts/build-warnings.txt
105105
fi
106106
107-
if [ -f ".pio/build/ttgo-lora32-v1-debug/firmware.map" ]; then
108-
cp .pio/build/ttgo-lora32-v1-debug/firmware.map ci-baseline-artifacts/debug-firmware.map
107+
if [ -f ".pio/build/minimal/firmware.map" ]; then
108+
cp .pio/build/minimal/firmware.map ci-baseline-artifacts/debug-firmware.map
109109
else
110110
echo "WARNING: debug firmware.map not found" >> ci-baseline-artifacts/build-warnings.txt
111111
fi
112112
113113
# Add debug build info to memory usage report
114-
echo "DEBUG BUILD (ttgo-lora32-v1-debug):" >> ci-baseline-artifacts/ci-memory-usage.txt
114+
echo "MINIMAL BUILD (minimal):" >> ci-baseline-artifacts/ci-memory-usage.txt
115115
echo "====================================" >> ci-baseline-artifacts/ci-memory-usage.txt
116116
if grep -q "RAM:\|Flash:" ci-build-debug.log; then
117117
grep -A 2 -B 2 "RAM:\|Flash:" ci-build-debug.log >> ci-baseline-artifacts/ci-memory-usage.txt

Makefile

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# CREATED BY VIM-PIO
2-
all:
2+
all: release
33
platformio -f -c vim run
44

55
upload:
@@ -15,22 +15,12 @@ uploadfs:
1515
platformio -f -c vim run --target uploadfs
1616

1717
# Build the optimized release firmware
18-
.PHONY: release
19-
release:
20-
platformio -f -c vim run -e ttgo-lora32-v1-release
21-
22-
# Build and immediately upload the release firmware
23-
.PHONY: upload-release
24-
upload-release: release
25-
platformio -f -c vim run -e ttgo-lora32-v1-release --target upload
26-
27-
.PHONY: test
28-
test:
29-
platformio test -e native
30-
31-
.PHONY: test-cli
32-
test-cli:
33-
cd cli && go test ./... -v
18+
.PHONY: release minimal
19+
release: ## Build main release env
20+
platformio run -e ttgo-lora32-v1
21+
minimal:
22+
platformio run -e minimal
23+
3424

3525
.PHONY: build-cli
3626
build-cli:

platformio.ini

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
; https://docs.platformio.org/page/projectconf.html
1010

1111
[platformio]
12-
default_envs = ttgo-lora32-v1-debug
12+
default_envs = ttgo-lora32-v1
1313

1414
[options]
1515
; Common build flags for all configurations
@@ -58,34 +58,11 @@ release_build_flags =
5858
release_lib_deps =
5959
${options.common_lib_deps}
6060

61-
unittesting_buildflag = -D unitTesting
62-
generic_hw_buildflag = -D generic_hw
63-
coverage_buildflag =
64-
-lgcov
65-
--coverage
66-
-fprofile-abs-path
6761
platform = espressif32
6862
board = ttgo-lora32-v1
6963
framework = arduino
7064

71-
[env:ttgo-lora32-v1-debug]
72-
monitor_speed = 115200
73-
platform = ${options.platform}
74-
board = ${options.board}
75-
framework = ${options.framework}
76-
board_build.partition_table = huge_app.csv
77-
board_build.maximum_size = 1572864
78-
; Skip program size check
79-
extra_scripts = pre:skip_size_check.py
80-
; Override the board's default maximum size
81-
board_upload.maximum_size = 1572864
82-
build_flags =
83-
${options.debug_build_flags}
84-
-std=gnu++14
85-
lib_deps = ${options.debug_lib_deps}
86-
87-
[env:ttgo-lora32-v1-release]
88-
monitor_speed = 115200
65+
[env:ttgo-lora32-v1]
8966
platform = ${options.platform}
9067
board = ${options.board}
9168
framework = ${options.framework}
@@ -98,8 +75,7 @@ build_flags =
9875
-std=gnu++14
9976
lib_deps = ${options.release_lib_deps}
10077

101-
[env:ttgo-lora32-v1-minimal]
102-
monitor_speed = 115200
78+
[env:minimal]
10379
platform = ${options.platform}
10480
board = ${options.board}
10581
framework = ${options.framework}
@@ -111,23 +87,7 @@ build_flags =
11187
${options.common_build_flags}
11288
-std=gnu++14
11389
-D MINIMAL_BUILD=1
114-
-D LMIC_DEBUG_LEVEL=0
115-
-D DISABLE_OTA=1
11690
lib_deps =
11791
mcci-catena/MCCI LoRaWAN LMIC library @ ^4.1.1
11892
adafruit/Adafruit MAX1704X@^1.0.3
11993

120-
# Native host environment used only for unit testing of platform-independent
121-
# helper functions. This allows running `pio test` on any CI host without
122-
# requiring embedded tool-chains or hardware.
123-
[env:native]
124-
platform = native
125-
build_flags =
126-
${options.unittesting_buildflag}
127-
-std=c++17
128-
-Itest/stubs
129-
${options.coverage_buildflag}
130-
-DUNIT_TEST
131-
build_src_filter = +<*> +<src/ota.cpp> -<src/version.cpp> +<test/stubs/ota.cpp> +<test/stubs/menu_stub.cpp>
132-
lib_deps =
133-
ArduinoJson @ ^7.2.0

test/stubs/Adafruit_MAX1704X.h

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)