Skip to content

Commit 706f719

Browse files
committed
Add lint-custom check to CI with first check that ensures docs have a link to an upstream API
1 parent b152181 commit 706f719

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

.github/workflows/pr-lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
- lint-examples-tf
3333
- lint-examples-sh
3434
- lint-generated
35+
- lint-custom
3536
steps:
3637
- uses: actions/setup-go@v2
3738
with:

.github/workflows/push.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
- lint-examples-tf
4545
- lint-examples-sh
4646
- lint-generated
47+
- lint-custom
4748
steps:
4849
- uses: actions/setup-go@v2
4950
with:

GNUmakefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ lint-generated: generate ## Check that "make generate" was called. Note this onl
5151
exit 1; \
5252
}
5353

54+
lint-custom: ## Run custom checks and validations that do not fit into an existing lint framework.
55+
@./scripts/lint-custom.sh
56+
5457
apicovered: tool-apicovered ## Run an analysis tool to estimate the GitLab API coverage.
5558
@$(GOBIN)/apicovered ./gitlab
5659

scripts/lint-custom.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env sh
2+
3+
# This script is run during the CI workflow in order to run additional custom checks and validations
4+
# that do not fit into an existing lint framework.
5+
#
6+
# This script uses GitHub workflow commands in order to add contextual error messages:
7+
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message
8+
#
9+
# Usage:
10+
# ./scripts/lint-custom.sh
11+
12+
has_failure=''
13+
14+
pattern="^\*\*Upstream API\*\*: \[.*\](.*)$"
15+
files_without_match="$(grep --recursive --files-without-match "$pattern" ./docs/resources ./docs/data-sources)"
16+
test -z "$files_without_match" || {
17+
has_failure='true'
18+
echo "$files_without_match" | xargs -I{} echo "::error file={}::Generated documentation file {} should reference an upstream GitLab API. Expected file to match regex \"$pattern\"."
19+
}
20+
21+
# ^^^ Add new checks above this line ^^^
22+
23+
test -z "$has_failure"

0 commit comments

Comments
 (0)