Commit 8f2b4fe9 authored by Dennis Gläser's avatar Dennis Gläser Committed by Dennis
Browse files

[ci] receive dumux mr info from upstream

parent 49ccd33c
......@@ -7,7 +7,7 @@ variables:
# rules for the default triggers:
# - pipelines are triggered for merge requests and external triggers (e.g. nightly build in dumux)
# - Within merge requests, we require to start the pipeline manually by clicking play for the trigger
# - if the pipeline was triggered externally (from dumux), we accept the variable DUMUX_MERGE_REQUEST_BRANCH
# - if the pipeline was triggered externally (from dumux), we may receive merge-request-related variables
.default-trigger:
stage: trigger pipelines
trigger:
......@@ -15,14 +15,15 @@ variables:
- local: .gitlab-ci/default.yml
strategy: depend
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == "pipeline"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual
variables:
DUMUX_MR_BRANCH: $DUMUX_MERGE_REQUEST_BRANCH
TRIGGER_SOURCE: $CI_PIPELINE_SOURCE
MR_TARGET_BRANCH_NAME: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
DUMUX_PIPELINE_SOURCE: $DUMUX_PIPELINE_SOURCE
DUMUX_MR_SOURCE_BRANCH: $DUMUX_MERGE_REQUEST_SOURCE_BRANCH
DUMUX_MR_TARGET_BRANCH: $DUMUX_MERGE_REQUEST_TARGET_BRANCH
full-dune-2.7-gcc:
extends: .default-trigger
......
......@@ -10,36 +10,54 @@ workflow:
rules:
- if: $CI_PIPELINE_SOURCE=="parent_pipeline"
# variables that may be overwritten by the trigger
variables:
TRIGGER_SOURCE: "unknown"
MR_TARGET_BRANCH_NAME: "master"
DUMUX_PIPELINE_SOURCE: "unknown"
DUMUX_MR_SOURCE_BRANCH: "unknown"
DUMUX_MR_TARGET_BRANCH: "unknown"
select tests:
stage: configure
before_script:
- |
DUMUX_CLONE_BRANCH=master
if [[ -n "${DUMUX_MR_BRANCH}" ]]; then
DUMUX_CLONE_BRANCH=${DUMUX_MR_BRANCH}
echo "Received upstream merge request branch ${DUMUX_MR_BRANCH}"
if [[ -n "${DUMUX_MR_SOURCE_BRANCH}" ]]; then
DUMUX_CLONE_BRANCH=${DUMUX_MR_SOURCE_BRANCH}
echo "Received upstream merge request branch ${DUMUX_MR_SOURCE_BRANCH}"
fi
- echo "Checking out branch ${DUMUX_CLONE_BRANCH} in dumux"
- git clone -b ${DUMUX_CLONE_BRANCH} --depth 1 https://git.iws.uni-stuttgart.de/dumux-repositories/dumux.git
- dunecontrol --opts=$DUNE_OPTS_FILE --only=dumux all
script:
- dunecontrol --opts=$DUNE_OPTS_FILE --current all
- |
dunecontrol --opts=$DUNE_OPTS_FILE --current all
if [[ -n "${DUMUX_MR_BRANCH}" ]]; then
echo "Detecting test affected by changes in Dumux"
python3 dumux/bin/testing/getchangedfiles.py -f dumux -o changedfiles.txt -t origin/$DUMUX_MR_BRANCH
python3 dumux/bin/testing/findtests.py -o affectedtests.json --file-list changedfiles.txt --build-dir build-cmake
echo "Check if tests affected by changes have to be identified"
if [[ "$DUMUX_PIPELINE_SOURCE" == "merge_request_event" ]]; then
CHECK_FOLDER="dumux"
SOURCE_TREE=origin/$DUMUX_MR_SOURCE_BRANCH
TARGET_TREE=origin/$DUMUX_MR_TARGET_BRANCH
elif [[ "$TRIGGER_SOURCE" == "merge_request_event" ]]; then
echo "Detecting test affected by changes in this merge request, using target branch $MR_TARGET_BRANCH_NAME"
python3 dumux/bin/testing/getchangedfiles.py -o changedfiles.txt -t origin/$MR_TARGET_BRANCH_NAME
python3 dumux/bin/testing/findtests.py -o affectedtests.json --file-list changedfiles.txt --build-dir build-cmake
CHECK_FOLDER="."
SOURCE_TREE="HEAD"
TARGET_TREE=origin/$MR_TARGET_BRANCH_NAME
fi
- |
if [[ -n "$SOURCE_TREE" ]]; then
echo "Detecting tests affected by changes in folder $CHECK_FOLDER,"
echo "using source/target trees: $SOURCE_TREE / $TARGET_TREE"
python3 dumux/bin/testing/getchangedfiles.py --folder $CHECK_FOLDER \
--source-tree $SOURCE_TREE \
--target-tree $TARGET_TREE \
--outfile changedfiles.txt
python3 dumux/bin/testing/findtests.py --outfile affectedtests.json \
--file-list changedfiles.txt \
--build-dir build-cmake
else
echo "Received trigger source / dumux pipeline source: $TRIGGER_SOURCE / $DUMUX_PIPELINE_SOURCE"
echo "Skipping test selection, build/test stages will consider all tests!"
echo "{}" >> affectedtests.json
touch affectedtests.json
fi
artifacts:
paths:
......@@ -54,7 +72,7 @@ build lecture:
- |
pushd build-cmake
make clean
if [[ -n "${DUMUX_MR_BRANCH}" ]]; then
if [ -s ../affectedtests.json ]; then
python3 ../dumux/bin/testing/runselectedtests.py -c ../affectedtests.json -b
else
python3 ../dumux/bin/testing/runselectedtests.py --all -b
......@@ -75,7 +93,7 @@ test lecture:
script:
- |
pushd build-cmake
if [[ -n "${DUMUX_MR_BRANCH}" ]]; then
if [ -s ../affectedtests.json ]; then
python3 ../dumux/bin/testing/runselectedtests.py -c ../affectedtests.json -t
else
python3 ../dumux/bin/testing/runselectedtests.py --all -t
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment