Skip to content

Unable to setup pip cache-dependency-path in a downstream action due to setup-python only considering the current GITHUB_WORKSPACE #1202

@PrinsonF77

Description

@PrinsonF77

Description:
When setup-python is used in a downstream composite action, we would want it to pick up the requirements.txt from the composite action files instead of the current GITHUB_WORKSPACE.

This is currently not possible and setup-python ends up giving an error: Error: No file in /home/ubuntu/actions-runner/_work/ matched to [**/requirements.txt or **/pyproject.toml], make sure you have checked out the target repository.

Ideally, as the composite action requires the python set up, we should also have the ability to look for the requirements.txt file in /home/ubuntu/actions-runner/_action.

The glob.hashFiles function that is called by setup-python does provide an option for current workspace: https://github.com/actions/toolkit/blob/f58042f9cc16bcaa87afaa86c2974a8c771ce1ea/packages/glob/src/internal-hash-files.ts#L9.
This issue can potentially be fixed by taking in an input for the workspace to look for the requirements.txt file. It can then be provided from the composite action as ${{ github.action_path }}.

Action version:
v6

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:
Using Python 3.13

Repro steps:

  1. Have a workflow in a repository that does not deal with python and therefore does not have requirements.txt or pyproject.toml
  2. Use a composite github action from another repository that requires python to perform its operations and has a requirements.txt
  3. Provide the complete path to this requirements.txt or **/requirements.txt in the cache-dependency-path input

Expected behavior:
The setup-python should pickup the requirements.txt from the _action directory and complete successfully

Actual behavior:
Setup python errors with Error: No file in /home/ubuntu/actions-runner/_work/<redacted> matched to [**/requirements.txt or **/pyproject.toml], make sure you have checked out the target repository.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions