Skip to content

Commit 66af934

Browse files
committed
chore: Refactor integration tests
Signed-off-by: Steve Hipwell <[email protected]>
1 parent a3b39ed commit 66af934

177 files changed

Lines changed: 7450 additions & 12557 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ jobs:
2424
defaults:
2525
run:
2626
shell: bash
27-
env:
28-
GITHUB_TEST_ORGANIZATION: kfcampbell-terraform-provider
2927
steps:
3028
- name: Checkout
3129
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0

.github/workflows/dotcom-acceptance-tests.yaml

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,30 @@ name: Acceptance Tests (github.com)
22

33
on:
44
workflow_dispatch:
5-
# push:
6-
# branches:
7-
# - main
8-
# - release-v*
9-
# pull_request_target:
10-
# types:
11-
# - opened
12-
# - synchronize
13-
# - reopened
14-
# - labeled
15-
# branches:
16-
# - main
17-
# - release-v*
5+
push:
6+
branches:
7+
- main
8+
- release-v*
9+
pull_request:
10+
types:
11+
- opened
12+
- synchronize
13+
- reopened
14+
- labeled
15+
branches:
16+
- main
17+
- release-v*
18+
19+
concurrency:
20+
group: acctest-dotcom-${{ github.ref }}
21+
cancel-in-progress: true
1822

1923
permissions: read-all
2024

2125
jobs:
2226
test:
2327
name: Test ${{ matrix.mode }}
28+
if: (github.event_name != 'pull_request' && github.event_name != 'pull_request_target') || contains(github.event.pull_request.labels.*.name, 'acctest')
2429
runs-on: ubuntu-latest
2530
permissions:
2631
contents: read
@@ -38,8 +43,9 @@ jobs:
3843
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
3944

4045
- name: Check secrets
46+
if: github.event_name == 'pull_request_target'
4147
env:
42-
INPUT_ALLOWED_SECRETS: ${{ vars.DOTCOM_ACCEPTANCE_TESTS_ALLOWED_SECRETS || 'DOTCOM_TEST_USER_TOKEN' }}
48+
INPUT_ALLOWED_SECRETS: ${{ vars.DOTCOM_ACCEPTANCE_TESTS_ALLOWED_SECRETS || 'GH_TEST_TOKEN' }}
4349
INPUT_SECRETS: ${{ toJSON(secrets) }}
4450
run: |
4551
set -eou pipefail
@@ -54,16 +60,16 @@ jobs:
5460
id: credentials
5561
if: matrix.mode != 'anonymous'
5662
env:
57-
TEST_USER_TOKEN: ${{ secrets.DOTCOM_TEST_USER_TOKEN }}
63+
GH_TEST_TOKEN: ${{ secrets.GH_TEST_TOKEN }}
5864
run: |
5965
set -eou pipefail
6066
61-
if [[ -z "${TEST_USER_TOKEN}" ]]; then
67+
if [[ -z "${GH_TEST_TOKEN}" ]]; then
6268
echo "::error::Missing credentials"
6369
exit 1
6470
fi
6571
66-
echo "token=${TEST_USER_TOKEN}" >> "${GITHUB_OUTPUT}"
72+
echo "token=${GH_TEST_TOKEN}" >> "${GITHUB_OUTPUT}"
6773
6874
- name: Set-up Go
6975
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
@@ -77,13 +83,28 @@ jobs:
7783
TF_LOG: INFO
7884
GITHUB_TOKEN: ${{ steps.credentials.outputs.token }}
7985
GITHUB_BASE_URL: https://api.github.com/
80-
GITHUB_TEST_TYPE: ${{ matrix.mode }}
81-
GITHUB_OWNER: ${{ (matrix.mode == 'individual' && 'github-terraform-test-user') || (matrix.mode == 'organization' && 'terraformtesting') || '' }}
82-
GITHUB_ORGANIZATION: ${{ (matrix.mode == 'organization' && 'terraformtesting') || '' }}
83-
GITHUB_TEST_ORGANIZATION: ${{ (matrix.mode == 'individual' && 'terraformtesting') || '' }}
84-
GITHUB_TEST_OWNER: ${{ (matrix.mode == 'organization' && 'github-terraform-test-user') || '' }}
85-
GITHUB_TEST_USER_TOKEN: ${{ steps.credentials.outputs.token }}
86-
run: go test -run "^TestAcc*" ./github -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 120m -count=1
86+
GITHUB_OWNER: ${{ (matrix.mode == 'individual' && vars.GH_TEST_LOGIN) || (matrix.mode == 'organization' && vars.GH_TEST_ORG_NAME) || '' }}
87+
GITHUB_USERNAME: ${{ vars.GH_TEST_LOGIN }}
88+
GITHUB_ENTERPRISE_SLUG: ${{ vars.GH_TEST_ENTERPRISE_SLUG }}
89+
GH_TEST_AUTH_MODE: ${{ matrix.mode }}
90+
GH_TEST_USER_REPOSITORY: ${{ vars.GH_TEST_USER_REPOSITORY }}
91+
GH_TEST_ORG_USER: ${{ vars.GH_TEST_ORG_USER }}
92+
GH_TEST_ORG_SECRET_NAME: ${{ vars.GH_TEST_ORG_SECRET_NAME }}
93+
GH_TEST_ORG_REPOSITORY: ${{ vars.GH_TEST_ORG_REPOSITORY }}
94+
GH_TEST_ORG_TEMPLATE_REPOSITORY: ${{ vars.GH_TEST_ORG_TEMPLATE_REPOSITORY }}
95+
GH_TEST_ORG_APP_INSTALLATION_ID: ${{ vars.GH_TEST_ORG_APP_INSTALLATION_ID }}
96+
GH_TEST_EXTERNAL_USER: ${{ vars.GH_TEST_EXTERNAL_USER }}
97+
GH_TEST_EXTERNAL_USER_TOKEN: ${{ secrets.GH_TEST_EXTERNAL_USER_TOKEN }}
98+
GH_TEST_EXTERNAL_USER2: ${{ vars.GH_TEST_EXTERNAL_USER2 }}
99+
GH_TEST_ADVANCED_SECURITY: ${{ vars.GH_TEST_ADVANCED_SECURITY || 'false' }}
100+
run: |
101+
set -eou pipefail
102+
103+
if [[ "${GH_TEST_AUTH_MODE}" != "anonymous" ]]; then
104+
go test ./github -v -sweep=all
105+
fi
106+
107+
go test -run "^TestAcc*" ./github -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 120m -count=1
87108
88109
check:
89110
name: Check DotCom Acceptance Tests

.github/workflows/ghes-acceptance-tests.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
# - main
1313
# - release-v*
1414

15+
concurrency:
16+
group: acctest-ghes-${{ github.ref }}
17+
cancel-in-progress: true
18+
1519
permissions: read-all
1620

1721
jobs:
@@ -30,6 +34,7 @@ jobs:
3034
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
3135

3236
- name: Check secrets
37+
if: github.event_name == 'pull_request_target'
3338
env:
3439
INPUT_ALLOWED_SECRETS: ${{ vars.GHES_ACCEPTANCE_TESTS_ALLOWED_SECRETS || 'GHES_TEST_USER_TOKEN' }}
3540
INPUT_SECRETS: ${{ toJSON(secrets) }}
@@ -91,11 +96,15 @@ jobs:
9196
TF_LOG: INFO
9297
GITHUB_TOKEN: ${{ steps.credentials.outputs.token }}
9398
GITHUB_BASE_URL: ${{ steps.server.outputs.address }}
94-
GITHUB_TEST_TYPE: enterprise
95-
GITHUB_OWNER: terraformtesting
96-
GITHUB_ORGANIZATION: terraformtesting
97-
GITHUB_TEST_USER_TOKEN: ${{ steps.credentials.outputs.token }}
98-
run: go test -run "^TestAcc*" ./github -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 120m -count=1
99+
GITHUB_OWNER: ""
100+
GITHUB_USERNAME: ""
101+
GITHUB_ENTERPRISE_SLUG: ""
102+
GH_TEST_AUTH_MODE: enterprise
103+
run: |
104+
set -eou pipefail
105+
106+
go test ./github -v -sweep=all
107+
go test -run "^TestAcc*" ./github -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 120m -count=1
99108
100109
check:
101110
name: Check GHES Acceptance Tests

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ terraform-provider-github
3636

3737
# do not commit secrets
3838
.env
39+
*_rsa
40+
*_rsa.pub

0 commit comments

Comments
 (0)