Skip to content

feature: add an option not to add/update environment variables #410

Closed

Description

@mayeut

Description:
Add an option not to add/update environment variables.

Justification:
When using actions/setup-python, it will update or add PATH, PythonLocation, PKG_CONFIG environment variables.
If one is to use actions/setup-python inside a composite action, those environment variables update might conflict with a user workflow.

e.g.

- uses: actions/setup-python@v3
  with:
    python-version: "3.7"
- uses: some/composite-action@v1 # Runs a different setup-python internally with python-version: "3.10"
- run: python --version  # this will show python 3.10 while the user expects 3.7

With this proposal, some/composite-action could use:

- uses: actions/setup-python@v3
  id: cp310
  with:
    python-version: "3.10"
    no-environment-update: true
- run: ${{ steps.cp310.outputs.python-path }} --version  # this will show python 3.10 in the composite action

The user workflow will now print python 3.7 as expected.

Are you willing to submit a PR?
Yes: #411

Activity

  1. henryiii commented on May 26, 2022

    @henryiii

    The example of usage to turn any Python application into a standalone action that can select any Python version I expect would be:

    runs:
      using: composite
      steps:
        - using: actions/setup-python@v3
          id: myapp-python
          with:
            no-environment-update: true
            python-version: "3.10"
        - run: >
            pipx run
            --python '${{ steps.myapp-python.outputs.python-path }}'
            --spec '${{ github.action_path }}'
            myapp
          shell: bash

    Then using the action would have no side effects for later steps - neither the Python activation nor the required dependencies are leaked. Currently, "nice" (non-leaky) composite actions are limited by what the default Python attached to pipx is.

  2. panticmilos commented on May 27, 2022

    @panticmilos
    Contributor

    Hi @mayeut!

    First of all thank you for submitting the PR, and opening the issue. We will investigate it deeper.

    Cheers

  3. dsame commented on Jun 20, 2022

    @dsame
    Contributor

    @panticmilos I would rename the option from no-environment-update to preserve-environment because the environment might need to be changed within the nested action and restored when the flow returns back to outer.

    Moreover it would make a sense to add this option to the all actions globally.

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

    feature requestNew feature or request to improve the current logic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions