Created
November 25, 2020 20:11
pre-commit cached with terraform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pre-commit: | |
image: python:3.8-buster | |
variables: | |
XDG_CACHE_HOME: ${CI_PROJECT_DIR}/.ci-cache | |
PYTHONUSERBASE: ${CI_PROJECT_DIR}/.ci-cache | |
TF_VERSION: 0.13.5 | |
PRE_COMMIT_VERSION: 2.9.0 | |
cache: | |
# bust the cache if the python version changes | |
key: ${CI_JOB_IMAGE} | |
paths: | |
- ${XDG_CACHE_HOME} | |
before_script: | |
- mkdir -p ${XDG_CACHE_HOME}/bin | |
- export PATH=${XDG_CACHE_HOME}/bin:$PATH | |
- pip install --user pre-commit==${PRE_COMMIT_VERSION} | |
- | | |
if ! ( terraform --version | grep v${TF_VERSION} ) 2>&1 > /dev/null; then | |
temp=/tmp/terraform-${TF_VERSION}.zip | |
curl -sSL -o $temp https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip | |
unzip $temp -d ${XDG_CACHE_HOME}/bin | |
fi | |
script: | |
- pre-commit run --all-files |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment