Skip to content

[MAINT] Fix actions_hosted_runner tests#3521

Open
deiga wants to merge 18 commits into
integrations:mainfrom
F-Secure-web:fix-actions-hosted-runner-test-resource-names
Open

[MAINT] Fix actions_hosted_runner tests#3521
deiga wants to merge 18 commits into
integrations:mainfrom
F-Secure-web:fix-actions-hosted-runner-test-resource-names

Conversation

@deiga

@deiga deiga commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Resolves #3405
Closes #3406


Before the change?

  • resource_github_actions_hosted_runner tests have naming collisions
  • resource_github_actions_hosted_runner uses legacy patterns

After the change?

  • resource_github_actions_hosted_runner tests use ConfigStateChecks and ConfigPlanChecks
  • Ensure resource_github_actions_hosted_runner tests don't use conflicting names
  • Refactors resource_github_actions_hosted_runner to use Context-aware CRUD functions
  • Refactors resource_github_actions_hosted_runner to not call Read after Update and Create
  • Refactors resource_github_actions_hosted_runner to use go-github API methods
  • Adds sweeper for Organization Runner Groups

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

👋 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.

@github-actions github-actions Bot added the Type: Bug Something isn't working as documented label Jul 5, 2026
@deiga deiga marked this pull request as ready for review July 5, 2026 18:36
@stevehipwell stevehipwell added this to the v6.14.0 milestone Jul 6, 2026

@stevehipwell stevehipwell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just a quick pre-review, the comments apply to all matching patterns not just the ones I commented on.

Comment thread github/resource_github_actions_hosted_runner.go Outdated
Comment thread github/resource_github_actions_hosted_runner.go Outdated
Comment thread github/resource_github_actions_hosted_runner.go Outdated
Comment thread github/resource_github_actions_hosted_runner.go Outdated
deiga added 17 commits July 8, 2026 21:33
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…_error`

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…figStateChecks`

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…cks` and `ConfigPlanChecks`

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…lanChecks`

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…` API methods

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
…are CRUD functions

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
@deiga deiga force-pushed the fix-actions-hosted-runner-test-resource-names branch from 35fd280 to 47f2e38 Compare July 8, 2026 18:51
@deiga deiga requested a review from Copilot July 8, 2026 18:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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-github API calls, with new expand/flatten helpers operating on typed structs.
  • Rewrite acceptance tests to statecheck/plancheck, unique subtest names, and a shared mustCreateTestOrganizationActionsRunnerGroup helper.
  • Add sweepOrganizationRunnerGroups/sweepRunnerGroupRunners sweepers and change SWEEP default to all.

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 — Delete passes runner.GetID() to waitForRunnerDeletion, but runner is nil on the async 202 path, so it polls runner ID 0, returns "deleted" immediately, and skips the real wait.
  • MEDIUM — last_active_on is set from Timestamp.GoString(), writing github.Timestamp{...} into state instead of the documented RFC3339 value (3 locations).
  • MEDIUM — Create sets the resource ID from a nil runner on the 202 path, producing ID "0" and empty computed state.

Comment thread github/resource_github_actions_hosted_runner.go
Comment thread github/resource_github_actions_hosted_runner.go Outdated
Comment thread github/resource_github_actions_hosted_runner.go Outdated
Comment thread github/resource_github_actions_hosted_runner.go Outdated
Comment thread github/resource_github_actions_hosted_runner.go
Comment thread github/acc_test.go
Comment on lines +387 to +400
if err != nil {
if err != nil {
if resp != nil && resp.StatusCode == http.StatusNotFound {
continue
}
if _, ok := errors.AsType[*github.AcceptedError](err); ok {
if err := waitForRunnerDeletion(ctx, client, owner, r.GetID(), 5*time.Minute); err != nil {
return fmt.Errorf("failed to wait for runner deletion %s: %w", r.GetName(), err)
}
continue
}
return fmt.Errorf("failed to delete hosted runner %s: %w", r.GetName(), err)
}
}
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Something isn't working as documented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: github_actions_hosted_runner resource must be replaced after import

3 participants