From a8d31a5185a04558bc36e7b173525dc7e14e8500 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 8 Jun 2021 13:52:20 +0200 Subject: [PATCH 1/4] ci triggered only for default branch or PR --- .gitlab-ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ef4b45cd1..dc4cdf56f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,15 @@ default: # All jobs are interruptible by default interruptible: true +# see: https://docs.gitlab.com/ee/ci/yaml/#switch-between-branch-pipelines-and-merge-request-pipelines +workflow: + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' # If we move to gitlab one day + - if: '$CI_PIPELINE_SOURCE == "external_pull_request_event"' # For github PR + - if: '$CI_COMMIT_REF_NAME =~ /$CI_DEFAULT_BRANCH/ && $CI_PIPELINE_SOURCE == "push"' # If it's not the default branch and if it's a push, then do not trigger a build + when: never + - when: always + variables: YNH_BUILD_DIR: "ynh-build" From 4b8e8be4498a82c4e53dcd989e604baf5848b4fb Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 8 Jun 2021 14:01:34 +0200 Subject: [PATCH 2/4] ci triggered only on file changed --- .gitlab/ci/test.gitlab-ci.yml | 50 ++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/.gitlab/ci/test.gitlab-ci.yml b/.gitlab/ci/test.gitlab-ci.yml index 308701475..c6c54ec20 100644 --- a/.gitlab/ci/test.gitlab-ci.yml +++ b/.gitlab/ci/test.gitlab-ci.yml @@ -58,69 +58,105 @@ test-helpers: script: - cd tests - bash test_helpers.sh + only: + changes: + - data/helpers.d/* test-apps: extends: .test-stage script: - cd src/yunohost - python3 -m pytest tests/test_apps.py + only: + changes: + - src/yunohost/app.py test-appscatalog: extends: .test-stage script: - cd src/yunohost - python3 -m pytest tests/test_appscatalog.py + only: + changes: + - src/yunohost/app.py test-appurl: extends: .test-stage script: - cd src/yunohost - python3 -m pytest tests/test_appurl.py + only: + changes: + - src/yunohost/app.py test-apps-arguments-parsing: extends: .test-stage script: - cd src/yunohost - python3 -m pytest tests/test_apps_arguments_parsing.py - -test-backuprestore: - extends: .test-stage - script: - - cd src/yunohost - - python3 -m pytest tests/test_backuprestore.py + only: + changes: + - src/yunohost/app.py test-changeurl: extends: .test-stage script: - cd src/yunohost - python3 -m pytest tests/test_changeurl.py + only: + changes: + - src/yunohost/app.py + +test-backuprestore: + extends: .test-stage + script: + - cd src/yunohost + - python3 -m pytest tests/test_backuprestore.py + only: + changes: + - src/yunohost/backup.py test-permission: extends: .test-stage script: - cd src/yunohost - python3 -m pytest tests/test_permission.py + only: + changes: + - src/yunohost/permission.py test-settings: extends: .test-stage script: - cd src/yunohost - python3 -m pytest tests/test_settings.py + only: + changes: + - src/yunohost/settings.py test-user-group: extends: .test-stage script: - cd src/yunohost - python3 -m pytest tests/test_user-group.py - + only: + changes: + - src/yunohost/user.py + test-regenconf: extends: .test-stage script: - cd src/yunohost - python3 -m pytest tests/test_regenconf.py + only: + changes: + - src/yunohost/regenconf.py test-service: extends: .test-stage script: - cd src/yunohost - python3 -m pytest tests/test_service.py + only: + changes: + - src/yunohost/service.py \ No newline at end of file From cdb6973b4fba7823399f740fd9cfccd5815ebd75 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 8 Jun 2021 15:08:24 +0200 Subject: [PATCH 3/4] fix --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc4cdf56f..1ee6763fa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ workflow: rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' # If we move to gitlab one day - if: '$CI_PIPELINE_SOURCE == "external_pull_request_event"' # For github PR - - if: '$CI_COMMIT_REF_NAME =~ /$CI_DEFAULT_BRANCH/ && $CI_PIPELINE_SOURCE == "push"' # If it's not the default branch and if it's a push, then do not trigger a build + - if: '$CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"' # If it's not the default branch and if it's a push, then do not trigger a build when: never - when: always From 9fdab0dd51f4c562dc83bb4611e05550d1fd936a Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 8 Jun 2021 16:08:26 +0200 Subject: [PATCH 4/4] allow tags --- .gitlab-ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1ee6763fa..892a8431f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,9 +15,10 @@ default: # see: https://docs.gitlab.com/ee/ci/yaml/#switch-between-branch-pipelines-and-merge-request-pipelines workflow: rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' # If we move to gitlab one day - - if: '$CI_PIPELINE_SOURCE == "external_pull_request_event"' # For github PR - - if: '$CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"' # If it's not the default branch and if it's a push, then do not trigger a build + - if: $CI_PIPELINE_SOURCE == "merge_request_event" # If we move to gitlab one day + - if: $CI_PIPELINE_SOURCE == "external_pull_request_event" # For github PR + - if: $CI_COMMIT_TAG # For tags + - if: $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" # If it's not the default branch and if it's a push, then do not trigger a build when: never - when: always