ci: add a runner for Windows 10
This is currently only manually invoked, and allows for failure because we only
have a single runner that takes over 2h for a full run, and there are a handful
of flakey tests, plus 3 known failing tests.
The system being used here is running MSYS, Python, Visual Studio, etc, as
installed by `install-windows-dependencies.ps1`. This script installs
everything to a specific directory instead of using the defaults, so we adjust
the MinGW shell path to compensate. Additionally, the script doesn't install
the launcher `py.exe`. It is possible to adjust the script to install it, but
it's an option to an existing python install (instead of a standalone installer),
and I've had the whole python install fail and rollback when requested to install
the launcher if it detects a newer one is already installed. In short, it is
a point of failure for a feature we don't (yet?) need.
Unlike other systems where the intepreter name includes the version, everything
here is `python.exe`, so they can't all exist on `PATH` and let the script
choose the desired one. (The `py.exe` launcher would accomplish, using the
registry instead of `PATH`, but that wouldn't allow for venv installs.) Because
of this, switch to the absolute path of the python interpreter to be used (in
this case a venv created from the py39 install, which is old, but what both
pyoxidizer and TortoiseHg currently use).
The `RUNTEST_ARGS` hardcodes `-j8` because this system has 4 cores, and
therefore runs 4 parallel tests by default. However on Windows, using more
parallel tests than cores results in better performance for whatever reason. I
don't have an optimal value yet (ideally the runner itself can make the
adjustment on Windows), but this results in saving ~15m on a full run that
otherwise takes ~2.5h. I'm also not concerned about how it would affect other
Windows machines, because we don't have any at this point, and I have no idea
when we can get more.
As far as system setup goes, the CI is run by a dedicated user that lacks admin
rights. The install script was run by an admin user, and then the standard user
was configured to use it. If I set this up again, I'd probably give the
dedicated user admin rights to run the install script, and reset to standard
user rights when done. The python intepreter failed in weird ways when run by
the standard user until it was manually reinstalled by the standard user:
Fatal Python error: init_fs_encoding: failed to get the Python codec of the
filesystem encoding
Additionally, changing the environment through the Windows UI prompts to
escalate to an admin user, and then setting the user level environment variables
like `TEMP` and `PATH` (to try to avoid exceeding the 260 character path limit)
didn't actually change the user's environment. (Likely it changed the admin
user's environment, but I didn't confirm that.) I ended up having to use the
registry editor for the standard user to make those changes.
# Don't run pipelines on branch "merge", since we're fast-forward only.
# Gitlab sees a new branch (since e.g. `topic/stable/my-topic` becomes
# `branch/stable`), but the hash hasn't changed. There is no reason to
# re-run the CI in our case, since we haven't built up any specific automation.
# Right now it's just wasted CI and developer time.
# One can still run the pipeline manually via the web interface,
# like in the case of releases, to make *extra* sure that the actual branch
# has succeeded.
workflow:
rules:
- if: $CI_COMMIT_BRANCH =~ /^branch\/.*/ && $CI_PIPELINE_SOURCE != "web"
when: never
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: $CI_PIPELINE_SOURCE == "push"
when: always
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
when: always
stages:
- build
- checks
- tests
- platform-compat
- py-version-compat
image: registry.heptapod.net/mercurial/ci-images/mercurial-core:$HG_CI_IMAGE_TAG
variables:
PYTHON: python
HG_CI_IMAGE_TAG: "v2.1"
TEST_HGTESTS_ALLOW_NETIO: "0"
SHOW_VERSION_OF: "$PYTHON"
.all_template: &all
when: on_success
needs: []
# TODO: we should use an image based on manylinux instead "all-in-one" image
# used for all test so far.
.build-wheel: &wheel
<<: *all
stage: build
variables:
WHEEL_TYPE: ""
FLAVOR: ""
before_script:
- echo "python used, $PYTHON"
- $PYTHON --version
- echo $WHEEL_TYPE
- test -n "$WHEEL_TYPE"
- echo $FLAVOR
- mkdir -p wheels/$WHEEL_TYPE
script:
- $PYTHON setup.py bdist_wheel $FLAVOR --dist-dir wheels/$WHEEL_TYPE
artifacts:
paths:
- wheels/$WHEEL_TYPE
expire_in: 1 week
build-c-wheel:
<<: *wheel
variables:
WHEEL_TYPE: "c"
# TODO: We should select the wheel compatible with the python (and plateform)
# we use. This is necessary to build multiple wheel.
.runtests_template: &runtests
<<: *all
stage: tests
# The runner made a clone as root.
# We make a new clone owned by user used to run the step.
before_script:
- echo "python used, $PYTHON"
- for tool in $SHOW_VERSION_OF ; do echo '#' version of $tool; $tool --version; done
- rm -rf /tmp/mercurial-ci/ # Clean slate if not using containers
- hg clone . /tmp/mercurial-ci/ --noupdate --config phases.publish=no
- hg -R /tmp/mercurial-ci/ update `hg log --rev '.' --template '{node}'`
- cd /tmp/mercurial-ci/
- ls -1 tests/test-check-*.* > /tmp/check-tests.txt
script:
- echo "$RUNTEST_ARGS"
- echo "$WHEEL_TYPE"
- WHEEL=""
- if test -n "$WHEEL_TYPE"; then
WHEEL="`ls -1 $CI_PROJECT_DIR/wheels/$WHEEL_TYPE/*.whl`";
test -n "$WHEEL";
fi
- if test -n "$WHEEL"; then
echo installing from $WHEEL;
HGTESTS_ALLOW_NETIO="$TEST_HGTESTS_ALLOW_NETIO" "$PYTHON" tests/run-tests.py --hg-wheel $WHEEL --color=always $RUNTEST_ARGS;
else
echo installing from source;
HGTESTS_ALLOW_NETIO="$TEST_HGTESTS_ALLOW_NETIO" "$PYTHON" tests/run-tests.py --color=always $RUNTEST_ARGS;
fi
checks:
<<: *runtests
stage: checks
variables:
SHOW_VERSION_OF: "$PYTHON black clang-format"
RUNTEST_ARGS: "--time --test-list /tmp/check-tests.txt"
CI_CLEVER_CLOUD_FLAVOR: S
rust-cargo-test:
<<: *all
stage: checks
script:
- make rust-tests
- make cargo-clippy
variables:
CI_CLEVER_CLOUD_FLAVOR: S
.test-c: &test_c
<<: *runtests
variables:
RUNTEST_ARGS: " --no-rust --blacklist /tmp/check-tests.txt"
TEST_HGTESTS_ALLOW_NETIO: "1"
test-c:
<<: *test_c
needs: [build-c-wheel]
variables:
WHEEL_TYPE: "c"
RUNTEST_ARGS: "--blacklist /tmp/check-tests.txt"
TEST_HGTESTS_ALLOW_NETIO: "1"
test-pure:
<<: *runtests
variables:
RUNTEST_ARGS: "--pure --blacklist /tmp/check-tests.txt"
test-rust: &test_rust
<<: *runtests
variables:
HGWITHRUSTEXT: cpython
RUNTEST_ARGS: "--rust --blacklist /tmp/check-tests.txt"
test-rhg:
<<: *runtests
variables:
HGWITHRUSTEXT: cpython
RUNTEST_ARGS: "--rust --rhg --blacklist /tmp/check-tests.txt"
test-chg:
<<: *runtests
variables:
RUNTEST_ARGS: "--blacklist /tmp/check-tests.txt --chg"
# note: we should probably get a full matrix for flavor × py-version, but this
# is a simple start to be able to check if we break the lowest supported
# version (and 3.12 have been giving us various troubles)
test-3.8-c:
<<: *test_c
stage: py-version-compat
when: manual # avoid overloading the CI by default
variables:
PYTHON: python3.8
test-3.12-c:
<<: *test_c
stage: py-version-compat
when: manual # avoid overloading the CI by default
variables:
PYTHON: python3.12
test-3.12-rust:
<<: *test_rust
stage: py-version-compat
when: manual # avoid overloading the CI by default
variables:
PYTHON: python3.12
test-3.13-c:
<<: *test_c
stage: py-version-compat
when: manual # avoid overloading the CI by default
variables:
PYTHON: python3.13
test-3.13-rust:
<<: *test_rust
stage: py-version-compat
when: manual # avoid overloading the CI by default
variables:
PYTHON: python3.13
check-pytype:
<<: *test_rust
stage: checks
before_script:
- export PATH="/home/ci-runner/vendor/pyenv/pyenv-2.4.7-adf3c2bccf09cdb81febcfd15b186711a33ac7a8/shims:/home/ci-runner/vendor/pyenv/pyenv-2.4.7-adf3c2bccf09cdb81febcfd15b186711a33ac7a8/bin:$PATH"
- echo "PATH, $PATH"
- hg clone . /tmp/mercurial-ci/ --noupdate --config phases.publish=no
- hg -R /tmp/mercurial-ci/ update `hg log --rev '.' --template '{node}'`
- cd /tmp/mercurial-ci/
- make local PYTHON=$PYTHON
- ./contrib/setup-pytype.sh
script:
- echo "Entering script section"
- sh contrib/check-pytype.sh
# `sh.exe --login` sets a couple of extra environment variables that are defined
# in the MinGW shell, but switches CWD to /home/$username. The previous value
# is stored in OLDPWD. Of the added variables, MSYSTEM is crucial to running
# run-tests.py- it is needed to make run-tests.py generate a `python3` script
# that satisfies the various shebang lines and delegates to `py -3`.
.window_runtests_template: &windows_runtests
<<: *all
when: manual # we don't have any Windows runners anymore at the moment
stage: platform-compat
before_script:
- C:/hgdev/MinGW/msys/1.0/bin/sh.exe --login -c 'cd "$OLDPWD" && ls -1 tests/test-check-*.* > C:/hgdev/tmp/check-tests.txt'
# TODO: find/install cvs, bzr, perforce, gpg, sqlite3
script:
- echo "Entering script section"
- echo "python used, $Env:PYTHON"
- Invoke-Expression "$Env:PYTHON -V"
- echo "$Env:RUNTEST_ARGS"
- echo "$Env:TMP"
- echo "$Env:TEMP"
- C:/hgdev/MinGW/msys/1.0/bin/sh.exe --login -c 'cd "$OLDPWD" && HGTESTS_ALLOW_NETIO="$TEST_HGTESTS_ALLOW_NETIO" $PYTHON tests/run-tests.py --color=always $RUNTEST_ARGS'
windows:
<<: *windows_runtests
when: manual
tags:
- windows
variables:
RUNTEST_ARGS: "-j 8 --blacklist C:/hgdev/tmp/check-tests.txt"
PYTHON: C:/hgdev/venvs/python39-x64/Scripts/python.exe
windows-pyox:
<<: *windows_runtests
when: manual # pyoxidizer builds seem broken with --no-use-pep517
tags:
- windows
variables:
RUNTEST_ARGS: "--blacklist C:/hgdev/tmp/check-tests.txt --pyoxidized"
PYTHON: C:/hgdev/venvs/python39-x64/Scripts/python.exe
macos:
<<: *test_c
stage: platform-compat
when: manual # avoid overloading the CI by default
tags:
- macos