diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..de907ac0c334cae2eb35e3413abf8bd616dd3457 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,59 @@ +# +# This file is a part of the CaosDB Project. +# +# Copyright (C) 2019-2021 Indiscale GmbH <info@indiscale.com> +# Copyright (C) 2019 Henrik tom Wörden <h.tomwoerden@indiscale.com> +# Copyright (C) 2020 Daniel Hornung <d.hornung@indiscale.com> +# Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# + +variables: + CI_REGISTRY_IMAGE: $CI_REGISTRY/caosdb/src/caosdb-clib/testenv:latest + +image: $CI_REGISTRY_IMAGE + +stages: + - setup + - test + +# Build a docker image in which tests for this repository can run +build-testenv: + tags: [ cached-dind ] + image: docker:20.10 + stage: setup + script: + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + # use here general latest or specific branch latest... + - docker pull $CI_REGISTRY_IMAGE|| true + - docker build + -f test/.docker/Dockerfile + --pull + --cache-from $CI_REGISTRY_IMAGE + -t $CI_REGISTRY_IMAGE . + - docker push $CI_REGISTRY_IMAGE + + +# cmocka tests +test: + tags: [ docker ] + stage: test + script: + - mkdir test_build + - cd test_build + - cmake -DCMAKE_BUILD_TYPE=Debug .. + - cmake --build . + - ctest + diff --git a/test/.docker/Dockerfile b/test/.docker/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2866eb8c9e89abf3d787e5e53e26dc4f6047b16e --- /dev/null +++ b/test/.docker/Dockerfile @@ -0,0 +1,6 @@ +FROM debian:latest +RUN apt-get update && \ + apt-get install -y \ + cmake + +COPY ./ caosdb-clib/ diff --git a/test/test_connection.c b/test/test_connection.c index 5522a6b776ae01bbbda40b7aaa2016322279325e..8ee7520bfb3537d31e5be8ca722d94dc630cae26 100644 --- a/test/test_connection.c +++ b/test/test_connection.c @@ -1,8 +1,8 @@ -#include "connection.h" -#include <cmocka.h> #include <setjmp.h> #include <stdarg.h> #include <stddef.h> +#include <cmocka.h> +#include "connection.h" static void test_configure_connection(void **state) { assert_int_equal(0, configure_connection("localhost", 8080));