diff --git a/.github/workflows/nightly-ecs-examples-validator.yml b/.github/workflows/nightly-ecs-examples-validator.yml index 3832fcfa..5a295664 100644 --- a/.github/workflows/nightly-ecs-examples-validator.yml +++ b/.github/workflows/nightly-ecs-examples-validator.yml @@ -1,61 +1,21 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + name: Nighly ECS example validator on: workflow_dispatch: jobs: get-go-version: - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./test/acceptance - outputs: - go-version: ${{ steps.get-go-version.outputs.go-version }} - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Determine Go version - id: get-go-version - run: | - echo "Building with Go $(cat .go-version)" - echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT" + uses: ./.github/workflows/reusable-get-go-version.yml go-fmt-and-lint-acceptance: - runs-on: ubuntu-latest needs: - - get-go-version - defaults: - run: - working-directory: ./test/acceptance - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Setup Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 - with: - go-version: ${{ needs.get-go-version.outputs.go-version }} - cache-dependency-path: ./test/acceptance/go.sum - - name: Go CI lint - uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 - with: - args: "--verbose --enable gofmt" - only-new-issues: false - skip-pkg-cache: true - skip-build-cache: true - working-directory: ./test/acceptance - - name: Lint Consul retry - run: | - go install github.com/hashicorp/lint-consul-retry@v1.3.0 - lint-consul-retry + - get-go-version + uses: ./.github/workflows/reusable-go-fmt-and-lint.yml + with: + go-version: ${{ needs.get-go-version.outputs.go-version }} terraform-fmt: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Setup Terraform - uses: hashicorp/setup-terraform@v3 - with: - terraform_version: 1.4.2 - - name: Validate - run: terraform fmt -check -recursive . + uses: ./.github/workflows/reusable-terraform-fmt.yml single-cluster: needs: - terraform-fmt diff --git a/.github/workflows/reusable-ecs-acceptance.yml b/.github/workflows/reusable-ecs-acceptance.yml index ee6dbe0d..1967a56b 100644 --- a/.github/workflows/reusable-ecs-acceptance.yml +++ b/.github/workflows/reusable-ecs-acceptance.yml @@ -1,3 +1,6 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + name: reusable-ecs-acceptance on: diff --git a/.github/workflows/reusable-ecs-example-validator.yml b/.github/workflows/reusable-ecs-example-validator.yml index 03b45833..cfebed7b 100644 --- a/.github/workflows/reusable-ecs-example-validator.yml +++ b/.github/workflows/reusable-ecs-example-validator.yml @@ -1,3 +1,6 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + name: reusable-ecs-example-validator on: diff --git a/.github/workflows/reusable-get-go-version.yml b/.github/workflows/reusable-get-go-version.yml new file mode 100644 index 00000000..8c9a7b6e --- /dev/null +++ b/.github/workflows/reusable-get-go-version.yml @@ -0,0 +1,28 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +name: get-go-version + +on: + workflow_call: + outputs: + go-version: + description: "The Go version detected by this workflow" + value: ${{ jobs.get-go-version.outputs.go-version }} + +jobs: + get-go-version: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./test/acceptance + outputs: + go-version: ${{ steps.get-go-version.outputs.go-version }} + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Determine Go version + id: get-go-version + run: | + echo "Building with Go $(cat .go-version)" + echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT" \ No newline at end of file diff --git a/.github/workflows/reusable-go-fmt-and-lint.yml b/.github/workflows/reusable-go-fmt-and-lint.yml new file mode 100644 index 00000000..2a7a1f11 --- /dev/null +++ b/.github/workflows/reusable-go-fmt-and-lint.yml @@ -0,0 +1,39 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +name: go-fmt-and-lint-acceptance + +on: + workflow_call: + inputs: + go-version: + description: "Golang version to be used by this workflow" + required: true + type: string + +jobs: + go-fmt-and-lint-acceptance: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./test/acceptance + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Setup Go + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + with: + go-version: ${{ inputs.go-version }} + cache-dependency-path: ./test/acceptance/go.sum + - name: Go CI lint + uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 + with: + args: "--verbose --enable gofmt" + only-new-issues: false + skip-pkg-cache: true + skip-build-cache: true + working-directory: ./test/acceptance + - name: Lint Consul retry + run: | + go install github.com/hashicorp/lint-consul-retry@v1.3.0 + lint-consul-retry \ No newline at end of file diff --git a/.github/workflows/reusable-terraform-fmt.yml b/.github/workflows/reusable-terraform-fmt.yml new file mode 100644 index 00000000..9cdfe674 --- /dev/null +++ b/.github/workflows/reusable-terraform-fmt.yml @@ -0,0 +1,20 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +name: terraform-fmt + +on: + workflow_call: + +jobs: + terraform-fmt: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Setup Terraform + uses: hashicorp/setup-terraform@v3 + with: + terraform_version: 1.4.2 + - name: Validate + run: terraform fmt -check -recursive . \ No newline at end of file diff --git a/.github/workflows/scenario-validator.yml b/.github/workflows/scenario-validator.yml new file mode 100644 index 00000000..55a3e4a1 --- /dev/null +++ b/.github/workflows/scenario-validator.yml @@ -0,0 +1,36 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +# Runs scenario tests for a given scenario +name: Scenario validator +on: + workflow_dispatch: + inputs: + scenario_name: + description: 'Name of the scenario to test' + required: true + +jobs: + get-go-version: + uses: ./.github/workflows/reusable-get-go-version.yml + + go-fmt-and-lint-acceptance: + needs: + - get-go-version + uses: ./.github/workflows/reusable-go-fmt-and-lint.yml + with: + go-version: ${{ needs.get-go-version.outputs.go-version }} + + terraform-fmt: + uses: ./.github/workflows/reusable-terraform-fmt.yml + validate-scenario: + needs: + - terraform-fmt + - go-fmt-and-lint-acceptance + - get-go-version + uses: ./.github/workflows/reusable-ecs-example-validator.yml + with: + name: 'Scenario validator' + scenario: ${{ inputs.scenario_name }} + go-version: ${{ needs.get-go-version.outputs.go-version }} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/terraform-ci.yml b/.github/workflows/terraform-ci.yml index 2025ed90..57363060 100644 --- a/.github/workflows/terraform-ci.yml +++ b/.github/workflows/terraform-ci.yml @@ -25,64 +25,17 @@ jobs: # we need to ignore the SC2086 rule to pass unescaped $VARS to the terraform commands args: -ignore SC2086 get-go-version: - runs-on: ubuntu-latest - needs: - - action-lint - defaults: - run: - working-directory: ./test/acceptance - outputs: - go-version: ${{ steps.get-go-version.outputs.go-version }} - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Determine Go version - id: get-go-version - # We use .go-version as our source of truth for current Go - # version, because "goenv" can react to it automatically. - run: | - echo "Building with Go $(cat .go-version)" - echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT" + uses: ./.github/workflows/reusable-get-go-version.yml go-fmt-and-lint-acceptance: - runs-on: ubuntu-latest needs: - - get-go-version - defaults: - run: - working-directory: ./test/acceptance - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Setup Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 - with: - go-version: ${{ needs.get-go-version.outputs.go-version }} - cache-dependency-path: ./test/acceptance/go.sum - - name: Go CI lint - uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 - with: - args: "--verbose --enable gofmt" - only-new-issues: false - skip-pkg-cache: true - skip-build-cache: true - working-directory: ./test/acceptance - - name: Lint Consul retry - run: | - go install github.com/hashicorp/lint-consul-retry@v1.3.0 - lint-consul-retry + - get-go-version + uses: ./.github/workflows/reusable-go-fmt-and-lint.yml + with: + go-version: ${{ needs.get-go-version.outputs.go-version }} terraform-fmt: - runs-on: ubuntu-latest needs: - - action-lint - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Setup Terraform - uses: hashicorp/setup-terraform@v3 - with: - terraform_version: 1.4.2 - - name: Validate - run: terraform fmt -check -recursive . + - action-lint + uses: ./.github/workflows/reusable-terraform-fmt.yml acceptance-fargate: needs: - get-go-version