diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 217fafb60a..2be13a169b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,5 @@ stages: + - upload_cache - pre_check - build - assign_test @@ -100,7 +101,7 @@ cache: paths: - .cache/pip # pull only for most of the use cases since it's cache dir. - # Only set "pull-push" policy for "scan_test" since it would **possibly** install all pypi packages + # Only set "push" policy for "upload_cache" stage jobs since it would install all pypi packages policy: pull .setup_tools_unless_target_test: &setup_tools_unless_target_test | @@ -226,6 +227,7 @@ default: include: - '.gitlab/ci/rules.yml' + - '.gitlab/ci/upload_cache.yml' - '.gitlab/ci/docs.yml' - '.gitlab/ci/static-code-analysis.yml' - '.gitlab/ci/pre_check.yml' diff --git a/.gitlab/ci/host-test.yml b/.gitlab/ci/host-test.yml index 29783e2201..9c0a764a4b 100644 --- a/.gitlab/ci/host-test.yml +++ b/.gitlab/ci/host-test.yml @@ -7,7 +7,11 @@ tags: - host_test dependencies: [] - needs: [] # run host_test jobs immediately + needs: + - job: upload-pip-cache-shiny + optional: true # run host_test jobs immediately, only after upload cache + - job: upload-pip-cache-brew + optional: true # run host_test jobs immediately, only after upload cache test_nvs_on_host: extends: .host_test_template diff --git a/.gitlab/ci/pre_check.yml b/.gitlab/ci/pre_check.yml index ac9ad2be7b..2c03670d12 100644 --- a/.gitlab/ci/pre_check.yml +++ b/.gitlab/ci/pre_check.yml @@ -160,13 +160,6 @@ scan_tests: - $TEST_APPS_OUTPUT_DIR - $COMPONENT_UT_OUTPUT_DIR expire_in: 1 week - cache: - key: pip-cache - paths: - - .cache/pip - # pull only for most of the use cases since it's cache dir. - # Only set "pull-push" policy for "scan_test" since it would **possibly** install all pypi packages - policy: pull-push variables: EXAMPLE_TEST_DIR: ${CI_PROJECT_DIR}/examples EXAMPLE_TEST_OUTPUT_DIR: ${CI_PROJECT_DIR}/examples/test_configs diff --git a/.gitlab/ci/rules.yml b/.gitlab/ci/rules.yml index f87b6c218d..f0f63001f4 100644 --- a/.gitlab/ci/rules.yml +++ b/.gitlab/ci/rules.yml @@ -12,6 +12,10 @@ - "components/**/Kconfig" - "components/**/CMakeList.txt" +.patterns-python-cache: &patterns-python-cache + - "tools/requirements.json" + - "tools/requirements/requirements.*.txt" + .patterns-python-files: &patterns-python-files - ".gitlab/ci/static-code-analysis.yml" - "**/*.py" @@ -232,6 +236,11 @@ rules: - <<: *if-protected-no_label +.rules:patterns:python-cache: + rules: + - <<: *if-dev-push + changes: *patterns-python-cache + .rules:dev: rules: - <<: *if-trigger diff --git a/.gitlab/ci/upload_cache.yml b/.gitlab/ci/upload_cache.yml new file mode 100644 index 0000000000..afbb0e0005 --- /dev/null +++ b/.gitlab/ci/upload_cache.yml @@ -0,0 +1,36 @@ +.upload_cache_template: + stage: upload_cache + image: $ESP_ENV_IMAGE + +.upload_pip_cache_template: + extends: + - .upload_cache_template + - .rules:patterns:python-cache + cache: + key: pip-cache + paths: + - .cache/pip + # pull only for most of the use cases since it's cache dir. + # Only set "push" policy for "upload_cache" stage jobs since it would install all pypi packages + policy: push + before_script: [] + script: + - source tools/ci/utils.sh + - is_based_on_commits $REQUIRED_ANCESTOR_COMMITS + - source tools/ci/setup_python.sh + - rm -rf .cache/pip # clear old packages + - $IDF_PATH/tools/idf_tools.py install-python-env --features pytest + # TODO: remove this, IDFCI-1207 + - pip install esptool -c ~/.espressif/${CI_PYTHON_CONSTRAINT_FILE} + +upload-pip-cache-shiny: + extends: .upload_pip_cache_template + tags: + - shiny + - build + +upload-pip-cache-brew: + extends: .upload_pip_cache_template + tags: + - brew + - build