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

fix: cargo install ignoring Cargo.lock #1047

Merged

Conversation

fabriziosestito
Copy link
Contributor

Description

By default, the Cargo.lock file that is included with the package will be ignored by cargo install.

Since the Dockerfile uses cargo auditable install, there were scenarios where the build regenerated Cargo.lock with updated dependencies.

As a result, the CI passed while the Docker build failed (see [GitHub Actions run](https://github.com/kubewarden/policy-server/actions/runs/12902609277/job/35976498867)).

This PR updates the Dockerfile to add --locked to the cargo auditable install instruction, fixing the issue.

@fabriziosestito fabriziosestito requested a review from a team as a code owner January 22, 2025 15:08
@@ -14,7 +14,7 @@ WORKDIR /usr/src/policy-server
COPY ./ ./

RUN cargo install cargo-auditable
RUN cargo auditable install --target aarch64-unknown-linux-musl --path .
RUN cargo auditable install --locked --target aarch64-unknown-linux-musl --path .
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't it be better to run build --release instead of install?

Copy link
Member

Choose a reason for hiding this comment

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

I think is fine to do that. We just need to copy the binary later, in the final image, from a different place.

Copy link
Member

Choose a reason for hiding this comment

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

I would be fine replacing the install with build --release as long as this doesn't make the Dockerfile more complicated (this is a multi-arch image, the build artifact would be located under two different paths, based on the architecture)

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.58%. Comparing base (fbe1b09) to head (3330629).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1047   +/-   ##
=======================================
  Coverage   63.58%   63.58%           
=======================================
  Files          17       17           
  Lines        1071     1071           
=======================================
  Hits          681      681           
  Misses        390      390           
Flag Coverage Δ
integration-tests 56.26% <ø> (ø)
unit-tests 37.29% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@flavio flavio left a comment

Choose a reason for hiding this comment

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

Good catch! I'm fine with the current PR, but I'm also open to use the build --release command as stated on my comment

@@ -14,7 +14,7 @@ WORKDIR /usr/src/policy-server
COPY ./ ./

RUN cargo install cargo-auditable
RUN cargo auditable install --target aarch64-unknown-linux-musl --path .
RUN cargo auditable install --locked --target aarch64-unknown-linux-musl --path .
Copy link
Member

Choose a reason for hiding this comment

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

I would be fine replacing the install with build --release as long as this doesn't make the Dockerfile more complicated (this is a multi-arch image, the build artifact would be located under two different paths, based on the architecture)

Copy link
Member

@viccuad viccuad left a comment

Choose a reason for hiding this comment

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

Nice catch indeed!

@flavio flavio merged commit ca9876c into kubewarden:main Jan 23, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants