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

[Core feature request] Support operators for type-safe expressions #372

Open
Vampire opened this issue Jul 29, 2022 · 4 comments
Open

[Core feature request] Support operators for type-safe expressions #372

Vampire opened this issue Jul 29, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@Vampire
Copy link
Collaborator

Vampire commented Jul 29, 2022

What feature do you need?
https://docs.github.com/en/actions/learn-github-actions/expressions#operators
It would be nice if you could construct more complex expressions using operators with the type-safe expr API.
One way would be to model them as explicit functions like expr { and(always(), success()) } to get ${{ always() && success() }}.
An even nicer way would of course be if operator overloading is used, so that you can actually do expr { always() && success() }} instead.
Those ways also need to support some way of textual input to support not yet supported contexts like step outcome, or matrix values.

Do you have an example usage?

if: always() && (steps.execute_action.outcome == 'success')

Is there a workaround for not having this feature? If yes, please describe it.
Work-around is to not use the type-safe API, but simple strings.

@Vampire Vampire added the enhancement New feature or request label Jul 29, 2022
@Vampire
Copy link
Collaborator Author

Vampire commented Apr 11, 2023

Another example:
https://stackoverflow.com/a/72408109/16358266 suggests to use

group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

It would be nice to be able to model it like

group = "${expr { github.workflow }}-${expr { github.eventPullRequest.pull_request.number || github.ref }"

instead of

group = "${expr { github.workflow }}-${expr("${github.eventPullRequest.pull_request.number} || ${github.ref}")}"

@LouisCAD
Copy link
Contributor

One nice thing about this is that it could allow for better checks beyond the expression itself.

For example when using job.result, it could runtime check that the job A whose job B is using the result is declared in the needs of job B.

Runtime check here is better than GitHub's post-commit runtime check, and almost as good as a compile-time check (I guess we can say the Kotlin script Workflow compiles to YAML in a way).

@Vampire
Copy link
Collaborator Author

Vampire commented Nov 20, 2023

it could runtime check that the job A whose job B is using the result is declared in the needs of job B.

Or it could maybe even auto-needs it.

@LouisCAD
Copy link
Contributor

True, would be even better!

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

No branches or pull requests

2 participants