Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
ci/external-mr: add checkout external MR option
Browse files Browse the repository at this point in the history
This patch adds the possibility to run `deployment-pipeline`
checking out an external public repository.

Signed-off-by: Leandro Belli <leandro.belli@arm.com>
Change-Id: I9ce6d3ec62588c693fd011e7846702193e8472fd
  • Loading branch information
leandro-arm committed May 7, 2024
1 parent dfd8410 commit 8cd7120
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 9 deletions.
11 changes: 11 additions & 0 deletions .gitlab/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ variables:
- "weekly-pipeline"
description: "The CI pipeline to run"

FETCH_PUBLIC_MR:
value : "false"
options:
- "false"
- "true"
description: "Fetch branch from public MR"

FETCH_PUBLIC_MR_NUMBER:
description: "MR number to fetch"


include:
- local: .gitlab/pipelines/deployment-pipeline.yml
rules:
Expand Down
63 changes: 54 additions & 9 deletions .gitlab/pipelines/deployment-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,97 @@
#

stages:
- test-workspace
- linting
- static-analysis
- unit-testing
- build
- scmi-test

include:
- local: .gitlab/templates/setup-workspace.yml
- local: .gitlab/templates/linting.yml
- local: .gitlab/templates/static-analysis.yml
- local: .gitlab/templates/unit-test.yml
- local: .gitlab/templates/build-test.yml
- local: .gitlab/templates/scmi-test.yml
- local: .gitlab/templates/coverity-test.yml


pull-mr:
stage: .pre
extends: .pull-mr

check-lint:
extends: .check-lint
extends:
- .check-lint
- .git-strategy-on-mr
stage: linting
dependencies:
- pull-mr

check-copyright:
extends: .check-copyright
before_script:
- ls .gitlab/templates
extends:
- .check-copyright
- .git-strategy-on-mr
stage: linting
dependencies:
- pull-mr

check-style:
extends: .check-style
extends:
- .check-style
- .git-strategy-on-mr
stage: linting
dependencies:
- pull-mr

banned-api:
extends: .banned-api
extends:
- .banned-api
- .git-strategy-on-mr
stage: static-analysis
dependencies:
- pull-mr

coverity-test:
stage: static-analysis
extends: .coverity-test
extends:
- .coverity-test
- .git-strategy-on-mr
dependencies:
- pull-mr

check-fwk:
extends: .check-fwk
extends:
- .check-fwk
- .git-strategy-on-mr
stage: unit-testing
dependencies:
- pull-mr

check-modules:
extends: .check-modules
extends:
- .check-modules
- .git-strategy-on-mr
stage: unit-testing
dependencies:
- pull-mr

build-products:
extends: .build-products
extends:
- .build-products
- .git-strategy-on-mr
stage: build
dependencies:
- pull-mr

scmi-test:
extends: .scmi-test
extends:
- .scmi-test
- .git-strategy-on-mr
stage: scmi-test
dependencies:
- pull-mr
50 changes: 50 additions & 0 deletions .gitlab/templates/setup-workspace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#
# Arm SCP/MCP Software
# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#


.pull-mr:
image: ${CI_REGISTRY_IMAGE}/ci-base:latest
variables:
GIT_STRATEGY: clone
GIT_CHECKOUT: "false"
script:
- |
MR_INFO=$(curl --fail \
"${PUBLIC_REPO_API_URL}/merge_requests/${FETCH_PUBLIC_MR_NUMBER}")
SCP_REFSPEC=$(printf "%s" "$MR_INFO" | jq -r .source_branch)
git fetch $PUBLIC_REPO_URL $SCP_REFSPEC
echo "Fetched commit:"
git rev-list --format=%B --max-count=1 FETCH_HEAD
git checkout FETCH_HEAD
git submodule update --init --recursive --depth 1
git fetch origin main
CI_MERGE_REQUEST_DIFF_BASE_SHA=$(git merge-base FETCH_HEAD origin/main)
# Save ENV variables
mkdir -p .env
echo "CI_MERGE_REQUEST_DIFF_BASE_SHA=$CI_MERGE_REQUEST_DIFF_BASE_SHA" \
>> .env/workspace.env
artifacts:
reports:
dotenv: .env/workspace.env
paths:
- . # Save workspace
rules:
- if: $FETCH_PUBLIC_MR == "true"

.git-strategy-on-mr:
rules:
- if: $FETCH_PUBLIC_MR == "true"
variables:
GIT_STRATEGY: none
- if: $FETCH_PUBLIC_MR == "false"
variables:
GIT_STRATEGY: fetch

0 comments on commit 8cd7120

Please sign in to comment.