actions / setup-python

Set up your GitHub Actions workflow with a specific version of Python
MIT License
1.69k stars 539 forks source link

Support cache-dependency-paths outside the current directory #361

Open PeterJCLaw opened 2 years ago

PeterJCLaw commented 2 years ago

Description:

I'm building a composite Action which uses actions/setup-python internally. When specifying the requirements.txt from the action setting up Python fails, though I thiiink I'm passing the right values.

Here's what I've got:

    - name: Set up Python
      uses: actions/setup-python@v3
      with:
        python-version: '3.10'
        cache: pip
        cache-dependency-path: ${{ github.action_path }}/requirements.txt

Here's the error I get:

No file in /home/runner/work/sr2022-comp/sr2022-comp matched to [/home/runner/work/_actions/PeterJCLaw/srcomp-validate-action/bd809ff12b77607cc2f0ebbd035d6f0a5c8d32fc/requirements.txt], make sure you have checked out the target repository

sr2022-comp is the repo I'm using to test the action, srcomp-validate-action is the action.

My specific use-case only has a couple of dependencies so #351 would likely work as a fix, though I can imagine that a more complex scenario would want this to work.

Platform: Ubuntu

PeterJCLaw commented 2 years ago

I'm currently working around this by coping the requirements file into a temporary directory within the working directory and then referencing that, instead of the original. This doesn't feel like a great solution though as it ends up polluting the target repo's working copy.

dmitry-shibanov commented 2 years ago

Hello @PeterJCLaw. Thank you for your report. Could you please provide a public repository to reproduce the issue ?

dmitry-shibanov commented 2 years ago

Hello @PeterJCLaw. Actually, I think the root cause of the issue in the toolkit/glob package. The hashFiles function tries to compare if the passed directory matches with GITHUB_WORKSPACE. The composite action's directory and checkout project's directory don't match, that is why if does hash the file and the actions setup-python throws an error.

PeterJCLaw commented 2 years ago

Thanks for your replies. For completeness the repos in question are:

I've raised https://github.com/actions/toolkit/issues/1035 for the underlying issue.

dmitry-shibanov commented 2 years ago

Hello @PeterJCLaw. For now I'm going to close the pull request because the root cause of the issue comes from the toolkit repository. If you have any concerns feel free to ping us.

PeterJCLaw commented 1 year ago

@dmitry-shibanov would you be open to reopening this issue? It looks like hashFiles has a new parameter now which allows callers to specify the workspace directory (https://github.com/actions/toolkit/pull/1318), which I think would help here?

dmitry-shibanov commented 1 year ago

Hello @PeterJCLaw. In this case I'm coming to reopen the issue to investigate it one more time.

edit: Sorry for edit in the first glance I thought it was a pull request.

zyv commented 11 months ago

@dmitry-shibanov we also got hit by this one, any news whether this can be addressed now, that there is a new parameter in toolkit available?

jaimehrubiks commented 8 months ago

I'm also hit by this issue, I guess this line is quite common:

${{ github.action_path }}
zyv commented 5 months ago

@dmitry-shibanov any progress on that?