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

Nested composite actions #862

Closed
palewire opened this issue Dec 15, 2020 · 5 comments
Closed

Nested composite actions #862

palewire opened this issue Dec 15, 2020 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@palewire
Copy link

palewire commented Dec 15, 2020

I would like to be able to create a composite action that contains other composite actions. This does not seem to currently work.

For example, there are four steps that go into installing Python and using pipenv to install and cache dependencies. I'd like to create a single composite action that does everything involved so I don't have to reproduce all of the steps in each of my workflows. I imagine such an action would look like this:

name: 'Python and pipenv installer'
description: 'Install all the things with Python and pipenv'
inputs:
  python-version:
    description: 'The version of Python to install'
    required: false
    default: 3.8
runs:
  using: "composite"
  steps: 
    - id: install-python
      name: Install Python 3.8
      uses: actions/setup-python@v2
      with:
        python-version: ${{ inputs.python-version }}

    - id: install-pipenv
      name: Install pipenv
      run: |
          python -m pip install --upgrade --no-cache-dir pip
          python -m pip install --no-cache-dir pipenv
      shell: bash
   
    - id: cache-dependencies
      name: Cache dependencies
      uses: actions/cache@v2
      with:
        path: |
          ~/.cache/pip
          ~/.cache/pipenv
        key: ${{ runner.os }}-pipenv-${{ hashFiles('Pipfile.lock') }}
        restore-keys: |
          ${{ runner.os }}-pipenv-
          ${{ runner.os }}-

    - id: sync-pipfile
      name: Install dependencies with pipenv
      run: pipenv sync  
      shell: bash

However, that does not seem to work. I get an error complaining like this when I try to use it.

Error: datadesk/python-pipenv-installer-action/v3/action.yaml (Line: 13, Col: 7): Unexpected value 'uses'
Error: datadesk/python-pipenv-installer-action/v3/action.yaml (Line: 14, Col: 7): Unexpected value 'with'
Error: datadesk/python-pipenv-installer-action/v3/action.yaml (Line: 11, Col: 7): Required property is missing: run
Error: datadesk/python-pipenv-installer-action/v3/action.yaml (Line: 11, Col: 7): Required property is missing: shell
Error: datadesk/python-pipenv-installer-action/v3/action.yaml (Line: 26, Col: 7): Unexpected value 'uses'
Error: datadesk/python-pipenv-installer-action/v3/action.yaml (Line: 27, Col: 7): Unexpected value 'with'
Error: datadesk/python-pipenv-installer-action/v3/action.yaml (Line: 24, Col: 7): Required property is missing: run
Error: datadesk/python-pipenv-installer-action/v3/action.yaml (Line: 13, Col: 7): Unexpected value 'uses'
Error: datadesk/python-pipenv-installer-action/v3/action.yaml (Line: 14, Col: 7): Unexpected value 'with'
Error: datadesk/python-pipenv-installer-action/v3/action.yaml (Line: 11, Col: 7): Required property is missing: run
Error: datadesk/python-pipenv-installer-action/v3/action.yaml (Line: 11, Col: 7): Required property is missing: shell
Error: datadesk/python-pipenv-installer-action/v3/action.yaml (Line: 26, Col: 7): Unexpected value 'uses'
Error: datadesk/python-pipenv-installer-action/v3/action.yaml (Line: 27, Col: 7): Unexpected value 'with'
Error: datadesk/python-pipenv-installer-action/v3/action.yaml (Line: 24, Col: 7): Required property is missing: run
Error: System.ArgumentException: Unexpected type '' encountered while reading 'steps item uses'. The type 'StringToken' was expected.

My presumption is that this means I can't have composite actions inside my composite. I suspect this is a common use case and I'd love to see a solution of some form.

@palewire palewire added the enhancement New feature or request label Dec 15, 2020
@Pierozi
Copy link

Pierozi commented Jan 30, 2021

As mention in issue #646 the implementation of uses are quite complex and are in-progress.

@thboop
Copy link
Collaborator

thboop commented Aug 12, 2021

We are hoping to support this soon, up to a certain depth level of ~9 or so. I'll follow up with more information once this is live.

@thboop thboop self-assigned this Aug 12, 2021
@thboop
Copy link
Collaborator

thboop commented Aug 18, 2021

This is supported now on dotcom, for more information please see: #646 (comment)

The recursion depth is up to 9, if we need to raise this, please let us know your use case and we can do so. Other features may handle reuse cases with depths that large better then we can do in composite, but I'm always open to discussing what limit is reasonable

@thboop thboop closed this as completed Aug 18, 2021
@make-github-pseudonymous-again

Thanks for landing this! When refactoring a workflow where shell is absent from a run step one needs to be explicit about shell. Is bash the recommended default? What would be the most generic explicit setting?

@alex-tsx
Copy link

Same issue. Looking forward tosee it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants