Skip to content

Commit c08d86f

Browse files
authored
Merge pull request #1 from smdn/devel-tests
Add workflow to run build integrity tests
2 parents 01fc903 + 7a41a7e commit c08d86f

10 files changed

Lines changed: 203 additions & 3 deletions

File tree

.github/workflows/test-build.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,17 @@ jobs:
5353
- name: Install python
5454
uses: actions/setup-python@v5.4.0
5555
with:
56-
python-version: '3.11'
56+
python-version: '3.12.3'
5757

5858
- name: Install PlatformIO Core
5959
run: |
6060
# ref: https://docs.platformio.org/en/stable/integration/ci/github-actions.html#using-cmd-run-command
6161
pip install --upgrade platformio
6262
63-
- name: Build PlatformIO Project
63+
- name: Run tests
6464
shell: pwsh
6565
run: |
66+
# TODO: use pio run --silent
6667
$verbose = '${{ inputs.verbose }}' -ieq 'true'
6768
68-
pio run
69+
tests/test-build/run.sh
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
2+
// SPDX-License-Identifier: MIT
3+
#include <Arduino.h>
4+
#include <MHZ19X.h>
5+
6+
auto mhz19c = MHZ19C<PIN_PA6, PIN_PA7>();
7+
8+
void setup()
9+
{
10+
// begin()
11+
mhz19c.begin();
12+
13+
// switchSelfCalibration()
14+
mhz19c.switchSelfCalibration(true);
15+
}
16+
17+
void loop()
18+
{
19+
uint16_t co2ppm = 0;
20+
MHZ19X_error_t result;
21+
22+
// getCO2Concentration()
23+
result = mhz19c.getCO2Concentration(co2ppm);
24+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
2+
; SPDX-License-Identifier: MIT
3+
[platformio]
4+
src_dir = .
5+
6+
[env:ATtiny402]
7+
platform = atmelmegaavr
8+
platform_packages = platformio/framework-arduino-megaavr-megatinycore@^2.6.7
9+
board = ATtiny402
10+
framework = arduino
11+
lib_extra_dirs = ../../../
12+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
2+
// SPDX-License-Identifier: MIT
3+
#include <Arduino.h>
4+
#include <MHZ19X.h>
5+
6+
auto mhz19c = MHZ19C();
7+
8+
void setup()
9+
{
10+
// begin()
11+
mhz19c.begin();
12+
13+
// switchSelfCalibration()
14+
mhz19c.switchSelfCalibration(true);
15+
}
16+
17+
void loop()
18+
{
19+
uint16_t co2ppm = 0;
20+
MHZ19X_error_t result;
21+
22+
// getCO2Concentration()
23+
result = mhz19c.getCO2Concentration(co2ppm);
24+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
2+
; SPDX-License-Identifier: MIT
3+
[platformio]
4+
src_dir = .
5+
6+
[env:nanoatmega328]
7+
platform = atmelavr
8+
board = nanoatmega328
9+
framework = arduino
10+
lib_extra_dirs = ../../../
11+
12+
build_flags = -Wno-unused-but-set-variable # disable -Wunused-but-set-variable
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
2+
// SPDX-License-Identifier: MIT
3+
#include <Arduino.h>
4+
#include <MHZ19X.h>
5+
6+
auto mhz19c_serial1 = MHZ19C_Serial1();
7+
8+
#if defined(HAVE_HWSERIAL2)
9+
auto mhz19c_serial2 = MHZ19C_Serial2();
10+
#endif
11+
12+
#if defined(HAVE_HWSERIAL3)
13+
auto mhz19c_serial3 = MHZ19C_Serial3();
14+
#endif
15+
16+
void setup()
17+
{
18+
// begin()
19+
mhz19c_serial1.begin();
20+
21+
#if defined(HAVE_HWSERIAL2)
22+
mhz19c_serial2.begin();
23+
#endif
24+
25+
#if defined(HAVE_HWSERIAL3)
26+
mhz19c_serial3.begin();
27+
#endif
28+
29+
// switchSelfCalibration()
30+
mhz19c_serial1.switchSelfCalibration(true);
31+
32+
#if defined(HAVE_HWSERIAL2)
33+
mhz19c_serial2.switchSelfCalibration(true);
34+
#endif
35+
36+
#if defined(HAVE_HWSERIAL3)
37+
mhz19c_serial3.switchSelfCalibration(true);
38+
#endif
39+
}
40+
41+
void loop()
42+
{
43+
uint16_t co2ppm = 0;
44+
MHZ19X_error_t result;
45+
46+
// getCO2Concentration()
47+
result = mhz19c_serial1.getCO2Concentration(co2ppm);
48+
49+
#if defined(HAVE_HWSERIAL2)
50+
result = mhz19c_serial2.getCO2Concentration(co2ppm);
51+
#endif
52+
53+
#if defined(HAVE_HWSERIAL3)
54+
result = mhz19c_serial3.getCO2Concentration(co2ppm);
55+
#endif
56+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
2+
; SPDX-License-Identifier: MIT
3+
[platformio]
4+
src_dir = .
5+
6+
[env:ATtiny402]
7+
platform = atmelmegaavr
8+
board = nano_every
9+
framework = arduino
10+
lib_extra_dirs = ../../../

tests/test-build/ESP32/main.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
2+
// SPDX-License-Identifier: MIT
3+
#include <Arduino.h>
4+
#include <MHZ19X.h>
5+
6+
auto mhz19c_uart1 = MHZ19C_UART1();
7+
auto mhz19c_uart2 = MHZ19C_UART2();
8+
9+
void setup()
10+
{
11+
// begin()
12+
mhz19c_uart1.begin();
13+
mhz19c_uart2.begin();
14+
15+
// switchSelfCalibration()
16+
mhz19c_uart1.switchSelfCalibration(true);
17+
mhz19c_uart2.switchSelfCalibration(true);
18+
}
19+
20+
void loop()
21+
{
22+
uint16_t co2ppm = 0;
23+
MHZ19X_error_t result;
24+
25+
// getCO2Concentration()
26+
result = mhz19c_uart1.getCO2Concentration(co2ppm);
27+
result = mhz19c_uart2.getCO2Concentration(co2ppm);
28+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
2+
; SPDX-License-Identifier: MIT
3+
[platformio]
4+
src_dir = .
5+
6+
[env:esp32dev]
7+
platform = espressif32
8+
board = esp32dev
9+
framework = arduino
10+
lib_extra_dirs = ../../../
11+

tests/test-build/run.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
3+
# SPDX-License-Identifier: MIT
4+
5+
# Note: This script was based on the answers provided by Microsoft Copilot.
6+
7+
base_dir=$(cd $(dirname $0) && pwd)
8+
pio_project_dirs=()
9+
10+
# get a list of directories where platformio.ini exists
11+
for dir in "$base_dir"/*; do
12+
if [ -d "$dir" ]; then
13+
if ls "$dir"/platformio.ini > /dev/null 2>&1; then
14+
pio_project_dirs+=("$dir")
15+
fi
16+
fi
17+
done
18+
19+
# build each projects
20+
for dir in "${pio_project_dirs[@]}"; do
21+
pio run --project-dir "$dir"
22+
done

0 commit comments

Comments
 (0)