Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs on how to run Pants in CI. #16503

Merged
merged 6 commits into from
Aug 13, 2022
Merged

Conversation

benjyw
Copy link
Sponsor Contributor

@benjyw benjyw commented Aug 12, 2022

Explain where remote caching can come in handy, and why.

Explain where remote caching can come in handy, and why.
Benjy Weinberger and others added 3 commits August 12, 2022 14:13
Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
@benjyw
Copy link
Sponsor Contributor Author

benjyw commented Aug 12, 2022

PTAL - I had to revamp a lot once I dug deeper into GHA caching and its immutability.


- `$HOME/.cache/pants/setup`<br>
This is the Pants bootstrap directory. Cache this against the version, as specified
in `pants.toml`. E.g., if using GitHub Actions you can use:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The named caches are harder, but for this it seems we could provide a step or two that used python + toml to parse out the version and set it as an output for the cache step to use as the right most key instead. In fact, we could can that as an action in pants build/actions and just point folks to use that in this setup rec. For later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but let's get this in for now, as it's a big improvement on what we had before, and we're not trying to be everyone's devops people, just give a sense of what can profitably be cached.

path: |
~/.cache/pants/setup
key: pants-setup-${{ runner.os }}-${{ hashFiles('pants.toml') }}
restore-keys: |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is left as a marker for all restore-key related comments which I won't repeat from pantsbuild/example-python#104 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(same comment about not being comfortable with using restore-keys)

Comment on lines 44 to 50
If you're not using a fine-grained [remote caching](doc:remote-caching-execution) service,
then you may also want to preserve the local Pants cache at `$HOME/.cache/pants/lmdb_store`.
This has to be invalidated on any file that can affect any process, e.g., `hashFiles('**/*')`.
Computing such a coarse hash, and saving and restoring large directories, can be unwieldy.
So this may be impractical and slow on medium and large repos.
A [remote cache service](doc:remote-caching-execution) integrates with Pants's fine-grained
invalidation and avoids these problems, and is recommended for the best CI performance.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another way to skin this cat that I don't see being discussed it self-hosted GitHub Runners, which can leverage a persistent filesystem.

https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have zero experience doing that, and again, it is out of scope for this change I think. We couldn't document that until we tried it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll file an issue and we can document later

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something you've actually done? It's a really interesting approach if so!

@benjyw
Copy link
Sponsor Contributor Author

benjyw commented Aug 13, 2022

This now links to example-python for specifics, rather than copying them here.

@benjyw benjyw requested a review from thejcannon August 13, 2022 13:59
@benjyw benjyw merged commit ecbe3eb into pantsbuild:main Aug 13, 2022
@benjyw benjyw deleted the tweak_ci_docs branch August 13, 2022 14:33
benjyw added a commit to benjyw/pants that referenced this pull request Aug 13, 2022
- More details on how to use the CI cache
- Explain where remote caching can come in handy, and why.
benjyw added a commit that referenced this pull request Aug 13, 2022
- More details on how to use the CI cache
- Explain where remote caching can come in handy, and why.
cczona pushed a commit to cczona/pants that referenced this pull request Sep 1, 2022
- More details on how to use the CI cache
- Explain where remote caching can come in handy, and why.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants