-
Notifications
You must be signed in to change notification settings - Fork 428
Fix Swift PR Checks on nightly-latest CLI
#1696
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
Conversation
Now that Swift analysis is on by default, we are autodetecting Swift, but Swift is not set up in this workflow. This change adds the Swift setup workflow.
We now can (and need to) to run these steps without the environment variable being set in the other PR checks.
|
Oh no, the step is now failing on past CLI versions. I'll simply pass the environment variable to the failing test then, and we can do The Right Thing when we remove the experimental flag for new versions. |
We cannot remove the conditional in the `setup-swift` workflow because it will fail to find the Swift extractor in prior versions without the experimental flag set. For now we replace the conditional and pass the experimental flag to the failing PR check.
henrymercer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
- Updating the autogenerated "Set environment variable for Swift enablement" step to stop setting
CODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFT=trueonnightly-latest - Updating
.github/actions/setup-swiftto run Swift setup if we're running on macOS/Linux andswiftis included incodeql resolve languages(Note that based on this, Linux analysis requires 5.7.3)
This should handle the case where Swift is enabled by default in nightly-latest. Once 2.13.3 is released, we can remove latest from the list in "Set environment variable for Swift enablement".
setup-swift workflow to debug artifacts PR checknightly-latest CLI
ddce3a1 to
27af7f7
Compare
db80b58 to
4418543
Compare
henrymercer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes, I think it made sense to do the work of updating the PR checks now. I think the only remaining piece is to update multi-language-autodetect.yml to check language autodetection for Swift on nightly-latest too. This is the only remaining read of CODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFT I found in the codebase.
| - uses: ./../action/.github/actions/setup-swift | ||
| if: matrix.version == 'nightly-latest' | ||
| with: | ||
| codeql-path: ${{ steps.init.outputs.codeql-path }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I think we just need to add id: init to the init step to make this work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah... I was wondering what the failure was coming from. Thanks.
Co-authored-by: Andrew Eisenberg <[email protected]>
Nice find — I've modified it to check on |
| - name: Check language autodetect for Swift | ||
| if: env.CODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFT == 'true' | ||
| if: >- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, but I'm slightly surprised to see us using env.CODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFT == 'true' for Ruby too — that seems like a subset. I'm good with us addressing this separately though to unblock PR checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, I noticed this as well. I wonder if it's because we had previously set the CODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFT variable globally, but then moved it individually to specific steps. I'll open a follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR at #1699
| # Specify 5.7.0, otherwise setup Action will default to latest minor version. | ||
| if [ $VERSION = "5.7" ]; then | ||
| VERSION="5.7.0" | ||
| if [ $SWIFT_EXTRACTOR_DIR = "null" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not critical here, but for the future we should quote variables to prevent problems with word splitting.
| CODEQL_PATH: ${{ inputs.codeql-path }} | ||
| run: | | ||
| if [ $RUNNER_OS = "macOS" ]; then | ||
| if [[ $RUNNER_OS = "macOS" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: we should probably pick one of (single brace, double brace) and (single equals, double equals) and run with it. I think for our purposes here they will behave the same though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree! I actually changed it to double brace here to match the other instances of $RUNNER_OS.
I think the bash I've seen so far in the workflow uses single equals for equality, but the Actions syntax outside of the bash scripts use double equals. That's what I've been following at least 😅
Now that Swift analysis is on by default in the latest nightly CLI version, we are autodetecting Swift, but Swift is not set up in this workflow. This change fixes the Swift setup workflow to unblock CI by:
setup-swiftworkflow, andCODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFTfor all versions exceptnightly-latestto the debug artifacts checkCODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFTflag for thenightly-latestCLI version, for any other check. This allows us to test the case where the flag is not set fornightly-latestas well.setup-swiftworkflow to only set up Swift if thecodeql resolve languagesincludes Swift.Once CLI v2.13.3 is released, we can stop setting the experimental flag for
latest.Merge / deployment checklist