question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi there

I’m running a molecule based Ansible role test via Tox, itself installed by pip. Hence trying to cache pip, tox and molecule. The cache never hit. To be sure I ran the job twice in a row with just a space added in the README.

First one

image

Second one

image

Here’s the workflow definition

name: Tests

on:
  push:
    tags:
      - "*"

jobs:
  tests:

    runs-on: ubuntu-latest
    strategy:
      matrix:
        python: [3.7]

    steps:
      - uses: actions/checkout@v2

      - name: Setup git credentials
        uses: fusion-engineering/setup-git-credentials@v2
        with:
          credentials: ${{secrets.GIT_CREDENTIALS}}

      - name: Setup Python
        uses: actions/setup-python@v1
        with:
          python-version: ${{ matrix.python }}

      - name: Cache pip
        uses: actions/cache@v1
        id: cache-pip
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-

      - name: Install Tox
        if: steps.cache-pip.outputs.cache-hit != 'true'
        run: pip install tox

      - name: Cache Tox
        uses: actions/cache@v1
        with:
          path: .tox
          key: ${{ runner.os }}-tox-${{ hashFiles('**/tox.ini') }}
          restore-keys: |
            ${{ runner.os }}-tox-

      - name: Cache Molecule
        uses: actions/cache@v1
        with:
          path: ~/.cache/molecule
          key: ${{ runner.os }}-molecule-${{ hashFiles('**/requirements.yml') }}
          restore-keys: |
            ${{ runner.os }}-molecule-

      - name: Run Tox
        run: tox

And the tox.ini which should be enough to reproduce

[tox]
envlist = molecule
skipsdist = true

[testenv:molecule]
deps =
  ansible-lint
  flake8
  molecule[docker]~=3.0
  netaddr
  requests
  testinfra
  yamllint
passenv =
  HOME
  SSH_AUTH_SOCK
  TERM
  TTY
commands = echo molecule {posargs:test}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dhadkacommented, May 27, 2020

👋 @nvivobume This type of behavior is typically caused by the cache scope. Details can be found in issue https://github.com/actions/cache/issues/79 and in the docs. If the docs aren’t clear or you still see the issue, please let me know.

@crane-hiromu Are the two screenshots from different tags? Is the develop branch the default branch for your repo? Two workflows triggered from tags won’t be able to share caches (same scoping issue I mention above), but can read from caches created by your default branch. I would suggest making sure the changes are in the default branch and a workflow is triggered from the default branch to create the cache.

0reactions
rgarriguecommented, Jun 10, 2020

Indeed, I c/ced my “tests.yml” to make a “make_cache.yml” workflow

on:
  push:
    branches:
      - master

# same stuff as my tests.yml workflow, only the "tox" command change a bit to only install the deps

And it works. “make_cache” is really fast, so doesn’t add much overhead on commits

Read more comments on GitHub >

github_iconTop Results From Across the Web

Second Level Cache never hits using, spring3, hibernate4 ...
The entity loading goes to 2st level cache, then 2nd level cache only to hit the db if there isn't such entity already...
Read more >
sccache never has cache hits when invoked through cargo #193
I have Rust 1.22 nightly installed. I installed sccache with cargo install sccache (sccache 0.2.1). I followed instruction to set up ...
Read more >
How to Deal with Common Causes of a Poor Cache hit Ratio
The cache hit ratio (or hit ratio for short) is the ratio of hits to cacheable requests (hits and misses combined).
Read more >
When They Occur (& How to Increase Cache Hit Ratio)
Learn why it is important to have a caching policy, when cache miss and cache hit occur, how cache hit ratio is calculated...
Read more >
cache-control, no-cache, no-store, max-age, ETag and etc.
Caching on the Web Explained with simple examples of how HTTP Caching works, including Proxy Caching and CDNs, and how the Cache -Control ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found