FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Output environment file for Windows by edoardopirovano · Pull Request #495 · github/codeql-action · GitHub

Output environment file for Windows - #495

Merged
adityasharad merged 2 commits into
github:mainfrom
edoardopirovano:windows-env-file
May 10, 2021
Merged

adityasharad merged 2 commits into
github:mainfrom
edoardopirovano:windows-env-file

Conversation

Copy link
Copy Markdown
Contributor

Currently, the environment file for the tracer is only being output in the Unix format. Thus, these variables are not being read by the tracer on Windows machines. This PR addresses this by also outputting the environment file in the Windows format.

I have also modified the runner-analyze-csharp-windows test to unset the CODEQL_EXTRACTOR_CSHARP_ROOT variable before the build step. This would cause the test to fail if the environment file being produced was not correct.

Comment thread package.json
"scripts": {
"build": "tsc",
"test": "ava src/** --serial --verbose",
"test-debug": "ava src/** --serial --verbose --timeout=20m",

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is fine, but are you aware that you can debug a test from inside of vscode? See the .vscode/launch.json file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, can't hurt to have this target too for people debugging in other ways though 🙂

Comment thread .github/workflows/pr-checks.yml Outdated

- name: Build code
shell: powershell
# Note this step unsets the CODEQL_EXTRACTOR_CSHARP_ROOT to ensure that the .win32env file is read correctly

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

In what situations is this not being read correctly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Before this PR the file was not being produced at all, so I figured we need to modify an integration test to make sure it actually gets read when it is produced.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Oh. I see, I misunderstood the comment and what you're doing here. By un-setting the CODEQL_EXTRACTOR_CSHARP_ROOT variable, you are ensuring that .win32env is being read correctly.

Could you update the comment to something like this?

Suggested change
# Note this step unsets the CODEQL_EXTRACTOR_CSHARP_ROOT to ensure that the .win32env file is read correctly
# Note we want to make sure that the .win32env file is read correctlyl, so we unset the CODEQL_EXTRACTOR_CSHARP_ROOT from the .sh file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Sure, done ✅

Comment thread .github/workflows/pr-checks.yml Outdated
(Get-Content ./codeql-runner/codeql-env.sh) | Select-String -pattern ".*CODEQL_EXTRACTOR_CSHARP_ROOT.*" -NotMatch | ? {$_.ToString().trim() -ne "" } | Set-Content ./codeql-runner/codeql-env.sh
$jsonEnv = Get-Content -Path ./codeql-runner/codeql-env.json -Raw | ConvertFrom-Json
$jsonEnv.PSObject.Properties.Remove('CODEQL_EXTRACTOR_CSHARP_ROOT')
$jsonEnv | ConvertTo-Json -Depth 1 | Out-File ./codeql-runner/codeql-env.json -Force

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Could we make this simpler, by removing CODEQL_EXTRACTOR_CSHARP_ROOT from the environment after the Invoke-Expression step below? I think Clear-Variable is the PowerShell command.
The step below doesn't use the JSON file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Aha, done. For reason I thought those files needed patching to stop the runner reading them again.

Comment thread src/tracer-config.ts Outdated
const envPath = `${spec}.environment`;
fs.writeFileSync(envPath, buffer);

// Prepare the content of the compound environment file on Windows

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What do you think about doing this step only when we're on Windows, vs unconditionally?

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I would have a (weak!) preference to only write the file that corresponds to the current platform. I doubt it makes any concrete difference either way, but it feels most right to try to mimic what the actual preload_tracer does.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Sure, done - except in the unit tests where we still test both regardless of platform.

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM.

The O(n²) buffer building makes me wince a bit, but (a) that's what the existing code does for Unix, (b) generally there are not that many environment variables to handle, and (c) the whole exercise ought to go away soon when we have multi-language support in the CLI anyway.

adityasharad merged commit 4c0671c into github:main May 10, 2021
edoardopirovano deleted the windows-env-file branch May 10, 2021 21:03
github-actions Bot mentioned this pull request May 17, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL