This repository has been archived by the owner on Mar 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from gruntwork-io/tf13
Update repo to work with Terraform 0.13.x
- Loading branch information
Showing
11 changed files
with
262 additions
and
174 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,127 +1,125 @@ | ||
version: 2.1 | ||
|
||
defaults: &defaults | ||
machine: true | ||
|
||
env: &env | ||
environment: | ||
GRUNTWORK_INSTALLER_VERSION: v0.0.23 | ||
TERRATEST_LOG_PARSER_VERSION: v0.13.13 | ||
HELM_VERSION: v3.1.2 | ||
MODULE_CI_VERSION: v0.18.4 | ||
TERRAFORM_VERSION: 0.12.20 | ||
GRUNTWORK_INSTALLER_VERSION: v0.0.30 | ||
TERRATEST_LOG_PARSER_VERSION: v0.30.4 | ||
MODULE_CI_VERSION: v0.29.1 | ||
TERRAFORM_VERSION: 0.13.5 | ||
TERRAGRUNT_VERSION: NONE | ||
PACKER_VERSION: NONE | ||
GOLANG_VERSION: 1.13.8 | ||
HELM_VERSION: v3.1.2 | ||
K8S_VERSION: v1.10.0 | ||
KUBECONFIG: /home/circleci/.kube/config | ||
|
||
install_gruntwork_utils: &install_gruntwork_utils | ||
name: install gruntwork utils | ||
command: | | ||
curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version "${GRUNTWORK_INSTALLER_VERSION}" | ||
gruntwork-install --module-name "gruntwork-module-circleci-helpers" --repo "https://github.com/gruntwork-io/module-ci" --tag "${MODULE_CI_VERSION}" | ||
gruntwork-install --binary-name "terratest_log_parser" --repo "https://github.com/gruntwork-io/terratest" --tag "${TERRATEST_LOG_PARSER_VERSION}" | ||
configure-environment-for-gruntwork-module \ | ||
--terraform-version ${TERRAFORM_VERSION} \ | ||
--terragrunt-version ${TERRAGRUNT_VERSION} \ | ||
--packer-version ${PACKER_VERSION} \ | ||
--go-version ${GOLANG_VERSION} \ | ||
--go-src-path ./test/ | ||
install_helm_client: &install_helm_client | ||
name: install helm client | ||
command: | | ||
# install helm client | ||
curl -Lo helm.tar.gz https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz | ||
tar -xvf helm.tar.gz | ||
chmod +x linux-amd64/helm | ||
sudo mv linux-amd64/helm /usr/local/bin/ | ||
version: 2 | ||
jobs: | ||
build: | ||
<<: *defaults | ||
precommit: | ||
<<: *env | ||
docker: | ||
- image: circleci/python:3.8.1 | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
keys: | ||
- gomod-{{ checksum "test/go.sum" }} | ||
|
||
# Install gruntwork utilities | ||
- run: | ||
<<: *install_gruntwork_utils | ||
|
||
- save_cache: | ||
key: gomod-{{ checksum "test/go.sum" }} | ||
paths: | ||
- $HOME/go/src/ | ||
|
||
name: install dependencies | ||
command: | | ||
curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version "${GRUNTWORK_INSTALLER_VERSION}" | ||
gruntwork-install --module-name "gruntwork-module-circleci-helpers" --repo "https://github.com/gruntwork-io/module-ci" --tag "${MODULE_CI_VERSION}" | ||
configure-environment-for-gruntwork-module \ | ||
--terraform-version ${TERRAFORM_VERSION} \ | ||
--terragrunt-version NONE \ | ||
--packer-version NONE \ | ||
--go-version ${GOLANG_VERSION} | ||
# Fail the build if the pre-commit hooks don't pass. Note: if you run pre-commit install locally, these hooks will | ||
# execute automatically every time before you commit, ensuring the build never fails at this step! | ||
- run: | ||
name: run pre-commit hooks | ||
command: | | ||
pyenv global 3.5.2 | ||
pip install pre-commit==1.21.0 cfgv==2.0.1 | ||
pip install pre-commit==1.21.0 cfgv==2.0.1 zipp==1.1.0 yapf | ||
pre-commit install | ||
pre-commit run --all-files | ||
- persist_to_workspace: | ||
root: /home/circleci | ||
paths: | ||
- project | ||
- terraform | ||
- packer | ||
|
||
test: | ||
<<: *defaults | ||
<<: *env | ||
steps: | ||
- attach_workspace: | ||
at: /home/circleci | ||
- checkout | ||
- run: echo 'export PATH=$HOME/terraform:$HOME/packer:$PATH' >> $BASH_ENV | ||
- run: | ||
<<: *install_gruntwork_utils | ||
- checkout | ||
- run: &install_gruntwork_tooling | ||
name: install gruntwork tooling | ||
command: | | ||
sudo apt-get -y update | ||
curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version "${GRUNTWORK_INSTALLER_VERSION}" | ||
gruntwork-install --module-name "gruntwork-module-circleci-helpers" --repo "https://github.com/gruntwork-io/module-ci" --tag "${MODULE_CI_VERSION}" | ||
gruntwork-install --module-name "git-helpers" --repo "https://github.com/gruntwork-io/module-ci" --tag "${MODULE_CI_VERSION}" | ||
gruntwork-install --binary-name "terratest_log_parser" --repo "https://github.com/gruntwork-io/terratest" --tag "${TERRATEST_LOG_PARSER_VERSION}" | ||
configure-environment-for-gruntwork-module --go-src-path ./test --terraform-version ${TERRAFORM_VERSION} --terragrunt-version ${TERRAGRUNT_VERSION} --packer-version ${PACKER_VERSION} --go-version ${GOLANG_VERSION} | ||
# Install helm | ||
- run: | ||
<<: *install_helm_client | ||
- run: | ||
name: install helm client | ||
command: | | ||
# install helm client | ||
curl -Lo helm.tar.gz https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz | ||
tar -xvf helm.tar.gz | ||
chmod +x linux-amd64/helm | ||
sudo mv linux-amd64/helm /usr/local/bin/ | ||
- run: | ||
name: update gcloud | ||
command: | | ||
sudo apt-get remove -y google-cloud-sdk | ||
sudo /opt/google-cloud-sdk/bin/gcloud --quiet components update | ||
sudo /opt/google-cloud-sdk/bin/gcloud --quiet components update beta kubectl | ||
- run: | ||
name: configure kubectl | ||
command: | | ||
mkdir -p ${HOME}/.kube | ||
touch ${HOME}/.kube/config | ||
- run: | ||
name: run tests | ||
command: | | ||
mkdir -p /tmp/logs | ||
# required for gcloud and kubectl to authenticate correctly | ||
echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=- | ||
gcloud --quiet config set project ${GOOGLE_PROJECT_ID} | ||
gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE} | ||
# required for terraform and terratest to authenticate correctly | ||
echo $GCLOUD_SERVICE_KEY > /tmp/gcloud.json | ||
export GOOGLE_APPLICATION_CREDENTIALS="/tmp/gcloud.json" | ||
# run the tests | ||
run-go-tests --path test --timeout 60m | tee /tmp/logs/all.log | ||
no_output_timeout: 3600s | ||
- run: | ||
command: terratest_log_parser --testlog /tmp/logs/all.log --outputdir /tmp/logs | ||
when: always | ||
- store_artifacts: | ||
path: /tmp/logs | ||
- store_test_results: | ||
path: /tmp/logs | ||
# Install external dependencies | ||
- run: | ||
name: update gcloud | ||
command: | | ||
sudo apt-get remove -y google-cloud-sdk | ||
sudo /opt/google-cloud-sdk/bin/gcloud --quiet components update | ||
sudo /opt/google-cloud-sdk/bin/gcloud --quiet components update beta kubectl | ||
- run: | ||
name: configure kubectl | ||
command: | | ||
mkdir -p ${HOME}/.kube | ||
touch ${HOME}/.kube/config | ||
- run: | ||
name: run tests | ||
command: | | ||
# required for gcloud and kubectl to authenticate correctly | ||
echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=- | ||
gcloud --quiet config set project ${GOOGLE_PROJECT_ID} | ||
gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE} | ||
# required for terraform and terratest to authenticate correctly | ||
echo $GCLOUD_SERVICE_KEY > /tmp/gcloud.json | ||
export GOOGLE_APPLICATION_CREDENTIALS="/tmp/gcloud.json" | ||
# run the tests | ||
mkdir -p /tmp/logs | ||
run-go-tests --path test --timeout 2h | tee /tmp/logs/all.log | ||
no_output_timeout: 1h | ||
|
||
- run: | ||
name: parse test output | ||
command: terratest_log_parser --testlog /tmp/logs/all.log --outputdir /tmp/logs | ||
when: always | ||
|
||
- store_artifacts: | ||
path: /tmp/logs | ||
- store_test_results: | ||
path: /tmp/logs | ||
|
||
workflows: | ||
version: 2 | ||
build-and-test: | ||
test: | ||
jobs: | ||
- build | ||
- test: | ||
requires: | ||
- build | ||
# We have to explicitly tell CircleCI to run on all tags and branches, or tag commits/pushes will not trigger | ||
# builds: https://circleci.com/docs/2.0/workflows/#git-tag-job-execution. | ||
- precommit: | ||
filters: | ||
branches: | ||
only: /.*/ | ||
tags: | ||
only: /.*/ | ||
- test: | ||
requires: | ||
- precommit | ||
filters: | ||
tags: | ||
only: /^v.*/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
repos: | ||
- repo: https://github.com/gruntwork-io/pre-commit | ||
sha: v0.0.2 | ||
rev: v0.1.10 | ||
hooks: | ||
- id: terraform-fmt | ||
- id: gofmt | ||
|
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
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
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
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
Oops, something went wrong.