integrations / terraform-provider-github

Terraform GitHub provider
https://www.terraform.io/docs/providers/github/
MIT License
905 stars 746 forks source link

Add GitHub Code Scanning Resource and Data Source #2036

Open VariableExp0rt opened 11 months ago

VariableExp0rt commented 11 months ago

Resolves #1648


Before the change?

After the change?

Pull request checklist

Does this introduce a breaking change?

Please see our docs on breaking changes to help!


I have a minor issue with my test setup, I have created an Org, and a test user, but the errors I am seeing are related to the running of the tests under the individual and organization scopes, which I've yet been able to resolve. I'd appreciate any help in that regard! It looks like I am seeing this

{
 "message": "No CodeQL supported languages were detected on this repository.",
 "documentation_url": "https://docs.github.com/rest/code-scanning/code-scanning#update-a-code-scanning-default-setup-configuration"
}

But then further down in the test log I can see (when tearing down):

{
 "state": "not-configured",
 "languages": [
  "python"
 ],
 "query_suite": "default",
 "updated_at": null,
 "schedule": null
}

I think this is because there is an action that is run on the enrolling repository, which takes a variable amount of time. Is there a good way to handle this? I presume the issue is perhaps down to the indexing happening as the codeql scanning resource is created. I've included a waiter for the codeql workflow job to finish.

kfcampbell commented 10 months ago

@VariableExp0rt I'm running into what I think is the same issue as you:

    testing.go:705: Step 0 error: errors during apply:

        Error: job scheduled on GitHub side; try again later

          on /tmp/tf-test3743193068/main.tf line 36:
          (source code not available)

CodeQL configuration can take several minutes...perhaps a true integration test would loop a wait and poll to see if/when it's enabled before running the checks. It wouldn't be something we'd want to run as a regular check due to the time associated, but perhaps it's still worth including. I don't know, I'm conflicted.

Can you post results of manual testing of the data source and resource you've conducted?

pacoguzman commented 7 months ago

Hi there, I've been working on this issue trying to solve the issues already mentioned here

A disclaimer about commit ownership I've removed @VariableExp0rt by mistake as I've started working from this PR.