Skip to content

Ruby: Use compilation cache for the qltest CI workflow #11344

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 6 commits into from
Nov 21, 2022

Conversation

erik-krogh
Copy link
Contributor

No description provided.

@erik-krogh erik-krogh force-pushed the all-the-cache branch 7 times, most recently from a13557f to b53327e Compare November 21, 2022 13:32
@erik-krogh erik-krogh changed the title test caching Ruby: Use compilation cache for the qltest CI workflow Nov 21, 2022
@erik-krogh erik-krogh marked this pull request as ready for review November 21, 2022 13:52
@erik-krogh erik-krogh requested review from a team as code owners November 21, 2022 13:52
@erik-krogh erik-krogh requested a review from aibaars November 21, 2022 13:53
Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

Looks plausible to me.

- name: Run QL tests
run: |
codeql test run --threads=0 --ram 5000 --slice ${{ matrix.slice }} --search-path "${{ github.workspace }}/ruby/extractor-pack" --check-databases --check-undefined-labels --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --consistency-queries ql/consistency-queries ql/test
codeql test run --threads=0 --search-path "${{ github.workspace }}/ruby/extractor-pack" --check-databases --check-undefined-labels --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --consistency-queries ql/consistency-queries ql/test --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK, it is still a good idea to set --ram. I believe these machines have 56 GB or RAM, so setting to e.g. 52 GB should work.

@github-actions github-actions bot removed the Ruby label Nov 21, 2022
aibaars
aibaars previously approved these changes Nov 21, 2022
BASE_BRANCH: ${{ github.base_ref }}
run: |
MERGE_BASE=$(git cat-file commit $GITHUB_SHA | grep '^parent ' | head -1 | cut -f 2 -d " ")
echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV
Copy link
Contributor

Choose a reason for hiding this comment

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

merge-base is not a valid environment variable in bash. You cant write ${merge-base} in a script. I'd recommend using merge_base or MERGE_BASE.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason for using GITHUB_ENV here instead of GITHUB_OUTPUT ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a reason for using GITHUB_ENV here instead of GITHUB_OUTPUT ?

Nope, it was just the first data-sharing mechanism I found.
But now that I look at it, I still like it. I don't have to do ${{ steps.step-name.outputs.output-name }}, but can just do ${{ env.merge_base }}.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

merge-base is not a valid environment variable in bash. You cant write ${merge-base} in a script. I'd recommend using merge_base or MERGE_BASE.

It works with merge-base 🤷
I changed it anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! It's true that merge-base works, however, things get annoying if you want to print the value in a bash script for debugging reasons. It's just to prevent our future selves from scratching our heads why ${merge-base} == "base" ;-)

Copy link
Contributor

@aibaars aibaars left a comment

Choose a reason for hiding this comment

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

Perhaps move caching the extractor to a follow-up PR.

uses: actions/cache@v3
with:
path: ruby/extractor-pack
key: ${{ runner.os }}-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}-${{ hashFiles('ruby/**/*.rs') }}
Copy link
Contributor

Choose a reason for hiding this comment

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

If we cache the entire extractor pack then we should also add the other files in the pack to the key.

@erik-krogh erik-krogh merged commit 4f08000 into github:main Nov 21, 2022
- name: Run QL tests
run: |
codeql test run --threads=0 --ram 5000 --slice ${{ matrix.slice }} --search-path "${{ github.workspace }}/ruby/extractor-pack" --check-databases --check-undefined-labels --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --consistency-queries ql/consistency-queries ql/test
codeql test run --threads=0 --ram 52000 --search-path "${{ github.workspace }}/ruby/extractor-pack" --check-databases --check-undefined-labels --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --consistency-queries ql/consistency-queries ql/test --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

@erik-krogh Did you mean to raise the --ram argument to 52G here?

Copy link
Contributor Author

@erik-krogh erik-krogh Nov 22, 2022

Choose a reason for hiding this comment

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

Yes.
That change was based on this comment by Tom further up.

I didn't observe any difference from changing --ram, so it seemed fine to me.

My first solution was just to delete the --ram argument and let CodeQL figure it out for itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants