Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dumux-repositories
dumux
Commits
2eda41b2
Commit
2eda41b2
authored
May 27, 2021
by
Dennis Gläser
Browse files
[ci] port pipeline status from mr to master
parent
894839f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
2eda41b2
stages
:
-
check-status
-
trigger
-
downstream modules
...
...
@@ -10,7 +11,39 @@ variables:
workflow
:
rules
:
-
if
:
$CI_PIPELINE_SOURCE == "schedule"
-
if
:
$CI_PIPELINE_SOURCE == "pipeline"
-
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 #
...
...
@@ -28,10 +61,13 @@ workflow:
strategy
:
depend
variables
:
TRIGGER_SOURCE
:
$CI_PIPELINE_SOURCE
COMMIT_BRANCH
:
$CI_COMMIT_BRANCH
MR_TARGET_BRANCH_NAME
:
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
rules
:
-
if
:
$CI_PIPELINE_SOURCE == "schedule"
when
:
always
-
if
:
$CI_PIPELINE_SOURCE == "pipeline"
when
:
always
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
when
:
manual
...
...
@@ -39,7 +75,7 @@ workflow:
.non-mr-trigger
:
extends
:
.base-trigger
rules
:
-
if
:
$CI_PIPELINE_SOURCE
!
= "
merge_request_event
"
-
if
:
$CI_PIPELINE_SOURCE
=
= "
schedule
"
#############################################
# pipelines to be created in merge requests #
...
...
@@ -77,6 +113,10 @@ full-dune-master-clang:
# trigger lecture test
trigger lecture
:
rules
:
-
if
:
$CI_PIPELINE_SOURCE == "schedule"
-
if
:
$CI_PIPELINE_SOURCE == "pipeline"
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
stage
:
downstream modules
trigger
:
project
:
dumux-repositories/dumux-lecture
...
...
.gitlab-ci/default.yml
View file @
2eda41b2
...
...
@@ -10,22 +10,57 @@ workflow:
rules
:
-
if
:
$CI_PIPELINE_SOURCE=="parent_pipeline"
# variables that
may
be overwritten by the trigger
# variables that
should
be overwritten by the trigger
variables
:
TRIGGER_SOURCE
:
"
undefined"
COMMIT_BRANCH
:
"
undefined"
MR_TARGET_BRANCH_NAME
:
"
undefined"
select tests
:
stage
:
configure
script
:
-
dunecontrol --opts=$DUNE_OPTS_FILE --current all
-
|
dunecontrol --opts=$DUNE_OPTS_FILE --current all
if [[ "$TRIGGER_SOURCE" == "merge_request_event" ]]; then
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/findtests.py -o affectedtests.json --file-list changedfiles.txt --build-dir build-cmake
python3 bin/testing/getchangedfiles.py --outfile changedfiles.txt \
--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
echo "
Received '$TRIGGER_SOURCE' as
pipeline trigger event"
echo "
Unknown
pipeline trigger event"
echo "Skipping test selection, build/test stages will consider all tests!"
touch affectedtests.json
fi
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment