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

Refactor expression evaluator to use parser from actionlint package #908

Merged
merged 5 commits into from
Jan 21, 2022

Conversation

ZauberNerd
Copy link
Contributor

@ZauberNerd ZauberNerd commented Nov 29, 2021

This is an early draft to showcase the general direction we're going with this change.

We will of course rebase the commits, so that we can create separate PRs for the preparation-changes (refactoring of contexts, etc).

Also there's still a few TODO comments that we have to resolve before this PR is ready to merge.

Anyways, feedback is welcome :)

Next steps:

  • manually track position in evaluator (actionlint parser gives us only the starting position of a token, but we need to know how far we've parsed)
  • extend toString to be able to print all types
  • get act tests to pass with the exprparser package
  • clean-up errors, todos, tests, etc

@mergify

This comment has been minimized.

@mergify mergify bot added the needs-work Extra attention is needed label Nov 29, 2021
@catthehacker
Copy link
Member

I think model is better place than common for contexts and stepresults

@mergify

This comment has been minimized.

@mergify mergify bot added the conflict PR has conflicts label Dec 8, 2021
@mergify mergify bot removed the conflict PR has conflicts label Dec 9, 2021
@mergify

This comment has been minimized.

@mergify

This comment has been minimized.

@mergify

This comment has been minimized.

1 similar comment
@mergify

This comment has been minimized.

@mergify

This comment has been minimized.

@mergify

This comment has been minimized.

@mergify

This comment has been minimized.

@mergify

This comment has been minimized.

@mergify

This comment has been minimized.

@mergify

This comment has been minimized.

1 similar comment
@mergify

This comment has been minimized.

@mergify

This comment has been minimized.

@ChristopherHX
Copy link
Contributor

Ah I got it, you forget to escape ${test} to ${{test}}, during conversion from multiple expressions to a big format expression

@mergify mergify bot removed the conflict PR has conflicts label Dec 22, 2021
@mergify

This comment has been minimized.

@mergify mergify bot added the needs-work Extra attention is needed label Dec 22, 2021
@mergify
Copy link
Contributor

mergify bot commented Dec 22, 2021

@ZauberNerd this pull request has failed checks 🛠

@ChristopherHX
Copy link
Contributor

@ZauberNerd @KnisterPeter
Can you please add this commit to your PR? ChristopherHX@312d395
This fixes the two things I mentioned today.
Github actions don't fail to evaluate on most errors, like access undefined map property.
However invalid json string in fromJSON and an invalid format string does fail your workflow.

@mergify
Copy link
Contributor

mergify bot commented Dec 22, 2021

@ZauberNerd this pull request has failed checks 🛠

@ZauberNerd
Copy link
Contributor Author

@ChristopherHX I think something with inputs and secrets broke while rebasing against master and now TestRunEvent/uses-nested-composite and TestRunEvent/local-action-via-composite-dockerfile are failing.
I guess it is related to this change: 9868e13#diff-4fe45e900ed33a3395bb42c8d8a85c1afb94987b2368bfe31d62e9e1ebd69060R449-R579 which I tried to incorporate here:

secrets := rc.Config.Secrets
if rc.Composite != nil {
secrets = nil
}
ee := &exprparser.EvaluationEnvironment{
Github: rc.getGithubContext(),
Env: rc.GetEnv(),
Job: rc.getJobContext(),
// todo: should be unavailable
// but required to interpolate/evaluate the step outputs on the job
Steps: rc.getStepsContext(),
Runner: map[string]interface{}{
"os": "Linux",
"temp": "/tmp",
"tool_cache": "/opt/hostedtoolcache",
},
Secrets: secrets,
and here:
Inputs: rc.Inputs,

Since you made some changes there, do you have an immediate idea what I'm doing wrong?

@ChristopherHX
Copy link
Contributor

I'm debugging it carefully, there are expression evaluation errors in the log. Some values are empty.

@ChristopherHX
Copy link
Contributor

@ZauberNerd The inputs context is always available, also on workflowlevel see reusable workflows.
The error was, that the inputs context was empty on runcontext level.
ChristopherHX@4c99bd7

@mergify mergify bot removed the needs-work Extra attention is needed label Dec 22, 2021
@ZauberNerd
Copy link
Contributor Author

The last open item (wrong implementation of contains()) has been fixed. Please take another look.
/cc @catthehacker @cplee

Copy link
Member

@catthehacker catthehacker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that massive work, I tried to review whole PR carefully and so far it seems good to me

@mergify mergify bot requested a review from a team January 6, 2022 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants