[turborepo] Cache miss occurs in GitHub Actions
What version of Turborepo are you using?
1.9.3
What package manager are you using / does the bug impact?
Yarn v1
What operating system are you using?
Mac
Describe the Bug
The value of 'team' is obtained from the username on https://vercel.com/account, and the value of 'token' is generated and used from https://vercel.com/account/tokens.
It seems that you are experiencing cache misses in GitHub Actions despite ena bling remote caching. Although you see the log message saying "Remote caching enabled," the results always show "0 cached, 3 total.
below is my code
name: Vercel Admin Preview
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_ADMIN }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
on:
push:
branches: ["main"]
pull_request:
types: [opened, synchronize]
paths:
- apps/admin/**
- packages/**
- turbo.json
- .npmrc
- .nvmrc
- "*.config.js"
- .github/workflows/admin-preview.yml
jobs:
Deploy-Preview-Admin:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18
cache: "yarn"
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Install dependencies
run: yarn install
- name: Build
run: yarn build --filter=admin... --team=${{ env.TURBO_TEAM }} --token=${{ env.TURBO_TOKEN }}
- name: Lint
run: yarn lint
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Pull Vercel Environment Information
run: vercel pull --yes --debug --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --debug --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
Expected Behavior
Remote caching should work properly.
To Reproduce
Verify if remote caching is working after executing turbo run build in GitHub Actions
Reproduction Repo
No response
Seeing the same issue on our codebase. Remote caching works when I run turbo locally but the cache gets missed on each run when running on github actions.
I'm using the turborepo example and seeing the same thing as well
Could you try running with -vvv and sharing results? Feel free to send privately to my email (<firstname.<lastname>@vercel.com)
same here, here is a repro, https://github.com/rnw-community/rnw-community/actions/runs/6604259034/job/17938224986
I hit something very similar and found that the root problem seemed to be that I was passing an empty TURBO_TOKEN env var (it was set to TURBO_TOKEN: ${{ vars.TURBO_TOKEN }} instead of TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}). Fixing the env var made the remote caching behave as expected.
What's strange is that this problem was reported subtly as cache misses, rather than as an authentication error. That made troubleshooting a lot more difficult than it needed to be.
What's strange is that this problem was reported subtly as cache misses, rather than as an authentication error. That made troubleshooting a lot more difficult than it needed to be.
I just ran into a problem where my Vercel token had expired. It took a bit to diagnose the problem because I was seeing the same issue -- it was just reporting everything as cache misses and there was no indication that authentication was the cause.
I would have expected, particularly with TURBO_REMOTE_ONLY set to true that there would have been a much more obvious message and/or failure of the CI run.
I also spent a lot of time debugging this. For some reason setting TURBO_TEAM
made it miss the cache. This is what I ended up in our github actions job:
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAMID: ${{ secrets.TURBO_TEAMID }}
TURBO_REMOTE_ONLY: true
Running commands with --verbosity=3 helped out in debugging why the cache was not working.