2023-04-27 22:42:37 +00:00
|
|
|
##########################################################################
|
|
|
|
# Test the formatting in a merge request using clang-format
|
|
|
|
##########################################################################
|
|
|
|
# The variable CI_COMMIT_BEFORE_SHA is not available in normal merge requests
|
|
|
|
# so we must build the commit hash ourselves, see:
|
2023-05-17 10:23:00 +00:00
|
|
|
# https://gitlab.com/gitlab-org/gitlab/-/issues/12850
|
2023-04-27 22:42:37 +00:00
|
|
|
test_formatting:
|
|
|
|
stage: test
|
|
|
|
needs: []
|
2023-05-06 12:20:56 +00:00
|
|
|
rules:
|
|
|
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
2023-04-27 22:42:37 +00:00
|
|
|
allow_failure: true
|
|
|
|
before_script:
|
|
|
|
# We must manually add the KiCad remote to ensure it is named sensibly
|
2023-07-06 05:56:21 +00:00
|
|
|
- git remote add product https://gitlab.com/kicad/code/kicad.git ||
|
|
|
|
git remote set-url product https://gitlab.com/kicad/code/kicad.git
|
|
|
|
- git remote add source ${CI_MERGE_REQUEST_SOURCE_PROJECT_URL}.git ||
|
|
|
|
git remote set-url source ${CI_MERGE_REQUEST_SOURCE_PROJECT_URL}.git
|
2023-04-27 22:42:37 +00:00
|
|
|
- git fetch -n product
|
|
|
|
- git fetch -n source
|
|
|
|
# Get the SHAs of the commits
|
|
|
|
- "TARGET_HEAD_SHA=$(git rev-parse product/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME})"
|
|
|
|
- "SOURCE_HEAD_SHA=$(git rev-parse source/${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME})"
|
|
|
|
- "MERGE_BASE_SHA=$(git merge-base ${TARGET_HEAD_SHA} ${SOURCE_HEAD_SHA})"
|
|
|
|
script:
|
|
|
|
- echo "Testing formatting from commit ${MERGE_BASE_SHA}"
|
|
|
|
- ./tools/check_coding.sh --diff --ci --commit ${MERGE_BASE_SHA}
|