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

Explicitly define what is allowed for a composite action #605

Merged
merged 15 commits into from
Jul 28, 2020

Conversation

ethanchewy
Copy link
Contributor

@ethanchewy ethanchewy commented Jul 20, 2020

In this PR, we explicitly define what is allowed for our composite action feature.

For each composite run step, we explicitly remove support for if, timeout-minutes, and continue-on-error. We'll support, id, shell, run, working-directory, and env all of which are optional except for run.

We don't want the defaults to flow to the composite action. Here is proof of them not flowing: https://github.com/ethanchewy/testing-actions/runs/895343022?check_suite_focus=true

Here is an example of the step level working-directory and env working: https://github.com/ethanchewy/testing-actions/runs/896147997?check_suite_focus=true

Shell requirement: https://github.com/ethanchewy/testing-actions/actions/runs/184525896

Example outputs demo working with explicit parameters: https://github.com/ethanchewy/testing-actions/runs/915495023?check_suite_focus=true

ID Context Expressions Not Allowed: https://github.com/ethanchewy/testing-actions/actions/runs/184536224, https://github.com/ethanchewy/testing-actions/actions/runs/184534064

Shell expression not allowed: https://github.com/ethanchewy/testing-actions/runs/915600890

@ethanchewy ethanchewy marked this pull request as draft July 20, 2020 21:43
@ethanchewy ethanchewy changed the title Explicitly define what is allowed for a composite action (In Progress) Explicitly define what is allowed for a composite action Jul 20, 2020
@ethanchewy ethanchewy changed the title (In Progress) Explicitly define what is allowed for a composite action (In Progress) Explicitly define what is allowed for a composite action + build in defaults Jul 21, 2020
@ethanchewy ethanchewy changed the title (In Progress) Explicitly define what is allowed for a composite action + build in defaults (In Progress) Explicitly define what is allowed for a composite action Jul 21, 2020
@ethanchewy
Copy link
Contributor Author

Tested if the defaults shell and working-dir values override the composite action steps' shell and working-dir. They do not override the steps inside of a composite action's shell or working-dir. This is want we want because we want the workflow to have no influence over the composite action in terms of defaults.

Why does this already work?

We don't check the ExecutionContext.Global.JobDefaults in ScriptHandler.cs unless the ExecutionContext.ScopeName is null for both the shell and working-dir:

cc @ericsciple

@ethanchewy
Copy link
Contributor Author

Originally had planned to just null the ExectionContext.Global.JobDefaults for each composite action step ]'s ExecutionContext but this would have nullified all .Global.JobDefaults since we share the same pointer to Global for every instance of ExecutionContext.

So, I think my isComposite solution is better suited: aeae15d

…andler for composite action"

This reverts commit aeae15d.
@ethanchewy
Copy link
Contributor Author

Reverting changes - if we change the run defaults logic in the future, we'll change it then.

@ethanchewy
Copy link
Contributor Author

example of if not being allowed: https://github.com/ethanchewy/testing-actions/runs/895611092?check_suite_focus=true

(all others should not work too like "needs", etc.)

@ethanchewy
Copy link
Contributor Author

ethanchewy commented Jul 21, 2020

Step level shell and working-directory not working in a composite action since the shell and working-directory are supposed to be mapped into the ActionStep.Inputs when we convert the step in the pipeline template converter. But for some reason it's not mapped when we process it in the Composite Action Handler.

The ActionRunner tries to retrieve these values from the ActionDefinitionData Inputs and then sets the handler's Inputs to this inputs dictionary.

Then, the ScriptHandler tries to get this working-directory and shell values from this handlerData.Inputs.

To fix this, I'm trying to figure out how to add the working-directory and shell values to the definition.Inputs dictionary. Currently debugging...

…bute which is only found in the ActionStep not IStep
@ethanchewy
Copy link
Contributor Author

ethanchewy commented Jul 21, 2020

This issue stems from the ConvertToSteps function in the pipeline template converter losing specificity. It originally returned a list of Steps which doesn't include the .Inputs attribute which is a dictionary that will contain working-directory and shell. Since we return it as a list of Steps and cast it back to a list of ActionSteps, we "lose" this .Inputs attribute.

@ethanchewy
Copy link
Contributor Author

Thought there was a bug with setting the working-dir and shell but it works as intended (it was a bug with my test :/). Reverting back to original code.

@ethanchewy ethanchewy marked this pull request as ready for review July 21, 2020 21:57
@ethanchewy
Copy link
Contributor Author

Ready for review.

@ethanchewy ethanchewy changed the title (In Progress) Explicitly define what is allowed for a composite action Explicitly define what is allowed for a composite action Jul 22, 2020
@ethanchewy
Copy link
Contributor Author

(leaving this unmerged till @ericsciple has the chance to look at it since this is a really important PR)

@@ -120,7 +120,22 @@
"hashFiles(1,255)"
],
"sequence": {
"item-type": "any"
"item-type": "composite-step"
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we have validation on the server that at least one step is required?

Copy link
Contributor Author

@ethanchewy ethanchewy Jul 27, 2020

Choose a reason for hiding this comment

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

@ericsciple For server side,

@@ -108,19 +108,26 @@
}
},
"composite-steps": {
"context": [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if the attribute needs a context, they'll have access (see "string-steps-context")

@ethanchewy
Copy link
Contributor Author

ethanchewy commented Jul 27, 2020

Ready for final review. (tested all edge cases [see description for links]).

@ethanchewy ethanchewy merged commit 855b90c into main Jul 28, 2020
fabianishere pushed a commit to fabianishere/runner that referenced this pull request Aug 24, 2020
* Explicitly define what is allowed for an action

* Add step-env

* Remove secrets + defaults

* new line

* Add safety check to prevent from checking defaults in ScriptHandler for composite action

* Revert "Add safety check to prevent from checking defaults in ScriptHandler for composite action"

This reverts commit aeae15d.

* Need to explictly use ActionStep type since we need the .Inputs attribute which is only found in the ActionStep not IStep

* Fix ActionManifestManager

* Remove todos

* Revert "Revert "Add safety check to prevent from checking defaults in ScriptHandler for composite action""

This reverts commit a22fcbc.

* revert

* Remove needs in env

* Make shell required + add inputs

* Remove passing context to all composite steps attribuyte
fabianishere pushed a commit to fabianishere/runner that referenced this pull request Sep 23, 2020
* Explicitly define what is allowed for an action

* Add step-env

* Remove secrets + defaults

* new line

* Add safety check to prevent from checking defaults in ScriptHandler for composite action

* Revert "Add safety check to prevent from checking defaults in ScriptHandler for composite action"

This reverts commit aeae15d.

* Need to explictly use ActionStep type since we need the .Inputs attribute which is only found in the ActionStep not IStep

* Fix ActionManifestManager

* Remove todos

* Revert "Revert "Add safety check to prevent from checking defaults in ScriptHandler for composite action""

This reverts commit a22fcbc.

* revert

* Remove needs in env

* Make shell required + add inputs

* Remove passing context to all composite steps attribuyte
AdamOlech pushed a commit to antmicro/runner that referenced this pull request Jan 28, 2021
* Explicitly define what is allowed for an action

* Add step-env

* Remove secrets + defaults

* new line

* Add safety check to prevent from checking defaults in ScriptHandler for composite action

* Revert "Add safety check to prevent from checking defaults in ScriptHandler for composite action"

This reverts commit aeae15d.

* Need to explictly use ActionStep type since we need the .Inputs attribute which is only found in the ActionStep not IStep

* Fix ActionManifestManager

* Remove todos

* Revert "Revert "Add safety check to prevent from checking defaults in ScriptHandler for composite action""

This reverts commit a22fcbc.

* revert

* Remove needs in env

* Make shell required + add inputs

* Remove passing context to all composite steps attribuyte
TingluoHuang pushed a commit that referenced this pull request Apr 21, 2021
* Explicitly define what is allowed for an action

* Add step-env

* Remove secrets + defaults

* new line

* Add safety check to prevent from checking defaults in ScriptHandler for composite action

* Revert "Add safety check to prevent from checking defaults in ScriptHandler for composite action"

This reverts commit aeae15d.

* Need to explictly use ActionStep type since we need the .Inputs attribute which is only found in the ActionStep not IStep

* Fix ActionManifestManager

* Remove todos

* Revert "Revert "Add safety check to prevent from checking defaults in ScriptHandler for composite action""

This reverts commit a22fcbc.

* revert

* Remove needs in env

* Make shell required + add inputs

* Remove passing context to all composite steps attribuyte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants