felixmosh / turborepo-gh-artifacts

A TurboRepo local cache server which uploads artifact cache to GH artifacts.
MIT License
122 stars 7 forks source link

`outputs: []` not cached #6

Closed humphd closed 2 years ago

humphd commented 2 years ago

We're trying to use turborepo-gh-artifacts in a workflow, and we've got it integrated, but it never caches anything for our lint/tests:

Post job cleanup.
Found server pid: 1881
Killing server pid: 1881
There is nothing to upload.
Server logs:
Cache dir: /home/runner/work/_temp/turbo-cache
Local Turbo server is listening at http://127.0.0.1:9080

Looking at your example run, it's clear that it is uploading cache items. However, you're also calling build vs. lint, which is what we're trying to do (i.e., run tests).

From the Turbo Repo docs, it implies that such tasks would still get cached:

If your task does not emit any files (e.g. unit tests with Jest), set outputs to an empty array (i.e. []). Turborepo will automagically cache the logs for you.

Your code appears to assume there will be a file produced: https://github.com/felixmosh/turborepo-gh-artifacts/blob/master/src/utils/uploadArtifacts.ts#L33-L44

Is this a bug, or confusion on our part?

felixmosh commented 2 years ago

Hi, thank you for reporting this issue 🙏

From your server logs looks like turbo didn't approached to the server (when it does, there are get / put requests)

I in my app there is a lint stage, and its logs are cached.

Let me test it again, and I will update here

felixmosh commented 2 years ago

I've tested it, it works properly, https://github.com/felixmosh/turborepo-gh-artifacts-example/actions/runs/2167137139

Theses 2 artifacts are for the lint output.

Pay ❤️, GITHUB_TOKEN must have actions: read permissions in order to be able to read repo's existing artifacts.

humphd commented 2 years ago

Ok, I'll debug some more. I can't see what we're missing, based on your example. Thanks for checking.

felixmosh commented 2 years ago

Any updates?

humphd commented 2 years ago

cc @menghif. I haven't had time to debug further, but it's not working for us.

felixmosh commented 2 years ago

Can you (or @menghif) prepare a repo that reproduces the issue?

humphd commented 2 years ago

You can see it in https://github.com/Seneca-CDOT/telescope, for example, the eslint workflow at https://github.com/Seneca-CDOT/telescope/blob/master/.github/workflows/eslint-ci.yml or unit tests at https://github.com/Seneca-CDOT/telescope/blob/master/.github/workflows/unit-tests-ci.yml.

Some runs:

felixmosh commented 2 years ago

Can you add the team flag as well. If I recall properly, without it the remote caching is not enabled.

menghif commented 2 years ago

I added the team flag and it now works. Thank you very much @felixmosh for your help!

Since in the Turborepo docs the team flag is not present, I assumed it was not required. Would it be possible to update the README page for this project?

humphd commented 2 years ago

I wonder if the reason I missed this, is that GitHub cuts it off, so I visually skimmed over it:

Screen Shot 2022-04-22 at 11 30 44 AM

It might be good to call out the args explicitly.

Thanks for making this @felixmosh, it's so cool to have it finally working in our repo!

felixmosh commented 2 years ago

Glad it helped you. :)

felixmosh commented 2 years ago

Can I close this issue?

humphd commented 2 years ago

Yes, thanks for all the help with this.