Skip to content

Add a --checkout option to tweak which jobs are run #8

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

Merged
merged 2 commits into from
May 15, 2025

Conversation

jacob-hughes
Copy link
Contributor

This is a big change, but one I have been wanting for a while. It fixes a huge limitation of TryCI which is that it could only fire off CI jobs from the working tree of a repository.

A lot of the time this was good enough, but it can lead to subtle bugs where TryCI behaves differently to our CI server. It's easy to accidentally have dirty files sent over as part of the build context and influence the CI result (even if they were .gitignored).

Now we can use TryCI to run CI jobs at specific git refs. This works with locally cloned repos and with remote URLs. Here are some examples:

tryci --checkout "HEAD"

tryci --checkout "feature-branch"

tryci --checkout "origin/master"

tryci --checkout "f5a7b2"

tryci --checkout "https://github.com/ykjit/yk#trying"

When the '--checkout ' option is used, TryCI will checkout in a tempdir which becomes the build context for that CI job. It also sets this temp repo up to emulate buildbot on bencher13 as closely as possible (cloning with a depth of 100; setting the correct remote-urls etc).

To ensure that docker build caching still works, this commit also adjusts the naming scheme for docker image tags. Checkouts of local builds will have the following format:

<user>-local-<rootdir>:<ref>-<dockerfile_suffix>

So running 'tryci --checkout "f5a7b2"' in a local yk repo will build the following image:

jake-local-yk:f5a7b2-debian

Remote builds will have the following format:

<user>-github.com_<org>_<repo>:<ref>-<dockerfile_suffix>

So 'tryci --checkout "https://github.com/ykjit/yk#trying"' would be:

jake-github.com_ykjit_yk:trying-debian

This way TryCI checkouts which are not based on the working tree will not invalidate the caches of previous jobs.

Perhaps the biggest win from this is that you can fire off a fresh CI job on a machine which you don't even have the repo cloned on. You can also do this in parallel because no two builds copy context from the same directory (i.e. your working tree). This makes bisecting so much easier.

Many of our .buildbot_dockerfile_* files use `docker buildx` as part of
the build process. If the host machine does not have this installed then
tryci jobs fail much later on with very strange error messages. We
should catch this early and make it clear what's going on.
@ltratt
Copy link
Member

ltratt commented May 15, 2025

Does this mean we should close #7 ?

@jacob-hughes
Copy link
Contributor Author

That one is still useful (I'm using a hacky version of it on b14). If/when you're happy with this I'll rebase it against this and update it to address your comment.

This is a big change, but one I have been wanting for a while. It fixes
a huge limitation of TryCI which is that it could only fire off CI jobs
from the working tree of a repository.

A lot of the time this was good enough, but it can lead to subtle bugs
where TryCI behaves differently to our CI server. It's easy to
accidentally have dirty files sent over as part of the build context and
influence the CI result (even if they were .gitignored).

Now we can use TryCI to run CI jobs at specific git refs. This works
with locally cloned repos and with remote URLs. Here are some examples:

```
tryci --checkout "HEAD"

tryci --checkout "feature-branch"

tryci --checkout "origin/master"

tryci --checkout "f5a7b2"

tryci --checkout "https://github.com/ykjit/yk#trying"
```

When the '--checkout <ref>' option is used, TryCI will checkout <ref> in
a tempdir which becomes the build context for that CI job. It also sets
this temp repo up to emulate buildbot on bencher13 as closely as
possible (cloning with a depth of 100; setting the correct remote-urls
etc).

To ensure that docker build caching still works, this commit also
adjusts the naming scheme for docker image tags. Checkouts of local
builds will have the following format:

<user>-local-<rootdir>:<ref>-<dockerfile_suffix>

So running 'tryci --checkout "f5a7b2"' in a local `yk` repo will build
the following image:

jake-local-yk:f5a7b2-debian

Remote builds will have the following format:

<user>-github.com_<org>_<repo>:<ref>-<dockerfile_suffix>

So 'tryci --checkout "https://github.com/ykjit/yk#trying"' would be:

jake-github.com_ykjit_yk:trying-debian

This way TryCI checkouts which are not based on the working tree will
not invalidate the caches of previous jobs.

Perhaps the biggest win from this is that you can fire off a fresh CI
job on a machine which you don't even have the repo cloned on. You can
also do this in parallel because no two builds copy context from the
same directory (i.e. your working tree). This makes bisecting so much
easier.
@jacob-hughes
Copy link
Contributor Author

Force-pushed a minor fix where I forgot to update the -c/--checkout names in the opts parser from their old placeholder name

@ltratt ltratt merged commit 7bc9058 into softdevteam:master May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants