-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Improve reporting of errors & efficiency of pr-size-labeler #7288
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
Changes from 11 commits
3f4087f
00bcb65
095cf41
5a71671
96b050c
36ec815
16b6020
15424d1
544afab
8c90b02
d6de407
37bf2f6
5720edd
747fd6a
fc7d3dc
0b6c8a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -37,9 +37,9 @@ on: | |||||||||
description: 'The PR number of the PR to label:' | ||||||||||
type: string | ||||||||||
required: true | ||||||||||
token: | ||||||||||
description: 'Token to use for authentication:' | ||||||||||
type: string | ||||||||||
trace: | ||||||||||
description: 'Turn on shell script debugging' | ||||||||||
type: boolean | ||||||||||
|
||||||||||
# Declare default permissions as read only. | ||||||||||
permissions: read-all | ||||||||||
|
@@ -55,15 +55,19 @@ jobs: | |||||||||
pull-requests: write | ||||||||||
env: | ||||||||||
PR_NUMBER: ${{inputs.pr-number || github.event.pull_request.number}} | ||||||||||
SHELLOPTS: ${{inputs.trace && 'xtrace' || '' }} | ||||||||||
steps: | ||||||||||
- name: Check out a copy of the git repository | ||||||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||||||||||
with: | ||||||||||
sparse-checkout: | | ||||||||||
./dev_tools/ci/size-labeler.sh | ||||||||||
|
||||||||||
- name: Label the PR with a size label | ||||||||||
id: label | ||||||||||
continue-on-error: true | ||||||||||
env: | ||||||||||
GITHUB_TOKEN: ${{inputs.token || github.token}} | ||||||||||
GITHUB_TOKEN: ${{github.token}} | ||||||||||
run: ./dev_tools/ci/size-labeler.sh |& tee action.out | ||||||||||
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. The pipe here masks the exit status from size-labeler.sh. PS: Or consider deleting the 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.
I don't believe that's necessary; according to https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#defaultsrunshell the default Bash invocation used by GitHub runners is bash --noprofile --norc -eo pipefail {0} 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.
I can't see any other reason why would labeler workflow report success at https://github.com/quantumlib/Cirq/actions/runs/14654500719/job/41127085113. The script terminated at the Cirq/dev_tools/ci/size-labeler.sh Lines 217 to 220 in 747fd6a
On a second look, the shell command is actually listed as /usr/bin/bash -e {0}, which is one of the possibilities in your link. Regardless of that, the final step just repeats the size-labeler.sh output and is not really necessary. The output of this workflow is not important to contributors and is not worth the extra complexity and space for bugs like we get here. Please consider taking it out and just have a simple execution of size-labeler.sh. PS: if size-labeler remains flaky, we should intentionally let it report success, e.g.,
so that contributors are not confused by CI failure that has nothing to do with their work. 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.
You're right! And now reading the GitHub docs, I think I understand what's happening: it seems that if there is no Anyway, I'll change it as you propose. |
||||||||||
|
||||||||||
- name: Detect and report errors in labeler action | ||||||||||
|
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.
is this used anywhere? If not please delete.
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.
Yes, it is. The environment variable is recognized by Bash: https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html#index-SHELLOPTS
Here what's happening is that when the Boolean
trace
is set by usingworkflow_dispatch
, it causes SHELLOPTS to get the valuextrace
. That's the same as usingset -x
: https://www.gnu.org/software/bash/manual/bash.html#index-set. Since the environment variable is set at the job level, all invocations get the SHELLOPTS value. The result is that all the Bash scripts and commands in the workflow get the equivalent ofset -x
, and thus output a trace of their steps. This is useful for debugging.The beauty of this approach is that it doesn't require modifying any of the
run:
commands to addset -x
, and it can be turned on and off at run time.