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

Nickez/build container in ci #1278

Merged
merged 7 commits into from
Aug 22, 2024

Conversation

NickeZ
Copy link
Collaborator

@NickeZ NickeZ commented Aug 19, 2024

Build container in CI and other cleanup regarding ci

@NickeZ NickeZ force-pushed the nickez/build-container-in-ci branch 9 times, most recently from 94011fc to 7ff7e70 Compare August 19, 2024 12:29
@NickeZ NickeZ self-assigned this Aug 19, 2024
Copy link
Collaborator

@benma benma left a comment

Choose a reason for hiding this comment

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

Reviewed the commits except the main commits to build the image in CI, I hope I'll get to them tomorrow.

Generally, please add a quick comment explaining the "why" to every commit message body so it's easier to review and understand.

E.g.

ci: Rename TARGET_BRANCH to COMPARE_REV

Or

ci: Use github checkout action to pull from git repo

(in this one I am not sure how the commit title relates to the changes in the commit)

Makefile Outdated Show resolved Hide resolved
@NickeZ NickeZ force-pushed the nickez/build-container-in-ci branch 7 times, most recently from 455466e to d5e56ef Compare August 20, 2024 08:54
@NickeZ NickeZ force-pushed the nickez/build-container-in-ci branch 7 times, most recently from 7d8f213 to 818037d Compare August 20, 2024 10:19
@NickeZ NickeZ marked this pull request as ready for review August 20, 2024 11:01
@NickeZ NickeZ requested a review from benma August 20, 2024 11:01
@NickeZ
Copy link
Collaborator Author

NickeZ commented Aug 20, 2024

this is ready for review again

Comment on lines +7 to +8
* The docker image is rebuilt if the `Dockerfile` or `.containerversion` file is modified. (In case
of a push event it is also automatically published to docker hub).
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens in the PR CI that modifies the Dockerfile? Technically the CI should run all commits starting from the one that modifies the Dockerfile against the new image, and the ones before against the old image.

Often Dockerfile modifications require other changes too, like fixing new clippy linters when updating the Rust toolchain, etc, and one wants to see if the PR passes CI with the new image.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this is exactly how it works. See my test here: NickeZ#3

Copy link
Collaborator

Choose a reason for hiding this comment

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

Amazing!

@NickeZ NickeZ force-pushed the nickez/build-container-in-ci branch 6 times, most recently from 7237b56 to 0a04e1a Compare August 22, 2024 08:25
NickeZ added 7 commits August 22, 2024 10:28
Since github will take the definition of the workflow from the merge
commit, we need to take the .ci scripts from there as well. If we check
out the .ci scripts from the current commit it might not match the
workflow definition.
Instead of running `git fetch` in a separate script, we specify
`fetch-depth: 0` in the github workflow.
When we list modified files we should only check the commits that are
being added or are under review. Therefore we should use the format `git
diff <commit> <commit>`. Using `git diff <commit>` will diff <commit>
against the current working tree, which is only correct if the working
tree is pristine.

TARGET_BRANCH doesn't have to be limited to being a branch, it can be
any kind of git revision.

Finally instead of hard coding `master`, we use the `event.before` which
has the tip of the branch before the push event.
* Check that container builds on PR
* Publish container from master branch
@NickeZ NickeZ force-pushed the nickez/build-container-in-ci branch from 0a04e1a to 51bc17b Compare August 22, 2024 08:28
@NickeZ NickeZ requested a review from benma August 22, 2024 09:22
Copy link
Collaborator

@benma benma left a comment

Choose a reason for hiding this comment

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

LGTM, nice!

@NickeZ NickeZ merged commit 062b450 into BitBoxSwiss:master Aug 22, 2024
8 checks passed
@NickeZ NickeZ deleted the nickez/build-container-in-ci branch August 22, 2024 11:23
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