From ff015d1872bea16d3a3c8b7b3b61e8976bea486c Mon Sep 17 00:00:00 2001 From: Chen Yudong Date: Tue, 19 Dec 2023 16:19:50 +0800 Subject: [PATCH 1/2] ci: differnet cache key for different idf ver update caches on release tags and nightly schedules --- .gitlab/ci/common.yml | 8 ++++++-- .gitlab/ci/rules.yml | 8 +++++++- .gitlab/ci/target-test.yml | 2 +- .gitlab/ci/upload_cache.yml | 4 ++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.gitlab/ci/common.yml b/.gitlab/ci/common.yml index 3e64980d24..e858331898 100644 --- a/.gitlab/ci/common.yml +++ b/.gitlab/ci/common.yml @@ -329,11 +329,15 @@ default: cache: # pull only for most of the use cases since it's cache dir. # Only set "push" policy for "upload_cache" stage jobs - - key: pip-cache + - key: pip-cache-${LATEST_GIT_TAG} + fallback_keys: + - pip-cache paths: - .cache/pip policy: pull - - key: submodule-cache + - key: submodule-cache-${LATEST_GIT_TAG} + fallback_keys: + - submodule-cache paths: - .cache/submodule_archives policy: pull diff --git a/.gitlab/ci/rules.yml b/.gitlab/ci/rules.yml index ae688f66b5..871dc7a1bb 100644 --- a/.gitlab/ci/rules.yml +++ b/.gitlab/ci/rules.yml @@ -349,6 +349,9 @@ .if-schedule: &if-schedule if: '$CI_PIPELINE_SOURCE == "schedule"' +.if-schedule-nightly: &if-schedule-nightly + if: '$CI_PIPELINE_SOURCE == "schedule" && $INCLUDE_NIGHTLY_RUN == "1"' + .if-schedule-test-build-system-windows: &if-schedule-test-build-system-windows if: '$CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_BUILD_SYSTEM_TEST_WIN == "true"' @@ -405,7 +408,8 @@ ### Patterns ### .rules:patterns:python-cache: rules: - - *if-schedule + - <<: *if-tag-release + - <<: *if-schedule-nightly - <<: *if-label-upload_cache when: manual - <<: *if-dev-push @@ -413,6 +417,8 @@ .rules:patterns:submodule: rules: + - <<: *if-tag-release + - <<: *if-schedule-nightly - <<: *if-label-upload_cache when: manual - <<: *if-dev-push diff --git a/.gitlab/ci/target-test.yml b/.gitlab/ci/target-test.yml index d8f8f9a490..8e7892eb11 100644 --- a/.gitlab/ci/target-test.yml +++ b/.gitlab/ci/target-test.yml @@ -7,7 +7,7 @@ dependencies: [] cache: # Usually do not need submodule-cache in target_test - - key: pip-cache + - key: pip-cache-${LATEST_GIT_TAG} paths: - .cache/pip policy: pull diff --git a/.gitlab/ci/upload_cache.yml b/.gitlab/ci/upload_cache.yml index b0a35ae4e1..30e49b545a 100644 --- a/.gitlab/ci/upload_cache.yml +++ b/.gitlab/ci/upload_cache.yml @@ -15,7 +15,7 @@ upload-pip-cache: - $GEO - cache cache: - key: pip-cache + key: pip-cache-${LATEST_GIT_TAG} paths: - .cache/pip policy: push @@ -35,7 +35,7 @@ upload-submodules-cache: - $GEO - cache cache: - key: submodule-cache + key: submodule-cache-${LATEST_GIT_TAG} paths: - .cache/submodule_archives policy: push From 77597f7ac83621f1d2e62a8e36377ad090fd461a Mon Sep 17 00:00:00 2001 From: Chen Yudong Date: Tue, 19 Dec 2023 19:32:31 +0800 Subject: [PATCH 2/2] ci: do not upload caches for dev branches by default --- .gitlab/ci/rules.yml | 31 +++++++++++++------------------ .gitlab/ci/upload_cache.yml | 4 ++-- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.gitlab/ci/rules.yml b/.gitlab/ci/rules.yml index 871dc7a1bb..589a89528f 100644 --- a/.gitlab/ci/rules.yml +++ b/.gitlab/ci/rules.yml @@ -197,9 +197,6 @@ - "components/bt/esp_ble_mesh/lib/lib" - ".gitmodules" -.patterns-danger-npm: &patterns-danger-npm - - ".gitlab/dangerjs/package-lock.json" - # for jobs: flash_encryption_wifi_high_traffic .patterns-example_test-ota-nightly_run: &patterns-example_test-ota-nightly_run - "examples/system/ota/**/*" @@ -337,6 +334,10 @@ .if-protected-no_label: &if-protected-no_label if: '($CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_BRANCH =~ /^release\/v/ || $CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/) && $BOT_TRIGGER_WITH_LABEL == null' +.if-protected-ref-push: &if-protected-ref-push + # rules:changes always evaluates to true for new branch pipelines or when there is no Git push event + if: '($CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_BRANCH =~ /^release\/v/) && $CI_PIPELINE_SOURCE == "push"' + .if-qa-test-tag: &if-qa-test-tag if: '$CI_COMMIT_TAG =~ /^qa-test/' @@ -405,32 +406,26 @@ rules: - <<: *if-tag-release -### Patterns ### -.rules:patterns:python-cache: +# Do not upload caches on dev branches by default +.rules:upload-python-cache: rules: - <<: *if-tag-release - <<: *if-schedule-nightly - - <<: *if-label-upload_cache - when: manual - - <<: *if-dev-push + - <<: *if-protected-ref-push changes: *patterns-python-cache + - <<: *if-label-upload_cache + when: manual -.rules:patterns:submodule: +.rules:upload-submodule-cache: rules: + # Needn't upload submodule cache in schedule pipeline - <<: *if-tag-release - - <<: *if-schedule-nightly - - <<: *if-label-upload_cache - when: manual - - <<: *if-dev-push + - <<: *if-protected-ref-push changes: *patterns-submodule - -.rules:patterns:dangerjs: - rules: - <<: *if-label-upload_cache when: manual - - <<: *if-dev-push - changes: *patterns-danger-npm +### Patterns ### .rules:patterns:clang_tidy: rules: - <<: *if-protected diff --git a/.gitlab/ci/upload_cache.yml b/.gitlab/ci/upload_cache.yml index 30e49b545a..173b63224b 100644 --- a/.gitlab/ci/upload_cache.yml +++ b/.gitlab/ci/upload_cache.yml @@ -10,7 +10,7 @@ upload-pip-cache: extends: - .upload_cache_template - .before_script:minimal - - .rules:patterns:python-cache + - .rules:upload-python-cache tags: - $GEO - cache @@ -30,7 +30,7 @@ upload-submodules-cache: extends: - .upload_cache_template - .before_script:minimal - - .rules:patterns:submodule + - .rules:upload-submodule-cache tags: - $GEO - cache