turbo icon indicating copy to clipboard operation
turbo copied to clipboard

[turborepo] Remote caching does not work on `workflow_call` event in github actions

Open marcofugaro opened this issue 3 years ago • 12 comments

What version of Turborepo are you using?

1.6.3

What package manager are you using / does the bug impact?

Yarn v2/v3 (node_modules linker only)

What operating system are you using?

Mac

Describe the Bug

When enabling remote caching on github actions as explained in the official guide, the remote caching is disabled when using the workflow_call event.

image

The workflow_call event, is used if you want to concatenate workflows, like this for example.

image

It is better explained in the reusing workflows section of the github actions guide.

Expected Behavior

Remote caching should work in workflow_call events.

To Reproduce

# .github/workflows/build.yml

name: Build

on:
  workflow_call:

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      TURBO_TOKEN: ${{ secrets. TURBO_TOKEN }}
      TURBO_TEAM: ${{ secrets. TURBO_TEAM }}

    steps:
      - name: Check out code
        uses: actions/checkout@v3

      - name: Use latest node
        uses: actions/setup-node@v3
        with:
          node-version: 16
          cache: 'yarn'

      - name: Install dependencies
        run: yarn install --immutable

      # remote caching does not work here... but it should
      - name: Build
        run: yarn build

      - name: Upload artifact
        uses: actions/upload-artifact@v3
        with:
          name: my-app
          path: ./apps/my-app/dist/
# .github/workflows/deploy.yml

name: Deploy 

on:
  push:
    branches:
      - main

jobs:
  build:
    uses: ./.github/workflows/build.yml

  deploy:
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Download artifact
        uses: actions/download-artifact@v3
        with:
          name: my-app
          path: ./

      - name: Display downloaded files
        run: ls -R ./

      - name: Deploy 
        # ...

Reproduction Repo

No response

marcofugaro avatar Dec 09 '22 10:12 marcofugaro

Same here too..

# review for PRs
name: Review

on:
  pull_request:
    branches:
      - master


jobs:
  review:
    runs-on: ubuntu-latest
    env:
      TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
      TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '16'
          cache: 'npm'

      - name: Install dependencies
        run: npm install

      - name: Build
        run: |
          npm run build

I changed build command as below, but it does not work too.

npm run build --team=$TURBO_TEAM --token=$TURBO_TOKEN

WANZARGEN avatar Mar 24 '23 08:03 WANZARGEN

I think is happening the same to me. I see turbo cache working on Vercel deploy but on GitHub action I see:

Remote caching disabled

andresgutgon avatar Apr 29 '23 17:04 andresgutgon

@marcofugaro @WANZARGEN @andresgutgon you are get any solution for miss caching issue ??

cw-ddedakiya avatar Oct 30 '23 10:10 cw-ddedakiya

@marcofugaro @WANZARGEN @andresgutgon you are get any solution for miss caching issue ??

No.. 😢

WANZARGEN avatar Oct 30 '23 10:10 WANZARGEN

Not using turbo repo these days sorry

andresgutgon avatar Oct 30 '23 11:10 andresgutgon

hi, guys, i have same issue, i guess. :rofl:

So what did you do with that problem?

oxxxxxy avatar Nov 06 '23 23:11 oxxxxxy

oh, sorry, it is not turbo issue.

oxxxxxy avatar Nov 07 '23 00:11 oxxxxxy

If it helps, I hit the same issue this week with our reusable workflow, but realised that secrets need to be passed from the calling workflow to the called workflow. This fixed the issue for me.

pauledwards241 avatar Jun 19 '24 09:06 pauledwards241

@pauledwards241 good find! if this is the required solution, I would like to see it mentioned at least in the official Vercel guide, then we can close this issue.

marcofugaro avatar Jun 19 '24 09:06 marcofugaro

I don't necessarily feel this is a Vercel issue. In my case it was a misunderstanding on how secrets and contexts work in GitHub reusable workflows. It does list this issue in the reusable workflow limitations.

However, It would have been nice to have slightly more detailed output from TurboRepo e.g. Missing TURBO_TOKEN (or something similar), as it was quite difficult to debug.

pauledwards241 avatar Jun 19 '24 10:06 pauledwards241

I noticed something similar in our actions, after doing turbo prune @some/app remote caching was no longer working even with TURBO_TOKEN present. We host our own cache and have committed .turbo/config.json containing teamId and apiUrl to Git. this file was not being included in the pruned output, simply copying the file into the pruned output fixed this issue for me.

marjorg avatar Oct 10 '24 14:10 marjorg

Hey, folks, looks like the conversation above about the original issue report is indicating that this is a quirk with how GItHub Actions passes secrets. I've created #10923 as a pointer to the GitHub documentation about this, so folks don't reach a dead end if they look in our documentation.

anthonyshew avatar Oct 03 '25 20:10 anthonyshew