We are working with Gitlab-CI and a strange behaviour just happened. We are trying to only run a given job (e.g, lint here below) only and only if we are in a merge request not a simple git branch, as well as only if *.py files shows changes. However, from what we have seen on the documentation we seems to be okay but not really as it do not work well at the moment. If, for example, I am going to push a change on the Readme.MD, the pipeline's job Lint here will be executed where it should have not.
Please, if you have any ideas/tips, We would be very grateful.
Thank you very much for your understanding, Bw.
---> Gitlab CI Yaml configuration:
.gitlab-ci.yml:
image: python:3.7
stages:
- pre-build
- test
.ci_rules:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_IID'
changes:
- tests/*.py
- tests/*/*.py
- src/*.py
- src/*/*.py
- if: $CI_COMMIT_REF_NAME == "develop"
- if: $CI_COMMIT_REF_NAME == "main"
lint:
stage: pre-build
script:
- pip install flake8
- flake8
rules:
- !reference [ .ci_rules, rules ]
# [... other jobs not relevant for the issue]