From 272f8f17239b81eeccb39151f31af78b4ef751a6 Mon Sep 17 00:00:00 2001 From: haruska <2803+haruska@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:38:35 -0500 Subject: [PATCH] require approval for acceptance tests on external PRs --- .github/workflows/acceptance_test.yml | 46 ++++++++++++++++++++++++ .github/workflows/test.yml | 52 +++++---------------------- 2 files changed, 54 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/acceptance_test.yml diff --git a/.github/workflows/acceptance_test.yml b/.github/workflows/acceptance_test.yml new file mode 100644 index 0000000..50d6db5 --- /dev/null +++ b/.github/workflows/acceptance_test.yml @@ -0,0 +1,46 @@ +name: Acceptance Testing + +on: pull_request_target + +jobs: + authorize: + environment: + ${{ github.event_name == 'pull_request_target' && + github.event.pull_request.head.repo.full_name != github.repository && + 'external' || 'internal' }} + runs-on: ubuntu-latest + steps: + - run: true + test: + name: Terraform Provider Acceptance Tests + needs: authorize + runs-on: ubuntu-latest + timeout-minutes: 15 + strategy: + fail-fast: false + matrix: + # list whatever Terraform versions here you would like to support + terraform: + - '1.0.*' + - '1.1.*' + - '1.2.*' + - '1.3.*' + - '1.4.*' + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha || github.ref }} + - uses: actions/setup-go@v4 + with: + go-version-file: 'go.mod' + cache: true + - uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3 + with: + terraform_version: ${{ matrix.terraform }} + terraform_wrapper: false + - run: go mod download + - env: + PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} + TF_ACC: "1" + run: go test -race -covermode=atomic -coverprofile=coverage.out -v ./pinecone/provider/ + timeout-minutes: 10 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7461663..53587d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,5 @@ -# Terraform Provider testing workflow. -name: Tests +name: Unit Testing -# This GitHub action runs your tests for each pull request and push. -# Optionally, you can turn it on using a schedule for regular testing. on: pull_request: branches: @@ -15,31 +12,31 @@ on: paths-ignore: - 'README.md' -# Testing only needs permissions to read the repository contents. permissions: contents: read jobs: - # Ensure project builds before running testing matrix build: - name: Build runs-on: ubuntu-latest - timeout-minutes: 5 steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v4 with: go-version-file: 'go.mod' cache: true - run: go mod download - run: go build -v . - name: Run linters - uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 + uses: golangci/golangci-lint-action@v3 with: version: latest + - name: Run tests + run: go test ./pinecone/... generate: runs-on: ubuntu-latest + needs: build steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 @@ -51,36 +48,3 @@ jobs: run: | git diff --compact-summary --exit-code || \ (echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1) - - # Run acceptance tests in a matrix with Terraform CLI versions - test: - name: Terraform Provider Acceptance Tests - needs: build - runs-on: ubuntu-latest - timeout-minutes: 15 - strategy: - fail-fast: false - matrix: - # list whatever Terraform versions here you would like to support - terraform: - - '1.0.*' - - '1.1.*' - - '1.2.*' - - '1.3.*' - - '1.4.*' - steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 - with: - go-version-file: 'go.mod' - cache: true - - uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3 - with: - terraform_version: ${{ matrix.terraform }} - terraform_wrapper: false - - run: go mod download - - env: - PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} - TF_ACC: "1" - run: go test -race -covermode=atomic -coverprofile=coverage.out -v ./pinecone/provider/ - timeout-minutes: 10