19
19
steps :
20
20
- uses : cisagov/setup-env-github-action@develop
21
21
- uses : actions/checkout@v2
22
- - name : Set up Python
23
- uses : actions/setup-python@v2
22
+ - uses : actions/setup-python@v2
24
23
with :
25
24
python-version : 3.8
26
25
- uses : actions/setup-go@v2
@@ -30,31 +29,40 @@ jobs:
30
29
run : |
31
30
echo "::set-env name=PY_VERSION::"\
32
31
"$(python -c "import platform;print(platform.python_version())")"
32
+ - name : Store installed Go version
33
+ run : |
34
+ echo "::set-env name=GO_VERSION::"\
35
+ "$(go version | sed 's/^go version go\([0-9.]\+\) .*/\1/')"
36
+ - name : Lookup go cache directory
37
+ id : go-cache
38
+ run : |
39
+ echo "::set-output name=dir::$(go env GOCACHE)"
33
40
- name : Cache linting environments
34
41
uses : actions/cache@v2
35
42
with :
43
+ # Note that the .terraform directory IS NOT included in the
44
+ # cache because if we were caching, then we would need to use
45
+ # the `-upgrade=true` option. This option blindly pulls down the
46
+ # latest modules and providers instead of checking to see if an
47
+ # update is required. That behavior defeats the benefits of caching.
48
+ # so there is no point in doing it for the .terraform directory.
36
49
path : |
37
50
${{ env.PIP_CACHE_DIR }}
38
51
${{ env.PRE_COMMIT_CACHE_DIR }}
39
- key : " lint-${{ runner.os }}-py${{ env.PY_VERSION }}-\
52
+ ${{ env.CURL_CACHE_DIR }}
53
+ ${{ steps.go-cache.outputs.dir }}
54
+ key : " lint-${{ runner.os }}-\
55
+ py${{ env.PY_VERSION }}-\
56
+ go${{ env.GO_VERSION }}-\
57
+ tf${{ env.TERRAFORM_VERSION }}-\
40
58
${{ hashFiles('**/requirements-test.txt') }}-\
41
59
${{ hashFiles('**/.pre-commit-config.yaml') }}"
42
- <<<<<<< HEAD
43
- - name : Cache curl downloads
44
- uses : actions/cache@v1
45
- with :
46
- path : ${{ env.CURL_CACHE_DIR }}
47
- key : " ${{ runner.os }}-curl-\
48
- terraform-${{ env.TERRAFORM_VERSION }}"
49
- - name : Lookup go cache directory
50
- id : go-cache
51
- run : |
52
- echo "::set-output name=dir::$(go env GOCACHE)"
53
- - name : Cache go
54
- uses : actions/cache@v1
55
- with :
56
- path : ${{ steps.go-cache.outputs.dir }}
57
- key : " ${{ runner.os }}-go"
60
+ restore-keys : |
61
+ lint-${{ runner.os }}-\
62
+ py${{ env.PY_VERSION }}-\
63
+ go${{ env.GO_VERSION }}-\
64
+ tf${{ env.TERRAFORM_VERSION }}-
65
+ lint-${{ runner.os }}-
58
66
- name : Install Terraform
59
67
run : |
60
68
mkdir -p ${{ env.CURL_CACHE_DIR }}
@@ -66,19 +74,17 @@ jobs:
66
74
sudo unzip -d /opt/terraform \
67
75
${{ env.CURL_CACHE_DIR }}/"${TERRAFORM_ZIP}"
68
76
sudo ln -s /opt/terraform/terraform /usr/bin/terraform
77
+ sudo mv /usr/local/bin/terraform /usr/local/bin/terraform-default
78
+ sudo ln -s /opt/terraform/terraform /usr/local/bin/terraform
69
79
- name : Install Terraform-docs
70
80
run : GO111MODULE=on go get github.com/segmentio/terraform-docs
71
81
- name : Find and initialize Terraform directories
72
82
run : |
73
- for path in [[ $(find . -type f -iname "*.tf" -exec dirname "{}" \; \
74
- | sort -u) ]]; do \
75
- terraform init -upgrade=true -input=false -backend=false "$path"; \
83
+ for path in $(find . -not \( -type d -name ".terraform" -prune \) \
84
+ -type f -iname "*.tf" -exec dirname "{}" \; | sort -u); do \
85
+ echo "Initializing '$path'..."; \
86
+ terraform init -input=false -backend=false "$path"; \
76
87
done
77
- =======
78
- restore-keys : |
79
- lint-${{ runner.os }}-py${{ env.PY_VERSION }}-
80
- lint-${{ runner.os }}-
81
- >>>>>>> 05c10e6aff9ff1f827e3b4b10511f9b28fa05b71
82
88
- name : Install dependencies
83
89
run : |
84
90
python -m pip install --upgrade pip
0 commit comments