Conversation
clang-format-docker/Dockerfile
Outdated
| RUN pip install "clang-format~=$CLANG_FORMAT_VERSION" \ | ||
| && mv -f "$(which clang-format)" /usr/bin/clang-format |
There was a problem hiding this comment.
You likely need to install pip and python first before being able to run pip. Not sure where you're seeing failures but this may be the cause.
There was a problem hiding this comment.
Ubuntu tends to come with those preinstalled, unless docker has a different, very barebones image. I see errors running the test CI in my own repo:
Run "/home/runner/work/clang-format-action/clang-format-action/./../clang-format-action/check.sh" "21.1.6" "test/known_pass" "llvm" "capital" ""
Unable to find image 'ghcr.io/jidicula/clang-format:21.1.6' locally
This path suggests to me that we don't use the Dockerfile directly but instead from some repo, likely to cache it? So would need @jidicula to deploy those first (once tested to work), maybe under a new base name to avoid conflicts. Though having to manually deploy them makes me wonder how to handle so many versions, perhaps do the ones currently present on pip plus prefixes, i.e. 21.1.6 => 21.1.6, 21.1, 21.
There was a problem hiding this comment.
It's because it isn't built yet, as the PR isn't merged. And for ghcr.io, you have to authenticate yourself before when downloading from the registry. In GItHub Actions, it is done automatically with the GITHUB_TOKEN
There was a problem hiding this comment.
@echoix Doesn't that create sort of chicken-and-egg scenario? We can't run CI on new images before we merge the PR, but shouldn't merge the PR without checking the new scenarios? Or is it just an artifact of me running in a fork whose token does not match the image cache? In any way I'll try testing the new image locally to ensure it works before marking as ready for review.
There was a problem hiding this comment.
For tests in CI like that, you could do it in two steps in the same job of a workflow file. First, build the image only tagging it with the commit hash or something generic, but don't push it!! Make sure the "load" option of docker/build-push-action is true for this.
Then, run the tests, using the commit hash or the tag used above.
Since the image was loaded to the local image store, it will be available.
Then, rerun the metadata action, with the full labels/tags wanted, and build the image again. Since nothing changed since the last build, the build cache will be used and the build will finish right away. On this build, you can specify to allow pushing to a registry.
That last step shouldn't be done in PRs. You don't want PRs for the general public to publish unreleased images under your image name.
There was a problem hiding this comment.
You don't want PRs for the general public to publish unreleased images under your image name.
I'll just make this my takeaway, the other stuff is a bit over my head 😄 . I'll do local testing then ask for someone to take over the merging once ready.
There was a problem hiding this comment.
You would want something similar to this example:
https://docs.docker.com/build/ci/github-actions/test-before-push/
But using two calls of https://github.com/docker/metadata-action. It will do the sanitation of tags, and help make sure the info is added. It's way simpler to use it rather than not use it.
There was a problem hiding this comment.
@echoix I have tested the new dockerfile locally, everything works as expected. Would you care taking over this PR to do the image publishing part? I unfortunately don't have time to learn this, especially since as first-time contributor to this repo, I can't even run the CI without maintainer approving them every time.
There was a problem hiding this comment.
Also, from what I understand, we need to rename all mentions of ghcr.io/jidicula/clang-format:"$CLANG_FORMAT_VERSION" to ghcr.io/jidicula/clang-format-pip:"$CLANG_FORMAT_VERSION", but then to pass CI we also need to manually build and deploy all those images, which sounds like something only @jidicula themselves can do.
89c6d20 to
e5d8dff
Compare
e5d8dff to
94035f6
Compare
| && echo "clang-format==${CLANG_FORMAT_VERSION}" \ | ||
| || echo "clang-format==${CLANG_FORMAT_VERSION}.*" \ | ||
| )" \ | ||
| # Clean cache |
There was a problem hiding this comment.
If serious about minimizing image, might want to purge python3-pip as well.
|
Sorry, but I won't be accepting this contribution because the pip build doesn't support pre-v6 versions of I'd prefer introducing a way to build |
That seems to only be 3 versions, do you have any telemetry on whether anyone actually uses them?
I may be missing something, but it seems to me like people who rely on old versions can simply not upgrade to newer version of the action. Or keep the old |
Replace
apt installwithpip install, as it allows specifying minor and patch versions. Specifying just major version installs the latest version with that major number. Specifying exact version installs that version.Partial versions like
21.1are not supported, since that would require us detecting whether version is complete, annoying since couple like13.0.1.1are 4 segment. Doable with$ pip index versions --json clang-format | jq -r '.versions.[]' | grep -qxF "$CLANG_FORMAT_VERSION", but that requires installingjqso it's probably not worth it, especially since we did not have multiple minors per major since version11.Tested dockerfile locally (also run the
test/known_{pass,fail}):Resolves #199