Skip to content

Commit 036e812

Browse files
authored
Merge pull request #1355 from hashicorp/sebasslash/enable-onprem-ci
Temporarily enable CI to test against enterprise instance
2 parents 5219dbf + 1a0b1eb commit 036e812

File tree

11 files changed

+140
-105
lines changed

11 files changed

+140
-105
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ runs:
77
using: composite
88
steps:
99
- name: Setup Go Environment
10-
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
10+
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
1111
with:
1212
go-version-file: "go.mod"
1313
cache: true
Lines changed: 63 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) HashiCorp, Inc.
22
# SPDX-License-Identifier: MPL-2.0
33

4-
name: TESTS ARE TEMPOARILY DISABLED
4+
name: Test
55
description: Tests terraform-provider-tfe within a matrix
66
inputs:
77
admin_configuration_token:
@@ -51,76 +51,72 @@ inputs:
5151
runs:
5252
using: composite
5353
steps:
54-
- name: NO-OP
54+
- name: Set up Go
55+
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
56+
with:
57+
go-version-file: go.mod
58+
cache: true
59+
60+
- name: Sync dependencies
5561
shell: bash
5662
run: |
57-
echo "Tests are skipped. Please test manually."
58-
# - name: Set up Go
59-
# uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
60-
# with:
61-
# go-version-file: go.mod
62-
# cache: true
63-
64-
# - name: Sync dependencies
65-
# shell: bash
66-
# run: |
67-
# go mod download
68-
# go mod tidy
63+
go mod download
64+
go mod tidy
6965
70-
# - name: Install gotestsum
71-
# shell: bash
72-
# run: go install gotest.tools/gotestsum@latest
66+
- name: Install gotestsum
67+
shell: bash
68+
run: go install gotest.tools/gotestsum@latest
7369

74-
# - name: Download artifact
75-
# id: download-artifact
76-
# uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615 # v2.27.0
77-
# with:
78-
# workflow_conclusion: success
79-
# name: junit-test-summary
80-
# if_no_artifact_found: warn
81-
# branch: main
70+
- name: Download artifact
71+
id: download-artifact
72+
uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615 # v2.27.0
73+
with:
74+
workflow_conclusion: success
75+
name: junit-test-summary
76+
if_no_artifact_found: warn
77+
branch: main
8278

83-
# - name: Split acceptance tests
84-
# id: test_split
85-
# uses: hashicorp-forge/go-test-split-action@796beedbdb3d1bea14cad2d3057bab5c5cf15fe5 # v1.0.2
86-
# with:
87-
# index: ${{ inputs.matrix_index }}
88-
# total: ${{ inputs.matrix_total }}
89-
# junit-summary: ./ci-summary-provider.xml
90-
# # When tests are split and run concurrently, lists_tests arg in ci.yml will skip the TestAccTFESAMLSettings_omnibus test suite
91-
# list: ${{ inputs.list_tests }}
79+
- name: Split acceptance tests
80+
id: test_split
81+
uses: hashicorp-forge/go-test-split-action@796beedbdb3d1bea14cad2d3057bab5c5cf15fe5 # v1.0.2
82+
with:
83+
index: ${{ inputs.matrix_index }}
84+
total: ${{ inputs.matrix_total }}
85+
junit-summary: ./ci-summary-provider.xml
86+
# When tests are split and run concurrently, lists_tests arg in ci.yml will skip the TestAccTFESAMLSettings_omnibus test suite
87+
list: ${{ inputs.list_tests }}
9288

93-
# - name: Run Tests
94-
# shell: bash
95-
# env:
96-
# TFE_HOSTNAME: "${{ inputs.hostname }}"
97-
# TFE_TOKEN: "${{ inputs.token }}"
98-
# TFE_ADMIN_CONFIGURATION_TOKEN: ${{ inputs.admin_configuration_token }}
99-
# TFE_ADMIN_PROVISION_LICENSES_TOKEN: ${{ inputs.admin_provision_licenses_token }}
100-
# TFE_ADMIN_SECURITY_MAINTENANCE_TOKEN: ${{ inputs.admin_security_maintenance_token }}
101-
# TFE_ADMIN_SITE_ADMIN_TOKEN: ${{ inputs.admin_site_admin_token }}
102-
# TFE_ADMIN_SUBSCRIPTION_TOKEN: ${{ inputs.admin_subscription_token }}
103-
# TFE_ADMIN_SUPPORT_TOKEN: ${{ inputs.admin_support_token }}
104-
# TFE_ADMIN_VERSION_MAINTENANCE_TOKEN: ${{ inputs.admin_version_maintenance_token }}
105-
# TFE_USER1: tfe-provider-user1
106-
# TFE_USER2: tfe-provider-user2
107-
# TF_ACC: "1"
108-
# ENABLE_TFE: "${{ inputs.enterprise }}"
109-
# RUN_TASKS_URL: "http://testing-mocks.tfe:22180/runtasks/pass"
110-
# GITHUB_POLICY_SET_IDENTIFIER: "hashicorp/test-policy-set"
111-
# GITHUB_REGISTRY_MODULE_IDENTIFIER: "hashicorp/terraform-random-module"
112-
# GITHUB_WORKSPACE_IDENTIFIER: "hashicorp/terraform-random-module"
113-
# GITHUB_WORKSPACE_BRANCH: "main"
114-
# GITHUB_TOKEN: "${{ inputs.testing-github-token }}"
115-
# MOD_PROVIDER: github.com/hashicorp/terraform-provider-tfe
116-
# MOD_TFE: github.com/hashicorp/terraform-provider-tfe/internal/provider
117-
# MOD_VERSION: github.com/hashicorp/terraform-provider-tfe/version
118-
# run: |
119-
# gotestsum --junitfile summary.xml --format short-verbose -- $MOD_PROVIDER $MOD_TFE $MOD_VERSION -v -timeout=30m -run "${{ steps.test_split.outputs.run }}"
89+
- name: Run Tests
90+
shell: bash
91+
env:
92+
TFE_HOSTNAME: "${{ inputs.hostname }}"
93+
TFE_TOKEN: "${{ inputs.token }}"
94+
TFE_ADMIN_CONFIGURATION_TOKEN: ${{ inputs.admin_configuration_token }}
95+
TFE_ADMIN_PROVISION_LICENSES_TOKEN: ${{ inputs.admin_provision_licenses_token }}
96+
TFE_ADMIN_SECURITY_MAINTENANCE_TOKEN: ${{ inputs.admin_security_maintenance_token }}
97+
TFE_ADMIN_SITE_ADMIN_TOKEN: ${{ inputs.admin_site_admin_token }}
98+
TFE_ADMIN_SUBSCRIPTION_TOKEN: ${{ inputs.admin_subscription_token }}
99+
TFE_ADMIN_SUPPORT_TOKEN: ${{ inputs.admin_support_token }}
100+
TFE_ADMIN_VERSION_MAINTENANCE_TOKEN: ${{ inputs.admin_version_maintenance_token }}
101+
TFE_USER1: tfe-provider-user1
102+
TFE_USER2: tfe-provider-user2
103+
TF_ACC: "1"
104+
ENABLE_TFE: "${{ inputs.enterprise }}"
105+
RUN_TASKS_URL: "http://testing-mocks.tfe:22180/runtasks/pass"
106+
GITHUB_POLICY_SET_IDENTIFIER: "hashicorp/test-policy-set"
107+
GITHUB_REGISTRY_MODULE_IDENTIFIER: "hashicorp/terraform-random-module"
108+
GITHUB_WORKSPACE_IDENTIFIER: "hashicorp/terraform-random-module"
109+
GITHUB_WORKSPACE_BRANCH: "main"
110+
GITHUB_TOKEN: "${{ inputs.testing-github-token }}"
111+
MOD_PROVIDER: github.com/hashicorp/terraform-provider-tfe
112+
MOD_TFE: github.com/hashicorp/terraform-provider-tfe/internal/provider
113+
MOD_VERSION: github.com/hashicorp/terraform-provider-tfe/version
114+
run: |
115+
gotestsum --junitfile summary.xml --format short-verbose -- $MOD_PROVIDER $MOD_TFE $MOD_VERSION -v -timeout=30m -run "${{ steps.test_split.outputs.run }}"
120116
121-
# - name: Upload test artifacts
122-
# uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
123-
# with:
124-
# name: junit-test-summary-${{ matrix.index }}
125-
# path: summary.xml
126-
# retention-days: 1
117+
- name: Upload test artifacts
118+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
119+
with:
120+
name: junit-test-summary-${{ matrix.index }}
121+
path: summary.xml
122+
retention-days: 1

.github/workflows/ci.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ concurrency:
99
cancel-in-progress: true
1010

1111
jobs:
12-
notice:
13-
name: TESTS ARE TEMPORARILY DISABLED- RUN CHANGED RESOURCE TESTS LOCALLY
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: NO-OP
17-
run: |
18-
echo "Tests are skipped. Please test manually."
1912
lint:
2013
name: lint
2114
runs-on: ubuntu-latest
@@ -31,8 +24,8 @@ jobs:
3124
fail-fast: false
3225
matrix:
3326
# If you adjust these parameters, also adjust the jrm input files on the "Merge reports" step below
34-
total: [ 1 ]
35-
index: [ 0 ]
27+
total: [ 5 ]
28+
index: [ 0, 1, 2, 3, 4 ]
3629
steps:
3730
- name: Fetch Outputs
3831
id: tflocal
@@ -80,7 +73,7 @@ jobs:
8073
run: npm install -g junit-report-merger
8174

8275
- name: Merge reports
83-
run: jrm ./ci-summary-provider.xml "junit-test-summary-0/*.xml"
76+
run: jrm ./ci-summary-provider.xml "junit-test-summary-0/*.xml" "junit-test-summary-1/*.xml" "junit-test-summary-2/*.xml" "junit-test-summary-3/*.xml" "junit-test-summary-4/*.xml"
8477

8578
- name: Upload test artifacts
8679
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3

.github/workflows/create-release-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
steps:
3636
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
3737
- name: Set up Go
38-
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
38+
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
3939
with:
4040
go-version-file: go.mod
4141
cache: true

.github/workflows/nightly-tfe-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
total: [ 1 ]
29-
index: [ 0 ]
28+
total: [ 5 ]
29+
index: [ 0, 1, 2, 3, 4 ]
3030
steps:
3131
- name: Fetch Outputs
3232
id: tflocal
@@ -99,7 +99,7 @@ jobs:
9999
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
100100

101101
- name: Set up Go
102-
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
102+
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
103103
with:
104104
go-version-file: go.mod
105105
check-latest: true

internal/provider/helper_test.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,18 @@ func skipUnlessBeta(t *testing.T) {
200200
}
201201
}
202202

203+
// Temporarily skip a test that may be experiencing API errors. This method
204+
// purposefully errors after the set date to remind contributors to remove this check
205+
// and verify that the API errors are no longer occurring.
206+
func skipUnlessAfterDate(t *testing.T, d time.Time) {
207+
today := time.Now()
208+
if today.After(d) {
209+
t.Fatalf("This test was temporarily skipped and has now expired. Remove this check to run this test.")
210+
} else {
211+
t.Skipf("Temporarily skipping test due to external issues: %s", t.Name())
212+
}
213+
}
214+
203215
func enterpriseEnabled() bool {
204216
return os.Getenv("ENABLE_TFE") == "1"
205217
}
@@ -255,9 +267,9 @@ func randomString(t *testing.T) string {
255267
return v
256268
}
257269

258-
type retryableFn func() (interface{}, error)
270+
type retryableFn func() (any, error)
259271

260-
func retryFn(maxRetries, secondsBetween int, f retryableFn) (interface{}, error) {
272+
func retryFn(maxRetries, secondsBetween int, f retryableFn) (any, error) {
261273
tick := time.NewTicker(time.Duration(secondsBetween) * time.Second)
262274
retries := 0
263275

internal/provider/provider_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ func TestConfigureEnvOrganization(t *testing.T) {
213213
// The TFE Provider tests use these environment variables, which are set in the
214214
// GitHub Action workflow file .github/workflows/ci.yml.
215215
func testAccGithubPreCheck(t *testing.T) {
216+
skipUnlessAfterDate(t, time.Date(2024, 5, 24, 0, 0, 0, 0, time.UTC))
217+
216218
if envGithubToken == "" {
217219
t.Skip("Please set GITHUB_TOKEN to run this test")
218220
}

internal/provider/resource_tfe_policy_set_test.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package provider
55

66
import (
7+
"context"
78
"fmt"
89
"os"
910
"regexp"
@@ -60,6 +61,19 @@ func TestAccTFEPolicySet_pinnedPolicyRuntimeVersion(t *testing.T) {
6061
sha := genSentinelSha(t, "secret", "data")
6162
version := genSafeRandomSentinelVersion()
6263

64+
adminClient := testAdminClient(t, versionMaintenanceAdmin)
65+
66+
opts := tfe.AdminSentinelVersionCreateOptions{
67+
Version: version,
68+
SHA: sha,
69+
URL: "https://hashicorp.com",
70+
}
71+
72+
tool, err := adminClient.Admin.SentinelVersions.Create(context.Background(), opts)
73+
if err != nil {
74+
t.Fatal(err)
75+
}
76+
6377
org, orgCleanup := createBusinessOrganization(t, tfeClient)
6478
t.Cleanup(orgCleanup)
6579

@@ -71,7 +85,7 @@ func TestAccTFEPolicySet_pinnedPolicyRuntimeVersion(t *testing.T) {
7185
CheckDestroy: testAccCheckTFEPolicySetDestroy,
7286
Steps: []resource.TestStep{
7387
{
74-
Config: testAccTFEPolicySet_pinnedPolicyRuntimeVersion(org.Name, version, sha),
88+
Config: testAccTFEPolicySet_pinnedPolicyRuntimeVersion(org.Name, tool.Version),
7589
Check: resource.ComposeTestCheckFunc(
7690
testAccCheckTFEPolicySetExists("tfe_policy_set.foobar", policySet),
7791
testAccCheckTFEPolicySetAttributes(policySet),
@@ -1034,14 +1048,8 @@ resource "tfe_policy_set" "foobar" {
10341048
}`, organization, organization)
10351049
}
10361050

1037-
func testAccTFEPolicySet_pinnedPolicyRuntimeVersion(organization string, version string, sha string) string {
1051+
func testAccTFEPolicySet_pinnedPolicyRuntimeVersion(organization string, version string) string {
10381052
return fmt.Sprintf(`
1039-
resource "tfe_sentinel_version" "foobar" {
1040-
version = "%s"
1041-
url = "https://www.hashicorp.com"
1042-
sha = "%s"
1043-
}
1044-
10451053
resource "tfe_sentinel_policy" "foo" {
10461054
name = "policy-foo"
10471055
policy = "main = rule { true }"
@@ -1055,7 +1063,7 @@ resource "tfe_policy_set" "foobar" {
10551063
agent_enabled = true
10561064
policy_tool_version = "%s"
10571065
policy_ids = [tfe_sentinel_policy.foo.id]
1058-
}`, version, sha, organization, organization, version)
1066+
}`, organization, organization, version)
10591067
}
10601068

10611069
func testAccTFEPolicySetOPA_basic(organization string, version string, sha string) string {

internal/provider/resource_tfe_registry_module_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,8 @@ func testAccCheckTFERegistryModuleDestroy(s *terraform.State) error {
942942
}
943943

944944
func testAccPreCheckTFERegistryModule(t *testing.T) {
945+
skipUnlessAfterDate(t, time.Date(2024, 5, 24, 0, 0, 0, 0, time.UTC))
946+
945947
if envGithubToken == "" {
946948
t.Skip("Please set GITHUB_TOKEN to run this test")
947949
}

internal/provider/resource_tfe_test_variable_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ func TestAccTFETestVariable_basic(t *testing.T) {
1919
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
2020

2121
resource.Test(t, resource.TestCase{
22-
PreCheck: func() { testAccPreCheck(t) },
22+
PreCheck: func() {
23+
testAccPreCheck(t)
24+
testAccGithubPreCheck(t)
25+
},
2326
ProtoV5ProviderFactories: testAccMuxedProviders,
2427
CheckDestroy: testAccCheckTFETestVariableDestroy,
2528
Steps: []resource.TestStep{
@@ -52,7 +55,10 @@ func TestAccTFETestVariable_update(t *testing.T) {
5255
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
5356

5457
resource.Test(t, resource.TestCase{
55-
PreCheck: func() { testAccPreCheck(t) },
58+
PreCheck: func() {
59+
testAccPreCheck(t)
60+
testAccGithubPreCheck(t)
61+
},
5662
ProtoV5ProviderFactories: testAccMuxedProviders,
5763
CheckDestroy: testAccCheckTFETestVariableDestroy,
5864
Steps: []resource.TestStep{
@@ -199,7 +205,7 @@ resource "tfe_organization" "foobar" {
199205
name = "tst-terraform-%d"
200206
201207
}
202-
208+
203209
resource "tfe_oauth_client" "foobar" {
204210
organization = tfe_organization.foobar.name
205211
api_url = "https://api.github.com"

0 commit comments

Comments
 (0)