Skip to content
Snippets Groups Projects
Commit 2eda41b2 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[ci] port pipeline status from mr to master

parent 894839f3
No related branches found
No related tags found
1 merge request!2644Feature/continuous master pipeline status
stages: stages:
- check-status
- trigger - trigger
- downstream modules - downstream modules
...@@ -10,7 +11,39 @@ variables: ...@@ -10,7 +11,39 @@ variables:
workflow: workflow:
rules: rules:
- if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_PIPELINE_SOURCE == "pipeline"
- if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == "master"
# for commits happening on master, we check if there was a successful
# pipeline on a related merge request already. If yes, we simply return
# to propagate that pipeline status on master. Otherwise, we trigger a new run.
check-pipeline-status:
image: $IMAGE_REGISTRY_URL/full:dune-2.7-gcc-ubuntu-20.04
stage: check-status
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_PIPELINE_SOURCE == "pipeline"
when: never
- if: $CI_COMMIT_BRANCH == "master"
when: always
script:
- |
curl --header --form "token=$CI_JOB_TOKEN" \
"https://git.iws.uni-stuttgart.de/api/v4/projects/31/pipelines/?status=success" \
> pipeline_status.json
- |
if ! python3 .gitlab-ci/getpipelineinfo.py --status-file pipeline_status.json \
--look-for HEAD \
--print-format pipeline-id; then
echo "No successful pipeline found. Triggering new pipeline..."
curl --request POST --form "token=$CI_JOB_TOKEN" \
--form ref=$CI_COMMIT_BRANCH \
"https://git.iws.uni-stuttgart.de/api/v4/projects/31/trigger/pipeline"
else
echo "Found successful pipeline for the current state of the branch"
fi
################################################################################### ###################################################################################
# Stage 1: trigger the Dumux test pipelines # # Stage 1: trigger the Dumux test pipelines #
...@@ -28,10 +61,13 @@ workflow: ...@@ -28,10 +61,13 @@ workflow:
strategy: depend strategy: depend
variables: variables:
TRIGGER_SOURCE: $CI_PIPELINE_SOURCE TRIGGER_SOURCE: $CI_PIPELINE_SOURCE
COMMIT_BRANCH: $CI_COMMIT_BRANCH
MR_TARGET_BRANCH_NAME: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME MR_TARGET_BRANCH_NAME: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
rules: rules:
- if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_PIPELINE_SOURCE == "schedule"
when: always when: always
- if: $CI_PIPELINE_SOURCE == "pipeline"
when: always
- if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual when: manual
...@@ -39,7 +75,7 @@ workflow: ...@@ -39,7 +75,7 @@ workflow:
.non-mr-trigger: .non-mr-trigger:
extends: .base-trigger extends: .base-trigger
rules: rules:
- if: $CI_PIPELINE_SOURCE != "merge_request_event" - if: $CI_PIPELINE_SOURCE == "schedule"
############################################# #############################################
# pipelines to be created in merge requests # # pipelines to be created in merge requests #
...@@ -77,6 +113,10 @@ full-dune-master-clang: ...@@ -77,6 +113,10 @@ full-dune-master-clang:
# trigger lecture test # trigger lecture test
trigger lecture: trigger lecture:
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_PIPELINE_SOURCE == "pipeline"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
stage: downstream modules stage: downstream modules
trigger: trigger:
project: dumux-repositories/dumux-lecture project: dumux-repositories/dumux-lecture
......
...@@ -10,22 +10,57 @@ workflow: ...@@ -10,22 +10,57 @@ workflow:
rules: rules:
- if: $CI_PIPELINE_SOURCE=="parent_pipeline" - if: $CI_PIPELINE_SOURCE=="parent_pipeline"
# variables that may be overwritten by the trigger # variables that should be overwritten by the trigger
variables: variables:
TRIGGER_SOURCE: "undefined" TRIGGER_SOURCE: "undefined"
COMMIT_BRANCH: "undefined"
MR_TARGET_BRANCH_NAME: "undefined" MR_TARGET_BRANCH_NAME: "undefined"
select tests: select tests:
stage: configure stage: configure
script: script:
- dunecontrol --opts=$DUNE_OPTS_FILE --current all
- | - |
dunecontrol --opts=$DUNE_OPTS_FILE --current all
if [[ "$TRIGGER_SOURCE" == "merge_request_event" ]]; then if [[ "$TRIGGER_SOURCE" == "merge_request_event" ]]; then
echo "Detecting changes w.r.t to target branch '$MR_TARGET_BRANCH_NAME'" echo "Detecting changes w.r.t to target branch '$MR_TARGET_BRANCH_NAME'"
python3 bin/testing/getchangedfiles.py -o changedfiles.txt -t origin/$MR_TARGET_BRANCH_NAME python3 bin/testing/getchangedfiles.py --outfile changedfiles.txt \
python3 bin/testing/findtests.py -o affectedtests.json --file-list changedfiles.txt --build-dir build-cmake --target.tree origin/$MR_TARGET_BRANCH_NAME
python3 bin/testing/findtests.py --outfile affectedtests.json \
--file-list changedfiles.txt \
--build-dir build-cmake
elif [[ "$TRIGGER_SOURCE" == "schedule" ]]; then
echo "Starting scheduled pipeline"
echo "Skipping test selection, build/test stages will consider all tests!"
touch affectedtests.json
elif [[ "$TRIGGER_SOURCE" == "pipeline" ]]; then
echo "Starting pipeline triggered from another pipeline"
echo "Determining sha with the last successful pipeline to test against"
curl --header --form "token=$CI_JOB_TOKEN" \
"https://git.iws.uni-stuttgart.de/api/v4/projects/31/pipelines/?status=success" \
> pipeline_status.json
if ! python3 .gitlab-ci/getpipelineinfo.py --status-file pipeline_status.json \
--look-for latest \
--print-format commit-sha; then
echo "Could not find a successful pipeline, will build/run all tests"
touch affectedtests.json
else
export COMMIT_SHA=$(python3 .gitlab-ci/getpipelineinfo.py --status-file pipeline_status.json \
--look-for latest \
--print-format commit-sha)
echo "Comparing against sha $COMMIT_SHA"
python3 bin/testing/getchangedfiles.py --outfile changedfiles.txt \
--source-tree HEAD \
--target-tree $COMMIT_SHA
python3 bin/testing/findtests.py --outfile affectedtests.json \
--file-list changedfiles.txt \
--build-dir build-cmake
fi
else else
echo "Received '$TRIGGER_SOURCE' as pipeline trigger event" echo "Unknown pipeline trigger event"
echo "Skipping test selection, build/test stages will consider all tests!" echo "Skipping test selection, build/test stages will consider all tests!"
touch affectedtests.json touch affectedtests.json
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment