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

define MSRV and check for it in CI #1098

Merged
merged 4 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 6 additions & 19 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,30 +224,18 @@ meta_task:
clone_script: &noop mkdir -p $CIRRUS_WORKING_DIR # source not needed
script: /usr/local/bin/entrypoint.sh

ubuntu20_build_task:
alias: ubuntu20_build
msrv_build_task:
alias: msrv_build
depends_on:
- "build"
gce_instance: *standard_gce_x86_64
container:
cpu: 2 # Do not increase, will result in scheduling delays
memory: "8Gb"
image: quay.io/libpod/ubuntu20rust
# When bumping the image always remember to update the README MSRV as well.
image: quay.io/libpod/nv-rust:1.76
script:
- cargo build


centos9_build_task:
alias: centos9_build
depends_on:
- "build"
gce_instance: *standard_gce_x86_64
container:
cpu: 2 # Do not increase, will result in scheduling delays
memory: "8Gb"
image: quay.io/libpod/centos9rust
script:
- cargo build
- make build


success_task:
Expand All @@ -263,8 +251,7 @@ success_task:
- "integration"
- "integration_aarch64"
- "meta"
- "ubuntu20_build"
- "centos9_build"
- "msrv_build"
gce_instance: *standard_gce_x86_64
env:
API_URL_BASE: "https://api.cirrus-ci.com/v1/artifact/build/${CIRRUS_BUILD_ID}"
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ Netavark is a tool for configuring networking for Linux containers. Its features
- [Podman](https://podman.io/docs) 4.0+
- [protoc](https://grpc.io/docs/protoc-installation/)

## MSRV (Minimum Supported Rust Version)

Copy link
Member

Choose a reason for hiding this comment

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

Add a sentence here: "Netavark is guaranteed to build on this Rust version and later." or similar

Copy link
Member Author

Choose a reason for hiding this comment

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

Given rust weird stance on backwards compatibility I find guaranteed to be a very strong word, i.e. it is not so recent that I think rust 1.80 failed to compile older version of the time crate
rust-lang/rust#127343 (comment)

i.e. it is impossible to build aardvark-dns 1.10.0 with rust v1.80 or newer. To their credit they provide a helpful error but still

error[E0282]: type annotations needed for `Box<_>`
  --> /home/pholzing/.cargo/registry/src/index.crates.io-6f17d22bba15001f/time-0.3.30/src/format_description/parse/mod.rs:83:9
   |
83 |     let items = format_items
   |         ^^^^^
...
86 |     Ok(items.into())
   |              ---- type must be known at this point
   |
   = note: this is an inference error on crate `time` caused by an API change in Rust 1.80.0; update `time` to version `>=0.3.35` by calling `cargo update`

And given we to not test all rust versions there might be some weird stuff in between so I think I rather s/guaranteed/supposed in your sentence

Copy link
Member

Choose a reason for hiding this comment

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

"We test that Netavark will build on the following Rust version. Newer versions should also build, and if they do not, the issue should be reported and will be fixed. Older versions are not guaranteed to build and issues will not be fixed"?

Copy link
Member Author

Choose a reason for hiding this comment

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

sounds good

v1.76

We test that Netavark can be build on this Rust version and on some newer versions.
All newer versions should also build, and if they do not, the issue should be
reported and will be fixed. Older versions are not guaranteed to build and issues
will not be fixed.

## Build

```console
Expand Down
2 changes: 0 additions & 2 deletions contrib/container_images/Dockerfile.CentOS9

This file was deleted.

2 changes: 0 additions & 2 deletions contrib/container_images/Dockerfile.Fedora

This file was deleted.

4 changes: 4 additions & 0 deletions contrib/container_images/Dockerfile.Rust
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Source for quay.io/libpod/nv-rust
# This version should always match the MSRV, when you update this also update the version in the root README.md.
FROM docker.io/library/rust:1.76
RUN apt-get update && apt-get -y install protobuf-compiler libprotobuf-dev
2 changes: 0 additions & 2 deletions contrib/container_images/Dockerfile.UbuntuLatest

This file was deleted.

9 changes: 9 additions & 0 deletions contrib/container_images/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Rust image

The point of this image is to verify the MSRV in CI so we can catch if a code or dependency change bumped the MSRV.
If this is acceptable then update the version in the Dockerfile.Rust FROM line then build the new image see below.

# Build and publish rust image

Make sure you have valid `quay.io/libpod` credentials in order to push the image there.
Then run the script `build_and_publish_rust_image.sh` to build and push it.
19 changes: 19 additions & 0 deletions contrib/container_images/build_and_publish_rust_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -e

PODMAN=${PODMAN:-podman}
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
DOCKERFILE="$(dirname "${BASH_SOURCE[0]}")/Dockerfile.Rust"

# get the tag from the Dockerfile so we do not duplicate it
TAG=$(awk -F':' '/FROM/{print $NF}' $DOCKERFILE)
Copy link
Member

Choose a reason for hiding this comment

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

What would you think of if [[ -z "$TAG" ]]; then echo "FOO! empty tag"; exit 1; fi or equivalent?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes sure

if [[ -z "$TAG" ]]; then
echo "Empty tag in $DOCKERFILE; the tag must specify the rust version to use" >&2
exit 1
fi

FULL_IMAGE_NAME="quay.io/libpod/nv-rust:$TAG"

$PODMAN build -t $FULL_IMAGE_NAME -f $DOCKERFILE
$PODMAN push $FULL_IMAGE_NAME