Skip to content

Self-hosted runners cache not working when using service containers #1021

Open
@omri-shilton

Description

Description:
Running on self hosted runner using the following: https://github.com/github-aws-runners/terraform-aws-github-runner
I have a workflow that has multiple jobs, some are regular and some have service containers ie:

  Job-A:
    runs-on: [self-hosted, linux, x64, ubuntu-latest]
    steps:
      - name: Check out repository code 🕵🏻‍♀️
        uses: actions/checkout@v4

      - uses: actions/setup-python@v4
        with:
          python-version: '3.10.10'
          cache: 'pip'

      - name: Run Mypy
        run: |
          pip install -r backend/requirements/linter-requirements.txt
          mypy --config backend/mypy.ini backend


  Job-B:
    runs-on: [self-hosted, linux, x64, ubuntu-latest]
    services:
      postgresql:
        image: somerepo/someimage:latest
        ports:
          - 5432:5432
        env:
          SOME_VAR: SOMEVAR
        credentials:
          username: someuser
          password: somepass
    steps:
      - name: Check out repository code 🕵🏻‍♀️
        uses: actions/checkout@v4

      - uses: actions/setup-python@v4
        with:
          python-version: '3.10.10'
          cache: 'pip'

      - name: Install newly added packages
        run: |
          pip install -r backend/requirements/requirements.txt
          pip install -r backend/requirements/dev-requirements.txt
          pip install psycopg2-binary==2.9.9

On the job that don't have service containers i'm getting these logs:
Image
you can see that the cache is found and then using the cached packages.

On the job that has service containers i'm getting these logs:
Image
you can see that the cache is found and then still downloading the packages instead of using the cache.

When I log into the machine that ran the second job i can see that .cache/pip/ folder has many packages.

Action version:
4

Platform:

  • Ubuntu

Runner type:

  • Self-hosted - version 2.322.0

Tools version:

3.10.10

Repro steps:
copy the workflow jobs that I listed and fill in some real data.

Expected behavior:
Cache to be used on both jobs.

Actual behavior:
cache is working only on jobs without service containers.

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions