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

Install wrapper script for Go on Linux to support tracing for Go 1.21 and above #1909

Merged
merged 29 commits into from
Oct 5, 2023

Conversation

mbg
Copy link
Member

@mbg mbg commented Sep 28, 2023

This PR modifies the init Action to add a go wrapper script to the PATH if we are running on Linux in order to better cope with tracing builds for Go 1.21 and above. This works as follows:

  • If we are initialising CodeQL for Go and we are running on Linux, then we obtain the current path to the go binary.
  • We query the type of executable with the file command.
  • If this contains the string "statically linked", we install the wrapper script to a bin directory in the CodeQL temporary directory.
  • We add that bin directory to the system PATH
  • We store the location of the wrapper script in a new environment variable, CODEQL_ACTION_GO_BINARY (we could probably omit this since the path can be reconstructed in the analyze step)

Additionally, we verify that the result of which go points to our wrapper script in the analyze step by checking it against the value of CODEQL_ACTION_GO_BINARY to make sure that users did not e.g. use a setup-go step after the init action.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

src/actions-util.ts Outdated Show resolved Hide resolved
src/actions-util.ts Show resolved Hide resolved
src/analyze-action.ts Outdated Show resolved Hide resolved
@mbg mbg changed the title Use Go 1.21 for Go tracing checks Install wrapper script for Go on Linux to support tracing for Go 1.21 and above Sep 28, 2023
@mbg mbg force-pushed the mbg/go-1.21-workaround branch from b5e2270 to d4722a8 Compare September 28, 2023 11:24
@mbg mbg marked this pull request as ready for review September 28, 2023 11:35
@mbg mbg requested a review from a team as a code owner September 28, 2023 11:35
@criemen
Copy link
Contributor

criemen commented Sep 28, 2023

Can we already add a feature gate/version flag to that, so that we automatically stop this wrapper script installation at some point in the future? Or a turn-off switch from the CLI?
Once we fix this in the CLI, we need to be able to retrospectively turn off this hack from the CLI, otherwise we'll extract go files with older codeql-action versions double.

Edit: Maybe we can use the new version feature already?

Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

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

This broadly looks good but still needs some sort of version gating mechanism so that we don't start double-tracing if and when the CLI starts handling this situation for itself.

@mbg mbg force-pushed the mbg/go-1.21-workaround branch from 5933ae0 to 0696c1b Compare October 4, 2023 16:40
Copy link
Contributor

@henrymercer henrymercer left a comment

Choose a reason for hiding this comment

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

As a general comment, are we happy with the test coverage here? Specifically, do we want to add some unit tests or some specific assertions to the PR checks? Or do the existing checks passing on Go 1.21.1 give us enough confidence?

pr-checks/checks/go-tracing-autobuilder.yml Outdated Show resolved Hide resolved
src/actions-util.ts Outdated Show resolved Hide resolved
src/actions-util.ts Show resolved Hide resolved
src/analyze-action.ts Outdated Show resolved Hide resolved
src/actions-util.ts Outdated Show resolved Hide resolved
src/init-action.ts Show resolved Hide resolved
src/init-action.ts Outdated Show resolved Hide resolved
src/init-action.ts Outdated Show resolved Hide resolved
src/resolve-environment.test.ts.ignore Outdated Show resolved Hide resolved
src/tools-features.ts Outdated Show resolved Hide resolved
@mbg mbg force-pushed the mbg/go-1.21-workaround branch from 0696c1b to 68d0b65 Compare October 4, 2023 19:03
Copy link
Contributor

@henrymercer henrymercer left a comment

Choose a reason for hiding this comment

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

Thanks, I'd like to hear what Chris thinks about how we should behave in the absence of file, but otherwise this looks good to me.

henrymercer
henrymercer previously approved these changes Oct 5, 2023
@mbg mbg force-pushed the mbg/go-1.21-workaround branch from 31af127 to faf7528 Compare October 5, 2023 12:11
@mbg mbg requested review from henrymercer and smowton October 5, 2023 13:09
henrymercer
henrymercer previously approved these changes Oct 5, 2023
Copy link
Contributor

@henrymercer henrymercer left a comment

Choose a reason for hiding this comment

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

Very nice!

src/analyze-action.ts Outdated Show resolved Hide resolved
src/analyze-action.ts Outdated Show resolved Hide resolved
@mbg mbg force-pushed the mbg/go-1.21-workaround branch from cb79d4d to 235bdca Compare October 5, 2023 13:27
@mbg mbg merged commit 1ea6a10 into main Oct 5, 2023
362 checks passed
@mbg mbg deleted the mbg/go-1.21-workaround branch October 5, 2023 14:31
@github-actions github-actions bot mentioned this pull request Oct 6, 2023
6 tasks
@mbg mbg mentioned this pull request Oct 13, 2023
3 tasks
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.

4 participants