reproducible-containers / buildkit-cache-dance

Save `RUN --mount=type=cache` caches on GitHub Actions ( Forked from https://github.com/overmindtech/buildkit-cache-dance )
Apache License 2.0
98 stars 25 forks source link

Support Glob Injection/Extraction #16

Open JakeCooper opened 6 months ago

JakeCooper commented 6 months ago

I'm attempting to load a cache I know exists into a cache mount

      - name: Cache All node_modules folders
        uses: actions/cache@v3
        with:
          path: ${{ github.workspace }}/**/node_modules
          key: ${{ runner.os }}-node_modules-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
          restore-keys: |
            ${{ runner.os }}-node_modules-${{ env.cache-name }}-
            ${{ runner.os }}-node_modules-
            ${{ runner.io }}-

I know the above works because the output of the pnpm install is as follows

Run pnpm install --frozen-lockfile --prefer-offline
Scope: all 11 workspace projects
Lockfile is up to date, resolution step is skipped
Packages: +3757
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

. postinstall$ rm -rf node_modules/@types/react-native
. postinstall: Done
Done in 3.4s

I've tried something as follows but it doesn't seem to mount correctly?

 - name: Load pnpm cache into Docker Container
    uses: reproducible-containers/buildkit-cache-dance@v2.1.3
     with:
         cache-source: ${{ runner.os }}-pnpm-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
          cache-target: /mono/**/node_modules
RUN --mount=type=cache,id=pnpm,target=/mono pnpm install --prod --frozen-lockfile

But alas no luck. Any pointers?

JakeCooper commented 6 months ago

I assume the glob mount is messing things up here....

AkihiroSuda commented 6 months ago

What will cache-target: /mono/**/node_modules mean?