diff --git a/.gitlab/.gitlab-ci.yml b/.gitlab/.gitlab-ci.yml index 2b23f96454396eb60071f137f85b53b678f65cef..62e5c5f05a7eb1baf6192fa9532f2b67e4c68d78 100644 --- a/.gitlab/.gitlab-ci.yml +++ b/.gitlab/.gitlab-ci.yml @@ -15,7 +15,7 @@ variables: description: "The CI pipeline to run" FETCH_PUBLIC_MR: - value : "false" + value: "false" options: - "false" - "true" diff --git a/.gitlab/pipelines/deployment-pipeline.yml b/.gitlab/pipelines/deployment-pipeline.yml index 2fb032df32773144c26137f513b8508b4f7908d3..5e661580fa6595d2572e8ef3bbf795d98115c1e9 100644 --- a/.gitlab/pipelines/deployment-pipeline.yml +++ b/.gitlab/pipelines/deployment-pipeline.yml @@ -15,6 +15,7 @@ stages: include: - local: .gitlab/templates/setup-workspace.yml + - local: .gitlab/templates/status-report.yml - local: .gitlab/templates/linting.yml - local: .gitlab/templates/static-analysis.yml - local: .gitlab/templates/unit-test.yml @@ -27,6 +28,18 @@ pull-mr: stage: .pre extends: .pull-mr +report-pipeline-start: + stage: .pre + extends: .report-pipeline-start + +report-pipeline-success: + stage: .post + extends: .report-pipeline-success + +report-pipeline-failure: + stage: .post + extends: .report-pipeline-failure + check-lint: extends: - .check-lint diff --git a/.gitlab/templates/status-report.yml b/.gitlab/templates/status-report.yml new file mode 100644 index 0000000000000000000000000000000000000000..8b402ae1c72da75f41b6b5b146a10319cccb26a2 --- /dev/null +++ b/.gitlab/templates/status-report.yml @@ -0,0 +1,51 @@ +# +# Arm SCP/MCP Software +# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +.report-status: + image: ${CI_REGISTRY_IMAGE}/ci-base:latest + script: + - | + curl --fail --location --request POST \ + "${PUBLIC_REPO_API_URL}/merge_requests/${FETCH_PUBLIC_MR_NUMBER}/notes" \ + --header "PRIVATE-TOKEN:${PUBLIC_REPO_API_KEY}" \ + --header "Content-Type:application/json" \ + --data-raw "{\"body\":\"CI Testing - Pipeline ${CI_PIPELINE_ID} - ${PIPELINE_STATUS_MSG}\"}" + +.report-pipeline-start: + extends: .report-status + variables: + PIPELINE_STATUS_MSG: "STARTED" + rules: + - if: $FETCH_PUBLIC_MR == "true" + +.report-pipeline-failure: + extends: .report-status + variables: + PIPELINE_STATUS_MSG: "FAILED" + after_script: + - | + echo "Status: FAILURE - Resseting approvals" + curl --fail --location --request PUT \ + --header "PRIVATE-TOKEN:${PUBLIC_REPO_API_KEY}" \ + "${PUBLIC_REPO_API_URL}/merge_requests/${FETCH_PUBLIC_MR_NUMBER}/reset_approvals" + when: on_failure + rules: + - if: $FETCH_PUBLIC_MR == "true" + +.report-pipeline-success: + extends: .report-status + variables: + PIPELINE_STATUS_MSG: "SUCCESS" + after_script: + - | + echo "Status: SUCCESS - MR Approved" + curl --fail --location --request POST \ + --header "PRIVATE-TOKEN:${PUBLIC_REPO_API_KEY}" \ + "${PUBLIC_REPO_API_URL}/merge_requests/${FETCH_PUBLIC_MR_NUMBER}/approve" + when: on_success + rules: + - if: $FETCH_PUBLIC_MR == "true"