Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix website tests #590

Merged
merged 3 commits into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
run: |
make test
make vet
make website-test
- uses: engineerd/setup-kind@v0.3.0
- name: Acceptance Tests
run: |
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/website.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: website
on:
push:
paths:
- "website/**"
pull_request:
branches:
- master

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: website-lint
run: |
make website-lint
29 changes: 29 additions & 0 deletions .markdownlinkcheck.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"ignorePatterns": [
{
"pattern": "^http(s)?:\/\/terraform.io/(.*)"
}
],
"replacementPatterns": [
{
"pattern": "^(/docs/(?!providers/helm/))",
"replacement": "https://terraform.io$1"
},
{
"pattern": "^(?!http(s)?://)(.*)\\.html(#.*)?$",
"replacement": "$2.html.markdown$3"
},
{
"pattern": "^/docs/providers/helm/",
"replacement": "file:///github/workspace/website/docs/"
},
{
"pattern": "^(getting-started).html.markdown(#.*)?$",
"replacement": "file:///github/workspace/website/docs/guides/$1.html.md$2"
},
{
"pattern": "^file:///github/workspace/website/docs/guides/(.*)\\.markdown(#.*)?$",
"replacement": "file:///github/workspace/website/docs/guides/$1.md$2"
}
]
}
17 changes: 17 additions & 0 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Configuration for markdownlint
# https://github.com/DavidAnson/markdownlint#configuration

default: true
MD007:
indent: 2

# Disabled Rules
# https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md

MD001: false
MD004: false
MD006: false
MD012: false
MD013: false
MD014: false
MD024: false
41 changes: 28 additions & 13 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,33 @@ packages:
clean:
@rm -rf $(BUILD_PATH)

website:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
# The docker command and run options may be overridden using env variables DOCKER and DOCKER_RUN_OPTS.
# Example:
# DOCKER="podman --cgroup-manager=cgroupfs" make website-lint
# DOCKER_RUN_OPTS="--userns=keep-id" make website-lint
# This option is needed for systems using SELinux and rootless containers.
# DOCKER_VOLUME_OPTS="rw,Z"
# For more info, see https://docs.docker.com/storage/bind-mounts/#configure-the-selinux-label
DOCKER?=$(shell which docker)
ifeq ($(strip $(DOCKER)),)
$(error "Docker binary could not be found in PATH. Please install docker, or specify an alternative by setting DOCKER=/path/to/binary")
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)

website-test:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
DOCKER_VOLUME_OPTS?="rw"
DOCKER_SELINUX := $(shell which setenforce)
ifeq ($(.SHELLSTATUS),0)
DOCKER_VOLUME_OPTS="rw,Z"
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)

.PHONY: build test testacc testrace cover vet fmt fmtcheck errcheck test-compile packages clean website website-test
# PROVIDER_DIR_DOCKER is used instead of PWD since docker volume commands can be dangerous to run in $HOME.
# This ensures docker volumes are mounted from within provider directory instead.
PROVIDER_DIR_DOCKER := $(abspath $(lastword $(dir $(MAKEFILE_LIST))))

website-lint:
@echo "==> Checking website against linters..."
@echo "==> Running markdownlint-cli using DOCKER='$(DOCKER)', DOCKER_RUN_OPTS='$(DOCKER_RUN_OPTS)' and DOCKER_VOLUME_OPTS='$(DOCKER_VOLUME_OPTS)'"
@$(DOCKER) run --rm $(DOCKER_RUN_OPTS) -v $(PROVIDER_DIR_DOCKER):/workspace:$(DOCKER_VOLUME_OPTS) -w /workspace 06kellyjac/markdownlint-cli ./website \
&& (echo; echo "PASS - website markdown files pass linting"; echo ) \
|| (echo; echo "FAIL - issues found in website markdown files"; echo ; exit 1)
@echo "==> Checking for broken links..."
@scripts/markdown-link-check.sh "$(DOCKER)" "$(DOCKER_RUN_OPTS)" "$(DOCKER_VOLUME_OPTS)" "$(PROVIDER_DIR_DOCKER)"

.PHONY: build test testacc testrace cover vet fmt fmtcheck errcheck test-compile packages clean website-lint
74 changes: 74 additions & 0 deletions scripts/markdown-link-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bash
# Local script runner for recursive markdown-link-check.
# Runs a dockerized version of this program: https://github.com/tcort/markdown-link-check
# Based on: https://github.com/gaurav-nelson/github-action-markdown-link-check/blob/master/entrypoint.sh
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
trap 'echo "ERROR at line ${LINENO}"' ERR

# Allow users to optionally specify additional docker options, path,
# or docker alternative (such as podman).
DOCKER=${1:-`command -v docker`}
DOCKER_RUN_OPTS=${2:-}
DOCKER_VOLUME_OPTS=${3:-}
PROVIDER_DIR=${4:-}

if [ -z "${PROVIDER_DIR}" ]; then
echo "Please specify the directory containing the helm provider"
exit 1
fi

echo "==> Checking Markdown links..."

error_file="markdown-link-check-errors.txt"
output_file="markdown-link-check-output.txt"

rm -f "./${error_file}" "./${output_file}"

${DOCKER} run ${DOCKER_RUN_OPTS} --rm -t \
-v ${PROVIDER_DIR}:/github/workspace:${DOCKER_VOLUME_OPTS} \
-w /github/workspace \
--entrypoint /usr/bin/find \
docker.io/robertbeal/markdown-link-checker \
website \( -type f -name "*.md" -or -name "*.markdown" \) -exec markdown-link-check --config .markdownlinkcheck.json --quiet --verbose {} \; \
| tee -a "${output_file}"

touch "${error_file}"
PREVIOUS_LINE=""
while IFS= read -r LINE; do
if [[ $LINE = *"FILE"* ]]; then
PREVIOUS_LINE=$LINE
if [[ $(tail -1 "${error_file}") != *FILE* ]]; then
echo -e "\n" >> "${error_file}"
echo "$LINE" >> "${error_file}"
fi
elif [[ $LINE = *"✖"* ]] && [[ $PREVIOUS_LINE = *"FILE"* ]]; then
echo "$LINE" >> "${error_file}"
else
PREVIOUS_LINE=""
fi
done < "${output_file}"

if grep -q "ERROR:" "${output_file}"; then
echo -e "==================> MARKDOWN LINK CHECK FAILED <=================="
if [[ $(tail -1 "${error_file}") = *FILE* ]]; then
sed '$d' "${error_file}"
else
cat "${error_file}"
fi
printf "\n"
echo -e "=================================================================="
exit 1
else
echo -e "==================> MARKDOWN LINK CHECK SUCCESS <=================="
printf "\n"
echo -e "[✔] All links are good!"
printf "\n"
echo -e "==================================================================="
fi

rm -f "./${error_file}" "./${output_file}"

exit 0
4 changes: 2 additions & 2 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ The `kubernetes` block supports:
* `cluster_ca_certificate` - (Optional) PEM-encoded root certificates bundle for TLS authentication. Can be sourced from `KUBE_CLUSTER_CA_CERT_DATA`.
* `config_context` - (Optional) Context to choose from the config file. Can be sourced from `KUBE_CTX`.
* `load_config_file` - (Optional) By default the local config (~/.kube/config) is loaded when you use this provider. This option at false disable this behaviour. Can be sourced from `KUBE_LOAD_CONFIG_FILE`.
* `exec` - (Optional) Configuration block to use an [exec-based credential plugin] (https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins), e.g. call an external command to receive user credentials.
* `exec` - (Optional) Configuration block to use an [exec-based credential plugin](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins), e.g. call an external command to receive user credentials.
* `api_version` - (Required) API version to use when decoding the ExecCredentials resource, e.g. `client.authentication.k8s.io/v1beta1`.
* `command` - (Required) Command to execute.
* `args` - (Optional) List of arguments to pass when executing the plugin.
* `env` - (Optional) Map of environment variables to set when executing the plugin.
* `env` - (Optional) Map of environment variables to set when executing the plugin.
6 changes: 3 additions & 3 deletions website/docs/r/release.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ A Chart is a Helm package. It contains all of the resource definitions necessary
```hcl
resource "helm_release" "example" {
name = "my-redis-release"
repository = "https://kubernetes-charts.storage.googleapis.com"
repository = "https://kubernetes-charts.storage.googleapis.com"
chart = "redis"
version = "6.0.1"

Expand Down Expand Up @@ -74,7 +74,7 @@ The following arguments are supported:
* `repository` - (Optional) Repository URL where to locate the requested chart.
* `repository_key_file` - (Optional) The repositories cert key file
* `repository_cert_file` - (Optional) The repositories cert file
* `repository_ca_file` - (Optional) The Repositories CA File.
* `repository_ca_file` - (Optional) The Repositories CA File.
* `repository_username` - (Optional) Username for HTTP basic authentication against the repository.
* `repository_password` - (Optional) Password for HTTP basic authentication against the repository.
* `devel` - (Optional) Use chart development versions, too. Equivalent to version '>0.0.0-0'. If version is set, this is ignored.
Expand Down Expand Up @@ -144,7 +144,7 @@ The `metadata` block supports:

A Helm Release resource can be imported using its namespace and name e.g.

```
```shell
$ terraform import helm_release.example default/example-name
```

Expand Down
22 changes: 17 additions & 5 deletions website/helm.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,33 @@
<% content_for :sidebar do %>
<div class="docs-sidebar hidden-print affix-top" role="complementary">
<ul class="nav docs-sidenav">
<li<%#= sidebar_current("docs-home") %>>

<li<%= sidebar_current("docs-home") %>>
<a href="/docs/providers/index.html">All Providers</a>
</li>

<li<%= sidebar_current("docs-helm-index") %>>
<a href="/docs/providers/helm/index.html">Helm Provider</a>
</li>

<li<%= sidebar_current("docs-helm-datasource") %>>
<a href="#">Data Sources</a>
<ul class="nav nav-visible">
<li<%= sidebar_current("docs-helm-resource") %>>
<a href="/docs/providers/helm/r/release.html">helm_release</a>
</li>
<li<%= sidebar_current("docs-helm-repository") %>>
<li<%= sidebar_current("docs-helm-datasource-repository") %>>
<a href="/docs/providers/helm/d/repository.html">helm_repository</a>
</li>
</ul>
</li>

<li<%= sidebar_current("docs-helm-resource") %>>
<a href="#">Resources</a>
<ul class="nav nav-visible">
<li<%= sidebar_current("docs-helm-resource-release") %>>
<a href="/docs/providers/helm/r/release.html">helm_release</a>
</li>
</ul>
</li>

</ul>
</div>
<% end %>
Expand Down