dongjoon-hyun commented on code in PR #60434:
URL: https://github.com/apache/spark/pull/60434#discussion_r4588927761
##########
.github/workflows/build_infra_images_cache.yml:
##########
@@ -52,7 +52,19 @@ on:
workflow_dispatch:
jobs:
main:
- if: github.repository == 'apache/spark'
+ if: >-
+ github.repository == 'apache/spark' &&
+ (
+ github.event_name != 'create' ||
+ (
+ github.ref_type == 'branch' &&
+ (github.ref_name == 'master' || startsWith(github.ref_name,
'branch-'))
Review Comment:
**[1] A created ref with `/` still passes the prefix checks, so every build
would fail as before.**
`startsWith` checks only the beginning of the name, so creating a branch
such as `branch-4.4/rc-prep`, or a tag such as `v5.0.0/test`, still runs the
job. Every build step puts `${{ github.ref_name }}` into its image tag and
cache refs, so all 12 builds would fail with the same `invalid reference
format` error as the run linked in the PR description. The `push` filter above
does not admit such names, because `*` in `branch-*` does not match `/`.
The [AI
review](https://github.com/apache/spark/pull/60434#pullrequestreview-5887253742)
notes this case and does not count it as a defect, since the release branches
and tags contain no `/` today. I agree it is unlikely, but `/` is the usual
separator in tool-made branch names: besides `dependabot/`, this workflow's
`create` runs this year include `codex/`, `feature/` and
`infrastructure-ruleset-bot/` branches. Would it be worth guarding on the
character itself, which would also make the condition consistent with the
`push` filter? For example:
```yaml
if: >-
github.repository == 'apache/spark' &&
(
github.event_name != 'create' ||
(
!contains(github.ref_name, '/') &&
(
(github.ref_type == 'branch' && startsWith(github.ref_name,
'branch-')) ||
(github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))
)
)
)
```
This sketch also leaves out the `master` comparison, see [2].
##########
.github/workflows/build_infra_images_cache.yml:
##########
@@ -52,7 +52,19 @@ on:
workflow_dispatch:
jobs:
main:
- if: github.repository == 'apache/spark'
+ if: >-
+ github.repository == 'apache/spark' &&
+ (
+ github.event_name != 'create' ||
+ (
+ github.ref_type == 'branch' &&
+ (github.ref_name == 'master' || startsWith(github.ref_name,
'branch-'))
Review Comment:
**[2] nit: the `master` comparison cannot match a `create` event in
practice.**
`create` fires only when a branch or tag is created, and `master` is the
default branch, which cannot be deleted while it is the default. So `branch-*`
names are the only branches that can pass here, and `github.ref_type ==
'branch' && startsWith(github.ref_name, 'branch-')` behaves the same. Would it
be clearer to drop the comparison? The PR description could then say `branch-*`
branches and `v*` tags.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]