forked from hashicorp/terraform-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 1
155 lines (151 loc) · 6.17 KB
/
website.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
## These checks will be superseded by documentation.yml
## when the provider documentation layout is moved to
## the Terraform Registry layout.
name: Website Checks
on:
push:
branches:
- master
- 'release/**'
pull_request:
paths:
- .github/workflows/website.yml
- .go-version
- .markdownlinkcheck.json
- .markdownlint.yml
- website/docs/**
- tools/go.mod
env:
GO111MODULE: on
jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gaurav-nelson/github-action-markdown-link-check@v1
name: markdown-link-check website/docs/**/*.markdown
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
config-file: '.markdownlinkcheck.json'
folder-path: 'website/docs'
file-extension: '.markdown'
- uses: gaurav-nelson/github-action-markdown-link-check@v1
name: markdown-link-check website/docs/**/*.md
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
config-file: '.markdownlinkcheck.json'
folder-path: 'website/docs'
file-extension: '.md'
markdown-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: avto-dev/markdown-lint@v1
with:
config: '.markdownlint.yml'
args: 'website/docs'
misspell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# See also: https://github.com/actions/setup-go/pull/62
- run: echo "GO_VERSION=$(cat .go-version)" >> $GITHUB_ENV
- uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@v2
continue-on-error: true
timeout-minutes: 2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }}
- run: cd tools && go install github.com/client9/misspell/cmd/misspell
- run: misspell -error -source text website/
terrafmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# See also: https://github.com/actions/setup-go/pull/62
- run: echo "GO_VERSION=$(cat .go-version)" >> $GITHUB_ENV
- uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@v2
continue-on-error: true
timeout-minutes: 2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }}
- run: cd tools && go install github.com/katbyte/terrafmt
- run: terrafmt diff ./website --check --pattern '*.markdown'
validate-terraform:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# See also: https://github.com/actions/setup-go/pull/62
- run: echo "GO_VERSION=$(cat .go-version)" >> $GITHUB_ENV
- uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@v2
continue-on-error: true
timeout-minutes: 2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }}
- run: cd tools && go install github.com/katbyte/terrafmt
- run: cd tools && go install github.com/terraform-linters/tflint
- run: |
exit_code=0
# Configure the rules for tflint.
# The *_invalid_* rules disabled here prevent evaluation of expressions.
# Do not disable *_invalid_name rules, since these are good checks for e.g. "%s" formatting verbs
# being carried over from test cases.
shared_rules=(
"--enable-rule=terraform_comment_syntax"
"--disable-rule=aws_cloudwatch_event_target_invalid_arn"
"--disable-rule=aws_cognito_user_pool_domain_invalid_domain"
"--disable-rule=aws_db_instance_default_parameter_group"
"--disable-rule=aws_elasticache_cluster_default_parameter_group"
"--disable-rule=aws_iam_saml_provider_invalid_saml_metadata_document"
"--disable-rule=aws_iam_server_certificate_invalid_certificate_body"
"--disable-rule=aws_iam_server_certificate_invalid_private_key"
"--disable-rule=aws_lb_invalid_load_balancer_type"
"--disable-rule=aws_lb_target_group_invalid_protocol"
"--disable-rule=aws_transfer_ssh_key_invalid_body"
"--disable-rule=aws_worklink_website_certificate_authority_association_invalid_certificate"
)
while read -r filename; do
rules=("${shared_rules[@]}")
if [[ "$filename" == "./website/docs/guides/version-2-upgrade.html.md" ]]; then
# ./website/docs/guides/version-2-upgrade.html.md should still include pre-0.12 syntax,
# since v1.0 does not support Terraform 0.12.
rules+=(
"--disable-rule=terraform_deprecated_interpolation"
"--disable-rule=terraform_deprecated_index"
)
elif [[ "$filename" == "./website/docs/guides/version-3-upgrade.html.md" ]]; then
# ./website/docs/guides/version-3-upgrade.html.md has one example showing migration from
# pre-0.12 syntax to 0.12 syntax. We can't customize rules per block, and adding a
# tflint-ignore directive to documentation is not ideal.
rules+=(
"--disable-rule=terraform_deprecated_interpolation"
"--enable-rule=terraform_deprecated_index"
)
else
rules+=(
"--enable-rule=terraform_deprecated_interpolation"
"--enable-rule=terraform_deprecated_index"
)
fi
# echo "Let's go with $filename..."
# We need to capture the output and error code here. We don't want to exit on the first error
set +e
./scripts/validate-terraform-file.sh "$filename" "${rules[@]}"
lint_exitcode=$?
set -e
if [ $lint_exitcode -ne 0 ]; then exit_code=1; fi
done < <(find ./website/docs -type f \( -name '*.md' -o -name '*.markdown' \) | sort -u)
exit $exit_code