diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 048ec23e21e513431586be81fc2ad0b973c9e5b1..b04d43842ab394df7175939cf69cfa823c20fc55 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,14 +23,16 @@ variables: # this is the image where cpplib repo is present (artifact from pipeline in # caosdb-cpplib) CPPLIB_REGISTRY_IMAGE: $CI_REGISTRY/caosdb/src/caosdb-cpplib/testenv - OCTAVE_REGISTRY_IMAGE: $CI_REGISTRY_IMAGE/testenv:$CI_COMMIT_REF_NAME + OCTAVELIB_REGISTRY_IMAGE: $CI_REGISTRY_IMAGE/testenv:$CI_COMMIT_REF_NAME CPPLIB_BRANCH: dev - OCTAVEINTTEST_PIPELINE: https://gitlab.indiscale.com/api/v4/projects/121/trigger/pipeline OCTAVEINTTEST_BRANCHES: https://gitlab.indiscale.com/api/v4/projects/121/repository/branches + # For storing cross-job values + DOTENV: custom.env -image: $OCTAVE_REGISTRY_IMAGE + +image: $OCTAVELIB_REGISTRY_IMAGE stages: - setup @@ -50,14 +52,14 @@ build-testenv: fi - DOCKER_BASE_IMAGE="${CPPLIB_REGISTRY_IMAGE}:${CPPLIB_BRANCH}" - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - - docker pull "$OCTAVE_REGISTRY_IMAGE" || true + - docker pull "$OCTAVELIB_REGISTRY_IMAGE" || true - docker build --build-arg DOCKER_BASE_IMAGE=$DOCKER_BASE_IMAGE --file .docker/Dockerfile --pull - --cache-from "$OCTAVE_REGISTRY_IMAGE" - --tag "$OCTAVE_REGISTRY_IMAGE" . - - docker push "$OCTAVE_REGISTRY_IMAGE" + --cache-from "$OCTAVELIB_REGISTRY_IMAGE" + --tag "$OCTAVELIB_REGISTRY_IMAGE" . + - docker push "$OCTAVELIB_REGISTRY_IMAGE" # Formatting with miss_hit @@ -99,12 +101,11 @@ linting_cpp: - make linting_cpp allow_failure: true -# trigger the integration tests -trigger_inttest: +trigger_prepare: + # Calculate the branch name tags: [ docker ] stage: deploy script: - ## Determine the octaveinttest branch... # ... sync'ed f-branch (f-bar on octavelib requires f-bar on octaveinttest)... - if echo "$CI_COMMIT_REF_NAME" | grep -c "^f-" ; then @@ -122,18 +123,34 @@ trigger_inttest: - OCTAVEINT_REF=${OCTAVEINT_REF:-dev} - F_BRANCH=$CI_COMMIT_REF_NAME - - echo "Triggering caosdb-octaveinttest@${OCTAVEINT_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[OCTAVELIB_REGISTRY_IMAGE]=$OCTAVE_REGISTRY_IMAGE" - -F "variables[F_BRANCH]=${F_BRANCH}" - -F ref=${OCTAVEINT_REF} $OCTAVEINTTEST_PIPELINE 2>HTTPCODE - - # fail if the request failed - - grep -c "HTTPCODE=2" HTTPCODE + # Write to dotenv + - echo "OCTAVEINT_REF=${OCTAVEINT_REF}" >> "$DOTENV" + - echo "F_BRANCH=${F_BRANCH}" >> "$DOTENV" + - cat "$DOTENV" + artifacts: + reports: + dotenv: "$DOTENV" + expire_in: 1 day + +# 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 + - OCTAVELIB_REGISTRY_IMAGE + variables: + # dotenv variables must be set again here. + F_BRANCH: $F_BRANCH + trigger: + project: caosdb/src/caosdb-octaveinttest + branch: $OCTAVEINT_REF + strategy: depend # Build the sphinx documentation and make it ready for deployment by Gitlab Pages # Special job for serving a static website. See https://docs.gitlab.com/ee/ci/yaml/README.html#pages