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

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

Closed
mayeut opened this issue May 26, 2022 · 3 comments · Fixed by #411
Closed

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

mayeut opened this issue May 26, 2022 · 3 comments · Fixed by #411
Labels
feature request New feature or request to improve the current logic

Comments

@mayeut
Copy link
Contributor

mayeut commented May 26, 2022

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

@mayeut mayeut added feature request New feature or request to improve the current logic needs triage labels May 26, 2022
@henryiii
Copy link

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.

@panticmilos
Copy link
Contributor

Hi @mayeut!

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

Cheers

@dsame
Copy link
Contributor

dsame commented Jun 20, 2022

@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
Labels
feature request New feature or request to improve the current logic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants