diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 022ad3e1851857c97a5588d066b8783d7ad3f8de..606324d15a38f8273b1e8d7d274f5fac9df64b10 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,23 @@ +# +# This file is a part of the CaosDB Project. +# +# Copyright (C) 2021-2022 IndiScale GmbH (info@indiscale.com) +# Copyright (C) 2021 Florian Spreckelsen <f.spreckelsen@indiscale.com> +# Copyright (C) 2022 Daniel Hornung <d.hornung@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/>. + # Taken an adapted from gitlab's example repos: # https://gitlab.com/gitlab-examples/julia @@ -16,7 +36,6 @@ variables: JULIALIB_REGISTRY_IMAGE: $CI_REGISTRY/caosdb/src/caosdb-julialib/testenv:$CI_COMMIT_REF_NAME - JULIAINTTEST_PIPELINE: https://gitlab.indiscale.com/api/v4/projects/120/trigger/pipeline JULIAINTTEST_BRANCHES: https://gitlab.indiscale.com/api/v4/projects/120/repository/branches GIT_SUBMODULE_STRATEGY: normal @@ -25,9 +44,11 @@ variables: TRIGGERED_BY_HASH: $CI_COMMIT_SHORT_SHA # The defalt branch to use with caosdb-cpplib - # TODO: Change back to dev once f-consolidate-c has been merged. CPP_DEFAULT_BRANCH: dev + # For storing cross-job values + DOTENV: custom.env + image: $JULIALIB_REGISTRY_IMAGE stages: @@ -153,8 +174,8 @@ test_pages: refs: - main -# trigger the integration tests -trigger_inttest: +trigger_prepare: + # Calculate the branch name tags: [ docker ] stage: deploy script: @@ -175,22 +196,40 @@ trigger_inttest: - JULIAINT_REF=${JULIAINT_REF:-dev} - F_BRANCH=$CI_COMMIT_REF_NAME - - echo "Triggering caosdb-juliainttest@${JULIAINT_REF} (F_BRANCH=$F_BRANCH)" - - curl -w "%{stderr}HTTPCODE=%{http_code}" -X POST - -F token=$CI_JOB_TOKEN - -F "variables[TRIGGERED_BY_REPO]=$TRIGGERED_BY_REPO" - -F "variables[TRIGGERED_BY_REF]=$TRIGGERED_BY_REF" - -F "variables[TRIGGERED_BY_HASH]=$TRIGGERED_BY_HASH" - -F "variables[JULIALIB_REGISTRY_IMAGE]=$JULIALIB_REGISTRY_IMAGE" - -F "variables[CPPLIB_REF]=${CPP_DEFAULT_BRANCH}" - -F "variables[F_BRANCH]=${F_BRANCH}" - -F ref=${JULIAINT_REF} $JULIAINTTEST_PIPELINE 2>HTTPCODE - - # fail if the request failed - - grep -c "HTTPCODE=2" HTTPCODE + # Write to dotenv + - echo "JULIAINT_REF=${JULIAINT_REF}" >> "$DOTENV" + - echo "F_BRANCH=${F_BRANCH}" >> "$DOTENV" + - echo "CPPLIB_REF=${CPP_DEFAULT_BRANCH}" >> "$DOTENV" + - cat "$DOTENV" + artifacts: + reports: + dotenv: "$DOTENV" + expire_in: 1 day -# WARNING: This template is using the `julia` images from [Docker +# trigger the integration tests +trigger_inttest: + stage: deploy + needs: [ trigger_prepare ] + inherit: + variables: + # List the variables that shall be inherited, which also means they will override any equally + # named varibles in child pipelines. + - TRIGGERED_BY_REPO + - TRIGGERED_BY_REF + - TRIGGERED_BY_HASH + - JULIALIB_REGISTRY_IMAGE + variables: + # dotenv variables must be set again here. + F_BRANCH: $F_BRANCH + CPPLIB_REF: $CPPLIB_REF + trigger: + project: caosdb/src/caosdb-juliainttest + branch: $JULIAINT_REF + strategy: depend + + +# WARNING: This template uses the `julia` images from [Docker # Hub][3]. One can use custom Julia images and/or the official ones # found in the same place. However, care must be taken to correctly # locate the binary file (`/opt/julia/bin/julia` above), which is