feat(ci): ensure docs are up-to-date on PRs (#767)

relates to STACKITTPR-153
This commit is contained in:
Ruben Hönle 2025-04-08 10:24:19 +02:00 committed by GitHub
parent c41d61cdc4
commit 37754e865d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 2 deletions

View file

@ -12,7 +12,7 @@ relates to #1234
- [ ] Issue was linked above
- [ ] Code format was applied: `make fmt`
- [ ] Examples were added / adjusted (see `examples/` directory)
- [ ] Docs are up-to-date: `make generate-docs`
- [x] Docs are up-to-date: `make generate-docs` (will be checked by CI)
- [ ] Unit tests got implemented or updated
- [ ] 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))
- [x] Unit tests are passing: `make test` (will be checked by CI)

View file

@ -12,13 +12,23 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
uses: ./.github/actions/build
with:
go-version: ${{ env.GO_VERSION }}
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
- name: "Ensure docs are up-to-date"
if: ${{ github.event_name == 'pull_request' }}
run: ./scripts/check-docs.sh
- name: Lint
run: make lint
- name: Test
run: make test

View file

@ -16,7 +16,7 @@ Observability scrape config data source schema. Must have a `region` specified i
data "stackit_observability_scrapeconfig" "example" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
job_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
name = "example"
}
```

21
scripts/check-docs.sh Executable file
View file

@ -0,0 +1,21 @@
#!/bin/bash
# This script is used to ensure for PRs the docs are up-to-date via the CI pipeline
# Usage: ./check-docs.sh
set -eo pipefail
ROOT_DIR=$(git rev-parse --show-toplevel)
before_hash=$(find docs -type f -exec sha256sum {} \; | sort | sha256sum | awk '{print $1}')
# re-generate the docs
$ROOT_DIR/scripts/tfplugindocs.sh
after_hash=$(find docs -type f -exec sha256sum {} \; | sort | sha256sum | awk '{print $1}')
if [[ "$before_hash" == "$after_hash" ]]; then
echo "Docs are up-to-date"
else
echo "Changes detected. Docs are *not* up-to-date."
exit 1
fi