From 71e4c84f52f7a826f59397395a1e82b5ec43eb7c Mon Sep 17 00:00:00 2001 From: Charles Treatman Date: Thu, 11 Jul 2024 09:55:13 -0500 Subject: [PATCH] chore(ci): rename acctest workflow since it only applies to Metal --- .github/workflows/acctest.yml | 2 +- .github/workflows/metal_acctest.yml | 131 ++++++++++++++++++++++++++++ .github/workflows/test.yml | 2 +- 3 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/metal_acctest.yml diff --git a/.github/workflows/acctest.yml b/.github/workflows/acctest.yml index da949c7b3..d45c83bd2 100644 --- a/.github/workflows/acctest.yml +++ b/.github/workflows/acctest.yml @@ -110,7 +110,7 @@ jobs: METAL_AUTH_TOKEN: ${{ secrets.METAL_AUTH_TOKEN }} TF_ACC_METAL_DEDICATED_CONNECTION_ID: ${{ secrets.TF_ACC_METAL_DEDICATED_CONNECTION_ID }} run: | - go test ./... -v -coverprofile coverage.txt -covermode=atomic -count 1 -parallel 8 -run "(Metal)|(Provider)|(Migration)" -timeout 180m + go test ./... -v -coverprofile coverage.txt -covermode=atomic -count 1 -parallel 8 -run "(Provider)|(Migration)" -timeout 180m - name: Sweeper if: ${{ always() }} diff --git a/.github/workflows/metal_acctest.yml b/.github/workflows/metal_acctest.yml new file mode 100644 index 000000000..083f31661 --- /dev/null +++ b/.github/workflows/metal_acctest.yml @@ -0,0 +1,131 @@ +name: Metal Acceptance Tests +# This workflow determines whether a PR comes from an external fork +# (which requires approval from us) or from a branch on this repository +# (which means it was made by us and can run immediately). Once a PR +# is approved, the PR code gains access to secrets referenced in this +# workflow. + +# The 'build' job and subsequent jobs, are executed only when the pull +# request is not a draft, regardless of whether it is from an internal +# branch or external fork. + +# Any changes to this job, even from internal contributors, require heavy scrutiny. + +on: + pull_request_target: + types: [opened, synchronize, reopened, ready_for_review] + paths-ignore: + - 'LICENSE' + - '**.md' + - 'website/**' + - 'docs/**' + - '.github/ISSUE_TEMPLATE/**' + workflow_dispatch: + +permissions: + pull-requests: read + contents: read + +jobs: + + authorize: + if: (github.event_name == 'workflow_dispatch') || (github.event_name == 'pull_request_target' && github.event.pull_request.draft == false) + environment: + ${{ github.event_name == 'pull_request_target' && + github.event.pull_request.head.repo.full_name != github.repository && + 'external' || 'internal' }} + runs-on: ubuntu-latest + concurrency: + group: ${{ github.event_name == 'pull_request_target' && format('acctest-authorize-pr-{0}', github.event.pull_request.number) || 'acctest-authorize' }} + cancel-in-progress: true + steps: + - run: true + + build: + name: Build + needs: authorize + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.ref }} + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: './go.mod' + id: go + + - name: Get dependencies + run: | + go mod download + + - name: Build + run: | + go build -v . + + test: + name: Matrix Test + needs: build + concurrency: acctest + runs-on: ubuntu-latest + timeout-minutes: 240 + strategy: + fail-fast: false + matrix: + version: + - stable + terraform: + - '1.5' + steps: + + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.ref }} + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: './go.mod' + id: go + + - name: Get dependencies + run: | + go mod download + + - uses: hashicorp/setup-terraform@v3 + with: + terraform_version: ${{ matrix.terraform }} + terraform_wrapper: false + + - name: TF acceptance tests + timeout-minutes: 180 + env: + TF_ACC: "1" + EQUINIX_API_TOKEN: ${{ secrets.EQUINIX_API_TOKEN }} + METAL_AUTH_TOKEN: ${{ secrets.METAL_AUTH_TOKEN }} + TF_ACC_METAL_DEDICATED_CONNECTION_ID: ${{ secrets.TF_ACC_METAL_DEDICATED_CONNECTION_ID }} + run: | + go test ./... -v -coverprofile coverage.txt -covermode=atomic -count 1 -parallel 8 -run "(Metal)" -timeout 180m + + - name: Sweeper + if: ${{ always() }} + env: + EQUINIX_API_TOKEN: ${{ secrets.EQUINIX_API_TOKEN }} + METAL_AUTH_TOKEN: ${{ secrets.METAL_AUTH_TOKEN }} + SWEEP: "all" #Flag required to define the regions that the sweeper is to be ran in + SWEEP_ALLOW_FAILURES: "true" #Enable to allow Sweeper Tests to continue after failures + run: | + # Added sweep-run to filter Metal test + go test $(go list ./... | grep 'internal/sweep\|equinix/equinix') -v -timeout 180m -sweep=${SWEEP} -sweep-allow-failures=${SWEEP_ALLOW_FAILURES} -sweep-run=$(grep -or 'AddTestSweepers("[^"]*"' | grep "_metal_" |cut -d '"' -f2 | paste -s -d, -) + + - name: Upload coverage to Codecov + if: ${{ always() }} + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b8b81f53a..3e2f31578 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,7 +50,7 @@ jobs: run: go build -v . - name: TF tests - run: go test -v --coverprofile coverage.txt -covermode=atomic -parallel 4 $(go list ./... |grep -v 'tests') + run: go test -v --coverprofile coverage.txt -covermode=atomic -parallel 4 ./... - name: Upload coverage to Codecov if: ${{ always() }}