-
Notifications
You must be signed in to change notification settings - Fork 661
Enable Integration tests in Windows CI #3280
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
Conversation
34afea9
to
2c17d3f
Compare
@@ -1,6 +1,8 @@ | |||
#!/usr/bin/env bash | |||
set -eu -o pipefail | |||
|
|||
export MSYS2_ARG_CONV_EXCL='*' |
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.
Needs a comment line for explanation
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.
Commented
hack/test-templates.sh
Outdated
@@ -234,32 +258,37 @@ nginx_image="ghcr.io/stargz-containers/nginx:1.19-alpine-org" | |||
alpine_image="ghcr.io/containerd/alpine:3.14.0" | |||
|
|||
if [[ -n ${CHECKS["container-engine"]} ]]; then | |||
sudo="" | |||
if [[ ${NAME} == "wsl2" ]]; 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.
This should check the vmType, not the instance name
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.
Do you have a snippet what is the recommended way to get vmType from inside the shell script.
Also, I'm thinking that this might be extracted to a variable "rootfulContainerEngine" and set it per template. I genuinely believe that it is possible to fix WSL2 template to support user level nerdctl instead. Or there is a possibility that such WSL2 template could appear.
WDYT?
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.
vmType
limactl ls --json "${NAME}" | jq -r .vmType
rootfulContainerEngine
No need to introduce a new variable:
docker info --format json | jq -r '.SecurityOptions | if index("name=rootless") then "rootless" else "rootful" end'
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.
For now I opted for vmType check. Check for rootless will be added when it is really needed (when WSL2 will be able to run nerdctl as non-root).
hack/test-templates.sh
Outdated
@@ -13,6 +15,9 @@ fi | |||
FILE="$1" | |||
NAME="$(basename -s .yaml "$FILE")" | |||
|
|||
HOME_SRC=${HOME_SRC:-$HOME} | |||
HOME_DST=${HOME_DST:-$HOME} |
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.
Needs a comment line
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'm also thinking of renaming this into
HOME_HOST
HOME_GUEST
And adding comment that on some platforms they might differ. Will this be fine?
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.
👍
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.
Renamed and description added with a comment
pkg/osutil/user.go
Outdated
@@ -141,7 +141,7 @@ func LimaUser(limaVersion string, warn bool) *user.User { | |||
warnings = append(warnings, warning) | |||
limaUser.Gid = formatUidGid(gid) | |||
} | |||
home, err := call([]string{"cygpath", limaUser.HomeDir}) | |||
home, err := call([]string{"realpath", "~"}) |
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.
Does this depend on MSYS2?
Eventually this should use pure Windows API that doesn't depend on MSYS2, Cygwin, or whatever else similar.
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.
The deps should be documented in https://lima-vm.io/docs/config/vmtype/#known-issues-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 will check this out and update documentation.
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.
Does this depend on MSYS2?
realpath is part of the same core/minimal msys2 package as cygpath (and is bundled with Git). But I will rework it back to cygpath + .linux suffix. This is needed to prevent nuking home dir, when used with QEMU
2c17d3f
to
30ce30d
Compare
hack/test-templates.sh
Outdated
mkdir -p "${tmpconfig}" | ||
defer "rm -rf \"$tmpconfig\"" | ||
tmpfile="${tmpconfig}/${NAME}.yaml" | ||
cp "$FILE" "${tmpfile}" | ||
FILE="${tmpfile}" | ||
INFO "Setup port forwarding rules for testing in \"${FILE}\"" | ||
"${scriptdir}/test-port-forwarding.pl" "${FILE}" | ||
limactl validate "$FILE" | ||
if [ "$(uname -o)" = "Msys" ]; then | ||
limactl validate "$(cygpath -w "$FILE")" |
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.
Maybe you should set $FILE_HOST
as in HOME_HOST
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.
Your comment lead to another discovery. I didn't think of it before. It would be more correct to always pass OS dependent path format into limactl and use unix like for tooling. So, I added FILE_HOST, where the platform specific representation of FILE resides and used it through the whole shell file, where appropriate.
@@ -234,32 +261,37 @@ nginx_image="ghcr.io/stargz-containers/nginx:1.19-alpine-org" | |||
alpine_image="ghcr.io/containerd/alpine:3.14.0" | |||
|
|||
if [[ -n ${CHECKS["container-engine"]} ]]; then | |||
sudo="" | |||
if [[ "$(limactl ls --json "${NAME}" | jq -r .vmType)" == "wsl2" ]]; then | |||
sudo="sudo" |
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.
Needs a comment to explain the reason
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.
Added
hack/test-templates.sh
Outdated
@@ -284,6 +316,9 @@ if [[ -n ${CHECKS["port-forwards"]} ]]; then | |||
if [ "${NAME}" = "opensuse" ]; then | |||
limactl shell "$NAME" sudo zypper in -y netcat-openbsd | |||
fi | |||
if [ "${NAME}" == "wsl2" ]; 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.
Probably this should check limactl shell "$NAME" command -v dnf
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.
Yes, this will be better. There is low probability to still face incompatibility with dnf distro, but with a different name of netcat package, but this could be fixed if it ever pops 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.
Another minor problem that it will result in a duplicate run for "fedora" case. It would result in noop install, but just is not 100% clean
hack/test-templates.sh
Outdated
@@ -306,6 +341,9 @@ if [[ -n ${CHECKS["port-forwards"]} ]]; then | |||
rm nerdctl-full.tgz | |||
sudo="sudo" | |||
fi | |||
if [[ ${NAME} == "wsl2" ]]; 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.
Better to check vmType?
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.
Agreed. Added.
hack/test-templates.sh
Outdated
@@ -360,7 +398,8 @@ if [[ -n ${CHECKS["restart"]} ]]; then | |||
fi | |||
|
|||
INFO "Stopping \"$NAME\"" | |||
limactl stop "$NAME" | |||
# TODO https://github.com/lima-vm/lima/issues/3221 | |||
limactl stop "$NAME" || [ "$(uname -o)" = "Msys" ] |
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.
The result of $(uname -o)
can be cached in the top of the script
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.
Implemented
30ce30d
to
a9f2a01
Compare
Signed-off-by: Arthur Sengileyev <[email protected]>
a9f2a01
to
22d86cc
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
Fixes #2775
My try to address Windows CI. This enables integration tests for Windows. My test run could be found here https://github.com/arixmkii/qcw/actions/runs/13531374510/job/37814107225
It is pretty unstable on my local machine, so, I have no idea if this will be flaky or not. With WSL2 tooling tests felt bullet proof, but Git bash and tooling is not as stable on my local machine.
The idea is that it will download locally the last known good portable Git for Windows and will use that tooling. Approach is not really suitable for production purposes, but pinning deps for tests only is on the edge of the acceptable.Let's at least see if this breaks some other stuff.