fix: allow yaml anchors - #5893
Conversation
* GitHub Actions finally supports them
🦙 MegaLinter status: ✅ SUCCESS
See detailed report in MegaLinter reports |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5893 +/- ##
==========================================
+ Coverage 74.65% 74.74% +0.08%
==========================================
Files 73 73
Lines 11139 11193 +54
==========================================
+ Hits 8316 8366 +50
- Misses 2186 2190 +4
Partials 637 637 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| job-with-condition: | ||
| runs-on: &label | ||
| self-hosted | ||
| if: success() || success('joba', 'jobb') || failure() || failure('joba', 'jobb') || always() || cancelled() |
There was a problem hiding this comment.
We may want to remove this if, since the parameters of success are removed (except from the schema)
| if: success() || success('joba', 'jobb') || failure() || failure('joba', 'jobb') || always() || cancelled() |
|
At the moment still broken, expressions inside anchors. EvaluateYamlNode needs updates as well to evaluate *os action expressions. on: push
jobs:
_:
runs-on: ubuntu-latest
strategy:
matrix:
os:
- &os ${{ github.event_name }}
- *os
- *os
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run Tests
run: echo 'Running tests... ${{ matrix.os }}' |
|
Broken as well jobs:
_:
runs-on: ubuntu-latest
strategy:
matrix:
on: &matrix [push, pull_request]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run Tests
run: echo 'Running tests...'
on: *matrix |
| if node != nil && node.Kind == yaml.DocumentNode { | ||
| return s.UnmarshalYAML(node.Content[0]) | ||
| } | ||
| if node.Kind == yaml.AliasNode { |
There was a problem hiding this comment.
| if node.Kind == yaml.AliasNode { | |
| if node != nil && node.Kind == yaml.AliasNode { |
to match the if above so you don't crash on nil
There was a problem hiding this comment.
or maybe just return an error if nil is passed in since checkExpression a few lines down would just crash next
There was a problem hiding this comment.
I have checked this yaml in a test
func TestNull(t *testing.T) {
var node yaml.Node
err := yaml.Unmarshal([]byte(`
on: push
jobs:
job-with-condition:
runs-on: self-hosted
steps:
-
`), &node)
if !assert.NoError(t, err) {
return
}
err = (&Node{
Definition: "workflow-root-strict",
Schema: GetWorkflowSchema(),
}).UnmarshalYAML(&node)
assert.NoError(t, err)
}Shows a non zero node passed with !null tag, by nested elements. I assume this can not crash at all.
|
After more consideration, due to yaml anchor problems across the codebase. I am going to discard this PR in favor of https://patch-diff.githubusercontent.com/raw/actions-oss/act-cli/pull/126.patch, it is better to explode yaml anchors right away that fixes a lot of other bugs documented here. |
|
would love to see a tracking issue for this @ChristopherHX if you don't mind |

See actions/runner#1182 (comment)