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

ci: individual caches for pre-commit jobs

parent 1c6714d2
No related branches found
No related tags found
1 merge request!81CI: individual caches for pre-commit jobs
Pipeline #97249 passed
......@@ -19,7 +19,6 @@ workflow:
.colorized:
variables:
DEFAULT: '\033[0m'
GREEN: '\033[0;32m'
RED: '\033[0;31m'
.ci_dir:
......@@ -27,48 +26,39 @@ workflow:
CI_GITIGNORE_DIR: ${CI_PROJECT_DIR}/.ci_dir
.common_pre_commit:
extends:
- .colorized
- .ci_dir
extends: .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 --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
(
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"
}
)
tags:
- alpine
cache:
- key: apk-pre-commit
paths:
- ${APK_CACHE_DIR}
policy: ${CACHE_POLICY}
- key:
prefix: ${CI_JOB_NAME_SLUG}
files:
- .pre-commit-config.yaml
paths:
- ${PRE_COMMIT_HOME}
policy: ${CACHE_POLICY}
Check licenses:
extends: .common_pre_commit
variables:
CACHE_POLICY: pull
script:
- pre-commit run --color=always --hook-stage manual reuse
rules:
......@@ -79,8 +69,6 @@ Check licenses:
Check style:
extends: .common_pre_commit
variables:
CACHE_POLICY: pull-push
script:
- pre-commit run --show-diff-on-failure --color=always --all-files
rules:
......
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