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

Fix invalid if condition in Github Actions #10957

Merged
merged 1 commit into from
Sep 23, 2024

Conversation

leonard84
Copy link
Contributor

The value of an if: entry is already an expression block, so usage of ${{ }} is not necessary, except in one rare case (https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/using-conditions-to-control-job-execution).
However, it is easy to accidentally create an invalid condition:
${{ matrix.java-build-tool }} == 'maven' will always evaluate to true, due to a quirk of how nested expression context are evaluated.
Correct is either

  • ${{ matrix.java-build-tool == 'maven' }}
  • matrix.java-build-tool == 'maven'

I've choosen to use the latter as it is simpler.
I've also cleaned up unnecessary use of ${{ }} in other if blocks.

The value of an `if:` entry is already an expression block, so usage of `${{ }}` is not necessary, except in one rare case (https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/using-conditions-to-control-job-execution).
However, it is easy to accidentally create an invalid condition:
`${{ matrix.java-build-tool }} == 'maven'` will always evaluate to true, due to a quirk of how nested expression context are evaluated.
Correct is either
- `${{ matrix.java-build-tool  == 'maven' }}`
- `matrix.java-build-tool == 'maven'`

I've choosen to use the latter as it is simpler. 
I've also cleaned up unnecessary use of `${{ }}` in other if blocks.
@CLAassistant
Copy link

CLAassistant commented Sep 23, 2024

CLA assistant check
All committers have signed the CLA.

@murdos murdos added area: bug 🐛 Something isn't working generator: CI and removed area: triage labels Sep 23, 2024
@leonard84
Copy link
Contributor Author

To see the bug in action, see both

If the condition were working as intended, only one of the cache actions should have been active, and the other would have been skipped.

@murdos murdos merged commit 1954cb4 into jhipster:main Sep 23, 2024
35 checks passed
@murdos
Copy link
Contributor

murdos commented Sep 23, 2024

Thanks @leonard84 for the fix and the explanation.
Much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: bug 🐛 Something isn't working generator: CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants