diff --git a/.github/workflows/check-version.yml b/.github/workflows/check-version.yml new file mode 100644 index 000000000000..ac3b063404de --- /dev/null +++ b/.github/workflows/check-version.yml @@ -0,0 +1,61 @@ +# This workflow is intended to run on PRs for preparing a new release. Those PRs may +# contain diffs for only the CHANGELOG and version/VERSION files, so we skip running +# the complete set of 'Quick Checks'. Instead we only run the tests present in the +# version package. This ensures that edits to the version/VERSION file are valid. +name: Check version package + +on: + workflow_dispatch: + pull_request: + types: + - opened + - ready_for_review + - reopened + - synchronize + paths: + - 'version/**' + push: + branches: + - '*' + tags: + - 'v[0-9]+.[0-9]+.[0-9]+*' + paths: + - 'version/**' + + +permissions: + contents: read + + +jobs: + check-version-package: + name: "Check version/VERSION value" + runs-on: ubuntu-latest + + steps: + - name: "Fetch source code" + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Determine Go version + id: go + uses: ./.github/actions/go-version + + - name: Install Go toolchain + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + with: + go-version: ${{ steps.go.outputs.version }} + + # NOTE: This cache is shared so the following step must always be + # identical across the unit-tests, e2e-tests, and consistency-checks + # jobs, or else weird things could happen. + - name: Cache Go modules + uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + with: + path: "~/go/pkg" + key: go-mod-${{ hashFiles('go.sum') }} + restore-keys: | + go-mod- + + - name: "Test version package" + run: | + go test -v github.com/hashicorp/terraform/version \ No newline at end of file