From fd7581f8babebdd9eeb13cc4a9800dbb80f893a4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 1 Dec 2021 16:08:28 +0100 Subject: [PATCH 01/20] Added formatting scripts 1. Added .clang-format file which contains information for the clang-format tool on how to format source files 2. Added shell helper script to apply all changes on HAL soures, test sources and primary sources The shell script was not applied yet. This should be done shortly before introducing the release. Also, it might be good idea to provide instructions on how to set up the formatter for Eclipse --- .clang-format | 7 +++++++ scripts/apply-clang-format.sh | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 .clang-format create mode 100755 scripts/apply-clang-format.sh diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..a3cf6a1f --- /dev/null +++ b/.clang-format @@ -0,0 +1,7 @@ +--- +BasedOnStyle: Google +IndentWidth: 2 +--- +Language: Cpp +ColumnWidth: 100 +--- diff --git a/scripts/apply-clang-format.sh b/scripts/apply-clang-format.sh new file mode 100755 index 00000000..36f5ee92 --- /dev/null +++ b/scripts/apply-clang-format.sh @@ -0,0 +1,8 @@ +#!/bin/bash +if [[ ! -f README.md ]]; then + cd .. +fi + +find ./src -iname *.h -o -iname *.cpp | xargs clang-format --style=file -i +find ./hal -iname *.h -o -iname *.cpp | xargs clang-format --style=file -i +find ./tests -iname *.h -o -iname *.cpp | xargs clang-format --style=file -i From 15dddd7fc407fa72d752c76c64279944986b2dc1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 1 Dec 2021 16:17:27 +0100 Subject: [PATCH 02/20] small README section for formatting --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 312bc077..5feda92c 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,12 @@ cmake --build . -- fsfw-tests_coverage -j The `coverage.py` script located in the `script` folder can also be used to do this conveniently. +## Formatting the sources + +The formatting is done by the `clang-format` tool. The configuration is contained within the +`.clang-format` file in the repository root. As long as `clang-format` is installed, you +can run the `apply-clang-format.sh` helper script to format all source files consistently. + ## Index [1. High-level overview](doc/README-highlevel.md#top)
From e952a82b6565292d649260b1441383b1d484f706 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Dec 2021 13:14:57 +0100 Subject: [PATCH 03/20] small tweaks and fixes --- .clang-format | 2 +- scripts/apply-clang-format.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.clang-format b/.clang-format index a3cf6a1f..ec53b72b 100644 --- a/.clang-format +++ b/.clang-format @@ -3,5 +3,5 @@ BasedOnStyle: Google IndentWidth: 2 --- Language: Cpp -ColumnWidth: 100 +ColumnLimit: 100 --- diff --git a/scripts/apply-clang-format.sh b/scripts/apply-clang-format.sh index 36f5ee92..27202324 100755 --- a/scripts/apply-clang-format.sh +++ b/scripts/apply-clang-format.sh @@ -3,6 +3,6 @@ if [[ ! -f README.md ]]; then cd .. fi -find ./src -iname *.h -o -iname *.cpp | xargs clang-format --style=file -i -find ./hal -iname *.h -o -iname *.cpp | xargs clang-format --style=file -i -find ./tests -iname *.h -o -iname *.cpp | xargs clang-format --style=file -i +find ./src -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i +find ./hal -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i +find ./tests -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i From 661b7b44e070f20b0162c530ed315abaa8bcbb41 Mon Sep 17 00:00:00 2001 From: David Date: Sun, 12 Dec 2021 18:53:29 +0100 Subject: [PATCH 04/20] improved win32 define --- src/fsfw/globalfunctions/timevalOperations.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fsfw/globalfunctions/timevalOperations.h b/src/fsfw/globalfunctions/timevalOperations.h index db68f330..41f4e52f 100644 --- a/src/fsfw/globalfunctions/timevalOperations.h +++ b/src/fsfw/globalfunctions/timevalOperations.h @@ -2,8 +2,9 @@ #define TIMEVALOPERATIONS_H_ #include +#include -#ifdef WIN32 +#ifdef PLATFORM_WIN #include #else #include From d0c7878da4c7591f199d6bda2fac221005b6a74d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Dec 2021 17:50:23 +0100 Subject: [PATCH 05/20] simplified test controller and added docs gitignore --- docs/.gitignore | 1 + .../integration/controller/TestController.cpp | 173 +----------------- .../integration/controller/TestController.h | 25 +-- 3 files changed, 10 insertions(+), 189 deletions(-) create mode 100644 docs/.gitignore diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 00000000..a485625d --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +/_build diff --git a/tests/src/fsfw_tests/integration/controller/TestController.cpp b/tests/src/fsfw_tests/integration/controller/TestController.cpp index 96da5fe3..8c2c9330 100644 --- a/tests/src/fsfw_tests/integration/controller/TestController.cpp +++ b/tests/src/fsfw_tests/integration/controller/TestController.cpp @@ -1,15 +1,12 @@ #include "TestController.h" -#include "OBSWConfig.h" #include #include #include -TestController::TestController(object_id_t objectId, object_id_t device0, object_id_t device1, +TestController::TestController(object_id_t objectId, object_id_t parentId, size_t commandQueueDepth): - ExtendedControllerBase(objectId, objects::NO_OBJECT, commandQueueDepth), - deviceDataset0(device0), - deviceDataset1(device1) { + ExtendedControllerBase(objectId, parentId, commandQueueDepth) { } TestController::~TestController() { @@ -20,136 +17,15 @@ ReturnValue_t TestController::handleCommandMessage(CommandMessage *message) { } void TestController::performControlOperation() { - /* We will trace vaiables if we received an update notification or snapshots */ -#if OBSW_CONTROLLER_PRINTOUT == 1 - if(not traceVariable) { - return; - } - switch(currentTraceType) { - case(NONE): { - break; - } - case(TRACE_DEV_0_UINT8): { - if(traceCounter == 0) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Tracing finished" << std::endl; -#else - sif::printInfo("Tracing finished\n"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ - traceVariable = false; - traceCounter = traceCycles; - currentTraceType = TraceTypes::NONE; - break; - } - - PoolReadGuard readHelper(&deviceDataset0.testUint8Var); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Tracing device 0 variable 0 (UINT8), current value: " << - static_cast(deviceDataset0.testUint8Var.value) << std::endl; -#else - sif::printInfo("Tracing device 0 variable 0 (UINT8), current value: %d\n", - deviceDataset0.testUint8Var.value); -#endif - traceCounter--; - break; - } - case(TRACE_DEV_0_VECTOR): { - break; - } - - } -#endif /* OBSW_CONTROLLER_PRINTOUT == 1 */ } void TestController::handleChangedDataset(sid_t sid, store_address_t storeId, bool* clearMessage) { - using namespace std; -#if OBSW_CONTROLLER_PRINTOUT == 1 - char const* printout = nullptr; - if(storeId == storeId::INVALID_STORE_ADDRESS) { - printout = "Notification"; - } - else { - printout = "Snapshot"; - } -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestController::handleChangedDataset: " << printout << " update from object " - "ID " << setw(8) << setfill('0') << hex << sid.objectId << - " and set ID " << sid.ownerSetId << dec << setfill(' ') << endl; -#else - sif::printInfo("TestController::handleChangedPoolVariable: %s update from object ID 0x%08x and " - "set ID %lu\n", printout, sid.objectId, sid.ownerSetId); -#endif - - if (storeId == storeId::INVALID_STORE_ADDRESS) { - if(sid.objectId == objects::TEST_DEVICE_HANDLER_0) { - PoolReadGuard readHelper(&deviceDataset0.testFloat3Vec); - float floatVec[3]; - floatVec[0] = deviceDataset0.testFloat3Vec.value[0]; - floatVec[1] = deviceDataset0.testFloat3Vec.value[1]; - floatVec[2] = deviceDataset0.testFloat3Vec.value[2]; -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Current float vector (3) values: [" << floatVec[0] << ", " << - floatVec[1] << ", " << floatVec[2] << "]" << std::endl; -#else - sif::printInfo("Current float vector (3) values: [%f, %f, %f]\n", - floatVec[0], floatVec[1], floatVec[2]); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ - } - } -#endif /* OBSW_CONTROLLER_PRINTOUT == 1 */ - - /* We will trace the variables for snapshots and update notifications */ - if(not traceVariable) { - traceVariable = true; - traceCounter = traceCycles; - currentTraceType = TraceTypes::TRACE_DEV_0_VECTOR; - } } void TestController::handleChangedPoolVariable(gp_id_t globPoolId, store_address_t storeId, bool* clearMessage) { - using namespace std; - -#if OBSW_CONTROLLER_PRINTOUT == 1 - char const* printout = nullptr; - if (storeId == storeId::INVALID_STORE_ADDRESS) { - printout = "Notification"; - } - else { - printout = "Snapshot"; - } - -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestController::handleChangedPoolVariable: " << printout << " update from object " - "ID 0x" << setw(8) << setfill('0') << hex << globPoolId.objectId << - " and local pool ID " << globPoolId.localPoolId << dec << setfill(' ') << endl; -#else - sif::printInfo("TestController::handleChangedPoolVariable: %s update from object ID 0x%08x and " - "local pool ID %lu\n", printout, globPoolId.objectId, globPoolId.localPoolId); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ - - if (storeId == storeId::INVALID_STORE_ADDRESS) { - if(globPoolId.objectId == objects::TEST_DEVICE_HANDLER_0) { - PoolReadGuard readHelper(&deviceDataset0.testUint8Var); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Current test variable 0 (UINT8) value: " << static_cast( - deviceDataset0.testUint8Var.value) << std::endl; -#else - sif::printInfo("Current test variable 0 (UINT8) value %d\n", - deviceDataset0.testUint8Var.value); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ - } - } -#endif /* OBSW_CONTROLLER_PRINTOUT == 1 */ - - /* We will trace the variables for snapshots and update notifications */ - if(not traceVariable) { - traceVariable = true; - traceCounter = traceCycles; - currentTraceType = TraceTypes::TRACE_DEV_0_UINT8; - } } LocalPoolDataSetBase* TestController::getDataSetHandle(sid_t sid) { @@ -162,50 +38,7 @@ ReturnValue_t TestController::initializeLocalDataPool(localpool::DataPool &local } ReturnValue_t TestController::initializeAfterTaskCreation() { - namespace td = testdevice; - HasLocalDataPoolIF* device0 = ObjectManager::instance()->get( - deviceDataset0.getCreatorObjectId()); - if(device0 == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TestController::initializeAfterTaskCreation: Test device handler 0 " - "handle invalid!" << std::endl; -#else - sif::printWarning("TestController::initializeAfterTaskCreation: Test device handler 0 " - "handle invalid!"); -#endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } - ProvidesDataPoolSubscriptionIF* subscriptionIF = device0->getSubscriptionInterface(); - if(subscriptionIF != nullptr) { - /* For DEVICE_0, we only subscribe for notifications */ - subscriptionIF->subscribeForSetUpdateMessage(td::TEST_SET_ID, getObjectId(), - getCommandQueue(), false); - subscriptionIF->subscribeForVariableUpdateMessage(td::PoolIds::TEST_UINT8_ID, - getObjectId(), getCommandQueue(), false); - } - - - HasLocalDataPoolIF* device1 = ObjectManager::instance()->get( - deviceDataset0.getCreatorObjectId()); - if(device1 == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TestController::initializeAfterTaskCreation: Test device handler 1 " - "handle invalid!" << std::endl; -#else - sif::printWarning("TestController::initializeAfterTaskCreation: Test device handler 1 " - "handle invalid!"); -#endif - } - - subscriptionIF = device1->getSubscriptionInterface(); - if(subscriptionIF != nullptr) { - /* For DEVICE_1, we will subscribe for snapshots */ - subscriptionIF->subscribeForSetUpdateMessage(td::TEST_SET_ID, getObjectId(), - getCommandQueue(), true); - subscriptionIF->subscribeForVariableUpdateMessage(td::PoolIds::TEST_UINT8_ID, - getObjectId(), getCommandQueue(), true); - } - return HasReturnvaluesIF::RETURN_OK; + return ExtendedControllerBase::initializeAfterTaskCreation(); } ReturnValue_t TestController::checkModeCommand(Mode_t mode, Submode_t submode, diff --git a/tests/src/fsfw_tests/integration/controller/TestController.h b/tests/src/fsfw_tests/integration/controller/TestController.h index 475d8703..7d94367d 100644 --- a/tests/src/fsfw_tests/integration/controller/TestController.h +++ b/tests/src/fsfw_tests/integration/controller/TestController.h @@ -8,20 +8,18 @@ class TestController: public ExtendedControllerBase { public: - TestController(object_id_t objectId, object_id_t device0, object_id_t device1, - size_t commandQueueDepth = 10); + TestController(object_id_t objectId, object_id_t parentId, size_t commandQueueDepth = 10); virtual~ TestController(); protected: - testdevice::TestDataSet deviceDataset0; - testdevice::TestDataSet deviceDataset1; - /* Extended Controller Base overrides */ + // Extended Controller Base overrides ReturnValue_t handleCommandMessage(CommandMessage *message) override; void performControlOperation() override; - /* HasLocalDatapoolIF callbacks */ - void handleChangedDataset(sid_t sid, store_address_t storeId, bool* clearMessage) override; - void handleChangedPoolVariable(gp_id_t globPoolId, store_address_t storeId, + // HasLocalDatapoolIF callbacks + virtual void handleChangedDataset(sid_t sid, store_address_t storeId, + bool* clearMessage) override; + virtual void handleChangedPoolVariable(gp_id_t globPoolId, store_address_t storeId, bool* clearMessage) override; LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; @@ -34,17 +32,6 @@ protected: ReturnValue_t initializeAfterTaskCreation() override; private: - - bool traceVariable = false; - uint8_t traceCycles = 5; - uint8_t traceCounter = traceCycles; - - enum TraceTypes { - NONE, - TRACE_DEV_0_UINT8, - TRACE_DEV_0_VECTOR - }; - TraceTypes currentTraceType = TraceTypes::NONE; }; From 78ddce249cf7340eb77b40731238fb943c478954 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 18 Jan 2022 18:29:54 +0100 Subject: [PATCH 06/20] try an optimization --- CMakeLists.txt | 9 ++------- src/CMakeLists.txt | 9 --------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb3d48b8..04aab3e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,13 +152,8 @@ else() set(OS_FSFW "host") endif() -if(FSFW_BUILD_UNITTESTS OR FSFW_BUILD_DOCS) - configure_file(src/fsfw/FSFW.h.in fsfw/FSFW.h) - configure_file(src/fsfw/FSFWVersion.h.in fsfw/FSFWVersion.h) -else() - configure_file(src/fsfw/FSFW.h.in FSFW.h) - configure_file(src/fsfw/FSFWVersion.h.in FSFWVersion.h) -endif() +configure_file(src/fsfw/FSFW.h.in fsfw/FSFW.h) +configure_file(src/fsfw/FSFWVersion.h.in fsfw/FSFWVersion.h) message(STATUS "Compiling FSFW for the ${FSFW_OS_NAME} operating system.") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e4670807..ed2f2522 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,12 +7,3 @@ target_include_directories(${LIB_FSFW_NAME} INTERFACE ) add_subdirectory(fsfw) - -# Configure File - -target_include_directories(${LIB_FSFW_NAME} PRIVATE - ${CMAKE_CURRENT_BINARY_DIR} -) -target_include_directories(${LIB_FSFW_NAME} INTERFACE - ${CMAKE_CURRENT_BINARY_DIR} -) From 6c63d82f5c77566a569756b79304c5e0790b53f2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 18 Jan 2022 18:47:29 +0100 Subject: [PATCH 07/20] better comment --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04aab3e3..1b3e9d53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,7 +90,7 @@ set(FSFW_CORE_INC_PATH "inc") set_property(CACHE FSFW_OSAL PROPERTY STRINGS host linux rtems freertos) -# Configure Files +# For configure files target_include_directories(${LIB_FSFW_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ) From bc5a6b4a51dd630ee5c98207d58165487cc4c47b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 26 Jan 2022 12:23:12 +0100 Subject: [PATCH 08/20] bump catch2 version to v3.0.0-preview4 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb3d48b8..67d07501 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,7 @@ if(FSFW_BUILD_UNITTESTS) FetchContent_Declare( Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v3.0.0-preview3 + GIT_TAG v3.0.0-preview4 ) FetchContent_MakeAvailable(Catch2) From fe95c3337ab58dd5fd39fe8e10e898effcaadb2a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 26 Jan 2022 12:28:30 +0100 Subject: [PATCH 09/20] changed builddir name in Jenkinsfile --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index d4a8e2ab..ba3f5afb 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { agent any environment { - BUILDDIR = 'build-unittests' + BUILDDIR = 'build-tests' } stages { stage('Create Docker') { From c453af591165b27a61eb86cfb8a258dd77bedb45 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 26 Jan 2022 15:30:01 +0100 Subject: [PATCH 10/20] cleanCI --- automation/Jenkinsfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index ba3f5afb..e7f85e28 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -16,6 +16,18 @@ pipeline { sh 'rm -rf $BUILDDIR' } } + stage('Clean') { + when { + anyOf { + changelog 'cleanCI' + changeset '*.cmake' + changeset 'CMakeLists.txt' + } + } + steps { + sh 'rm -rf $BUILDDIR' + } + } stage('Configure') { agent { dockerfile { From 441b3b83c883cd4ccc41e8c7c07d537998f0bdf7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 27 Jan 2022 11:30:33 +0100 Subject: [PATCH 11/20] Changes to Dockerfile and Jenkinsfile 1. Install Catch2 from sources inside a Docker stage/layer 2. Some tweaks to Jenkinsfile --- automation/Dockerfile | 6 ++++++ automation/Jenkinsfile | 36 +++++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/automation/Dockerfile b/automation/Dockerfile index 93a4fe7d..52e5acfb 100644 --- a/automation/Dockerfile +++ b/automation/Dockerfile @@ -6,3 +6,9 @@ RUN apt-get --yes upgrade #tzdata is a dependency, won't install otherwise ARG DEBIAN_FRONTEND=noninteractive RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano + +RUN git clone https://github.com/catchorg/Catch2.git && \ + cd Catch2 && \ + git checkout v3.0.0-preview4 && \ + cmake -Bbuild -H. -DBUILD_TESTING=OFF && \ + cmake --build build/ --target install diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index e7f85e28..3050a68b 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -1,22 +1,28 @@ pipeline { agent any environment { + DOCKER_TAG = 'fsfw-build' BUILDDIR = 'build-tests' } stages { - stage('Create Docker') { - agent { - dockerfile { - dir 'automation' - additionalBuildArgs '--no-cache' - reuseNode true + stage('Build Container') { + when { + anyOf { + changeset "automation/Dockerfile"; + changelog 'cleanDocker' } } steps { - sh 'rm -rf $BUILDDIR' + sh 'docker build -t $DOCKER_TAG - < automation/Dockerfile' } } stage('Clean') { + agent { + docker { + image '$DOCKER_TAG' + reuseNode true + } + } when { anyOf { changelog 'cleanCI' @@ -30,8 +36,8 @@ pipeline { } stage('Configure') { agent { - dockerfile { - dir 'automation' + docker { + image '$DOCKER_TAG' reuseNode true } } @@ -43,8 +49,8 @@ pipeline { } stage('Build') { agent { - dockerfile { - dir 'automation' + docker { + image '$DOCKER_TAG' reuseNode true } } @@ -56,8 +62,8 @@ pipeline { } stage('Unittests') { agent { - dockerfile { - dir 'automation' + docker { + image '$DOCKER_TAG' reuseNode true } } @@ -69,8 +75,8 @@ pipeline { } stage('Valgrind') { agent { - dockerfile { - dir 'automation' + docker { + image '$DOCKER_TAG' reuseNode true } } From 386843e3e70e2249c1e880cdfbfb973e3bf35f59 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Jan 2022 13:33:06 +0100 Subject: [PATCH 12/20] update jenkinsfile --- automation/Jenkinsfile | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 3050a68b..551dea84 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -1,25 +1,28 @@ pipeline { agent any environment { - DOCKER_TAG = 'fsfw-build' + DOCK_FILE_DIR = 'automation' BUILDDIR = 'build-tests' } stages { - stage('Build Container') { - when { - anyOf { - changeset "automation/Dockerfile"; - changelog 'cleanDocker' + stage('Create Docker') { + agent { + dockerfile { + dir '$DOCK_FILE_DIR' + additionalBuildArgs '--no-cache' } } - steps { - sh 'docker build -t $DOCKER_TAG - < automation/Dockerfile' + when { + anyOf { + changeset "$DOCK_FILE_DIR/Dockerfile"; + changelog 'cleanDocker' + } } } stage('Clean') { agent { - docker { - image '$DOCKER_TAG' + dockerfile { + dir '$DOCK_FILE_DIR' reuseNode true } } @@ -36,8 +39,8 @@ pipeline { } stage('Configure') { agent { - docker { - image '$DOCKER_TAG' + dockerfile { + dir '$DOCK_FILE_DIR' reuseNode true } } @@ -49,8 +52,8 @@ pipeline { } stage('Build') { agent { - docker { - image '$DOCKER_TAG' + dockerfile { + dir '$DOCK_FILE_DIR' reuseNode true } } @@ -62,8 +65,8 @@ pipeline { } stage('Unittests') { agent { - docker { - image '$DOCKER_TAG' + dockerfile { + dir '$DOCK_FILE_DIR' reuseNode true } } @@ -75,8 +78,8 @@ pipeline { } stage('Valgrind') { agent { - docker { - image '$DOCKER_TAG' + dockerfile { + dir '$DOCK_FILE_DIR' reuseNode true } } From 8414c9d47193775ccaa898f35b3dd6755938458a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Jan 2022 13:36:43 +0100 Subject: [PATCH 13/20] added steps --- automation/Jenkinsfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 551dea84..eefcdabf 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -10,6 +10,7 @@ pipeline { dockerfile { dir '$DOCK_FILE_DIR' additionalBuildArgs '--no-cache' + reuseNode true } } when { @@ -18,6 +19,9 @@ pipeline { changelog 'cleanDocker' } } + steps { + sh 'rm -rf $BUILDDIR' + } } stage('Clean') { agent { From cf3d4d8de31fddad7ce439908d659688f3a67930 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Jan 2022 13:43:21 +0100 Subject: [PATCH 14/20] cleanDocker --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index eefcdabf..595f6963 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -15,7 +15,7 @@ pipeline { } when { anyOf { - changeset "$DOCK_FILE_DIR/Dockerfile"; + changeset "${DOCK_FILE_DIR}/Dockerfile"; changelog 'cleanDocker' } } From bf7fabd7bac4ef6932020ad11c1796a32cd97c6d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Jan 2022 13:46:05 +0100 Subject: [PATCH 15/20] commented out when block --- automation/Jenkinsfile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 595f6963..afb43365 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -13,12 +13,13 @@ pipeline { reuseNode true } } - when { - anyOf { - changeset "${DOCK_FILE_DIR}/Dockerfile"; - changelog 'cleanDocker' - } - } + // Does not work, but maybe not necessary anyway.. + //when { + // anyOf { + // changeset "${DOCK_FILE_DIR}/Dockerfile"; + // changelog 'cleanDocker' + // } + //} steps { sh 'rm -rf $BUILDDIR' } From eba9abfc9aa1a97b5a13110f38c9cbdebf3521a0 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 28 Jan 2022 14:10:24 +0100 Subject: [PATCH 16/20] Jenkinsfile syntax is weird, maybe this works... --- automation/Jenkinsfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index afb43365..1853308c 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -8,7 +8,7 @@ pipeline { stage('Create Docker') { agent { dockerfile { - dir '$DOCK_FILE_DIR' + dir DOCK_FILE_DIR additionalBuildArgs '--no-cache' reuseNode true } @@ -27,7 +27,7 @@ pipeline { stage('Clean') { agent { dockerfile { - dir '$DOCK_FILE_DIR' + dir DOCK_FILE_DIR reuseNode true } } @@ -45,7 +45,7 @@ pipeline { stage('Configure') { agent { dockerfile { - dir '$DOCK_FILE_DIR' + dir DOCK_FILE_DIR reuseNode true } } @@ -58,7 +58,7 @@ pipeline { stage('Build') { agent { dockerfile { - dir '$DOCK_FILE_DIR' + dir DOCK_FILE_DIR reuseNode true } } @@ -71,7 +71,7 @@ pipeline { stage('Unittests') { agent { dockerfile { - dir '$DOCK_FILE_DIR' + dir DOCK_FILE_DIR reuseNode true } } @@ -84,7 +84,7 @@ pipeline { stage('Valgrind') { agent { dockerfile { - dir '$DOCK_FILE_DIR' + dir DOCK_FILE_DIR reuseNode true } } From b98127cea6496487d3dbc9f0f19406c7431f9117 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 31 Jan 2022 14:59:45 +0100 Subject: [PATCH 17/20] Updated CI Build - Always clean and rebuild docker image. - Use single docker container --- automation/Jenkinsfile | 68 ++++++------------------------------------ 1 file changed, 9 insertions(+), 59 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 1853308c..0d62538e 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -1,54 +1,22 @@ pipeline { - agent any environment { - DOCK_FILE_DIR = 'automation' - BUILDDIR = 'build-tests' + DOCK_FILE_DIR = 'automation' + BUILDDIR = 'build-tests' + } + agent { + dockerfile { + dir DOCK_FILE_DIR + additionalBuildArgs '--no-cache' + reuseNode true + } } stages { - stage('Create Docker') { - agent { - dockerfile { - dir DOCK_FILE_DIR - additionalBuildArgs '--no-cache' - reuseNode true - } - } - // Does not work, but maybe not necessary anyway.. - //when { - // anyOf { - // changeset "${DOCK_FILE_DIR}/Dockerfile"; - // changelog 'cleanDocker' - // } - //} - steps { - sh 'rm -rf $BUILDDIR' - } - } stage('Clean') { - agent { - dockerfile { - dir DOCK_FILE_DIR - reuseNode true - } - } - when { - anyOf { - changelog 'cleanCI' - changeset '*.cmake' - changeset 'CMakeLists.txt' - } - } steps { sh 'rm -rf $BUILDDIR' } } stage('Configure') { - agent { - dockerfile { - dir DOCK_FILE_DIR - reuseNode true - } - } steps { dir(BUILDDIR) { sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON ..' @@ -56,12 +24,6 @@ pipeline { } } stage('Build') { - agent { - dockerfile { - dir DOCK_FILE_DIR - reuseNode true - } - } steps { dir(BUILDDIR) { sh 'cmake --build . -j' @@ -69,12 +31,6 @@ pipeline { } } stage('Unittests') { - agent { - dockerfile { - dir DOCK_FILE_DIR - reuseNode true - } - } steps { dir(BUILDDIR) { sh 'cmake --build . -- fsfw-tests_coverage -j' @@ -82,12 +38,6 @@ pipeline { } } stage('Valgrind') { - agent { - dockerfile { - dir DOCK_FILE_DIR - reuseNode true - } - } steps { dir(BUILDDIR) { sh 'valgrind --leak-check=full --error-exitcode=1 ./fsfw-tests' From 5b968f7e5adcb173a229f20e984c4120b86b7382 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 31 Jan 2022 15:01:45 +0100 Subject: [PATCH 18/20] Can't use env variables in top leve agent section --- automation/Jenkinsfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 0d62538e..af4ad6a5 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -1,11 +1,10 @@ pipeline { environment { - DOCK_FILE_DIR = 'automation' - BUILDDIR = 'build-tests' + BUILDDIR = 'build-tests' } agent { dockerfile { - dir DOCK_FILE_DIR + dir 'automation' additionalBuildArgs '--no-cache' reuseNode true } From 1ead156c645c89cdea104268f34e8d7c291a66d1 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 31 Jan 2022 15:08:52 +0100 Subject: [PATCH 19/20] added --pull to the docker build --- automation/Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index af4ad6a5..09ac9649 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -5,7 +5,9 @@ pipeline { agent { dockerfile { dir 'automation' - additionalBuildArgs '--no-cache' + #force docker to redownload base image and rebuild all steps instead of caching them + #this way, we always get an up to date docker image one each build + additionalBuildArgs '--no-cache --pull' reuseNode true } } From 8a39971a1c3b86b607814a3fe5738d7357ace588 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 31 Jan 2022 15:11:37 +0100 Subject: [PATCH 20/20] oops, wrong language --- automation/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 09ac9649..dae2da2c 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -5,8 +5,8 @@ pipeline { agent { dockerfile { dir 'automation' - #force docker to redownload base image and rebuild all steps instead of caching them - #this way, we always get an up to date docker image one each build + //force docker to redownload base image and rebuild all steps instead of caching them + //this way, we always get an up to date docker image one each build additionalBuildArgs '--no-cache --pull' reuseNode true }