-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
3rd party tests conditional runs syntax #522
Comments
Nice catch! I think using From what I can tell, if you use In particular, all of the following conditions don't work and always evaluate to true: # Bad: extra characters outside ${{ }}
if: |
# I'm not actually a comment
${{ false }}
# Bad: extraneous blank lines outside ${{ }}
if: >-
${{ false }}
# Bad: trailing newline outside ${{ }}
if: |
${{ false }} But these work: # Good: no issues with single line
if: ${{ false }}
# Good: '-' need to strip trailing newline when using ${{ }}.
# Using `|-` also seems to work.
if: >-
${{
false && 'anything goes here!'
}}
# Good: newlines don't matter when ${{ }} is omitted
if: |
false Here's a workflow run demonstrating all the variants I could think of: https://github.com/brianschubert/typing_extensions/actions/runs/12439837061 workflow fileon: [ push ]
permissions:
contents: read
jobs:
single-line:
runs-on: ubuntu-latest
steps: [ run: true ]
if: ${{ false }}
pipe:
runs-on: ubuntu-latest
steps: [ run: true ]
if: |
${{ false }}
pipe-comment:
runs-on: ubuntu-latest
steps: [ run: true ]
if: |
# foo
${{ false }}
pipe-blank:
runs-on: ubuntu-latest
steps: [ run: true ]
if: |
${{ false }}
pipe-dash:
runs-on: ubuntu-latest
steps: [ run: true ]
if: |-
${{ false }}
pipe-dash-comment:
runs-on: ubuntu-latest
steps: [ run: true ]
if: |-
# foo
${{ false }}
pipe-dash-blank:
runs-on: ubuntu-latest
steps: [ run: true ]
if: |-
${{ false }}
bracket:
runs-on: ubuntu-latest
steps: [ run: true ]
if: >
${{ false }}
bracket-comment:
runs-on: ubuntu-latest
steps: [ run: true ]
if: >
# foo
${{ false }}
bracket-blank:
runs-on: ubuntu-latest
steps: [ run: true ]
if: >
${{ false }}
bracket-dash:
runs-on: ubuntu-latest
steps: [ run: true ]
if: >-
${{ false }}
bracket-dash-comment:
runs-on: ubuntu-latest
steps: [ run: true ]
if: >-
# foo
${{ false }}
bracket-dash-blank:
runs-on: ubuntu-latest
steps: [ run: true ]
if: >-
${{ false }}
omit-single-line:
runs-on: ubuntu-latest
steps: [ run: true ]
if: false
omit-pipe:
runs-on: ubuntu-latest
steps: [ run: true ]
if: |
false
# # Invalid workflow syntax.
# omit-pipe-comment:
# runs-on: ubuntu-latest
# steps: [ run: true ]
# if: |
# # foo
# false
omit-pipe-blank:
runs-on: ubuntu-latest
steps: [ run: true ]
if: |
false
omit-pipe-dash:
runs-on: ubuntu-latest
steps: [ run: true ]
if: |-
false
# # Invalid workflow syntax.
# omit-pipe-dash-comment:
# runs-on: ubuntu-latest
# steps: [ run: true ]
# if: |-
# # foo
# false
omit-pipe-dash-blank:
runs-on: ubuntu-latest
steps: [ run: true ]
if: |-
false
omit-bracket:
runs-on: ubuntu-latest
steps: [ run: true ]
if: >
false
# # Invalid workflow syntax.
# omit-bracket-comment:
# runs-on: ubuntu-latest
# steps: [ run: true ]
# if: >
# # foo
# false
omit-bracket-blank:
runs-on: ubuntu-latest
steps: [ run: true ]
if: >
false
omit-bracket-dash:
runs-on: ubuntu-latest
steps: [ run: true ]
if: >-
false
# # Invalid workflow syntax.
# omit-bracket-dash-comment:
# runs-on: ubuntu-latest
# steps: [ run: true ]
# if: >-
# # foo
# false
omit-bracket-dash-blank:
runs-on: ubuntu-latest
steps: [ run: true ]
if: >-
false
I think the right fix would be to move the "comment" to outside the |
Inspired by
typing-extensions
' third-party tests, we are doing something similar in Pydantic.However, the conditional syntax we used (identical to yours) seems to not be working as expected with GHA. We ended up using the
|
syntax instead, fixed here: pydantic/pydantic#11162.This might be why it was mentioned that the condition did not work as expected in ttps://github.com//pull/226. Happy to fix this.
The text was updated successfully, but these errors were encountered: