Commit 56fe31f3 authored by Timo Koch's avatar Timo Koch
Browse files

Merge branch 'feature/ci-pass-reference-sha-downstream' into 'master'

[ci] find ref commit in check-pipeline

See merge request !2663
parents 680f07eb f2ce1f8d
Pipeline #4923 passed with stages
in 0 seconds
......@@ -30,13 +30,29 @@ check-pipeline-status:
when: always
script:
- |
getLastSuccessful() {
python3 .gitlab-ci/getpipelineinfo.py \
--access-token $CI_JOB_API_READ_TOKEN \
--look-for latest-merge \
--print-format commit-sha
}
if ! python3 .gitlab-ci/getpipelineinfo.py --access-token $CI_JOB_API_READ_TOKEN \
--look-for HEAD \
--print-format pipeline-id; then
echo "No successful pipeline found. Triggering new pipeline..."
echo "No successful pipeline found."
REFERENCE_SHA=""
if getLastSuccessful; then
REFERENCE_SHA=$(getLastSuccessful);
echo "Triggering new pipeline against reference commit $REFERENCE_SHA."
else
echo "Latest successful pipeline not found. Trigger complete pipeline."
fi
curl --request POST --form "token=$CI_JOB_TOKEN" \
--form ref=$CI_COMMIT_BRANCH \
--form "variables[CI_TEST_AGAINST_LAST_SUCCESSFUL]=true" \
--form "variables[CI_REFERENCE_SHA]=$REFERENCE_SHA" \
"https://git.iws.uni-stuttgart.de/api/v4/projects/31/trigger/pipeline"
else
echo "Found successful pipeline for the current state of the branch. Not testing again."
......@@ -57,10 +73,8 @@ check-pipeline-status:
include: .gitlab-ci/default.yml
strategy: depend
variables:
TRIGGER_SOURCE: $CI_PIPELINE_SOURCE
COMMIT_BRANCH: $CI_COMMIT_BRANCH
MR_TARGET_BRANCH_NAME: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
TEST_AGAINST_LAST_SUCCESSFUL: $CI_TEST_AGAINST_LAST_SUCCESSFUL
REFERENCE_SHA: $CI_REFERENCE_SHA
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: always
......@@ -121,6 +135,7 @@ trigger lecture:
branch: master
strategy: depend
variables:
DUMUX_PIPELINE_SOURCE: $CI_PIPELINE_SOURCE
DUMUX_MERGE_REQUEST_SOURCE_BRANCH: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
DUMUX_MERGE_REQUEST_TARGET_BRANCH: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
DUMUX_COMMIT_SHA: $CI_COMMIT_SHA
DUMUX_REFERENCE_SHA: $CI_REFERENCE_SHA
......@@ -12,23 +12,15 @@ workflow:
# variables that should be overwritten by the trigger
variables:
TRIGGER_SOURCE: "undefined"
COMMIT_BRANCH: "undefined"
MR_TARGET_BRANCH_NAME: "undefined"
MR_TARGET_BRANCH_NAME: ""
REFERENCE_SHA: ""
select tests:
stage: configure
script:
- dunecontrol --opts=$DUNE_OPTS_FILE --current all
- |
getLastSuccesful() {
python3 .gitlab-ci/getpipelineinfo.py \
--access-token $CI_JOB_API_READ_TOKEN \
--look-for latest-merge \
--print-format commit-sha
}
if [[ "$TRIGGER_SOURCE" == "merge_request_event" ]]; then
if [[ -n "$MR_TARGET_BRANCH_NAME" ]]; then
echo "Detecting changes w.r.t to target branch '$MR_TARGET_BRANCH_NAME'"
python3 bin/testing/getchangedfiles.py --outfile changedfiles.txt \
--target-tree origin/$MR_TARGET_BRANCH_NAME
......@@ -36,30 +28,17 @@ select tests:
--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 [ -n $TEST_AGAINST_LAST_SUCCESSFUL ]; then
echo "Determining sha of the last successful pipeline to test against"
if ! getLastSuccesful; then
echo "Could not find a successful pipeline, will build/run all tests"
touch affectedtests.json
else
COMMIT_SHA=$(getLastSuccesful)
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
elif [[ -n "$REFERENCE_SHA" ]]; then
echo "Detecting changes w.r.t to reference commit $REFERENCE_SHA"
python3 bin/testing/getchangedfiles.py --outfile changedfiles.txt \
--source-tree HEAD \
--target-tree $REFERENCE_SHA
python3 bin/testing/findtests.py --outfile affectedtests.json \
--file-list changedfiles.txt \
--build-dir build-cmake
else
echo "Unknown pipeline trigger event"
echo "No reference information given."
echo "Skipping test selection, build/test stages will consider all tests!"
touch affectedtests.json
fi
......
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