From 1500bfe07b43ed024172ae4257ffe25fc0c6480b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Gauthier?= Date: Wed, 10 Dec 2025 16:15:39 +0100 Subject: [PATCH] last tentative ci gitlab --- .gitlab-ci.yml | 37 +++++++++++++++++++++++++++++++++++++ platformio.ini | 9 +++++---- test/EEPROM_test_struct.cpp | 22 ++++++---------------- test_init.py | 12 ++++++++++++ 4 files changed, 60 insertions(+), 20 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 test_init.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..9a24ca7 --- /dev/null +++ b/.gitlab-ci.yml @@ -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" \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index a7ab5ea..0b29f4b 100755 --- a/platformio.ini +++ b/platformio.ini @@ -17,9 +17,10 @@ test_framework = unity build_flags = -std=gnu++17 -I lib/ - ;-D DEBUG - + ;-D DEBUG lib_deps = northernwidget/DS3231@^1.1.2 - -lib_ldf_mode = deep+ \ No newline at end of file + ; arduino-libraries/Ethernet + ; robtillaart/CRC +lib_ldf_mode = deep+ +extra_scripts = pre:test_init.py \ No newline at end of file diff --git a/test/EEPROM_test_struct.cpp b/test/EEPROM_test_struct.cpp index f8ce630..f800d87 100644 --- a/test/EEPROM_test_struct.cpp +++ b/test/EEPROM_test_struct.cpp @@ -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); } //WARNING: Tests are not exhaustive and do not cover all possibilities. int main( int argc, char **argv) { 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_struct); - RUN_TEST(test_set_struct); RUN_TEST(test_get_measure_at); RUN_TEST(test_add_measure); + RUN_TEST(test_get_struct); + RUN_TEST(test_set_struct); + // RUN_TEST(test_put_measure); + UNITY_END(); } \ No newline at end of file diff --git a/test_init.py b/test_init.py new file mode 100644 index 0000000..d6788d8 --- /dev/null +++ b/test_init.py @@ -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" + ] +) \ No newline at end of file