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
Add rust support to CI #1966
Add rust support to CI #1966
Conversation
904fc8f
to
b223b8b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the initial integration added some comments
.ci/install_rust.sh
Outdated
fi | ||
|
||
# rust specific packages | ||
sudo -E apt-get update && apt-get install -y build-essential g++ \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This are distro specific installs could you move this to https://github.com/kata-containers/tests/blob/master/.ci/setup_env_ubuntu.sh, and as bonus would be nice to add to all the distros.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmake/musl-libc is missed/outdated in some other distro, that why ubuntu is used for rust agent.
maybe we will resolve cmake/musl-libc in other distros later, as what we do in osbuilder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some pakages(libstdc++-8-dev) are only in bionic. It is needed to build rust agent. move this into specific distro script error out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
rustup toolchain install ${release}-${rustarch}-unknown-linux-gnu | ||
rustup default ${release}-${rustarch}-unknown-linux-gnu | ||
rustup target install ${rustarch}-unknown-linux-musl | ||
ln -sf /usr/bin/g++ /bin/musl-g++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks distro dependent as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, it is not
.ci/static-checks.sh
Outdated
local -r libs=("rustjail" "oci") | ||
local -r bins=(".") | ||
for lib in ${libs[@]}; do | ||
rustfmt --check ${lib}/src/lib.rs > /dev/null 2>&1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This depend on the repo this is run where is run and will work only in agent (as we expect but should not be this then in the agent repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand it. directory problem?
The functions for go also assume that script 's work directory is the repo directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @jcvenegas is saying (and I agree) that you shouldn't be assuming $dir/src/lib.rs
. Instead, why not do something like:
find . -type f -name "*.rs" | egrep -v "grpc-rs/|target/" | xargs rustfmt ...
Admittedly, that still hard-codes a small amount of rust agent knowledge (the grpc-rs
), but that problem could be overcome easily by moving grpc-rs/
into vendor/grpc-rs/
and updating the new agents Cargo.toml
to specify:
grpcio = { path = "vendor/grpc-rs" }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grpc-rs has dozens of submodules, it might be easier to use it as submodule instead of a vendor directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib crates have src/lib.rs, bin crates have src/main.rs. I don't understand what the problem is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @jcvenegas is saying (and I agree) that you shouldn't be assuming
$dir/src/lib.rs
. Instead, why not do something like:find . -type f -name "*.rs" | egrep -v "grpc-rs/|target/" | xargs rustfmt ...Admittedly, that still hard-codes a small amount of rust agent knowledge (the
grpc-rs
), but that problem could be overcome easily by movinggrpc-rs/
intovendor/grpc-rs/
and updating the new agentsCargo.toml
to specify:grpcio = { path = "vendor/grpc-rs" }
I see. clone submodule into vendor/grpc-rs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
.ci/static-checks.sh
Outdated
@@ -1090,6 +1114,23 @@ main() | |||
fi | |||
fi | |||
|
|||
if [ "${RUST_AGENT:-}" == "yes" ]; then | |||
# skip checks specific to go | |||
if [[ "${func}" =~ "go_arch_specific" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If someone modify this function names, the rust agent CI will be broken easily
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
.ci/static-checks.sh
Outdated
@@ -299,6 +299,27 @@ static_check_go_arch_specific() | |||
eval "$linter" "${linter_args}" "$dirs" | |||
} | |||
|
|||
static_check_rust_arch_specific() | |||
{ | |||
local -r libs=("rustjail" "oci") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is only for rust agent but I wonder if would be good to make this a ENV variable that the script checks and in an repo we are free to set what libs we want to analyse or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
a8acbba
to
0d64502
Compare
.ci/install_rust.sh
Outdated
release="nightly" | ||
|
||
if [ "${rustarch}" == "ppc64le" ]; then | ||
rustarch="powerpc64le" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could consider adding a --rust
option to https://github.com/kata-containers/tests/blob/master/.ci/kata-arch.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
# sudo -E apt-get -y install build-essential g++ make cmake automake autoconf m4 libc6-dev libstdc++-8-dev coreutils binutils debianutils gcc musl musl-dev musl-tools git | ||
|
||
rustup toolchain install ${release}-${rustarch}-unknown-linux-gnu | ||
rustup default ${release}-${rustarch}-unknown-linux-gnu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to add a check for KATA_DEV_MODE
to avoid surprising people running this "outside of the CI":
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
.ci/setup_env_ubuntu.sh
Outdated
@@ -43,6 +43,8 @@ declare -A packages=( \ | |||
[redis]="redis-server" \ | |||
) | |||
|
|||
rust_agent_pkgs="build-essential g++ make cmake automake autoconf m4 libc6-dev libstdc++-8-dev coreutils binutils debianutils gcc musl musl-dev musl-tools git" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
rust_agent_pkgs=()
rust_agent_pkgs+=(build-essential)
rust_agent_pkgs+=(g++)
rust_agent_pkgs+=(make)
That makes it easier to read the list, easier to diff and easier to sort alphabetically 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
.ci/setup_env_ubuntu.sh
Outdated
@@ -63,6 +65,11 @@ main() | |||
done | |||
fi | |||
|
|||
# packages for rust agent, build on 18.04 or later | |||
if [ "${VERSION_ID}" >= "18.04" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand - if building on an older version of Ubuntu, you don't need these packages? Do you mean we should exit the script with an error if version <= 18.04
?
Also, this test doesn't work. You need to do something like one of the following:
result=$(echo "$VERSION_ID > 18.04" | bc)
or,
int_version=$(echo $VERSION_ID|tr -d \.)
[ $int_version -ge 1804 ] && ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some packages are missed in older version of ubuntu. They are needed for build rust agent. I think the string comparison is ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-_-. string comparison has no >=. The ! version < "18.04" works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fxied
.ci/static-checks.sh
Outdated
local -r libs=("rustjail" "oci") | ||
local -r bins=(".") | ||
for lib in ${libs[@]}; do | ||
rustfmt --check ${lib}/src/lib.rs > /dev/null 2>&1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @jcvenegas is saying (and I agree) that you shouldn't be assuming $dir/src/lib.rs
. Instead, why not do something like:
find . -type f -name "*.rs" | egrep -v "grpc-rs/|target/" | xargs rustfmt ...
Admittedly, that still hard-codes a small amount of rust agent knowledge (the grpc-rs
), but that problem could be overcome easily by moving grpc-rs/
into vendor/grpc-rs/
and updating the new agents Cargo.toml
to specify:
grpcio = { path = "vendor/grpc-rs" }
This patch adds preliminary support to rust agent. Fixes: kata-containers#1965 Signed-off-by: Yang Bo <bo@hyper.sh>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @yyyeerbo.
lgtm
/test |
Restarted two of the CI's which failed due to what looks like transitory issues. |
-_-. Time out when downloading kernel |
This patch adds preliminary support to rust agent.
Fixes: #1965
Signed-off-by: Yang Bo bo@hyper.sh