Skip to content

Commit

Permalink
ci: lint not on upstream branches
Browse files Browse the repository at this point in the history
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] conventional-changelog/commitlint#896
[2] https://gitlab.com/kwinft/wrapland/-/jobs/495110391

(cherry picked from commit 9980354)
  • Loading branch information
romangg committed Apr 1, 2020
1 parent 5cb5deb commit 6ca654a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 6ca654a

Please sign in to comment.