Skip to content

Commit 37754e8

Browse files
authored
feat(ci): ensure docs are up-to-date on PRs (#767)
relates to STACKITTPR-153
1 parent c41d61c commit 37754e8

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ relates to #1234
1212
- [ ] Issue was linked above
1313
- [ ] Code format was applied: `make fmt`
1414
- [ ] Examples were added / adjusted (see `examples/` directory)
15-
- [ ] Docs are up-to-date: `make generate-docs`
15+
- [x] Docs are up-to-date: `make generate-docs` (will be checked by CI)
1616
- [ ] Unit tests got implemented or updated
1717
- [ ] Acceptance tests got implemented or updated (see e.g. [here](https://github.com/stackitcloud/terraform-provider-stackit/blob/f5f99d170996b208672ae684b6da53420e369563/stackit/internal/services/dns/dns_acc_test.go))
1818
- [x] Unit tests are passing: `make test` (will be checked by CI)

.github/workflows/ci.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,23 @@ jobs:
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v4
15+
1516
- name: Build
1617
uses: ./.github/actions/build
1718
with:
1819
go-version: ${{ env.GO_VERSION }}
20+
1921
- name: Setup Terraform
2022
uses: hashicorp/setup-terraform@v2
23+
with:
24+
terraform_wrapper: false
25+
26+
- name: "Ensure docs are up-to-date"
27+
if: ${{ github.event_name == 'pull_request' }}
28+
run: ./scripts/check-docs.sh
29+
2130
- name: Lint
2231
run: make lint
32+
2333
- name: Test
2434
run: make test

docs/data-sources/observability_scrapeconfig.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Observability scrape config data source schema. Must have a `region` specified i
1616
data "stackit_observability_scrapeconfig" "example" {
1717
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1818
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
19-
job_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
19+
name = "example"
2020
}
2121
```
2222

scripts/check-docs.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# This script is used to ensure for PRs the docs are up-to-date via the CI pipeline
4+
# Usage: ./check-docs.sh
5+
set -eo pipefail
6+
7+
ROOT_DIR=$(git rev-parse --show-toplevel)
8+
9+
before_hash=$(find docs -type f -exec sha256sum {} \; | sort | sha256sum | awk '{print $1}')
10+
11+
# re-generate the docs
12+
$ROOT_DIR/scripts/tfplugindocs.sh
13+
14+
after_hash=$(find docs -type f -exec sha256sum {} \; | sort | sha256sum | awk '{print $1}')
15+
16+
if [[ "$before_hash" == "$after_hash" ]]; then
17+
echo "Docs are up-to-date"
18+
else
19+
echo "Changes detected. Docs are *not* up-to-date."
20+
exit 1
21+
fi

0 commit comments

Comments
 (0)