last tentative ci gitlab

This commit is contained in:
Aurélien Gauthier 2025-12-10 16:15:39 +01:00
parent 88b68cb13d
commit 1500bfe07b
4 changed files with 60 additions and 20 deletions

37
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,37 @@
stages:
- build
- test
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
PLATFORMIO_CACHE_DIR: "$CI_PROJECT_DIR/.cache/platformio"
ARDUINO_ENV: "megaADK"
cache:
paths:
- .cache/pip
- .cache/platformio
key: "$CI_COMMIT_REF_SLUG"
pio_build:
image: python:latest
stage: build
before_script:
- pip install -U platformio
# - pio lib install "ThrowTheSwitch/Unity@^2.6.0"
script:
- "pio run -e $ARDUINO_ENV"
pio_test:
image: python:latest
stage: test
before_script:
- pip install -U platformio
script:
- pio test -e $ARDUINO_ENV --without-uploading
# - pio ci --lib='.' --board=$ARDUINO_ENV test/EEPROM_test_struct.cpp
# - "pio ci --lib='.' --board=$ARDUINO_ENV test"

View file

@ -18,8 +18,9 @@ build_flags =
-std=gnu++17 -std=gnu++17
-I lib/ -I lib/
;-D DEBUG ;-D DEBUG
lib_deps = lib_deps =
northernwidget/DS3231@^1.1.2 northernwidget/DS3231@^1.1.2
; arduino-libraries/Ethernet
; robtillaart/CRC
lib_ldf_mode = deep+ lib_ldf_mode = deep+
extra_scripts = pre:test_init.py

View file

@ -312,32 +312,22 @@ void test_get_measure_at(){
} }
} }
// Définition de la fonction de préparation
void setUp(void) {
Serial.begin(9600);
// mettez ici le code qui doit s'exécuter AVANT CHAQUE test
// Par exemple : initialisation de variables, nettoyage d'états
}
// Définition de la fonction de nettoyage
void tearDown(void) {
// mettez ici le code qui doit s'exécuter APRÈS CHAQUE test
// Par exemple : désallocation de mémoire, réinitialisation de l'état
}
void setup(void){ void setup(void)
{
Serial.begin(9600); Serial.begin(9600);
} }
//WARNING: Tests are not exhaustive and do not cover all possibilities. //WARNING: Tests are not exhaustive and do not cover all possibilities.
int main( int argc, char **argv) { int main( int argc, char **argv) {
UNITY_BEGIN(); UNITY_BEGIN();
// The following commented test is here for faciltate the debug "test_get_measure_at", test_get_measure is private function for the storage_interface class
// Maybe removed later
// RUN_TEST(test_get_measure); // RUN_TEST(test_get_measure);
RUN_TEST(test_get_struct);
RUN_TEST(test_set_struct);
RUN_TEST(test_get_measure_at); RUN_TEST(test_get_measure_at);
RUN_TEST(test_add_measure); RUN_TEST(test_add_measure);
RUN_TEST(test_get_struct);
RUN_TEST(test_set_struct);
// RUN_TEST(test_put_measure);
UNITY_END(); UNITY_END();
} }

12
test_init.py Normal file
View file

@ -0,0 +1,12 @@
# test_init.py
Import("env")
test_env_name = env["PIOENV"]
# Injecte manuellement les chemins d'inclusion nécessaires (Unity et votre config)
env.Append(
CPPPATH=[
"test",
".pio/libdeps/" + test_env_name + "/Unity/src"
]
)