Repository navigation
Conversation
|
👋 Hi, and thank you for this contribution! This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can. You can help us prioritize by joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions. 🤖 This is an automated message. |
stevehipwell
left a comment
There was a problem hiding this comment.
Just a quick pre-review, the comments apply to all matching patterns not just the ones I commented on.
35fd280 to
47f2e38
Compare
There was a problem hiding this comment.
Pull request overview
These provider review instructions are being used.
This PR modernizes the github_actions_hosted_runner resource and its acceptance tests. It migrates the resource CRUD functions to the *Context variants returning diag.Diagnostics, replaces hand-rolled client.NewRequest/client.Do calls and map[string]any payload plumbing with typed go-github Actions.*HostedRunner methods, and stops calling Read after Create/Update (consistent with this provider's no-read-after-write convention). The tests are rewritten to use ConfigStateChecks/ConfigPlanChecks, share a single runner group created via a new helper, and use non-colliding subtest names. A new sweeper for organization runner groups (and their hosted runners) is added, and the default sweep target is broadened.
Changes:
- Refactor the hosted-runner resource to context-aware CRUD + typed
go-githubAPI calls, with newexpand/flattenhelpers operating on typed structs. - Rewrite acceptance tests to
statecheck/plancheck, unique subtest names, and a sharedmustCreateTestOrganizationActionsRunnerGrouphelper. - Add
sweepOrganizationRunnerGroups/sweepRunnerGroupRunnerssweepers and changeSWEEPdefault toall.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
github/resource_github_actions_hosted_runner.go |
Context-aware CRUD, typed API calls, new flatten/expand helpers; introduces GoString() state bug and nil-runner dereferences on the 202/AcceptedError paths. |
github/resource_github_actions_hosted_runner_test.go |
Tests migrated to state/plan checks, unique subtest names, shared runner group, updated import-verify ignore list. |
github/acc_test.go |
Adds organization runner-group sweeper and helper; contains a redundant nested if err != nil. |
github/acc_helpers_test.go |
Adds mustCreateTestOrganizationActionsRunnerGroup helper with cleanup. |
GNUmakefile |
Broadens default SWEEP to all and targets ./github for the sweep run. |
Key findings
- HIGH —
Deletepassesrunner.GetID()towaitForRunnerDeletion, butrunneris nil on the async202path, so it polls runner ID0, returns "deleted" immediately, and skips the real wait. - MEDIUM —
last_active_onis set fromTimestamp.GoString(), writinggithub.Timestamp{...}into state instead of the documented RFC3339 value (3 locations). - MEDIUM —
Createsets the resource ID from a nil runner on the202path, producing ID"0"and empty computed state.
7b58c0c to
5536de9
Compare
08c2677 to
ede0321
Compare
ede0321 to
8076b34
Compare
stevehipwell
left a comment
There was a problem hiding this comment.
A couple of minor change requests. I think the common permissions/plan docs should be a seperate PR but was just explaining why I don't think the top level description needs to mention this.
8076b34 to
921a886
Compare
921a886 to
318bbd2
Compare
rilical
left a comment
There was a problem hiding this comment.
I found a few regressions in the move to the typed hosted-runner client that are worth addressing together. last_active_on can be null, but Create, Read, and Update currently format the zero value and leave 0001-01-01T00:00:00Z in state. The AcceptedError path has a similar problem: go-github returns a nil runner with the error, then the code continues and copies empty or zero values into state. The typed response also no longer exposes image_gen, which the previous raw JSON Read preserved, so imports can lose that value. Could we keep the old null handling, avoid updating state from a nil runner, and either retain an image_gen fallback or document the limitation? It would also be good to restore the optional-parameter state checks that were removed from the acceptance test so these paths stay covered.
|
This is now pending on #3627, since the public IP checks are failing otherwise |
…` API methods Signed-off-by: Timo Sand <[email protected]>
…are CRUD functions Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
…ctive_on` Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
dde9f26 to
9afb9e7
Compare
| Timeouts: &schema.ResourceTimeout{ | ||
| Delete: schema.DefaultTimeout(10 * time.Minute), | ||
| }, |
There was a problem hiding this comment.
| Timeouts: &schema.ResourceTimeout{ | |
| Delete: schema.DefaultTimeout(10 * time.Minute), | |
| }, |
Let's remove this for consistency.
There was a problem hiding this comment.
At a minimum this should be // TODO marked for removal as part of v7 for consistency and the default should be updated to 20 min given that's the default for everything else.
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
|
@stevehipwell please re-review. |
stevehipwell
left a comment
There was a problem hiding this comment.
RE testing, we should fast path 204 responses and rely on a sweeper to cleanup anything that eventually fails.
| Timeouts: &schema.ResourceTimeout{ | ||
| Delete: schema.DefaultTimeout(10 * time.Minute), | ||
| }, |
There was a problem hiding this comment.
At a minimum this should be // TODO marked for removal as part of v7 for consistency and the default should be updated to 20 min given that's the default for everything else.
@stevehipwell I don't agree with this, since this would leave the runner group always behind. Since running tests should use some level of parallelism this wait doesn't have much of an impact on a full run |
I don't see anywhere in the test code that would do anything different by waiting? And we can only ever have 100 concurrent connection to GitHub, so 20s of polling for no real reason is expensive in this context. |
Resolves #3405
Closes #3406
Before the change?
resource_github_actions_hosted_runnertests have naming collisionsresource_github_actions_hosted_runneruses legacy patternsAfter the change?
resource_github_actions_hosted_runnertests useConfigStateChecksandConfigPlanChecksresource_github_actions_hosted_runnertests don't use conflicting namesresource_github_actions_hosted_runnerto use Context-aware CRUD functionsresource_github_actions_hosted_runnerto not callReadafterUpdateandCreateresource_github_actions_hosted_runnerto usego-githubAPI methodsPull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!