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

pre-commit install fails with no .pre-commit-config.yaml in root directory #44

Closed
mshriver opened this issue Aug 28, 2020 · 3 comments
Closed

Comments

@mshriver
Copy link

I have my .pre-commit-config.yaml file in a specific directory for my github actions.

While I can specify this config file location using extra_args, the installation of pre-commit fails.

I don't see a way to deal with this in the documentation, or while having a quick peek at the implementation.

My github workflow configuration:

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-python@v2
    - name: Install Collections
      run: |
        sudo apt install software-properties-common
        sudo apt-add-repository --yes --update ppa:ansible/ansible
        sudo apt install ansible
        ansible-galaxy collection install -f -r .github/collections/requirements.yml
    - uses: pre-commit/action@v2.0.0
      with:
        extra_args: -c .github/workflow-config/.pre-commit-config.yml

The relevant logging during the workflow failure:

> Run pre-commit/action@v2.0.0
> install pre-commit
##[error]ENOENT: no such file or directory, open '.pre-commit-config.yaml'

Thanks for pre-commit and this action!

@asottile
Copy link
Member

yeah the caching code requires the pre-commit configuration to be at the conventional place

@mshriver
Copy link
Author

mshriver commented Aug 28, 2020

For anyone working with this action that runs into a similar situation and finds this, you can work around it by copying or symlinking your pre-commit config file to the root project directory within the github workflow.

Note the specific file name is required, with .yaml extension.

For example, my original workflow from the issue description could be updated like:

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-python@v2
    - name: Install Collections
      run: |
        sudo apt install software-properties-common
        sudo apt-add-repository --yes --update ppa:ansible/ansible
        sudo apt install ansible
        ansible-galaxy collection install -f -r .github/collections/requirements.yml
    - name: Hack pre-commit
      # https://github.com/pre-commit/action/issues/44
      run: |
        sudo cp .github/workflow-config/.pre-commit-config.yml .pre-commit-config.yaml
    - uses: pre-commit/action@v2.0.0

@asottile
Copy link
Member

sudo is probably not needed for cp fwiw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants