-
Notifications
You must be signed in to change notification settings - Fork 21
/
config.yml
117 lines (107 loc) · 3.77 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
defaults: &defaults
machine: true
environment:
GRUNTWORK_INSTALLER_VERSION: v0.0.23
TERRATEST_LOG_PARSER_VERSION: v0.13.13
MODULE_CI_VERSION: v0.13.3
TERRAFORM_VERSION: 0.12.3
TERRAGRUNT_VERSION: NONE
PACKER_VERSION: 1.5.4
GOLANG_VERSION: 1.11.2
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 \
--circle-ci-2-machine-executor \
--terraform-version ${TERRAFORM_VERSION} \
--terragrunt-version ${TERRAGRUNT_VERSION} \
--packer-version ${PACKER_VERSION} \
--use-go-dep \
--go-version ${GOLANG_VERSION} \
--go-src-path test
version: 2
jobs:
build:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- dep-v1-{{ checksum "test/Gopkg.lock" }}
# Install gruntwork utilities
- run:
<<: *install_gruntwork_utils
- save_cache:
key: dep-v1-{{ checksum "test/Gopkg.lock" }}
paths:
- ./test/vendor
# 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: pip install pre-commit==1.11.2 cfgv==2.0.1
- run: pre-commit install
- run: pre-commit run --all-files
- persist_to_workspace:
root: /home/circleci
paths:
- project
- terraform
- packer
test:
<<: *defaults
steps:
- attach_workspace:
at: /home/circleci
- checkout
- run: echo 'export PATH=$HOME/terraform:$HOME/packer:$PATH' >> $BASH_ENV
- run:
<<: *install_gruntwork_utils
- 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: run tests
command: |
mkdir -p /tmp/logs
# required for gcloud 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
workflows:
version: 2
build-and-test:
jobs:
- build
- test:
requires:
- build
nightly:
triggers:
- schedule:
cron: "0 6 * * *"
filters:
branches:
only: master
jobs:
- build
- test:
requires:
- build