Skip to content

Commit 352212f

Browse files
committed
WIP
1 parent 03ff1cb commit 352212f

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

.github/actions/test-provider-tfe/action.yml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ inputs:
3737
token:
3838
description: HCP Terraform or Terraform Enterprise token
3939
required: true
40-
testing-github-token:
40+
testing_github_token:
4141
description: The GitHub token used for testing scenarios
4242
required: false
4343
enterprise:
@@ -51,6 +51,9 @@ inputs:
5151
description: The mock run tasks URL to use for testing.
5252
required: false
5353
default: "http://testing-mocks.tfe:22180/runtasks/pass"
54+
test_name:
55+
description: Name identifier for the test suite being run
56+
required: true
5457

5558
runs:
5659
using: composite
@@ -82,18 +85,31 @@ runs:
8285

8386
- name: Split acceptance tests
8487
id: test_split
88+
if: inputs.test_name == 'tests'
8589
uses: hashicorp-forge/go-test-split-action@796beedbdb3d1bea14cad2d3057bab5c5cf15fe5 # v1.0.2
8690
with:
8791
index: ${{ inputs.matrix_index }}
8892
total: ${{ inputs.matrix_total }}
8993
junit-summary: ./ci-summary-provider.xml
9094
list: ${{ inputs.list_tests }}
9195

96+
- name: Fallback test selection
97+
id: test_fallback
98+
shell: bash
99+
run: |
100+
if [ "${{ steps.test_split.outcome }}" = "failure" ] || [ -z "${{ steps.test_split.outputs.run }}" ]; then
101+
echo "Junit splitting failed or no output, using regex fallback"
102+
echo "run=${{ inputs.list_tests }}" >> $GITHUB_OUTPUT
103+
else
104+
echo "Using junit split output"
105+
echo "run=${{ steps.test_split.outputs.run }}" >> $GITHUB_OUTPUT
106+
fi
107+
92108
- name: Run Tests
93109
shell: bash
94110
env:
95-
TFE_HOSTNAME: "${{ inputs.hostname }}"
96-
TFE_TOKEN: "${{ inputs.token }}"
111+
TFE_HOSTNAME: ${{ inputs.hostname }}
112+
TFE_TOKEN: ${{ inputs.token }}
97113
TFE_ADMIN_CONFIGURATION_TOKEN: ${{ inputs.admin_configuration_token }}
98114
TFE_ADMIN_PROVISION_LICENSES_TOKEN: ${{ inputs.admin_provision_licenses_token }}
99115
TFE_ADMIN_SECURITY_MAINTENANCE_TOKEN: ${{ inputs.admin_security_maintenance_token }}
@@ -104,22 +120,27 @@ runs:
104120
TFE_USER1: tfe-provider-user1
105121
TFE_USER2: tfe-provider-user2
106122
TF_ACC: "1"
107-
ENABLE_TFE: "${{ inputs.enterprise }}"
108-
RUN_TASKS_URL: "${{ inputs.run_tasks_url }}"
123+
ENABLE_TFE: ${{ inputs.enterprise }}
124+
RUN_TASKS_URL: ${{ inputs.run_tasks_url }}
109125
GITHUB_POLICY_SET_IDENTIFIER: "hashicorp/test-policy-set"
110126
GITHUB_REGISTRY_MODULE_IDENTIFIER: "hashicorp/terraform-random-module"
111127
GITHUB_WORKSPACE_IDENTIFIER: "hashicorp/terraform-random-module"
112128
GITHUB_WORKSPACE_BRANCH: "main"
113-
GITHUB_TOKEN: "${{ inputs.testing-github-token }}"
129+
GITHUB_TOKEN: ${{ inputs.testing_github_token }}
114130
MOD_PROVIDER: github.com/hashicorp/terraform-provider-tfe
115131
MOD_TFE: github.com/hashicorp/terraform-provider-tfe/internal/provider
116132
MOD_VERSION: github.com/hashicorp/terraform-provider-tfe/version
117133
run: |
118-
gotestsum --junitfile summary.xml --format short-verbose -- $MOD_PROVIDER $MOD_TFE $MOD_VERSION -v -timeout=60m -run "${{ steps.test_split.outputs.run }}"
134+
if [ "${{ inputs.test_name }}" = "tests" ] && [ -n "${{ steps.test_split.outputs.run }}" ]; then
135+
TEST_PATTERN="${{ steps.test_split.outputs.run }}"
136+
else
137+
TEST_PATTERN="${{ inputs.list_tests }}"
138+
fi
139+
gotestsum --junitfile summary.xml --format short-verbose -- $MOD_PROVIDER $MOD_TFE $MOD_VERSION -v -timeout=60m -run "$TEST_PATTERN"
119140
120141
- name: Upload test artifacts
121142
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
122143
with:
123-
name: junit-test-summary-${{ matrix.index }}
144+
name: junit-${{ inputs.test_name }}-summary-${{ inputs.matrix_index }}
124145
path: summary.xml
125146
retention-days: 1

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,33 @@ jobs:
6262
include:
6363
# Standard tests with 5-runner matrix
6464
- test_suite: "Standard Tests"
65+
test_name: "tests"
6566
list_tests: "[^(TestAccTFESAMLSettings_omnibus|TestAcc.*_RunDependent)]"
6667
total: 5
6768
index: 0
6869
- test_suite: "Standard Tests"
70+
test_name: "tests"
6971
list_tests: "[^(TestAccTFESAMLSettings_omnibus|TestAcc.*_RunDependent)]"
7072
total: 5
7173
index: 1
7274
- test_suite: "Standard Tests"
75+
test_name: "tests"
7376
list_tests: "[^(TestAccTFESAMLSettings_omnibus|TestAcc.*_RunDependent)]"
7477
total: 5
7578
index: 2
7679
- test_suite: "Standard Tests"
80+
test_name: "tests"
7781
list_tests: "[^(TestAccTFESAMLSettings_omnibus|TestAcc.*_RunDependent)]"
7882
total: 5
7983
index: 3
8084
- test_suite: "Standard Tests"
85+
test_name: "tests"
8186
list_tests: "[^(TestAccTFESAMLSettings_omnibus|TestAcc.*_RunDependent)]"
8287
total: 5
8388
index: 4
8489
# Dependent tests with 1-runner matrix
8590
- test_suite: "Dependent Tests"
91+
test_name: "run-dependent-tests"
8692
list_tests: "TestAcc.*_RunDependent"
8793
total: 1
8894
index: 0
@@ -95,7 +101,7 @@ jobs:
95101
matrix_total: ${{ matrix.total }}
96102
hostname: ${{ needs.setup.outputs.hostname }}
97103
token: ${{ needs.setup.outputs.token }}
98-
testing-github-token: ${{ secrets.TESTING_GITHUB_TOKEN }}
104+
testing_github_token: ${{ secrets.TESTING_GITHUB_TOKEN }}
99105
admin_configuration_token: ${{ needs.setup.outputs.admin_configuration_token }}
100106
admin_provision_licenses_token: ${{ needs.setup.outputs.admin_provision_licenses_token }}
101107
admin_security_maintenance_token: ${{ needs.setup.outputs.admin_security_maintenance_token }}
@@ -104,6 +110,7 @@ jobs:
104110
admin_support_token: ${{ needs.setup.outputs.admin_support_token }}
105111
admin_version_maintenance_token: ${{ needs.setup.outputs.admin_version_maintenance_token }}
106112
list_tests: ${{ matrix.list_tests }}
113+
test_name: ${{ matrix.test_name }}
107114

108115
tests-combine-summaries:
109116
name: Combine Test Reports

0 commit comments

Comments
 (0)