Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Code Scanning Resource and Data Source #2036

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

VariableExp0rt
Copy link

@VariableExp0rt VariableExp0rt commented Dec 1, 2023

Resolves #1648


Before the change?

  • Before the change, code scanning was not able to be configured with a Terraform resource, and it's state was not able to be retrieved by a data source.

After the change?

  • The provider now supports configuring code scanning via its corresponding resource for a given repository, and the data source is able to retrieve it's current configuration.

Pull request checklist

  • 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

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.

liam.baker added 4 commits December 1, 2023 08:54
Signed-off-by: liam.baker <liam.baker@sage.com>
Signed-off-by: liam.baker <liam.baker@sage.com>
Signed-off-by: liam.baker <liam.baker@sage.com>
Signed-off-by: liam.baker <liam.baker@sage.com>
@kfcampbell
Copy link
Member

@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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT]: Support Code Scanning default setup
3 participants