use cache of non container job in container job
See original GitHub issueI cant use the created cache inside a container job, if the cache was created in an non container job.
The error is see in the container job “js-jest” is:
/usr/bin/docker exec d681d1c1d1bcf898d5a7572538c549201c3d35aa22e366f14085ed1681753d31 sh -c "cat /etc/*release | grep ^ID"
Cache not found for input keys: Linux-node--d427a8aabcc0acf518e5cf6e5e4f3541ac6d9d8b4d3d10b1e26d8704b65748f7, Linux-node-
The non container “prettier” job uses the cache and works. Even if its not realy used here i’ve added an “ls -al” to the run part so i could see, that the cache was there.
This is the whole workflow config:
name: ci
on:
pull_request:
jobs:
install-npm:
runs-on: ubuntu-20.04
steps:
- name: Checkout Code
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '10.19'
- uses: actions/cache@v2
id: cache-npm
with:
path: |
.env
.npm
node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- name: run npm
if: steps.cache-npm.outputs.cache-hit != 'true'
run: |
make
npm ci --no-progress
js-jest:
container:
image: specialpurposecontainer:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
needs: install-npm
runs-on: ubuntu-20.04
steps:
- name: Checkout Code
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '10.19'
- uses: actions/cache@v2
id: cache-npm
with:
path: |
.env
.npm
node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- name: run npm
run: npm run test:ci
prettier:
needs: install-npm
runs-on: ubuntu-20.04
steps:
- name: Checkout Code
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '10.19'
- uses: actions/cache@v2
id: cache-npm
with:
path: |
.env
.npm
node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- name: run npm
run: npm run prettier
If there is some special config needed to use the cache inside the container, i would be glad if somebody could share it.
What seems to be a workaround is to run all jobs in containers but that makes ci slower.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Azure DevOps Container Jobs: Cache Container for multiple ...
So has anyone solved caching the container? Here is an example: # in this example, all jobs use the same container. # in...
Read more >Define container jobs (YAML) - Azure Pipelines - Microsoft Learn
The container job uses the underlying host agent Docker config.json for image registry authorization, which logs out at the end of the Docker ......
Read more >Cache key file paths incorrectly presented in container jobs
File paths shown in the log for the Cache/CacheBeta task are incorrectly shown in their "host path" form when running in a container...
Read more >Working with OneDev Cache - Medium
Working with OneDev Cache ... CI/CD jobs running in a container always starts with a clean environment, and can be slow as it...
Read more >Caching in GitLab CI/CD
A cache is one or more files a job downloads and saves. Subsequent jobs that use the same cache don't have to download...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks! Yes, as I expected the container is unable to find
zstd
:Any chance you can create the container image with
zstd
?Not sure why building on top of a node image didn’t work but I managed to build on top of ubuntu:
The Dockerfile can be found here: https://github.com/jderrough/node-zstd You can get the images here: https://hub.docker.com/repository/docker/jderrough/node-zstd And refence them like so: