Skip to content

Next Steps for Fully Functioning Composite Actions #646

Closed

Description

@ethanchewy

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

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

see: https://github.com/actions/runner/blob/main/docs/adrs/0549-composite-run-steps.md#if-condition

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?

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

Activity

  1. ethanchewy commented on Aug 5, 2020

    @ethanchewy
    ContributorAuthor

    will reopen when feature launches.

  2. latacora-tomekr commented on Aug 7, 2020

    @latacora-tomekr

    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?

  3. ethanchewy commented on Aug 7, 2020

    @ethanchewy
    ContributorAuthor

    Great question @latacora-tomekr . Yes, this can be referenced from the local repository as well.

  4. jeffeb3 commented on Aug 8, 2020

    @jeffeb3

    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

  5. daandemeyer commented on Aug 8, 2020

    @daandemeyer

    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!

  6. bewuethr commented on Aug 10, 2020

    @bewuethr

    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_PATH to 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?

  7. ethanchewy commented on Aug 10, 2020

    @ethanchewy
    ContributorAuthor

    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_PATH to 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?

    @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.

  8. mikeparker commented on Aug 13, 2020

    @mikeparker

    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.

  9. ethanchewy commented on Aug 13, 2020

    @ethanchewy
    ContributorAuthor

    @mikeparker good point - I'll add it to our tracking issue so that we can think it through. Thanks for bringing this up!

  10. bewuethr commented on Aug 13, 2020

    @bewuethr

    @mikeparker @ethanchewy I can see that issue on the roadmap for Q1 2021.

  11. sidvishnoi commented on Aug 17, 2020

    @sidvishnoi

    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 uses step) for composite actions? Something like core.group() for each composite step would be nice for starters 🙏
    Right now, I'm manually setting the group workflow command in each step.

  12. 116 remaining items

  13. umarcor commented on Nov 12, 2021

    @umarcor

    @aramfe, what about "other jobs" consuming the action as if it was external?

    - uses: your/repository/.github/path/to/your-action@main
    

    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/checkout step 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.

  14. pllim commented on Nov 19, 2021

    @pllim

    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 ?

  15. airtower-luna commented on Nov 19, 2021

    @airtower-luna

    @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

  16. Kurt-von-Laven commented on May 7, 2022

    @Kurt-von-Laven

    @aramfe, you could maintain a workflow tag of your monorepo that contains only your workflows. That would essentially allow you to do a sparse checkout of only .github/workflows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions