Github cache action is not able to find the pip cache

I’m trying to run Pytest and it requires some of the dependencies. Since installing dependencies take time, i’m trying to cache it using the Github [email protected] action. Every time the job is run, cache action is not able to find the cache.

Please let me now if i’m missing anything.

Cache action output:

Run actions/[email protected]
  with:
    path: ~/.cache/pip
    key: Linux-pip-fleet-pip-cache-08116b29148fe20ecd799de0bf0e3e2e49746df391b7812be8e8e69cb174b71b
    restore-keys: Linux-pip-fleet-pip-cache-
  Linux-pip-
  Linux-
  
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.6.13/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.6.13/x64/lib
    cache-name: fleet-pip-cache
Cache not found for input keys: Linux-pip-fleet-pip-cache-08116b29148fe20ecd799de0bf0e3e2e49746df391b7812be8e8e69cb174b71b, Linux-pip-fleet-pip-cache-, Linux-pip-, Linux-

Below is the workflow code:

#workflow-name
name: Code Quality Checks

#Triggger events
on:
  push:
    branches:
      - develop
      - master
  pull_request:
    branches:
      - develop
      - master

jobs:
  pytest:
    name: pytest
    runs-on: ubuntu-latest
    needs: [black, flake8, mypy]
    strategy:
      matrix:
        python-version: [ 3.6 ] #Python versions
    steps:
      - name: Checkout
        uses: actions/[email protected]
      #Setup python environment
      - name: Setup python ${{ matrix.python-version }}
        uses: actions/[email protected]
        with:
          python-version: ${{ matrix.python-version }}
      #Cache pip modules
      - name: Cache pip
        id: fleet-pip-cache
        uses: actions/[email protected]
        env:
          cache-name: fleet-pip-cache
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ env.cache-name }}-${{ hashFiles('**/dev-requirements.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-${{ env.cache-name }}-
            ${{ runner.os }}-pip-
            ${{ runner.os }}-
      #Install dependencies
      - name: Install dependencies
        if: steps.fleet-pip-cache.outputs.cache-hit != 'true'
        env:
          PIP_USERNAME: ${{ secrets.PIP_USERNAME }}
          PIP_PASSWORD: ${{ secrets.PIP_PASSWORD }}
          PIP_TRUSTED_HOST: ${{ secrets.PIP_TRUSTED_HOST }}
        run: |
          if [ -f ./requirements/dev-requirements.txt ]; then pip install -r ./requirements/dev-requirements.txt --extra-index-url https://$PIP_USERNAME:[email protected]$PIP_TRUSTED_HOST --trusted-host https://$PIP_TRUSTED_HOST; fi
      #Run PyTest
      - name: Test with Pytest
        shell: bash
        run: |
          pytest ./api/

Source: Python-3x Questions

LEAVE A COMMENT