Skip to content

Instantly share code, notes, and snippets.

@mmerickel
Created November 25, 2020 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mmerickel/e0d6e23ce9a77efa4a11a6d61f26b030 to your computer and use it in GitHub Desktop.
Save mmerickel/e0d6e23ce9a77efa4a11a6d61f26b030 to your computer and use it in GitHub Desktop.
pre-commit cached with terraform
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