case() function's requirement for pure booleans instead of coercible booleans is incredibly frustrating
#185992
-
Why are you starting this discussion?Product Feedback What GitHub Actions topic or product is this about?Actions Runner Discussion DetailsHere's my first attempt at applying The extra Here's my hopefully final first attempt at applying It wasn't. This is the "best" code improvement -- note that it's getting close to hardly an improvement: - ${{
- inputs.task == 'comment' &&
- github.event.issue.pull_request &&
- github.event.pull_request.base.sha ||
- github.event_name == 'issue_comment' &&
- github.event.issue.pull_request &&
- github.event.pull_request.head.sha ||
- ''
+ ${{ case(
+ inputs.task == 'comment' && !!github.event.issue.pull_request,
+ github.event.pull_request.base.sha,
+ github.event_name == 'issue_comment' && !!github.event.issue.pull_request,
+ github.event.pull_request.head.sha,
+ ''
+ )
}}This isn't terrible: - fetch-depth: ${{ !contains(inputs.check_commit_messages, 'commits') && '1' || '0' }}
- filter: ${{ contains(inputs.check_commit_messages, 'commits') && 'tree:0' || '' }}
+ fetch-depth: ${{ case(contains(inputs.check_commit_messages, 'commits'), '0', '1') }}
+ filter: ${{ case(contains(inputs.check_commit_messages, 'commits'), 'tree:0', '') }}These all smell: - ${{ inputs.report_title_suffix && format('{0}-{1}', 'check-spelling-comment', inputs.report_title_suffix) || 'check-spelling-comment' }}
+ ${{ case(inputs.report_title_suffix != '', format('{0}-{1}', 'check-spelling-comment', inputs.report_title_suffix), 'check-spelling-comment') }}- name: ${{ inputs.report_title_suffix && format('{0}-{1}', 'check-spelling-sarif', inputs.report_title_suffix) || 'check-spelling-sarif' }}
+ name: ${{ case(inputs.report_title_suffix != '', format('{0}-{1}', 'check-spelling-sarif', inputs.report_title_suffix), 'check-spelling-sarif') }}This should smell (but doesn't because the original code had an at the time superfluous - wait-for-processing: ${{ inputs.wait-for-sarif-processing != '' && inputs.wait-for-sarif-processing || 'false' }}
+ wait-for-processing: ${{ case(inputs.wait-for-sarif-processing != '', inputs.wait-for-sarif-processing, 'false') }}smells: - category: ${{ inputs.report_title_suffix && format('{0}-{1}', 'check-spelling', inputs.report_title_suffix) || 'check-spelling' }}
+ category: ${{ case(inputs.report_title_suffix != '', format('{0}-{1}', 'check-spelling', inputs.report_title_suffix), 'check-spelling') }}This is worse than what it started with: - trace: ${{ (inputs.debug || github.run_attempt > 1) && '1' || '' }}
+ trace: ${{ case((inputs.debug || github.run_attempt > 1) && true, '1', '') }}smelly: - default: ${{ matrix && toJson(matrix) || '' }}
+ default: ${{ case(!!matrix, toJson(matrix), '') }}The failure mode for this is also absolutely lousy. I had random workflows die and it's taken a bunch of iterations to hopefully catch all of the cases where I was relying on coercion that used to work and now doesn't. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
💬 Your Product Feedback Has Been Submitted 🎉
Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users.
Here's what you can expect moving forward ⏩