Rewrite contexts before evaluating them#287
Merged
cplee merged 5 commits intonektos:masterfrom Jun 24, 2020
Merged
Conversation
Contributor
|
@badouralix - this is freaking awesome...how can i help? |
The current contextPattern is quite constraining and would fail the rewrite of a context with trailing spaces. Triming happens during the execution of Interpolate, and these tests aim to detect future breaking changes on this behavior.
6d75931 to
d7eec0a
Compare
cplee
approved these changes
Jun 24, 2020
Contributor
cplee
left a comment
There was a problem hiding this comment.
thanks for the contribution!
|
🙌 thank you! |
|
Can you cut a new release with this? |
|
yes please release |
Contributor
|
@justincy @myselfhimself - new release |
|
Perfect I will test against expressions like |
|
Fix confirmed thanks! |
This was referenced Nov 17, 2020
This was referenced Nov 18, 2020
Merged
Merged
Closed
github-actions(deps): bump shivammathur/setup-php from 2.5.0 to 2.8.0
ffflabs/php_library_example#38
Closed
Closed
Closed
github-actions(deps): bump shivammathur/setup-php from 2.7.0 to 2.8.0
mimmi20/ua-generic-request#127
Merged
Merged
github-actions(deps): bump shivammathur/setup-php from 2.7.0 to 2.8.0
Lctrs/php-library-skeleton#209
Merged
github-actions(deps): bump shivammathur/setup-php from 2.7.0 to 2.8.0
OskarStark/env-var-extension#6
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR aims to fix #104. In a nutshell,
actuses a javascript virtual machine to interpret and evaluate expressions in github actions. It works pretty well, except for expressions likeobject.property-with-hyphenswhich are correctly handled by github action runners, but not by the javascript vm.This solution is heavily inspired by #104 (comment) written by @Shadowfiend, although the implementation diverged a little bit from the initial proposal. The idea is to tweak just a little bit the expression and transform it into
object['property-with-hyphens']which is both github actions and javascript compliant.To do so, we introduce the
Rewritemethod which job is exactly the one described above, and we call it just before evaluating the expression in the javascript vm.Explanations
That being said, using regex for this rewriting is really hard to get right !
Here is a snapshot of what I tried...
One thing to keep in mind is that not all
.nor not all-are bad. For instance we do not want to rewrite filenames with extension.But also, we would need to identify strings, escaped characters, already-bracketed expressions, recursive expressions, etc.
So let's keep it simple for now. We choose to only rewrite contexts, which is a subset of expressions
https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#contexts
The pattern defines three groups, as described below :
Here is the execution of the method step by step with
in := "ecole.centrale.paris". See also https://play.golang.org/p/bu2rO817ycUBefore entering the loop
re"ecole.centrale.paris"First iteration
matches[0]"ecole.centrale.paris"matches[1]"ecole"matches[2]"centrale"matches[3]".paris"re"ecole['centrale'].paris"Second iteration
matches[0]"ecole['centrale'].paris"matches[1]"ecole['centrale']"matches[2]"paris"matches[3]""re"ecole['centrale']['paris']"Third iteration
matches[0]"ecole['centrale']['paris']"matches[1]"ecole['centrale']['paris']"matches[2]""matches[3]""re"ecole['centrale']['paris']"Here we trigger the break condition and the function returns
Testing
Before the fix :
After the fix :
References