Skip to content

Commit

Permalink
Merge pull request #9 from Elektrobit/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
gehwolf authored Jul 24, 2024
2 parents 7ea9b6a + 30251fc commit 9ed321e
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 45 deletions.
82 changes: 57 additions & 25 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,65 @@
---
variables:
DOCKER_HOST: "tcp://docker:2375"
DOCKER_IMAGE: samconf-ci:$CI_COMMIT_REF_SLUG

workflow:
auto_cancel:
on_new_commit: interruptible


stages:
- docker-image
- build
- test

default:
image: ubuntu:jammy
image: $CI_REGISTRY_IMAGE/$DOCKER_IMAGE
services:
- name: docker:24-dind
alias: docker
variables:
DOCKER_TLS_CERTDIR: ""
tags:
- "docker"
interruptible: true

before_script:
- apt-get update
- apt-get install -y curl bash jq docker.io
- docker info
- ip a
- env | sort

build-docker-image:
stage: docker-image
image: ubuntu:jammy
before_script:
- apt-get update
- apt-get install -y docker.io
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -t $DOCKER_IMAGE -f ci/Dockerfile
--build-arg UID=$(id -u) --build-arg GID=$(id -g)
--build-arg ASMCOV_URI="$ASMCOV_URI"
ci/
- docker tag $DOCKER_IMAGE $CI_REGISTRY_IMAGE/$DOCKER_IMAGE
- docker push $CI_REGISTRY_IMAGE/$DOCKER_IMAGE

build-dependencies:
stage: build
needs: []
needs:
- build-docker-image
script:
- ci/docker-run.sh ci/install_deps.py -c ci/dependencies_emlix.json
- ci/install_deps.py -c ci/dependencies_emlix.json
artifacts:
paths:
- build/deps/lib/
- build/deps/include/

build-release:
stage: build
needs: [build-dependencies]
needs:
- build-docker-image
- build-dependencies
script:
- ci/docker-run.sh ci/build.sh --ci Release
- ci/build.sh --ci Release
artifacts:
paths:
- build/Release/dist/
Expand All @@ -47,9 +69,11 @@ build-release:

build-debug:
stage: build
needs: [build-dependencies]
needs:
- build-docker-image
- build-dependencies
script:
- ci/docker-run.sh ci/build.sh --ci Debug
- ci/build.sh --ci Debug
artifacts:
paths:
- build/Debug/dist/
Expand All @@ -58,10 +82,11 @@ build-debug:
unit-test-release:
stage: test
needs:
- build-docker-image
- build-release
- build-dependencies
script:
- ci/docker-run.sh ci/run_utest.sh Release
- ci/run_utest.sh Release
artifacts:
when: always
paths:
Expand All @@ -72,10 +97,11 @@ unit-test-release:
unit-test-debug:
stage: test
needs:
- build-docker-image
- build-debug
- build-dependencies
script:
- ci/docker-run.sh ci/run_utest.sh Debug
- ci/run_utest.sh Debug
artifacts:
when: always
paths:
Expand All @@ -86,46 +112,52 @@ unit-test-debug:
code-lint:
stage: test
needs:
- build-docker-image
- build-release
- build-dependencies
script:
- ci/docker-run.sh ci/code_lint.py --ci
- ci/docker-run.sh ci/checklicense.sh
- ci/code_lint.py --ci
- ci/checklicense.sh
artifacts:
when: always
paths:
- build/Release/cmake/lint_results/

code-coverage:
rules:
- when: never
allow_failure: true
stage: test
tags:
- "intelpt"
- "docker"
needs:
- build-docker-image
- build-release
- build-dependencies
script:
- ci/docker-run.sh ci/create_coverage.sh
- cat /proc/cpuinfo
- ls -lah /sys/devices/intel_pt
- ci/create_coverage.sh
artifacts:
when: always
paths:
- build/Release/result/coverage_results/

publish-kpis:
rules:
- when: never
allow_failure: true
needs: [code-coverage]
stage: test
needs:
- build-docker-image
- build-release
- code-coverage
script:
- ci/publish_pkis.sh
- ci/publish_kpis.sh

documentation:
stage: build
needs:
- build-docker-image
- build-release
- build-dependencies
script:
- ci/docker-run.sh ci/build_doc.sh
- ci/build_doc.sh
artifacts:
paths:
- build/doc/
Expand Down
14 changes: 9 additions & 5 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ OPTION_CI=0
OPTION_CLEAN=0
OPTION_VERBOSE=0
OPTION_PACKAGE=0
for element in "$@"; do
case $element in
while [ $# -gt 0 ]; do
case ${1} in
--ci) OPTION_CI=1 ;;
--clean|-c) OPTION_CLEAN=1 ;;
--verbose|-v) OPTION_VERBOSE=1 ;;
--package) OPTION_PACKAGE=1 ;;
-*) echo "error: unknown option: $1"; exit 1 ;;
*) PARAM="$PARAM $element" ;;
-D) CMAKE_PARAM="${CMAKE_PARAM} -D ${2}"
shift ;;
-D*) CMAKE_PARAM="$CMAKE_PARAM} ${1}" ;;
-*) echo "error: unknown option: ${1}"; exit 1 ;;
*) PARAM="${PARAM} ${1}" ;;
esac
shift
done

set -- $PARAM
Expand All @@ -31,7 +35,7 @@ elif [ $OPTION_CI -eq 1 ]; then
echo "error: build-type must be explicitely set in CI mode"
exit 1
fi
CMAKE_PARAM="-DENABLE_CI=1"
CMAKE_PARAM="${CMAKE_PARAM} -DENABLE_CI=1"
OPTION_CLEAN=1
OPTION_VERBOSE=1
fi
Expand Down
2 changes: 1 addition & 1 deletion ci/create_debian_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function create_and_publish_debian_main() {
rm debian/README.md
echo "3.0 (quilt)" > debian/source/format

dch -M "--newversion=${NEW_VERSION}-1" "New upstream tag ${NEW_VERSION}"
dch -D unstable -M "--newversion=${NEW_VERSION}-1" "New upstream tag ${NEW_VERSION}"
git add debian/ && git commit -m "New upstream tag ${NEW_VERSION}"
git checkout HEAD -- debian.native && git clean -fxd -- debian.native
}
Expand Down
2 changes: 1 addition & 1 deletion ci/publish_kpis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function add_kpi {
}

function push_all_kpis {
curl -v -i "${KPI_API_URL}" \
curl -v --http1.1 -i "${KPI_API_URL}" \
--header "Authorization: Token ${KPI_API_TOKEN}" \
--header "Content-Type: text/plain; charset=utf-8" \
--data-binary "@/tmp/kpis_to_send"
Expand Down
29 changes: 17 additions & 12 deletions cmake/project.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: MIT
set(SAMCONF_VERSION 0.54.0)
set(SAMCONF_VERSION 0.56.3)

# Attention: Aside from the version, as many things as possible in this file
# should be put into functions, as this solves potential issues with commands
Expand All @@ -21,6 +21,7 @@ macro(project_set_environment)
option(ENABLE_ANALYZER "Build with -fanalyzer" ON)
option(ENABLE_CI "Use CI mode for building" OFF)
option(ENABLE_ASAN "Link with ASAN" ON)
option(ENABLE_GIT_VERSION "Enable the git hash for the version" ON)

option(UNIT_TESTS "Build unit tests" ${SAMCONF_BUILD_DEFAULTS})
option(INSTALL_UNIT_TESTS "Install unit tests" ${UNIT_TESTS})
Expand Down Expand Up @@ -69,7 +70,6 @@ macro(project_set_environment)
endif()
endmacro()

find_package(Git REQUIRED)
function(project_set_version_variables)
if(ARGN)
cmake_parse_arguments(PSVV "" "NAME" "" ${ARGN})
Expand All @@ -89,17 +89,22 @@ function(project_set_version_variables)
set(${ver_micro_name} ${PROJECT_VERSION_PATCH} PARENT_SCOPE)
set(PKG_VERSION ${ver_pkg} PARENT_SCOPE)

execute_process(
COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE exit_code
OUTPUT_VARIABLE git_output
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT exit_code EQUAL 0)
message(WARNING "failed to retrive git short commit hash")
if (ENABLE_GIT_VERSION)
find_package(Git REQUIRED)
execute_process(
COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE exit_code
OUTPUT_VARIABLE git_output
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT exit_code EQUAL 0)
message(WARNING "failed to retrive git short commit hash")
set(git_output "none")
endif()
else ()
set(git_output "none")
endif()
endif ()
set(${ver_git_name} ${git_output} PARENT_SCOPE)
message(STATUS "-- Set version for ${prj_name}: ${ver_pkg}.${git_output}")
endfunction()
Expand Down
1 change: 1 addition & 0 deletions debian.native/control
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Depends:
${misc:Depends},
libsamconf0 (= ${binary:Version}),
libmock-samconf0 (= ${binary:Version}),
libsamconf-test-utils0 (= ${binary:Version}),
libsafu-dev,
Description: Development package for signed and mergable configuration
It stands for signed and mergable configuration. It is used by elos. The
Expand Down
3 changes: 2 additions & 1 deletion src/demo/samprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ int main(int argc, char **argv) {
fprintf(stderr, "ERR: Signature was invalid");
return EXIT_FAILURE;
} else if (config == NULL) {
fprintf(stderr, "ERR: unexpected error occuirred, where config was initialized but no expected error was caught");
fprintf(stderr,
"ERR: unexpected error occurred, where config was initialized but no expected error was caught");
return EXIT_FAILURE;
}

Expand Down

0 comments on commit 9ed321e

Please sign in to comment.