Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
9909ecc
Ensure tests use `GITHUB_TEST_*` values for Owner and Organization
deiga Dec 2, 2025
d3bafe6
Update `skipUnlessMode` to check for enterprise ENV variables
deiga Dec 2, 2025
a4f929b
Use `testOwnerFunc` to set `testOwner` so that `GITHUB_TEST_OWNER` wo…
deiga Dec 3, 2025
fbc8707
Switch from `NewSubsystemLoggingHTTPTransport` to `NewLoggingHTTPTran…
deiga Dec 3, 2025
6966690
Update to use Context aware CRUD functions
deiga Dec 7, 2025
a60ac7f
Ensure `update_allows_fetch_and_merge` isn't added for Org Ruleset
deiga Dec 4, 2025
3e2cd38
Update name of resource, to make debugging failing tests easier
deiga Dec 4, 2025
d82c614
Need to have one of `repository_name` or `repository_id` defined
deiga Dec 4, 2025
b2c3570
Need to have a valid repo reference
deiga Dec 4, 2025
6954994
Actions repository access level needs to be set properly
deiga Dec 4, 2025
a41b2f3
Required workflow needs to be in the `.github/workflows` folder
deiga Dec 4, 2025
41b3dec
Update indentation
deiga Dec 4, 2025
512db50
Need to have one of `repository_name` or `repository_id` defined
deiga Dec 4, 2025
bdc4729
Add handling of `AllowedMergeMethods`
deiga Dec 4, 2025
405d3b6
Add `allowed_merge_methods` to `rules` for Org & Repo rulesets
deiga Dec 6, 2025
986ae22
Fixed type conversion for `allowed_merge_methods`
deiga Dec 6, 2025
581ff8c
Update test content to actually pass the GH API
deiga Dec 4, 2025
e97f75c
Convert `github_repository` to use `*Context` CRUD methods
deiga Dec 6, 2025
f096f44
Enable `TestGithubOrganizationRulesets/Creates_and_updates_organizati…
deiga Dec 6, 2025
2d77c1e
`make fmt`
deiga Dec 7, 2025
9d22505
Add workaround for GH API bug that OrgAdmin actor_id is returned as `…
deiga Dec 6, 2025
74bcfe7
`make fmt`
deiga Dec 7, 2025
4808483
Fix `TestGithubOrganizationRulesets/Creates_organization_ruleset_with…
deiga Dec 7, 2025
f698cd2
Fix tests regarding `bypass_actors` ordering
deiga Dec 7, 2025
3752c16
Rename test resources for easier debugging
deiga Dec 7, 2025
cf35bf9
Update descriptions and validations
deiga Nov 27, 2025
35ff668
Add `CustomizeDiff` logic to validate on `plan`
deiga Nov 27, 2025
a944da8
Allow `organization` in tests as well
deiga Nov 29, 2025
e471a58
Remove unused leftover
deiga Nov 29, 2025
92fc538
Add first validation test
deiga Nov 29, 2025
4f2ea6a
Update formatting
deiga Nov 30, 2025
0e81c85
Add validation error when `conditions` is missing
deiga Nov 30, 2025
056a70f
Add further validation tests
deiga Nov 30, 2025
740c5e2
Remove unnecessary skip blocks as `individual` and `anonymous` access…
deiga Dec 2, 2025
4fc2f51
Switch `ref_name` to `Optional` as `push` doesn't need a `ref_name`
deiga Dec 2, 2025
a70831e
Add Debug logging with `tflog` to validation
deiga Dec 3, 2025
9d85734
Fix validation as `ref_name`, `repository_name` and `repository_id` a…
deiga Dec 3, 2025
5b88bb2
Correctly use `enterprise` runner
deiga Dec 3, 2025
08a73fc
Fix test output expectation
deiga Dec 3, 2025
3f34fb6
Remove unnecessary panic test
deiga Dec 3, 2025
776fc64
Improve validation output messages
deiga Dec 3, 2025
7f65508
Update to use Context aware CRUD functions
deiga Dec 3, 2025
2479b73
Fix condition to require only one of `repository_name` or `repository…
deiga Dec 3, 2025
4666bbe
Add validation to `required_workflow.path`
deiga Dec 6, 2025
e9c10b4
`make fmt`
deiga Dec 6, 2025
519ea54
Rename test resources for easier debugging
deiga Dec 7, 2025
21e2e02
Fix linter issues
deiga Dec 7, 2025
77e8cfe
Add validation to ensure `rules.required_status_checks.required_check…
deiga Dec 8, 2025
6782aab
`go mod tidy`
deiga Dec 8, 2025
97e2351
Add test to ensure that `required_checks` is always required
deiga Dec 8, 2025
8717361
Remove `repository` as possible `target` value.
deiga Dec 10, 2025
e8b41f4
Improve legibility of `conditions` description
deiga Dec 10, 2025
66e0a1d
Update descriptions
deiga Dec 14, 2025
75e58b2
Add Acc test for push ruleset.
deiga Dec 14, 2025
be29a43
Add failing test for `flattenConditions` with no `ref_name` condition
deiga Dec 14, 2025
73f817b
Fix `flattenConditions` to work with `push` rulesets
deiga Dec 15, 2025
b46cae4
Add more tests for `flattenConditions`
deiga Dec 15, 2025
6b91f57
Enable debug logging in `flattenConditions`
deiga Dec 15, 2025
cec204f
Ensures that `flattenConditions` returns an empty list on empty API r…
deiga Dec 15, 2025
18c860e
Add validation for `push` `rules`
deiga Dec 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion github/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var GHECDataResidencyHostMatch = regexp.MustCompile(`^[a-zA-Z0-9.\-]+\.ghe\.com\
func RateLimitedHTTPClient(client *http.Client, writeDelay, readDelay, retryDelay time.Duration, parallelRequests bool, retryableErrors map[int]bool, maxRetries int) *http.Client {
client.Transport = NewEtagTransport(client.Transport)
client.Transport = NewRateLimitTransport(client.Transport, WithWriteDelay(writeDelay), WithReadDelay(readDelay), WithParallelRequests(parallelRequests))
client.Transport = logging.NewSubsystemLoggingHTTPTransport("GitHub", client.Transport)
client.Transport = logging.NewLoggingHTTPTransport(client.Transport)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why we need this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't inititialize the GitHub subsystem anywhere and from my understanding subsystems are usually per-resource things.
With an unitialized Subsystem the logs get spammed with warnings about it.

But this implementation is "actually" in this PR #2976 and any modifications to it should happen there

client.Transport = newPreviewHeaderInjectorTransport(map[string]string{
// TODO: remove when Stone Crop preview is moved to general availability in the GraphQL API
"Accept": "application/vnd.github.stone-crop-preview+json",
Expand Down
12 changes: 7 additions & 5 deletions github/provider_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var (
isPaidPlan = os.Getenv("GITHUB_PAID_FEATURES")
testEnterprise = os.Getenv("ENTERPRISE_SLUG")
testOrganization = testOrganizationFunc()
testOwner = os.Getenv("GITHUB_OWNER")
testOwner = testOwnerFunc()
testToken = os.Getenv("GITHUB_TOKEN")
testBaseURLGHES = os.Getenv("GHES_BASE_URL")
)
Expand Down Expand Up @@ -54,8 +54,8 @@ func skipUnlessMode(t *testing.T, providerMode string) {
t.Log("GITHUB_TOKEN environment variable should be empty")
}
case enterprise:
if os.Getenv("GITHUB_TOKEN") == "" {
t.Log("GITHUB_TOKEN environment variable should be set")
if os.Getenv("GITHUB_TOKEN") == "" || os.Getenv("ENTERPRISE_ACCOUNT") != "true" || os.Getenv("ENTERPRISE_SLUG") == "" {
t.Log("GITHUB_TOKEN and ENTERPRISE_ACCOUNT and ENTERPRISE_SLUG environment variables should be set")
} else {
return
}
Expand All @@ -67,10 +67,10 @@ func skipUnlessMode(t *testing.T, providerMode string) {
t.Log("GITHUB_TOKEN and GITHUB_OWNER environment variables should be set")
}
case organization:
if os.Getenv("GITHUB_TOKEN") != "" && os.Getenv("GITHUB_ORGANIZATION") != "" {
if os.Getenv("GITHUB_TOKEN") != "" && (os.Getenv("GITHUB_ORGANIZATION") != "" || os.Getenv("GITHUB_TEST_ORGANIZATION") != "") {
return
} else {
t.Log("GITHUB_TOKEN and GITHUB_ORGANIZATION environment variables should be set")
t.Log("GITHUB_TOKEN and GITHUB_ORGANIZATION or GITHUB_TEST_ORGANIZATION environment variables should be set")
}
}

Expand Down Expand Up @@ -120,6 +120,7 @@ func testOrganizationFunc() string {
organization := os.Getenv("GITHUB_ORGANIZATION")
if organization == "" {
organization = os.Getenv("GITHUB_TEST_ORGANIZATION")
os.Setenv("GITHUB_ORGANIZATION", organization)
}
return organization
}
Expand All @@ -128,6 +129,7 @@ func testOwnerFunc() string {
owner := os.Getenv("GITHUB_OWNER")
if owner == "" {
owner = os.Getenv("GITHUB_TEST_OWNER")
os.Setenv("GITHUB_OWNER", owner)
}
return owner
}
Expand Down
Loading