Skip to content

Commit 4c9ac44

Browse files
authored
Merge branch 'main' into feat/enterprise-ip-allow-list
2 parents 2511b0b + 5a83a3d commit 4c9ac44

564 files changed

Lines changed: 30633 additions & 48130 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.

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# https://git-scm.com/docs/gitattributes
2+
# https://docs.github.com/en/repositories/working-with-files/managing-files/customizing-how-changed-files-appear-on-github
3+
4+
# Ignore vendor directory in language statistics
5+
vendor/** linguist-generated=true

.github/workflows/codeql.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
cache: true
5050

5151
- name: Initialize CodeQL
52-
uses: github/codeql-action/init@6bc82e05fd0ea64601dd4b465378bbcf57de0314 # v4.32.1
52+
uses: github/codeql-action/init@9e907b5e64f6b83e7804b09294d44122997950d6 # v4.32.3
5353
with:
5454
languages: ${{ matrix.language }}
5555
build-mode: ${{ matrix.build-mode }}
@@ -60,6 +60,6 @@ jobs:
6060
run: go build ./...
6161

6262
- name: Perform CodeQL Analysis
63-
uses: github/codeql-action/analyze@6bc82e05fd0ea64601dd4b465378bbcf57de0314 # v4.32.1
63+
uses: github/codeql-action/analyze@9e907b5e64f6b83e7804b09294d44122997950d6 # v4.32.3
6464
with:
6565
category: "/language:${{matrix.language}}"

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
cache: true
4242

4343
- name: Install Syft
44-
uses: anchore/sbom-action/download-syft@deef08a0db64bfad603422135db61477b16cef56 # v0.22.1
44+
uses: anchore/sbom-action/download-syft@28d71544de8eaf1b958d335707167c5f783590ad # v0.22.2
4545

4646
- name: Install Cosign
4747
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0

CONTRIBUTING.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ This section describes a typical sequence performed when developing locally. Ful
3333
Once you have the repository cloned, there's a couple of additional steps you'll need to take. Since most of the testing is acceptance or integration testing, we need to manipulate real GitHub resources in order to run it. Useful setup steps are listed below:
3434

3535
- If you haven't already, [create a GitHub organization you can use for testing](#github-organization).
36-
- Optional: you may find it beneficial to create a test user as well in order to avoid potential rate-limiting issues on your main account.
37-
- Your organization _must_ have a repository called `terraform-template-module`. The [terraformtesting/terraform-template-module](https://github.com/terraformtesting/terraform-template-module) repo is a good, re-usable example.
38-
- You _must_ make sure that the "Template Repository" item in Settings is checked for this repo.
36+
- Optional: you may find it beneficial to create a test user as well in order to avoid potential rate-limiting issues on your main account.
37+
- Your organization _must_ have a repository called `terraform-template-module`. The [terraformtesting/terraform-template-module](https://github.com/terraformtesting/terraform-template-module) repo is a good, re-usable example.
38+
- You _must_ make sure that the "Template Repository" item in Settings is checked for this repo.
3939
- If you haven't already, generate a Personal Access Token (PAT) for authenticating your test runs.
4040
- Export the necessary configuration for authenticating your provider with GitHub
4141

@@ -52,7 +52,7 @@ Once you have the repository cloned, there's a couple of additional steps you'll
5252
### Local Development Iteration
5353

5454
1. Write a test describing what you will fix. See [`github_label`](./github/resource_github_issue_label_test.go) for an example format.
55-
1. Run your test and observe it fail. Enabling debug output allows for observing the underlying requests and responses made as well as viewing state (search `STATE:`) generated during the acceptance test run.
55+
2. Run your test and observe it fail. Enabling debug output allows for observing the underlying requests and responses made as well as viewing state (search `STATE:`) generated during the acceptance test run.
5656

5757
```sh
5858
TF_LOG=DEBUG TF_ACC=1 go test -v ./... -run ^TestAccGithubIssueLabel
@@ -182,6 +182,9 @@ export GH_TEST_ENTERPRISE_EMU_GROUP_ID=
182182

183183
# Configure test options
184184
export GH_TEST_ADVANCED_SECURITY=
185+
186+
# Configure if the enterprise is an EMU enterprise
187+
export GH_TEST_ENTERPRISE_IS_EMU=
185188
```
186189

187190
There are also a small amount of unit tests in the provider. Due to the nature of the provider, such tests are currently only recommended for exercising functionality completely internal to the provider. These may be executed by running `make test`.

github/acc_test.go

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"testing"
1212

1313
"github.com/google/go-github/v82/github"
14-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1514
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
15+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1616
)
1717

1818
type testMode string
@@ -43,7 +43,8 @@ type testAccConfig struct {
4343
token string
4444

4545
// Enterprise configuration
46-
enterpriseSlug string
46+
enterpriseSlug string
47+
enterpriseIsEMU bool
4748

4849
// Global test configuration
4950
testPublicRepository string
@@ -76,6 +77,9 @@ type testAccConfig struct {
7677

7778
// Test options
7879
testAdvancedSecurity bool
80+
81+
// Test repository configuration
82+
testRepositoryVisibility string
7983
}
8084

8185
var testAccConf *testAccConfig
@@ -130,6 +134,8 @@ func TestMain(m *testing.M) {
130134
testExternalUserToken: os.Getenv("GH_TEST_EXTERNAL_USER_TOKEN"),
131135
testExternalUser2: os.Getenv("GH_TEST_EXTERNAL_USER2"),
132136
testAdvancedSecurity: os.Getenv("GH_TEST_ADVANCED_SECURITY") == "true",
137+
testRepositoryVisibility: "public",
138+
enterpriseIsEMU: authMode == enterprise && os.Getenv("GH_TEST_ENTERPRISE_IS_EMU") == "true",
133139
}
134140

135141
if config.authMode != anonymous {
@@ -165,6 +171,10 @@ func TestMain(m *testing.M) {
165171
if err == nil {
166172
config.testEnterpriseEMUGroupId = i
167173
}
174+
175+
if config.enterpriseIsEMU {
176+
config.testRepositoryVisibility = "private"
177+
}
168178
}
169179

170180
i, err := strconv.Atoi(os.Getenv("GH_TEST_ORG_APP_INSTALLATION_ID"))
@@ -300,6 +310,36 @@ func skipUnlessEnterprise(t *testing.T) {
300310
}
301311
}
302312

313+
func skipUnlessHasAppInstallations(t *testing.T) {
314+
t.Helper()
315+
316+
meta, err := getTestMeta()
317+
if err != nil {
318+
t.Fatalf("failed to get test meta: %s", err)
319+
}
320+
321+
installations, _, err := meta.v3client.Organizations.ListInstallations(context.Background(), meta.name, nil)
322+
if err != nil {
323+
t.Fatalf("failed to list app installations: %s", err)
324+
}
325+
326+
if len(installations.Installations) == 0 {
327+
t.Skip("Skipping because no GitHub App installations found in the test organization")
328+
}
329+
}
330+
331+
func skipUnlessEMUEnterprise(t *testing.T) {
332+
if !testAccConf.enterpriseIsEMU {
333+
t.Skip("Skipping as test mode is not EMU enterprise")
334+
}
335+
}
336+
337+
func skipIfEMUEnterprise(t *testing.T) {
338+
if testAccConf.enterpriseIsEMU {
339+
t.Skip("Skipping as this test is not supported for EMU enterprise")
340+
}
341+
}
342+
303343
func skipUnlessMode(t *testing.T, testModes ...testMode) {
304344
if !slices.Contains(testModes, testAccConf.authMode) {
305345
t.Skip("Skipping as not supported test mode")

github/data_source_github_actions_environment_public_key_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"fmt"
55
"testing"
66

7-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
8-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
7+
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
8+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
99
)
1010

1111
func TestAccGithubActionsEnvironmentPublicKeyDataSource(t *testing.T) {

github/data_source_github_actions_environment_secrets_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"fmt"
55
"testing"
66

7-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
8-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
7+
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
8+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
99
)
1010

1111
func TestAccGithubActionsEnvironmentSecretsDataSource(t *testing.T) {

github/data_source_github_actions_environment_variables_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"strings"
66
"testing"
77

8-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
9-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
8+
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
9+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1010
)
1111

1212
func TestAccGithubActionsEnvironmentVariablesDataSource(t *testing.T) {

github/data_source_github_actions_organization_oidc_subject_claim_customization_template_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package github
33
import (
44
"testing"
55

6-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
6+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
77
)
88

99
func TestAccGithubActionsOrganizationOIDCSubjectClaimCustomizationTemplateDataSource(t *testing.T) {

github/data_source_github_actions_organization_public_key_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package github
33
import (
44
"testing"
55

6-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
6+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
77
)
88

99
func TestAccGithubActionsOrganizationPublicKeyDataSource(t *testing.T) {

0 commit comments

Comments
 (0)