@@ -2,25 +2,30 @@ name: Acceptance Tests (github.com)
22
33on :
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
1923permissions : read-all
2024
2125jobs :
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
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,36 +60,70 @@ 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
7076 with :
7177 go-version-file : go.mod
7278 cache : true
7379
80+ - name : Setup Terraform
81+ uses : hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
82+ with :
83+ terraform_version : latest
84+ terraform_wrapper : false
85+
86+ - name : Terraform lookup
87+ id : tf
88+ run : |
89+ set -euo pipefail
90+
91+ {
92+ echo "version=$(terraform version -json | jq --raw-output '.terraform_version')"
93+ echo "path=$(command -v terraform || true)"
94+ } >> "${GITHUB_OUTPUT}"
95+
7496 - name : Run tests
7597 env :
98+ TF_ACC_PROVIDER_NAMESPACE : " "
99+ TF_ACC_TERRAFORM_VERSION : ${{ steps.tf.outputs.version }}
100+ TF_ACC_TERRAFORM_PATH : ${{ steps.tf.outputs.path }}
76101 TF_ACC : " 1"
77- TF_LOG : INFO
102+ TF_LOG : WARN
78103 GITHUB_TOKEN : ${{ steps.credentials.outputs.token }}
79104 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
105+ GITHUB_OWNER : ${{ (matrix.mode == 'individual' && vars.GH_TEST_LOGIN) || (matrix.mode == 'organization' && vars.GH_TEST_ORG_NAME) || '' }}
106+ GITHUB_USERNAME : ${{ vars.GH_TEST_LOGIN }}
107+ GITHUB_ENTERPRISE_SLUG : ${{ vars.GH_TEST_ENTERPRISE_SLUG }}
108+ GH_TEST_AUTH_MODE : ${{ matrix.mode }}
109+ GH_TEST_USER_REPOSITORY : ${{ vars.GH_TEST_USER_REPOSITORY }}
110+ GH_TEST_ORG_USER : ${{ vars.GH_TEST_ORG_USER }}
111+ GH_TEST_ORG_SECRET_NAME : ${{ vars.GH_TEST_ORG_SECRET_NAME }}
112+ GH_TEST_ORG_REPOSITORY : ${{ vars.GH_TEST_ORG_REPOSITORY }}
113+ GH_TEST_ORG_TEMPLATE_REPOSITORY : ${{ vars.GH_TEST_ORG_TEMPLATE_REPOSITORY }}
114+ GH_TEST_ORG_APP_INSTALLATION_ID : ${{ vars.GH_TEST_ORG_APP_INSTALLATION_ID }}
115+ GH_TEST_EXTERNAL_USER : ${{ vars.GH_TEST_EXTERNAL_USER }}
116+ GH_TEST_EXTERNAL_USER_TOKEN : ${{ secrets.GH_TEST_EXTERNAL_USER_TOKEN }}
117+ GH_TEST_EXTERNAL_USER2 : ${{ vars.GH_TEST_EXTERNAL_USER2 }}
118+ GH_TEST_ADVANCED_SECURITY : ${{ vars.GH_TEST_ADVANCED_SECURITY || 'false' }}
119+ run : |
120+ set -eou pipefail
121+
122+ if [[ "${GH_TEST_AUTH_MODE}" != "anonymous" ]]; then
123+ go test ./github -v -sweep=all
124+ fi
125+
126+ go test -run "^TestAcc*" ./github -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 120m -count=1
87127
88128 check :
89129 name : Check DotCom Acceptance Tests
0 commit comments