Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4aad37a

Browse files
committed
Improve environment isolation in Cygwin and Alpine Linux on CI
The main change here is to the Cygwin test workflow, which now runsthe tests in a venv (a Python virtual environment), to avoid mixingup our intended dependencies with other files installed by Pythonrelated packages on the system. This should either fix the problemwhere `test_handle_process_output` reports an extra line in stderrfor the `cat_file.py` subprocess on CI or Cygwin, or at least makeit somewhat easier to continue investigating the problem. I thinkthis change is also valuable for its own sake.The connection to the `test_handle_process_output` failure is thatthe extra line in stderr appears at the beginning and is an errormessage about a missing import needed for subprocess code coverage.With the recently added more detailed error reporting, it shows: self.assertEqual(line_counts[1], expected_line_count, repr(lines[1])) > self.assertEqual(line_counts[2], expected_line_count, repr(lines[2])) E AssertionError: 5003 != 5002 : ['pytest-cov: Failed to setup subprocess coverage. Environ: {\'COV_CORE_SOURCE\': \'git\', \'COV_CORE_CONFIG\': \':\', \'COV_CORE_DATAFILE\': \'/cygdrive/d/a/GitPython/GitPython/.coverage\'} Exception: ModuleNotFoundError("No module named \'iniconfig\'")\n', 'From github.com:jantman/gitpython_issue_301\n', ' = [up to date] master -> origin/master\n', ' = [up to date] testcommit1 -> origin/testcommit1\n', ' = [up to date] testcommit10 -> origin/testcommit10\n', ' = [up to date] testcommit100 -> origin/testcommit100\n', ' = [up to date] testcommit1000 -> origin/testcommit1000\n', ' = [up to date] testcommit1001 -> origin/testcommit1001\n', ' = [up to date] testcommit1002 -> origin/testcommit1002\n', ' = [up to date] testcommit1003 -> origin/testcommit1003\n', ' = [up to date] testcommit1004 -> origin/testcommit1004\n', ' = [up to date] testcommit1005 -> origin/testcommit1005\n', ' = [up to date] testcommit test/test_git.py:793: AssertionErrorThis could possibly be worked around by attempting to install apackage to provide `iniconfig`, by configuring `pytest-cov` in away that does not require it, or by temporarily disabling codecoverage reports on Cygwin. Before exploring those or otheroptions, this change seeks to prepare a more isolated environmentin which different package versions are more likely to workproperly together.In addition to that change to the Cygwin workflow, this alsochanges the way the Alpine Linux test workflow is made to use avenv, using the technique that is used here, and undoing somechanges in the Alpine Linux workflow that should not be necessary.The reason for making that change together with this Cygwin changeis that if either does not work as expected, it might shed light onwhat is going wrong with the other.Although the same technique is used on Cygwin and in Alpine Linux,it looks a little different, because the environment variable onCygwin is `BASH_ENV` (since script steps are run in `bash`), whilethe environment variable is `ENV` (since script steps are run in`busybox sh`) and this must also be allowed to pass through `sudo`(since `sh`, which is `busybox sh` on this system, is being invokedthrough `sudo`).
1 parenta0f8425 commit4aad37a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

‎.github/workflows/alpine-test.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
steps:
1717
-name:Prepare Alpine Linux
1818
run:|
19-
apk add sudo git git-daemon python3 py3-pip py3-setuptools py3-virtualenv py3-wheel
20-
echo 'Defaults env_keep += "CI GITHUB_* RUNNER_*"' >/etc/sudoers.d/ci_env
19+
apk add sudo git git-daemon python3 py3-pip py3-virtualenv
20+
echo 'Defaults env_keep += "CIENVGITHUB_* RUNNER_*"' >/etc/sudoers.d/ci_env
2121
addgroup -g 127 docker
2222
adduser -D -u 1001 runner # TODO: Check if this still works on GHA as intended.
2323
adduser runner docker
@@ -47,17 +47,19 @@ jobs:
4747
-name:Set up virtualenv
4848
run:|
4949
python -m venv .venv
50-
. .venv/bin/activate
51-
printf '%s=%s\n' 'PATH' "$PATH" 'VIRTUAL_ENV' "$VIRTUAL_ENV" >>"$GITHUB_ENV"
50+
echo 'ENV=.venv/bin/activate' >> "$GITHUB_ENV" # ENV (not BASH_ENV) for BusyBox sh.
51+
52+
-name:Update PyPA packages
53+
run:|
54+
# Get the latest pip, wheel, and prior to Python 3.12, setuptools.
55+
python -m pip install -U pip $(pip freeze --all | grep -ow ^setuptools) wheel
5256
5357
-name:Install project and test dependencies
5458
run:|
55-
. .venv/bin/activate
5659
pip install ".[test]"
5760
5861
-name:Show version and platform information
5962
run:|
60-
. .venv/bin/activate
6163
uname -a
6264
command -v git python
6365
git version
@@ -66,5 +68,4 @@ jobs:
6668
6769
-name:Test with pytest
6870
run:|
69-
. .venv/bin/activate
7071
pytest --color=yes -p no:sugar --instafail -vv

‎.github/workflows/cygwin-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ jobs:
5555
# and cause subsequent tests to fail
5656
cat test/fixtures/.gitconfig >> ~/.gitconfig
5757
58-
-name:Ensure the "pip" command is available
58+
-name:Set up virtualenv
5959
run:|
60-
# This is used unless, and before, an updated pip is installed.
61-
ln -s pip3 /usr/bin/pip
60+
python -m venv .venv
61+
echo 'BASH_ENV=.venv/bin/activate' >>"$GITHUB_ENV"
6262
6363
-name:Update PyPA packages
6464
run:|

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp