Skip to content

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

Merged
merged 1 commit into from
Mar 3, 2025

Conversation

arixmkii
Copy link
Contributor

@arixmkii arixmkii commented Feb 25, 2025

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.

@arixmkii arixmkii force-pushed the fix-windows-ci branch 2 times, most recently from 34afea9 to 2c17d3f Compare February 25, 2025 22:15
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -eu -o pipefail

export MSYS2_ARG_CONV_EXCL='*'
Copy link
Member

@AkihiroSuda AkihiroSuda Feb 26, 2025

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Commented

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

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

Copy link
Contributor Author

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?

Copy link
Member

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'

Copy link
Contributor Author

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).

@@ -13,6 +15,9 @@ fi
FILE="$1"
NAME="$(basename -s .yaml "$FILE")"

HOME_SRC=${HOME_SRC:-$HOME}
HOME_DST=${HOME_DST:-$HOME}
Copy link
Member

Choose a reason for hiding this comment

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

Needs a comment line

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'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?

Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Contributor Author

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

@@ -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", "~"})
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@arixmkii arixmkii Feb 26, 2025

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.

Copy link
Contributor Author

@arixmkii arixmkii Feb 26, 2025

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

@AkihiroSuda AkihiroSuda added this to the v1.1 (tentative) milestone Feb 26, 2025
@arixmkii arixmkii changed the title Fix Windows CI Enable Integration tests in Windows CI Feb 26, 2025
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")"
Copy link
Member

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

Copy link
Contributor Author

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

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

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

@@ -306,6 +341,9 @@ if [[ -n ${CHECKS["port-forwards"]} ]]; then
rm nerdctl-full.tgz
sudo="sudo"
fi
if [[ ${NAME} == "wsl2" ]]; then
Copy link
Member

Choose a reason for hiding this comment

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

Better to check vmType?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Added.

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda requested a review from a team March 1, 2025 17:11
@AkihiroSuda AkihiroSuda merged commit bfac818 into lima-vm:master Mar 3, 2025
31 checks passed
@arixmkii arixmkii deleted the fix-windows-ci branch March 6, 2025 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Windows CI began to fail on Oct 21
2 participants