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

YAML references aren't supported, but aren't caught by action-validator #70

Open
sourcefrog opened this issue Jan 26, 2024 · 1 comment
Labels
pr-welcome This would be a good fix/feature, but the maintainer isn't planning on doing the work

Comments

@sourcefrog
Copy link

In sourcefrog/cargo-mutants@b7cdf07 I tried using YAML references to reduce duplication:

diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index eaafc66..1169d22 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -4,11 +4,8 @@ permissions:
   contents: read
 
 on:
-  push:
-    branches:
-      - main
   pull_request:
-    paths:
+    paths: &test_affecting_paths
       - ".cargo/*.toml"
       - ".github/workflows/tests.yml"
       - "Cargo.*"
@@ -16,6 +13,10 @@ on:
       - "src/**"
       - "testdata/**"
       - "tests/**"
+  push:
+    branches:
+      - main
+    paths: *test_affecting_paths
 
 # see https://matklad.github.io/2021/09/04/fast-rust-builds.html
 env:

GitHub rejects this with

Invalid workflow file: .github/workflows/tests.yml#L1
The workflow is not valid. .github/workflows/tests.yml: Anchors are not currently supported. Remove the anchor 'test_affecting_paths'

but action-validator says nothing about it.

@mpalmer
Copy link
Owner

mpalmer commented Jan 26, 2024

GitHub's half-baked YAML parser strikes again...

Given how much of a basic feature YAML anchors/references are, there's no way to tell the Rust YAML parser to not support them (per #7). Thus, the only way to implement this would be to either do a quick pre-check of the file for "things that look like anchors/references" (which seems prone to false-positives), or else write a custom YAML parser that more closely imitated GitHub's broken implementation (which is rather a lot of work). Adding another 👍 to the actions/runner issue for anchors support probably won't help anything, but it's unlikely to make the issue any worse...

As this is the second time this has come up, I'll leave this issue open with a pr-welcome tag, just in case someone gets a rush of blood to the head, but it's too big a chunk of work for me to take on at the moment.

@mpalmer mpalmer added the pr-welcome This would be a good fix/feature, but the maintainer isn't planning on doing the work label Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-welcome This would be a good fix/feature, but the maintainer isn't planning on doing the work
Projects
None yet
Development

No branches or pull requests

2 participants