-
Notifications
You must be signed in to change notification settings - Fork 2k
CI: try only to fill the compilation cache from main in the compile-queries workflow #11162
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,21 +24,21 @@ jobs: | |||||||||||
| run: | | ||||||||||||
| MERGE_BASE=$(git merge-base --fork-point origin/$BASE_BRANCH) | ||||||||||||
| echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV | ||||||||||||
| - name: Calculate merge-base - branch | ||||||||||||
| if: ${{ github.event_name != 'pull_request' }} | ||||||||||||
| # using github.sha instead, since we're directly on a branch, and not in a PR | ||||||||||||
| run: | | ||||||||||||
| MERGE_BASE=${{ github.sha }} | ||||||||||||
| echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV | ||||||||||||
| - name: Cache CodeQL query compilation | ||||||||||||
| - name: Read CodeQL query compilation - PR | ||||||||||||
| if: ${{ github.event_name == 'pull_request' }} | ||||||||||||
| uses: actions/cache@v3 | ||||||||||||
| with: | ||||||||||||
| path: '*/ql/src/.cache' | ||||||||||||
| # current GH HEAD first, merge-base second, generic third | ||||||||||||
| key: codeql-stable-compile-${{ github.sha }} | ||||||||||||
| key: codeql-compile-pr-${{ github.sha }} # deliberately not using the `compile-compile-main` keys here. | ||||||||||||
| restore-keys: | | ||||||||||||
| codeql-stable-compile-${{ env.merge-base }} | ||||||||||||
| codeql-stable-compile- | ||||||||||||
| codeql-compile-main-${{ env.merge-base }} | ||||||||||||
| codeql-compile-main- | ||||||||||||
|
Comment on lines
+34
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| - name: Fill CodeQL query compilation cache - main | ||||||||||||
| if: ${{ github.event_name != 'pull_request' }} | ||||||||||||
| uses: actions/cache@v3 | ||||||||||||
| with: | ||||||||||||
| path: '*/ql/src/.cache' | ||||||||||||
| key: codeql-compile-main-${{ github.sha }} # just fill on main | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps:
Suggested change
|
||||||||||||
| - name: Setup CodeQL | ||||||||||||
| uses: ./.github/actions/fetch-codeql | ||||||||||||
| with: | ||||||||||||
|
|
||||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think we can simplify this to simply take the SHA of the first parent of the merge commit. That may actually be better than the "fork point". It also avoids having to fetch the commit history.
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.
Can I get a parent commit if I don't fetch the commit history?
Do you have some code you think would 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.
We have some code in the Foundations team benchmarking infrastructure that does this by calling the GitHub API, you could do something similar here: https://github.com/github/semmle-code/blob/db3086b9699c8c8c9846cd6239b78da431f27dc3/.github/actions/benchmark-prepare/lib/index.js#L55-L70 (with apologies to any external users for the link to our internal code)
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 should work too. There must be a simpler way....
Uh oh!
There was an error while loading. Please reload this page.
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'm not sure there is.
Your code gets the parent of the HEAD commit, which will only work when there's exactly one commit in the PR.
I could use the rest API (I got code doing something similar in DCA already), but I want to keep it simple, so I think I'll keep the current approach.
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.
The
HEADcommit should be a merge commit of the the base and the head branches of a pull request.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.
See also: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
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.
Yes, I know. But I still don't see how that's useful for getting the merge-base.
I have something better when running on main (´github.sha`).
And when running in a PR I don't see how I can use the HEAD commit, because the parent of the HEAD commit is most of the time not the commit I'm looking for.