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

Can't cache dependencies from a composite action #377

Closed
2 of 5 tasks
fjelliott opened this issue Apr 5, 2022 · 3 comments
Closed
2 of 5 tasks

Can't cache dependencies from a composite action #377

fjelliott opened this issue Apr 5, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@fjelliott
Copy link

fjelliott commented Apr 5, 2022

Description:
So I have a repo with a python script that is a CI/CD tool used in other GitHub Actions across my organization. I had the idea of creating a composite action for this tool's repo that just sets up the python environment and gets it added to the PATH so it can be called by subsequent actions. I've already sorted out the 'Admin privileges required' nonsense (which I think you should also fix, btw). I know I can get all of this to work if I move the code from the action.yml file to a workflow_dispatch Action in my tool's repository. But it fails when I try to use the same steps in a composite action.

Also, I know people are going to warn me about affecting the outside python environment, etc. I don't really care about that. I just want this functionality to work.

I also get it that I can just not cache the virtualenv. Yes, this is true, but that adds a fair amount of time to the process. I would like to use the caching feature if possible.

Action version:
actions/setup-python@v3

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:
Python 3.10.4

Repro steps:
Have a repo (I'm calling it 'my-org/my-tool.git' in this setup) containing a python package with a setup.py file that has an entry_point defined (for purposes of this setup, we'll call the entry point 'my-tool'). Also, I'm using pipenv. and there's a Pipfile.lock in the my-org/my-tool.git repo.

Create an action.yml in my-org/my-tool.git:

name: Setup My Tool
description: "Setup My Tool so 'my-tool.exe' is in the PATH and subsequent actions can call it."
runs:
  using: composite
  steps:
  - name: Install pipenv
    run: pip install pipenv
    shell: cmd
  - name: Setup Python
    uses: action/setup-python@v3
    with:
      cache: pipenv
      python-version: 3.10.4
      cache-dependency-path: "${{ github.action_path }}/Pipfile.lock"
  - name: Install My Tool and Dependencies
    run: pipenv sync --python 3.10.4
    working-directory: "${{ github.action_path }}"
    shell: cmd

Then, create an Actions workflow file .github/workflows/random_workflow.yml in another repo (let's say 'my-org/my-project.git'):

name: Some random workflow
on: [workflow_dispatch]
jobs:
  runTool:
    runs-on: [self-hosted, Windows, yadda, yadda, yadda]
    steps:
    - name: Setup My Tool
      uses: my-org/my-tool@master
    - name: Use My Tool
      run: my-tool.exe some-args --and --stuff
      shell: cmd

Expected behavior:
It Just Works.©

Actual behavior:
When the composite action reaches the setup-python step, it throws this error:
Error: No file in D:\B\my-project\my-project matched to [D:\B\_actions\my-org\my-tool\master/Pipfile.lock], make sure you have checked out the target repository

To my eye, it looks like the setup-python action is trying to prevent specifying paths for cache-dependency-path outside of the GitHub Actions working directory. This restriction should be relaxed to allow specifying paths inside the _actions folder as well.

@fjelliott fjelliott added bug Something isn't working needs triage labels Apr 5, 2022
@dmitry-shibanov dmitry-shibanov self-assigned this Apr 5, 2022
@dmitry-shibanov
Copy link
Contributor

Hello @fjelliott. Thank you for your report. I think it can be related to this issue: #361

@fjelliott
Copy link
Author

Okay... So, can it be patch in the toolkit repo?

@dmitry-shibanov
Copy link
Contributor

Hello @fjelliott. Sorry for the late response. I think it should be patched in the toolkit repository because the action relies on toolkit's packages.

For now I'm going to close the issue.

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
None yet
Development

No branches or pull requests

2 participants