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

The pythonLocation environment variable is shown as invalid access in this context #439

Open
Julfried opened this issue Jan 14, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@Julfried
Copy link

Describe the bug

When using the pythonLocation environment variable set by the actions/setup-python action, this extension reports "Context access might be invalid" even though it is a valid environment variable documented in the official setup-python action.

To Reproduce

Steps to reproduce the behavior:

  1. With this workflow:

    name: Test Workflow
    
    on:
      workflow_dispatch:
    
    jobs:
      test:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v4
          - uses: actions/setup-python@v5
            with:
              python-version: '3.12'
          - name: Cache pip
            uses: actions/cache@v4
            with:
              path: ${{ env.pythonLocation }}/.cache/pip
              key: python-${{ hashFiles('setup.py', 'pyproject.toml') }}
  2. Open the "Problems" panel in VS Code.

  3. See the error:

    Context access might be invalid: pythonLocation
    

Expected behavior

The pythonLocation environment variable, which is documented and valid when using actions/setup-python, should be recognized properly by this extension.

Screenshots

If applicable, include screenshots of the warning in the Problems panel.

Extension Version

vX.Y.Z

Additional context


@muzimuzhi
Copy link

muzimuzhi commented Jan 14, 2025

In my understanding, currently vscode-github-actions only lint inputs and outputs recorded in action.yml of an action (see the action.yml of setup-python action), hence it has no knowledge about what environment variables and dynamic outputs are set.

@Julfried
Copy link
Author

Thanks for clarification, this limitation makes sense. I found a workaround to address this issue: explicitly setting pythonLocation as a workflow environment variable within the env block for steps that use it:

- name: Cache pip
  id: cache-pip
  uses: actions/cache@v4
  with:
    path: ${{ env.pythonLocation }}
    key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py', 'pyproject.toml') }}
  env:
    pythonLocation: ${{ env.pythonLocation }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog 🗒
Development

No branches or pull requests

2 participants