From e3d345d428b7b497b6e18b64ca664a8b0c28b816 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 15 Apr 2023 18:20:41 +0100 Subject: [PATCH] ci: Refactor paths, and only build containers for CI path changes --- .gitlab-ci/ci-rules.yml | 42 ++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/.gitlab-ci/ci-rules.yml b/.gitlab-ci/ci-rules.yml index b26b97756..34eb71be9 100644 --- a/.gitlab-ci/ci-rules.yml +++ b/.gitlab-ci/ci-rules.yml @@ -15,6 +15,26 @@ # Outside of monado. - if: &is-forked-branch '$CI_PROJECT_NAMESPACE != "monado" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME != $CI_COMMIT_REF_NAME' when: manual + # GitLab CI paths + - changes: &paths-ci-files + - ".gitlab-ci.yml" + - ".gitlab-ci/**/*" + when: on_success + # All paths, 1 hours have been wasted trying to combine the above arrays. + - changes: &paths-ci-code-sys-files + # Code + - "scripts/**/*" + - "src/**/*" + # Build sys + - CMakeLists.txt + - "*.cmake" + - "**/*.gradle" + - "cmake/**/*" + - "gradle/**/*" + # CI paths + - ".gitlab-ci.yml" + - ".gitlab-ci/**/*" + when: on_success # When to automatically run the CI for build jobs @@ -22,19 +42,8 @@ rules: # If any files affecting the pipeline are changed, build/test jobs run # automatically once all dependency jobs have passed - - changes: &all_paths - # build sys - - CMakeLists.txt - - "*.cmake" - - "**/*.gradle" - - "cmake/**/*" - - "gradle/**/*" - # GitLab CI - - ".gitlab-ci.yml" - - ".gitlab-ci/**/*" - # Source code - - "scripts/**/*" - - "src/**/*" + - changes: + *paths-ci-code-sys-files when: on_success # Don't build on forked repos. - if: *is-forked-branch @@ -48,20 +57,19 @@ # configuration files were changed, to ensure docker images are up to date - if: *is-post-merge changes: - - ".gitlab-ci.yml" - - ".gitlab-ci/**/*" + *paths-ci-files when: on_success # Run pipeline by default if it is for a merge request, and any files # affecting the pipeline were changed - if: *is-pre-merge changes: - *all_paths + *paths-ci-files when: on_success # Allow triggering jobs manually in other cases if any files affecting the # pipeline were changed: Disabled for now because it causes the pipeline on # main to be blocked because it gets stuck in the container stage. #- changes: - # *all_paths + # *paths-ci-files # when: manual # Don't build on forked repos. - if: *is-forked-branch