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

Go: update make and CI to use bazel #16398

Merged
merged 7 commits into from
May 13, 2024
Merged

Go: update make and CI to use bazel #16398

merged 7 commits into from
May 13, 2024

Conversation

redsun82
Copy link
Contributor

@redsun82 redsun82 commented May 2, 2024

No description provided.

@github-actions github-actions bot added the Go label May 2, 2024
@redsun82 redsun82 added the depends on internal PR This PR should only be merged in sync with an internal Semmle PR label May 2, 2024
@redsun82 redsun82 changed the base branch from main to redsun82/go May 2, 2024 11:09
@redsun82 redsun82 changed the title Redsun82/go make Go: update make and CI to work with bazel May 2, 2024
@redsun82 redsun82 changed the title Go: update make and CI to work with bazel Go: update make and CI to use bazel May 2, 2024
@redsun82 redsun82 mentioned this pull request May 6, 2024
Base automatically changed from redsun82/go to main May 6, 2024 14:56
@redsun82 redsun82 marked this pull request as ready for review May 6, 2024 15:43
@redsun82 redsun82 requested a review from a team as a code owner May 6, 2024 15:43
@redsun82 redsun82 requested a review from mbg May 6, 2024 15:44
@redsun82 redsun82 removed the depends on internal PR This PR should only be merged in sync with an internal Semmle PR label May 7, 2024
Copy link
Member

@mbg mbg left a comment

Choose a reason for hiding this comment

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

Thank you for separating this out in its own PR! Mostly looks good: I have a few minor points, and a couple of questions/suggestions for possibly improving the developer experience.

go/actions/test/action.yml Outdated Show resolved Hide resolved
go/actions/test/action.yml Outdated Show resolved Hide resolved
go/actions/test/action.yml Outdated Show resolved Hide resolved
Comment on lines 34 to 50
- name: Check that all Go code is autoformatted
if: inputs.run-code-checks == 'true'
shell: bash
run: |
cd go
make check-formatting

- name: Check checked-in generated code
if: inputs.run-code-checks == 'true'
shell: bash
run: |
bazel run go:gen
git add .
git diff --exit-code HEAD || (
echo "please run bazel run //go:gen"
exit 1
)
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to change the conditions to inputs.run-code-checks == 'true' && always() so that they run, even if a previous step failed? That way the checks would be performed, even if the build / a previous check fails and save us from potentially needing multiple CI runs / incremental fixes. (Would need to check that the proposed conditions work as intended, since always() is sort of magical.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion, but I guess that this shouldn't be required if we move this check up as you suggested

Copy link
Member

Choose a reason for hiding this comment

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

I think it would probably still make sense to have for the "Check checked-in generated code" step, since it would be nice to run it even if "Check that all Go code is autoformatted" fails so that potentially two issues can become apparent from one CI run.

Copy link
Contributor Author

@redsun82 redsun82 May 8, 2024

Choose a reason for hiding this comment

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

Indeed. As far as I know the correct magic github action incantation to get that is !cancelled() (as otherwise always() would run even when the workflow got cancelled, which is not ideal, and cancellation is forcibly done any way after a short timeout)

)

- name: Compile qhelp files to markdown
if: inputs.run-code-checks == 'true'
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, this on the other hand might make sense to render independent... but maybe we could do that with a separate parallel job?

Copy link
Member

Choose a reason for hiding this comment

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

A separate parallel job would work, too. The downside to doing that may be that it requires the overhead of checking out the repo on a separate runner. It's a question of whether we care about that overhead or not. I have no strong opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up keeping it here, as there was also the go setup being required, which I prefer having shared here with one place where the go version should be updated.

env QHELP_OUT_DIR=qhelp-out make qhelp-to-markdown

- name: Upload qhelp markdown
if: inputs.run-code-checks == 'true'
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

- name: Build
shell: bash
run: |
bazel run go:create-extractor-pack
Copy link
Member

Choose a reason for hiding this comment

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

It may be good to add a comment here noting that this explicitly does not run make (and therefore no bazel run :gen) because we want generated files to be checked-in. This uses whatever is checked-in for the extractor pack and the later check then complains if the generated files aren't up-to-date.

Related question: Might we want the "Check checked-in generated code" step to take place before "Build" to fail the build if the generated files are not up-to-date, rather than performing this step with whatever is checked-in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, yeah, it makes sense to do that I think, thanks!

Copy link
Collaborator

@criemen criemen left a comment

Choose a reason for hiding this comment

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

LGTM, but I'll defer to the go team for approval on this.

go/actions/test/action.yml Outdated Show resolved Hide resolved
go/actions/test/action.yml Outdated Show resolved Hide resolved
@redsun82 redsun82 requested a review from mbg May 8, 2024 13:28
Copy link
Member

@mbg mbg left a comment

Choose a reason for hiding this comment

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

LGTM, thank you ✨

@redsun82 redsun82 merged commit c30ca4d into main May 13, 2024
12 checks passed
@redsun82 redsun82 deleted the redsun82/go-make branch May 13, 2024 06:37
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.

3 participants