Repository navigation
Description
NOTE:
For those who are not aware, I'm a college student who interned at GitHub for Summer 2020. Thank you all for all the thoughtful comments and feedback on this thread but since I'm not working at GitHub currently, I will not be responding to any new comments below in this thread.
================================================
Hi there 👋
We just released a new feature called composite run steps actions(https://docs.github.com/en/actions/creating-actions/about-actions#composite-run-steps-actions).
This issue thread will serve as a point of reference for people who are curious about the next steps after this feature and what we plan to work on next. There are probably quite a few questions about when we are going to support in the future like "when are you going to support 'uses' steps in a composite action"? In this Issue thread, I'll talk about the technical problems that we are planning to solve to accomplish this. Throughout the next week, I'll update it with any additional updates.
tl;dr in this issue, I'll go over what we currently support for composite run steps and how we plan on developing fully functioning composite actions.
Composite run steps background
What is a composite run steps action?
Many of you have been asking us to build a feature that enables them to nest actions within actions (ex: #438).
An important first step for supporting nesting within action is to first start supporting the execution of multiple run steps in an action.
For some developers, they may want to execute a variety of scripts and commands in different languages and shells in a single action and map those outputs to the workflow. We’ve also heard from our community that many developers want to reuse parts of their workflows into other workflows. This new action type, composite run steps, can help developers do just that! For example, developers can abstract parts of their workflows as composite run steps actions and reuse them for other workflows.
Thus, we created this feature called composite run steps which allows users to run multiple run steps in an action!
What does composite run steps currently support?
For each run step in a composite action, we support:
- name
- id
- run
- env
- shell
- working-directory
In addition, we support mapping input and outputs throughout the action.
See docs for more info.
What does Composite Run Steps Not Support
We don't support setting conditionals, continue-on-error, timeout-minutes, "uses", and secrets on individual steps within a composite action right now.
(Note: we do support these attributes being set in workflows for a step that uses a composite run steps action)
Examples of how you can use composite run steps actions
- Outputs + Inputs:
- Step-level shell and working_Dir:
- Timeout-error:
- Step-level env:
- JSON Error Messaging:
- Workflow: https://github.com/ethanchewy/testing-actions/actions/runs/184588237/workflow
- Action: https://github.com/ethanchewy/testing-composite-errors/blob/json/action.yml
- Results: https://github.com/ethanchewy/testing-actions/actions/runs/184588237?check_suite_focus=true
- Scripts:
Next Steps for Developing Fully Functioning Composite Run Steps
In this section, I'll describe some current features that we are currently working on or are planning to work on. You can see more details about each of these in https://github.com/actions/runner/blob/users/ethanchewy/compositeADR/docs/adrs/0549-composite-run-steps.md.
If conditionals
For if conditionals, we treat the composite action as a completely new slate. Each proceeding step depends on the proceeding step's states (failure, cancelled, or success).
To keep track of these states, we can create a new ExecutionContext for composite actions that keep track of the attributes we need such as the current state of a composite action step before evaluating. When we support nesting, we need to follow some sort of inheritance model (maybe something like state = (parent state && child state)?
Uses
Related questions that we need to answer first before we can support uses:
- How are we going to handle post and pre steps? Should we aggregate them into one individual step for each type?
- When should we download the repos for nested actions
Current experimentation for this: #612
timeout-minutes
It makes a ton of sense creating a separate execution context for composite actions especially in the cases for keeping track of the conditional status of the step. This would make it easier to some sort of "time element" to easily get the "correct" condition of the step in log time (something like this algorithm: https://maksimdan.gitbook.io/interview-practice-problems/leetcode_sessions/design/permission-management-for-a-general-tree)
For the nested timeout-minutes support, couldn't we just link all children tokens to their parents? The time left will trickle down to the children. For example,
|A (30 min.)|
[B (15 min.)|
|B2|
|C (None)|
|C2|
Let's say the A composite action whole step has a timeout-minutes fo 30 minutes and the step B (which is a step inside the composite action) has a timeout-minutes of 15 minutes and the step B exceeds that time, we can easily fail that thread and differentiate that between a cancellation. Then, we would move onto the next step C which doesn't have a timeout-minutes set and since it has ~15 minutes left, it will still start running. If the next step C takes more than 15 minutes, then we fail the whole action since the whole action has taken more than 30 minutes (the step C will automatically fail as well as the whole composite action step since they are linked)
Areas that we are also thinking about
There are many more layers of complexity for fully functioning composite actions.
For example at a high level,
- How would we use multiple Docker actions in a composite action effectively?
- How do we propagate and resolve errors effectively with nested actions?
- Should we support the shell attribute for a uses step? (probably not)
Runner specific questions:
- Should we create a separate, slimmed-down version of ExecutionContext for Composite Actions?
- Yes, because this would reduce confusion and create an easier way to add onto it + easily hook this up with the .Global ExecutionContext.
- How do we map our Scopes in nested actions?
- We've already come up with a pretty clever solution for generating a context name (i.e.
{context.ScopeName}.{context.ContextName}) - Our dictionary for resolving outputs is in the nested dictionary StepsContext[Step_Name][Scope_Name]["outputs"]. Could we flatten the dictionary to reduce lookup time?
- We've already come up with a pretty clever solution for generating a context name (i.e.
TODOs
- Handle Continue-on-error (we need to change how we handle failures in the composite action handler [i.e. don't call Complete(TaskResult.Failed))
- Handle private actions
- Outcomes?
- Revisit defaults? Does it make sense to add defaults once we have fully functional composite actions.
Extra Information
How we built it
- ADR: https://github.com/actions/runner/blob/users/ethanchewy/compositeADR/docs/adrs/0549-composite-run-steps.md
- Composite Actions related code: https://github.com/actions/runner/commits?author=ethanchewy
- PRs: ADR (Composite Run Steps ADR #554), Composite Actions Support for Multiple Run Steps #549, Composite Actions: Support Env Flow #557, Improve Error Messaging for Actions by Using ExecutionContext's FileTable as Single Source of Truth and by Passing FileID to All Children Tokens. #564, Composite Run Steps Outputs #568, Composite Actions UI #578, Composite Run Steps Refactoring #591, Clean Up Composite UI #610, Improve Debugging Messages for Empty Tokens #609, Clarify details for defaults, shell, and working-dir #607, Explicitly define what is allowed for a composite action #605, Fix Timeout-minutes for Whole Composite Action Step #599
Activity
ethanchewy commentedon Aug 5, 2020
will reopen when feature launches.
latacora-tomekr commentedon Aug 7, 2020
Thanks for the release! Can composited actions be referenced from the local repository (in the way standard actions can https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#referencing-an-action-in-the-same-repository-where-a-workflow-file-uses-the-action) or can they only be referenced from separate public repositories?
ethanchewy commentedon Aug 7, 2020
Great question @latacora-tomekr . Yes, this can be referenced from the local repository as well.
jeffeb3 commentedon Aug 8, 2020
Thank you @latacora-tomekr for that pointer. I was trying to follow this example:
https://docs.github.com/en/actions/creating-actions/creating-a-composite-run-steps-action
And it wasn't seeing the action. I tried it with the relative path, and it worked in my dummy repo. I will leave this up, despite my embarrassment, in the hopes it will help others:
https://github.com/jeffeb3/hello-world-composite-run-steps-action
daandemeyer commentedon Aug 8, 2020
Thank you for this feature! I was wondering today if it would be possible to reuse Github Actions yaml steps and found out this was just released. Talk about great timing!
Aside from what's already in the roadmap (uses, visualization), it would be great to have action scope env and shell keywords to allow specifying action scope step shell and action scope environment variables.
Thanks again for working on this!
bewuethr commentedon Aug 10, 2020
This is very useful and fits my use case well: I mostly run shell scripts in my workflows, and making them reusable is now a lot simpler.
I've noticed that the "Scripts" example uses an environment variable
$GITHUB_ACTION_PATHto access files living in the same directory tree as the action itself. This isn't documented anywhere, neither under Creating a composite steps action nor under Default environment variables, and should probably be amended?ethanchewy commentedon Aug 10, 2020
@bewuethr Thanks for the kind words!
github.action_path is documented here: https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context (see "
github.action_path). github.action_path is equivalent to GITHUB_ACTION_PATH.We follow this same pattern of also adding the github context attribute as an environment variable like github.token = GITHUB_TOKEN.
mikeparker commentedon Aug 13, 2020
Hi, this is really great. Maybe I missed it, am I right in saying the composite action must be in a public repo right now? If so, is there a plan for referencing private actions? We don't really want to make our all CICD scripts public just to reuse them and we have many repos that all need to reference central pipelines / scripts / actions.
ethanchewy commentedon Aug 13, 2020
@mikeparker good point - I'll add it to our tracking issue so that we can think it through. Thanks for bringing this up!
bewuethr commentedon Aug 13, 2020
@mikeparker @ethanchewy I can see that issue on the roadmap for Q1 2021.
sidvishnoi commentedon Aug 17, 2020
Steps in workflow are shown as different collapsible sections in the UI. Are there any plans for supporting similar UI (nested within the workflow's
usesstep) for composite actions? Something likecore.group()for each composite step would be nice for starters 🙏Right now, I'm manually setting the
groupworkflow command in each step.116 remaining items
Fix end-to-end tests post Next.js migration
Fix end-to-end tests post Next.js migration
umarcor commentedon Nov 12, 2021
@aramfe, what about "other jobs" consuming the action as if it was external?
That is uncomfortable in the PRs where the action itself is modified. However, it should work for any other modification.
Overall, I agree with your feature request, as I'm running into a similar use case. I would like to include the
actions/checkoutstep inside the reusable workflow (composite action). For completeness, see https://github.com/hdl/containers/blob/main/.github/workflows/boolector.yml#L57-L68 and https://github.com/hdl/containers/blob/main/utils/build-test-release/action.yml#L55-L62. Using it as external does not work in this case, because the Action is expected to be modified frequently.chore(ci): use composite actions
chore(ci): use composite actions
pllim commentedon Nov 19, 2021
Is the composite action mentioned in #646 (comment) the same thing as re-usable workflows mentioned in https://docs.github.com/en/actions/learn-github-actions/reusing-workflows ?
airtower-luna commentedon Nov 19, 2021
@pllim No, those are separate things with different purposes (with some overlap). The documentation for composite actions is here: https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
Temporary disabled `continue-on-error` because of pipeline error: `Un…
FP-891 fix external workbench access disrupted by onboarding (#358)
Deduplicate GitHub Actions steps.
Deduplicate GitHub Actions steps. (#81)
Kurt-von-Laven commentedon May 7, 2022
@aramfe, you could maintain a
workflowtag of your monorepo that contains only your workflows. That would essentially allow you to do a sparse checkout of only.github/workflows.Temporary disabled `continue-on-error` because of pipeline error: `Un…
fix(ci): checkout in caller before local composite ./.github/actions/…
fix(composite): reference docker-cache sub-action by full repo path