diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 088dfb4c4..b01df3feb 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -12,7 +12,7 @@ relates to #1234 - [ ] Issue was linked above - [ ] Code format was applied: `make fmt` - [ ] Examples were added / adjusted (see e.g. [here](https://github.com/stackitcloud/stackit-cli/blob/ef291d1683ca5b0d719ec0a26ecb999a32685117/internal/cmd/ske/cluster/create/create.go#L49-L63)) -- [ ] 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 - [x] Unit tests are passing: `make test` (will be checked by CI) - [x] No linter issues: `make lint` (will be checked by CI) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 329ec530c..d069884e7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,11 +12,18 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Build uses: ./.github/actions/build with: go-version: ${{ env.GO_VERSION }} + + - 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 diff --git a/scripts/check-docs.sh b/scripts/check-docs.sh new file mode 100755 index 000000000..d81181db9 --- /dev/null +++ b/scripts/check-docs.sh @@ -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 +go run $ROOT_DIR/scripts/generate.go + +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