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

CI: try only to fill the compilation cache from main in the compile-queries workflow #11162

Merged
merged 1 commit into from Nov 8, 2022

Conversation

erik-krogh
Copy link
Contributor

@erik-krogh erik-krogh commented Nov 8, 2022

I changed all the cache keys so it won't hit the old caches.

I didn't find a way to have actions/cache run in a "read-only" mode, so I'm using different cache keys depending on whether the workflow runs in a PR or on main.

When running on this PR the cache is empty, so the workflow is slow.
But this PR should help get better cache hits in the future.

@erik-krogh erik-krogh changed the title try only to fill the cache from main CI: try only to fill the compilation cache from main in the compile-queries workflow Nov 8, 2022
@erik-krogh erik-krogh marked this pull request as ready for review Nov 8, 2022
@erik-krogh erik-krogh requested a review from a team as a code owner Nov 8, 2022
@erik-krogh erik-krogh requested a review from aibaars Nov 8, 2022
aibaars
aibaars approved these changes Nov 8, 2022
Copy link
Contributor

@aibaars aibaars left a comment

Looks good to me. Some suggestions to simplify the merge-base and to make the workflow also work for rc and other branches.

uses: actions/cache@v3
with:
path: '*/ql/src/.cache'
key: codeql-compile-main-${{ github.sha }} # just fill on main
Copy link
Contributor

@aibaars aibaars Nov 8, 2022

Choose a reason for hiding this comment

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

Perhaps:

Suggested change
key: codeql-compile-main-${{ github.sha }} # just fill on main
key: codeql-compile-${{ github.ref }}-${{ github.sha }} # just fill on main

@@ -24,21 +24,21 @@ jobs:
run: |
MERGE_BASE=$(git merge-base --fork-point origin/$BASE_BRANCH)
Copy link
Contributor

@aibaars aibaars Nov 8, 2022

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.

Copy link
Contributor Author

@erik-krogh erik-krogh Nov 8, 2022

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?

Copy link
Contributor

@edoardopirovano edoardopirovano Nov 8, 2022

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)

Copy link
Contributor

@aibaars aibaars Nov 8, 2022

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

git cat-file commit  HEAD | grep '^parent ' | head -1 | cut -d ' ' -f 

codeql-compile-main-${{ env.merge-base }}
codeql-compile-main-
Copy link
Contributor

@aibaars aibaars Nov 8, 2022

Choose a reason for hiding this comment

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

Suggested change
codeql-compile-main-${{ env.merge-base }}
codeql-compile-main-
codeql-compile-${{ github.base_ref }}-${{ env.merge-base }}
codeql-compile-${{ github.base_ref }}-
codeql-compile-refs/heads/main-

@erik-krogh erik-krogh merged commit 8b11e98 into github:main Nov 8, 2022
4 checks passed
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.

None yet

3 participants