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

ci: extract the pre-commit caching to a hidden job

parent 17d84c7c
No related branches found
No related tags found
1 merge request!69Add pre-commit hook to check licenses
......@@ -25,6 +25,30 @@ workflow:
variables:
CI_GITIGNORE_DIR: ${CI_PROJECT_DIR}/.ci_dir
.common_pre_commit:
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 update --cache-dir "${APK_CACHE_DIR}"
- apk add --cache-dir "${APK_CACHE_DIR}" git pre-commit
tags:
- alpine
cache:
- key: ${CI_COMMIT_REF_SLUG}
paths:
- ${APK_CACHE_DIR}
policy: ${CACHE_POLICY}
- key:
files:
- .pre-commit-config.yaml
paths:
- ${PRE_COMMIT_HOME}
policy: ${CACHE_POLICY}
Check licenses:
before_script:
- python -m pip install --upgrade pip
......@@ -41,32 +65,16 @@ Check licenses:
interruptible: true
Check style:
extends: .ci_dir
extends: .common_pre_commit
variables:
APK_CACHE_DIR: ${CI_GITIGNORE_DIR}/apk-cache
PRE_COMMIT_HOME: ${CI_GITIGNORE_DIR}/pre-commit
before_script:
- mkdir -p "${APK_CACHE_DIR}"
- apk update --cache-dir "${APK_CACHE_DIR}"
- apk add --cache-dir "${APK_CACHE_DIR}" git pre-commit
CACHE_POLICY: pull-push
script:
- pre-commit run --show-diff-on-failure --color=always --all-files
tags:
- alpine
rules:
- if: $CI_PIPELINE_SOURCE == "web"
when: manual
- when: always
interruptible: true
cache:
- key: ${CI_COMMIT_REF_SLUG}
paths:
- ${APK_CACHE_DIR}
- key:
files:
- .pre-commit-config.yaml
paths:
- ${PRE_COMMIT_HOME}
include:
- project: "anw_dienste/ci-templates"
......
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