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: ...@@ -7,7 +7,7 @@ variables:
# rules for the default triggers: # rules for the default triggers:
# - pipelines are triggered for merge requests and external triggers (e.g. nightly build in dumux) # - 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 # - 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: .default-trigger:
stage: trigger pipelines stage: trigger pipelines
trigger: trigger:
...@@ -15,14 +15,15 @@ variables: ...@@ -15,14 +15,15 @@ variables:
- local: .gitlab-ci/default.yml - local: .gitlab-ci/default.yml
strategy: depend strategy: depend
rules: rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == "pipeline" - if: $CI_PIPELINE_SOURCE == "pipeline"
- if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual when: manual
variables: variables:
DUMUX_MR_BRANCH: $DUMUX_MERGE_REQUEST_BRANCH
TRIGGER_SOURCE: $CI_PIPELINE_SOURCE TRIGGER_SOURCE: $CI_PIPELINE_SOURCE
MR_TARGET_BRANCH_NAME: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME 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: full-dune-2.7-gcc:
extends: .default-trigger extends: .default-trigger
......
...@@ -10,36 +10,54 @@ workflow: ...@@ -10,36 +10,54 @@ workflow:
rules: rules:
- if: $CI_PIPELINE_SOURCE=="parent_pipeline" - if: $CI_PIPELINE_SOURCE=="parent_pipeline"
# variables that may be overwritten by the trigger
variables: variables:
TRIGGER_SOURCE: "unknown" TRIGGER_SOURCE: "unknown"
MR_TARGET_BRANCH_NAME: "master" MR_TARGET_BRANCH_NAME: "master"
DUMUX_PIPELINE_SOURCE: "unknown"
DUMUX_MR_SOURCE_BRANCH: "unknown"
DUMUX_MR_TARGET_BRANCH: "unknown"
select tests: select tests:
stage: configure stage: configure
before_script: before_script:
- | - |
DUMUX_CLONE_BRANCH=master DUMUX_CLONE_BRANCH=master
if [[ -n "${DUMUX_MR_BRANCH}" ]]; then if [[ -n "${DUMUX_MR_SOURCE_BRANCH}" ]]; then
DUMUX_CLONE_BRANCH=${DUMUX_MR_BRANCH} DUMUX_CLONE_BRANCH=${DUMUX_MR_SOURCE_BRANCH}
echo "Received upstream merge request branch ${DUMUX_MR_BRANCH}" echo "Received upstream merge request branch ${DUMUX_MR_SOURCE_BRANCH}"
fi fi
- echo "Checking out branch ${DUMUX_CLONE_BRANCH} in dumux" - 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 - 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 - dunecontrol --opts=$DUNE_OPTS_FILE --only=dumux all
script: script:
- dunecontrol --opts=$DUNE_OPTS_FILE --current all
- | - |
dunecontrol --opts=$DUNE_OPTS_FILE --current all echo "Check if tests affected by changes have to be identified"
if [[ -n "${DUMUX_MR_BRANCH}" ]]; then if [[ "$DUMUX_PIPELINE_SOURCE" == "merge_request_event" ]]; then
echo "Detecting test affected by changes in Dumux" CHECK_FOLDER="dumux"
python3 dumux/bin/testing/getchangedfiles.py -f dumux -o changedfiles.txt -t origin/$DUMUX_MR_BRANCH SOURCE_TREE=origin/$DUMUX_MR_SOURCE_BRANCH
python3 dumux/bin/testing/findtests.py -o affectedtests.json --file-list changedfiles.txt --build-dir build-cmake TARGET_TREE=origin/$DUMUX_MR_TARGET_BRANCH
elif [[ "$TRIGGER_SOURCE" == "merge_request_event" ]]; then elif [[ "$TRIGGER_SOURCE" == "merge_request_event" ]]; then
echo "Detecting test affected by changes in this merge request, using target branch $MR_TARGET_BRANCH_NAME" CHECK_FOLDER="."
python3 dumux/bin/testing/getchangedfiles.py -o changedfiles.txt -t origin/$MR_TARGET_BRANCH_NAME SOURCE_TREE="HEAD"
python3 dumux/bin/testing/findtests.py -o affectedtests.json --file-list changedfiles.txt --build-dir build-cmake 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 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 "Skipping test selection, build/test stages will consider all tests!"
echo "{}" >> affectedtests.json touch affectedtests.json
fi fi
artifacts: artifacts:
paths: paths:
...@@ -54,7 +72,7 @@ build lecture: ...@@ -54,7 +72,7 @@ build lecture:
- | - |
pushd build-cmake pushd build-cmake
make clean make clean
if [[ -n "${DUMUX_MR_BRANCH}" ]]; then if [ -s ../affectedtests.json ]; then
python3 ../dumux/bin/testing/runselectedtests.py -c ../affectedtests.json -b python3 ../dumux/bin/testing/runselectedtests.py -c ../affectedtests.json -b
else else
python3 ../dumux/bin/testing/runselectedtests.py --all -b python3 ../dumux/bin/testing/runselectedtests.py --all -b
...@@ -75,7 +93,7 @@ test lecture: ...@@ -75,7 +93,7 @@ test lecture:
script: script:
- | - |
pushd build-cmake pushd build-cmake
if [[ -n "${DUMUX_MR_BRANCH}" ]]; then if [ -s ../affectedtests.json ]; then
python3 ../dumux/bin/testing/runselectedtests.py -c ../affectedtests.json -t python3 ../dumux/bin/testing/runselectedtests.py -c ../affectedtests.json -t
else else
python3 ../dumux/bin/testing/runselectedtests.py --all -t python3 ../dumux/bin/testing/runselectedtests.py --all -t
......
Supports Markdown
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