+
Skip to content

template-injection: add subfeatures #958

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

Merged
merged 11 commits into from
Jun 23, 2025
Merged

Conversation

woodruffw
Copy link
Member

Following #949.

Signed-off-by: William Woodruff william@yossarian.net

Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
@woodruffw woodruffw self-assigned this Jun 20, 2025
@woodruffw woodruffw added the enhancement New feature or request label Jun 20, 2025
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
@woodruffw
Copy link
Member Author

woodruffw commented Jun 20, 2025

I still need to de-regress #569 with this change:

template-injection failed on reusable-tsan.yml

Caused by:
    failed to find subfeature 'fromJSON(inputs.free-threading)
        && '_free_threading'
        || ''
      ' in feature '|
            echo "TSAN_OPTIONS=log_path=${GITHUB_WORKSPACE}/tsan_log suppressions=${GITHUB_WORKSPACE}/Tools/tsan/suppressions${{
                fromJSON(inputs.free-threading)
                && '_free_threading'
                || ''
              }}.txt handle_segv=0" >> "$GITHUB_ENV"
            echo "CC=clang" >> "$GITHUB_ENV"
            echo "CXX=clang++" >> "$GITHUB_ENV"'

This is caused by the subfeature having multiple lines, which don't match the exact substring on the YAML side (since the extracted YAML feature has extra indentation to make it syntactically correct). The subfeature on the other hand comes from the parsed YAML, so we don't see the indentation difference until it's too late.

I'll need to think about the best way to handle this -- it's interestingly non-trivial because the YAML feature equivalent of the subfeature is actually longer/has more bytes in it.

Edit: Thinking out loud: one idea is to match the span on the first line, allow all intermediate lines, and then match the span on the final line. Not pretty, but doesn't require any special normalization or other steps that would mess with the concrete feature.

Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
@woodruffw
Copy link
Member Author

De-regressed, but I'm not very happy with how brittle the approach is. I need to think about it more.

@woodruffw
Copy link
Member Author

woodruffw commented Jun 22, 2025

I thought of another solution to this, one that should be less brittle: instead of trying to match the "head" and "tail" of the subfeature's fragment, we could support pattern-style fragments that accept differences in whitespace.

This would still be mostly useful only in the case of multi-line subfeature fragments, but would allow us to transform a fragment like this:

foo.bar
  && abc
  || def

into:

foo\.bar\s+&&\s+abc\s+||\s+def

...which would then match correctly, regardless of how the subfeature is indented on the YAML syntax side of things.

This should be pretty easy to do by walking an Expr<'src> and building up a Regex with the appropriate APIs from the regex crate (incl. regex::escape).

Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
@woodruffw woodruffw merged commit 4615ee2 into main Jun 23, 2025
8 checks passed
@woodruffw woodruffw deleted the ww/template-injection-subfeatures branch June 23, 2025 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载