Skip to content

Cache problem with Node.js #45

@KOliver94

Description

@KOliver94

Hi everybody,

I noticed a problem with pre-commit action's cache and using Node.js environment. I'm using eslint in pre-commit and to make eslint-plugin-import work properly I need to install the dependencies. So, my workflow looks the following:

jobs:
  pre-commit:
    name: Pre-commit hooks
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Set up Python 3.8
      uses: actions/setup-python@v2
      with:
        python-version: '3.8'
    - name: Use Node.js 14
      uses: actions/setup-node@v2-beta
      with:
        node-version: '14'
    - name: Cache Node.js modules
      uses: actions/cache@v2
      with:
        path: ~/.npm
        key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
        restore-keys: |
          ${{ runner.OS }}-node-
          ${{ runner.OS }}-
    - name: Install frontend dependencies
      run: npm install
      working-directory: frontend
    - name: Run pre-commit hooks
      uses: pre-commit/action@v2.0.0

The problem is that because I only use node-version: '14' in the setup-node phase the Node.js version will change after a while to a newer version but the pre-commit action's cache does not care for that and tries to use a cached version where a previous version of Node.js was used and the following error occurs:

eslint...................................................................Failed
- hook id: eslint
- exit code: 127

/home/runner/.cache/pre-commit/repoibq27hfw/node_env-system/bin/node: line 5: /opt/hostedtoolcache/node/14.8.0/x64/bin/node: No such file or directory
/home/runner/.cache/pre-commit/repoibq27hfw/node_env-system/bin/node: line 5: /opt/hostedtoolcache/node/14.8.0/x64/bin/node: No such file or directory

##[error]The process '/opt/hostedtoolcache/Python/3.8.5/x64/bin/pre-commit' failed with exit code 1

and I can see that the setup-node used version 14.9.0.

Run actions/setup-node@v2-beta
version: 14
Found in cache @ /opt/hostedtoolcache/node/14.9.0/x64

I used a "workaround" a specified a fully qualified node-version but I don't think this is the best solution. Is there any way to either disable the cache or make it sensitive for the Node.js version?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions