From 6ca654af73db9d5895418708a1944a3dd998f78e Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Thu, 2 Apr 2020 01:18:21 +0200 Subject: [PATCH] ci: lint not on upstream branches It is problematic to lint commits on upstream branches in case a commit with wrong format was pushed. Or when there is some bug in the linter, what is currently the case, see [1][2]. Make sure the linter is only always run on merge requests and for other branches. [1] https://github.com/conventional-changelog/commitlint/issues/896 [2] https://gitlab.com/kwinft/wrapland/-/jobs/495110391 (cherry picked from commit 99803545c72eb988257bfa685aab185c3093a1f0) --- .gitlab-ci.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e487d42a..c9462dc8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,22 +9,29 @@ variables: workflow: rules: - - if: $CI_MERGE_REQUEST_IID - when: never - when: always Message lint: stage: Compliance image: node:latest + rules: + - if: $CI_MERGE_REQUEST_IID + when: always + - if: '$CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH =~ /^Plasma\//' + when: never + - when: always variables: UPSTREAM: https://${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}@${CI_SERVER_HOST}/kwinft/wrapland.git script: + - if [ -n "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]; + then export COMPARE_BRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME; else export COMPARE_BRANCH=master; fi + - "echo Branch to compare: $COMPARE_BRANCH" - yarn global add @commitlint/cli - yarn add conventional-changelog-conventionalcommits - git remote add _upstream $UPSTREAM || git remote set-url _upstream $UPSTREAM - - git fetch -q _upstream master - - commitlint --verbose --config=ci/commitlint.config.js --from=_upstream/master + - git fetch -q _upstream $COMPARE_BRANCH + - commitlint --verbose --config=ci/commitlint.config.js --from=_upstream/$COMPARE_BRANCH cache: paths: - node_modules/ @@ -77,16 +84,12 @@ Autotests: needs: - job: Normal build artifacts: true - - job: Message lint - artifacts: false Sanitizers: <<: *common-test needs: - job: Sanitizers build artifacts: true - - job: Message lint - artifacts: false Master image trigger: