Skip to content

Commit 302488f

Browse files
authored
Merge branch 'main' into feat/organization-security-configuration
2 parents 6d3c919 + d63fa1f commit 302488f

2,756 files changed

Lines changed: 1250 additions & 811666 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.

.golangci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
version: "2"
2-
run:
3-
modules-download-mode: vendor
42

53
linters:
64
default: none

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
@@ -10,7 +10,7 @@ import (
1010
"strings"
1111
"testing"
1212

13-
"github.com/google/go-github/v82/github"
13+
"github.com/google/go-github/v83/github"
1414
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1515
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1616
)
@@ -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/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"strings"
1010
"time"
1111

12-
"github.com/google/go-github/v82/github"
12+
"github.com/google/go-github/v83/github"
1313
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
1414
"github.com/shurcooL/githubv4"
1515
"golang.org/x/oauth2"

github/data_source_github_actions_environment_secrets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"net/url"
66

7-
"github.com/google/go-github/v82/github"
7+
"github.com/google/go-github/v83/github"
88

99
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1010
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

github/data_source_github_actions_environment_variables.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"net/url"
66

7-
"github.com/google/go-github/v82/github"
7+
"github.com/google/go-github/v83/github"
88

99
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1010
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

github/data_source_github_actions_organization_secrets.go

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

6-
"github.com/google/go-github/v82/github"
6+
"github.com/google/go-github/v83/github"
77

88
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
99
)

github/data_source_github_actions_organization_variables.go

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

6-
"github.com/google/go-github/v82/github"
6+
"github.com/google/go-github/v83/github"
77

88
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
99
)

github/data_source_github_actions_secrets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"fmt"
66

7-
"github.com/google/go-github/v82/github"
7+
"github.com/google/go-github/v83/github"
88

99
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1010
)

github/data_source_github_actions_variables.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"fmt"
66

7-
"github.com/google/go-github/v82/github"
7+
"github.com/google/go-github/v83/github"
88

99
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1010
)

0 commit comments

Comments
 (0)