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

Add rust support to CI #1966

Merged
merged 1 commit into from Oct 11, 2019
Merged

Add rust support to CI #1966

merged 1 commit into from Oct 11, 2019

Conversation

yyyeerbo
Copy link
Contributor

This patch adds preliminary support to rust agent.

Fixes: #1965

Signed-off-by: Yang Bo bo@hyper.sh

.ci/install_rust.sh Outdated Show resolved Hide resolved
.ci/static-checks.sh Outdated Show resolved Hide resolved
Copy link
Member

@jcvenegas jcvenegas left a 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

fi

# rust specific packages
sudo -E apt-get update && apt-get install -y build-essential g++ \
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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++
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, it is not

local -r libs=("rustjail" "oci")
local -r bins=(".")
for lib in ${libs[@]}; do
rustfmt --check ${lib}/src/lib.rs > /dev/null 2>&1
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor

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" }

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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" }

I see. clone submodule into vendor/grpc-rs.

Copy link
Contributor Author

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 Show resolved Hide resolved
@@ -1090,6 +1114,23 @@ main()
fi
fi

if [ "${RUST_AGENT:-}" == "yes" ]; then
# skip checks specific to go
if [[ "${func}" =~ "go_arch_specific" ]]; then
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -299,6 +299,27 @@ static_check_go_arch_specific()
eval "$linter" "${linter_args}" "$dirs"
}

static_check_rust_arch_specific()
{
local -r libs=("rustjail" "oci")
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@yyyeerbo
Copy link
Contributor Author

.ci/install_rust.sh Outdated Show resolved Hide resolved
.ci/static-checks.sh Show resolved Hide resolved
.ci/static-checks.sh Show resolved Hide resolved
release="nightly"

if [ "${rustarch}" == "ppc64le" ]; then
rustarch="powerpc64le"
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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":

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -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"
Copy link
Contributor

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 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -63,6 +65,11 @@ main()
done
fi

# packages for rust agent, build on 18.04 or later
if [ "${VERSION_ID}" >= "18.04" ]; then
Copy link
Contributor

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 ] && ...

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fxied

local -r libs=("rustjail" "oci")
local -r bins=(".")
for lib in ${libs[@]}; do
rustfmt --check ${lib}/src/lib.rs > /dev/null 2>&1
Copy link
Contributor

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>
Copy link
Contributor

@jodh-intel jodh-intel left a comment

Choose a reason for hiding this comment

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

Thanks @yyyeerbo.

lgtm

@chavafg
Copy link
Contributor

chavafg commented Oct 10, 2019

/test

@jodh-intel
Copy link
Contributor

Restarted two of the CI's which failed due to what looks like transitory issues.

@yyyeerbo
Copy link
Contributor Author

-_-. Time out when downloading kernel

@chavafg chavafg merged commit 72b3159 into kata-containers:master Oct 11, 2019
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.

Preliminary support for rust agent ci
4 participants