Skip to content
Snippets Groups Projects
Commit 28522e25 authored by Sergey Kosukhin's avatar Sergey Kosukhin
Browse files

ci: extra cache validation for pre-commit jobs

parent f590148b
No related branches found
No related tags found
1 merge request!79Extra cache validation for pre-commit jobs
Pipeline #97231 passed
......@@ -19,6 +19,7 @@ workflow:
.colorized:
variables:
DEFAULT: '\033[0m'
GREEN: '\033[0;32m'
RED: '\033[0;31m'
.ci_dir:
......@@ -26,19 +27,34 @@ workflow:
CI_GITIGNORE_DIR: ${CI_PROJECT_DIR}/.ci_dir
.common_pre_commit:
extends: .ci_dir
extends:
- .colorized
- .ci_dir
variables:
APK_CACHE_DIR: ${CI_GITIGNORE_DIR}/apk-cache
PRE_COMMIT_HOME: ${CI_GITIGNORE_DIR}/pre-commit
CACHE_POLICY: pull
before_script:
- mkdir -p "${APK_CACHE_DIR}"
- apk update --cache-dir "${APK_CACHE_DIR}"
- apk add --cache-dir "${APK_CACHE_DIR}" git pre-commit
- apk --cache-dir "${APK_CACHE_DIR}" --update-cache add git pre-commit
- |
# Clean up cache
case ${CACHE_POLICY} in
*push) (
set -o pipefail
apk --cache-dir "${APK_CACHE_DIR}" cache clean
python3 --version | diff - "${PRE_COMMIT_HOME}/python_version.txt" 2>/dev/null || {
rm -rf "${PRE_COMMIT_HOME}"
mkdir -p "${PRE_COMMIT_HOME}"
python3 --version > "${PRE_COMMIT_HOME}/python_version.txt"
}
) ;;
*) printf "${GREEN}Skipped due to policy.\n${DEFAULT}" ;;
esac
tags:
- alpine
cache:
- key: ${CI_COMMIT_REF_SLUG}
- key: apk-pre-commit
paths:
- ${APK_CACHE_DIR}
policy: ${CACHE_POLICY}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment