-
Notifications
You must be signed in to change notification settings - Fork 964
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
Conditional operator or function for expression syntax #409
Comments
Another alternative syntax could be:
like CircleCI. |
It seems, although not identical, |
Syntax: fake ternary example steps:
- name: stuff
env:
PR_NUMBER_OR_MASTER: ${{ github.event.number == 0 && 'master' || format('pr-{0}', github.event.number) }} on condition is that your first |
I don't like this but it seems there's no way to conditionally set the environment variable. See also actions/runner#409 Will possibly change to conditional steps later.
* Start running with Intel compiler * Use correct compiler command I don't like this but it seems there's no way to conditionally set the environment variable. See also actions/runner#409 Will possibly change to conditional steps later. * Remember Intel-related parameters The scripts set the PATH (and maybe other variables?) but those are not preserved across steps. Since the build step is becoming more distinct between the two compilers, let's try splitting it in two conditional ones. * Try caching Intel installation * Look for Intel libraries before tests * Try to cache whole directory * Allow running tests with MPI * Fix syntax * Install MPI compilers when needed * Try to force use of ifort with MPI By default, the Intel version of mpif90 uses gfortran. We can either switch to using mpiifort instead, or try to control the underlying compiler this way. See also, for example: https://www.hpc.cineca.it/center_news/important-use-intel-mpi-wrappers-mpif90-mpicc-mpicxx * Make sure cache names don't clash with/without MPI * Update variables so MKL and BLACS can be found * Fix MKL installation * Show some more info and build faster on CI * Only use one MPI process on CI for debugging See if the error still happens when testing. * Avoid reading from stdin * Build faster on CI with gfortran * Avoid segmentation fault with quick gfortran build This reverts commit b8413c6. * Replicate execution on cluster temporarily Adding the mpiio option may be required for now but will eventually be removed. * Don't test file_intensity with MPI It's currently failing when run with MPI and > 1 processes (not just on GitHub Actions, also on CSD3). * Simplify USE_MPI in Makefile and CI Now behaving similar to the other Makefile variables. This also lets us make the GitHub Actions job a bit simpler. * Don't install MKL twice when using MPI, clean up
Example use case https://github.com/TWiStErRob/net.twisterrob.gradle/pull/136/files |
The fact that in a year no one said a word about this, means that the team isn't interested in following up on this one? |
A note about the workaround This only works if |
Seems that there is already an approach https://docs.github.com/en/actions/learn-github-actions/expressions#example env:
MY_ENV_VAR: ${{ github.ref == 'refs/heads/main' && 'value_for_main_branch' || 'value_for_other_branches' }} I think this issue can be closed. |
@islishude you |
Interesting, you saying I can't comment, is the comment illegal?
|
It's good to see GitHub embracing the workaround as a stop-gap, they even mention its limitation in the docs @islishude linked. On one hand it's good they added it, because at least now it's easier to discover, but on the other hand I do hope it doesn't mean they consider ternary "supported". It would be great to get some official response from GitHub staff. 🤔 |
It's ridiculous that we do not have ternary operator and this issue is 3+ y.o. |
Correct answer for booleans |
The docs state, "In this example, we're using a ternary operator to set the value of the
Great exposition on just why this is a poor solution: https://7tonshark.com/posts/github-actions-ternary-operator/ |
Thank you for your interest in the runner application and taking the time to provide your valuable feedback. We kindly ask you to redirect this feedback to the GitHub Community Support Forum which our team actively monitors and would be a better place to start a discussion for new feature requests in GitHub Actions. For more information on this policy please read our contribution guidelines. 😃 |
Looks more as unsolved than "completed" |
Couldn't find an existing thread there so I created one: https://github.com/orgs/community/discussions/75928 |
See actions/runner#409 (comment) on true value needs to evaluate to true
Describe the enhancement
I'd like some kind of conditional operation added to expression syntax. This can be an actual ternary operator (
?
:
) or a built-in function (e.g.,if(<condition>, <true-value>, <false-value>)
).Additional information
There is a workaround: using shell scripts to evaluate the condition, setting step outputs, and having other steps reference those outputs. But it would be much cleaner to have some kind of ternary / if/then/else / conditional branching built in to the expression syntax.
The text was updated successfully, but these errors were encountered: