Skip to content

Commit cca2d21

Browse files
authored
fix(ci): use available Python versions in migration tests (#153)
1 parent 3bad5c2 commit cca2d21

4 files changed

Lines changed: 96 additions & 42 deletions

.github/workflows/integration-test-migrate-python-macos-system.yml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,19 @@ jobs:
3434
echo "$HOME/.dtvem/shims" >> $GITHUB_PATH
3535
echo "$HOME/.dtvem/bin" >> $GITHUB_PATH
3636
37-
- name: "Install Python 3.10 via Homebrew"
37+
- name: "Set up Python 3.11.9 (available in python-build-standalone)"
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: '3.11.9'
41+
42+
- name: "Verify Python version"
43+
id: detect-python
3844
run: |
39-
brew install python@3.10
40-
brew link --overwrite python@3.10
41-
echo "System Python installed at: $(which python3.10)"
42-
python3.10 --version
45+
echo "System Python installed at: $(which python3)"
46+
python3 --version
47+
# Extract version for verification
48+
VERSION=$(python3 --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
49+
echo "PYTHON_VERSION=$VERSION" >> $GITHUB_OUTPUT
4350
4451
- name: "Migrate system Python to dtvem"
4552
run: |
@@ -51,17 +58,24 @@ jobs:
5158
./dist/dtvem list python
5259
5360
- name: "Verify migrated version"
61+
env:
62+
EXPECTED_VERSION: ${{ steps.detect-python.outputs.PYTHON_VERSION }}
5463
run: |
55-
./dist/dtvem list python | grep -E "3\.10\." || (echo "ERROR: Expected Python 3.10.x to be migrated" && exit 1)
56-
echo "SUCCESS: Python 3.10.x was migrated from system"
64+
# Extract major.minor from detected version (e.g., "3.11" from "3.11.9")
65+
MAJOR_MINOR=$(echo "$EXPECTED_VERSION" | cut -d. -f1,2)
66+
echo "Looking for Python $MAJOR_MINOR.x"
67+
./dist/dtvem list python | grep -E "${MAJOR_MINOR}\." || (echo "ERROR: Expected Python ${MAJOR_MINOR}.x to be migrated" && exit 1)
68+
echo "SUCCESS: Python ${MAJOR_MINOR}.x was migrated from system"
5769
5870
- name: Generate summary
5971
if: always()
72+
env:
73+
EXPECTED_VERSION: ${{ steps.detect-python.outputs.PYTHON_VERSION }}
6074
run: |
6175
echo "## Python Migration from System (macOS)" >> $GITHUB_STEP_SUMMARY
6276
echo "" >> $GITHUB_STEP_SUMMARY
63-
echo "**Source:** Homebrew" >> $GITHUB_STEP_SUMMARY
64-
echo "**Version:** 3.10.x" >> $GITHUB_STEP_SUMMARY
77+
echo "**Source:** actions/setup-python" >> $GITHUB_STEP_SUMMARY
78+
echo "**Version:** $EXPECTED_VERSION" >> $GITHUB_STEP_SUMMARY
6579
echo "" >> $GITHUB_STEP_SUMMARY
6680
echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY
6781
echo '```' >> $GITHUB_STEP_SUMMARY

.github/workflows/integration-test-migrate-python-ubuntu-system.yml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,19 @@ jobs:
3434
echo "$HOME/.dtvem/shims" >> $GITHUB_PATH
3535
echo "$HOME/.dtvem/bin" >> $GITHUB_PATH
3636
37-
- name: "Install Python 3.10 via apt (deadsnakes PPA)"
37+
- name: "Set up Python 3.11.9 (available in python-build-standalone)"
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: '3.11.9'
41+
42+
- name: "Verify Python version"
43+
id: detect-python
3844
run: |
39-
sudo add-apt-repository ppa:deadsnakes/ppa -y
40-
sudo apt-get update
41-
sudo apt-get install -y python3.10 python3.10-venv python3.10-dev
42-
echo "System Python installed at: $(which python3.10)"
43-
python3.10 --version
45+
echo "System Python installed at: $(which python3)"
46+
python3 --version
47+
# Extract version for verification
48+
VERSION=$(python3 --version | grep -oP '\d+\.\d+\.\d+')
49+
echo "PYTHON_VERSION=$VERSION" >> $GITHUB_OUTPUT
4450
4551
- name: "Migrate system Python to dtvem"
4652
run: |
@@ -52,17 +58,24 @@ jobs:
5258
./dist/dtvem list python
5359
5460
- name: "Verify migrated version"
61+
env:
62+
EXPECTED_VERSION: ${{ steps.detect-python.outputs.PYTHON_VERSION }}
5563
run: |
56-
./dist/dtvem list python | grep -E "3\.10\." || (echo "ERROR: Expected Python 3.10.x to be migrated" && exit 1)
57-
echo "SUCCESS: Python 3.10.x was migrated from system"
64+
# Extract major.minor from detected version (e.g., "3.11" from "3.11.9")
65+
MAJOR_MINOR=$(echo "$EXPECTED_VERSION" | cut -d. -f1,2)
66+
echo "Looking for Python $MAJOR_MINOR.x"
67+
./dist/dtvem list python | grep -E "${MAJOR_MINOR}\." || (echo "ERROR: Expected Python ${MAJOR_MINOR}.x to be migrated" && exit 1)
68+
echo "SUCCESS: Python ${MAJOR_MINOR}.x was migrated from system"
5869
5970
- name: Generate summary
6071
if: always()
72+
env:
73+
EXPECTED_VERSION: ${{ steps.detect-python.outputs.PYTHON_VERSION }}
6174
run: |
6275
echo "## Python Migration from System (Ubuntu)" >> $GITHUB_STEP_SUMMARY
6376
echo "" >> $GITHUB_STEP_SUMMARY
64-
echo "**Source:** apt (deadsnakes PPA)" >> $GITHUB_STEP_SUMMARY
65-
echo "**Version:** 3.10.x" >> $GITHUB_STEP_SUMMARY
77+
echo "**Source:** actions/setup-python" >> $GITHUB_STEP_SUMMARY
78+
echo "**Version:** $EXPECTED_VERSION" >> $GITHUB_STEP_SUMMARY
6679
echo "" >> $GITHUB_STEP_SUMMARY
6780
echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY
6881
echo '```' >> $GITHUB_STEP_SUMMARY

.github/workflows/integration-test-migrate-python-windows-pyenv.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,31 @@ jobs:
4747
"$env:USERPROFILE\.pyenv\pyenv-win\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
4848
"$env:USERPROFILE\.pyenv\pyenv-win\shims" | Out-File -FilePath $env:GITHUB_PATH -Append
4949
50-
- name: "Install Python 3.11.9 via pyenv-win"
50+
- name: "Find and install available Python 3.11.x via pyenv-win"
51+
id: install-python
5152
shell: pwsh
5253
run: |
5354
$env:Path = "$env:USERPROFILE\.pyenv\pyenv-win\bin;$env:USERPROFILE\.pyenv\pyenv-win\shims;$env:Path"
54-
pyenv install 3.11.9
55-
pyenv global 3.11.9
55+
56+
# List available versions and find latest 3.11.x (non-dev, non-rc)
57+
Write-Host "Available Python 3.11.x versions:"
58+
$versions = pyenv install -l | Select-String "^\s*3\.11\.\d+$" | ForEach-Object { $_.Line.Trim() }
59+
$versions | ForEach-Object { Write-Host " $_" }
60+
61+
# Get the latest 3.11.x version (last one in sorted list)
62+
$latestVersion = $versions | Sort-Object { [version]$_ } | Select-Object -Last 1
63+
Write-Host "Installing Python $latestVersion"
64+
65+
pyenv install $latestVersion
66+
pyenv global $latestVersion
5667
pyenv rehash
68+
5769
Write-Host "pyenv-win Python version:"
5870
python --version
5971
72+
# Output the version for later steps
73+
"PYTHON_VERSION=$latestVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
74+
6075
- name: "Migrate pyenv-win Python to dtvem"
6176
shell: bash
6277
run: |
@@ -69,18 +84,23 @@ jobs:
6984
7085
- name: "Verify migrated version"
7186
shell: bash
87+
env:
88+
EXPECTED_VERSION: ${{ steps.install-python.outputs.PYTHON_VERSION }}
7289
run: |
73-
./dist/dtvem.exe list python | grep -E "3\.11\.9" || (echo "ERROR: Expected Python 3.11.9 to be migrated" && exit 1)
74-
echo "SUCCESS: Python 3.11.9 was migrated from pyenv-win"
90+
echo "Looking for Python $EXPECTED_VERSION"
91+
./dist/dtvem.exe list python | grep -E "$EXPECTED_VERSION" || (echo "ERROR: Expected Python $EXPECTED_VERSION to be migrated" && exit 1)
92+
echo "SUCCESS: Python $EXPECTED_VERSION was migrated from pyenv-win"
7593
7694
- name: Generate summary
7795
if: always()
7896
shell: bash
97+
env:
98+
EXPECTED_VERSION: ${{ steps.install-python.outputs.PYTHON_VERSION }}
7999
run: |
80100
echo "## Python Migration from pyenv-win (Windows)" >> $GITHUB_STEP_SUMMARY
81101
echo "" >> $GITHUB_STEP_SUMMARY
82102
echo "**Source:** pyenv-win" >> $GITHUB_STEP_SUMMARY
83-
echo "**Version:** 3.11.9" >> $GITHUB_STEP_SUMMARY
103+
echo "**Version:** $EXPECTED_VERSION" >> $GITHUB_STEP_SUMMARY
84104
echo "" >> $GITHUB_STEP_SUMMARY
85105
echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY
86106
echo '```' >> $GITHUB_STEP_SUMMARY

.github/workflows/integration-test-migrate-python-windows-system.yml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ jobs:
3737
"$env:USERPROFILE\.dtvem\shims" | Out-File -FilePath $env:GITHUB_PATH -Append
3838
"$env:USERPROFILE\.dtvem\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
3939
40-
- name: "Install Python 3.10 via Chocolatey"
40+
- name: "Detect pre-installed Python version"
41+
id: detect-python
4142
shell: pwsh
4243
run: |
43-
choco install python310 -y
44-
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
45-
Write-Host "System Python installed"
46-
python --version
47-
48-
- name: "Add Chocolatey Python to PATH"
49-
shell: pwsh
50-
run: |
51-
$pythonPath = "C:\Python310"
52-
if (Test-Path $pythonPath) {
53-
$pythonPath | Out-File -FilePath $env:GITHUB_PATH -Append
54-
"$pythonPath\Scripts" | Out-File -FilePath $env:GITHUB_PATH -Append
44+
# GitHub runners have Python pre-installed, use that version
45+
$pythonVersion = python --version 2>&1
46+
Write-Host "Pre-installed Python: $pythonVersion"
47+
# Extract version number (e.g., "3.9.13" from "Python 3.9.13")
48+
if ($pythonVersion -match "Python (\d+\.\d+\.\d+)") {
49+
$version = $Matches[1]
50+
Write-Host "Detected version: $version"
51+
"PYTHON_VERSION=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
52+
} else {
53+
Write-Host "ERROR: Could not detect Python version"
54+
exit 1
5555
}
5656
5757
- name: "Migrate system Python to dtvem"
@@ -66,18 +66,25 @@ jobs:
6666
6767
- name: "Verify migrated version"
6868
shell: bash
69+
env:
70+
EXPECTED_VERSION: ${{ steps.detect-python.outputs.PYTHON_VERSION }}
6971
run: |
70-
./dist/dtvem.exe list python | grep -E "3\.10\." || (echo "ERROR: Expected Python 3.10.x to be migrated" && exit 1)
71-
echo "SUCCESS: Python 3.10.x was migrated from system"
72+
# Extract major.minor from detected version (e.g., "3.9" from "3.9.13")
73+
MAJOR_MINOR=$(echo "$EXPECTED_VERSION" | cut -d. -f1,2)
74+
echo "Looking for Python $MAJOR_MINOR.x"
75+
./dist/dtvem.exe list python | grep -E "${MAJOR_MINOR}\." || (echo "ERROR: Expected Python ${MAJOR_MINOR}.x to be migrated" && exit 1)
76+
echo "SUCCESS: Python ${MAJOR_MINOR}.x was migrated from system"
7277
7378
- name: Generate summary
7479
if: always()
7580
shell: bash
81+
env:
82+
EXPECTED_VERSION: ${{ steps.detect-python.outputs.PYTHON_VERSION }}
7683
run: |
7784
echo "## Python Migration from System (Windows)" >> $GITHUB_STEP_SUMMARY
7885
echo "" >> $GITHUB_STEP_SUMMARY
79-
echo "**Source:** Chocolatey" >> $GITHUB_STEP_SUMMARY
80-
echo "**Version:** 3.10.x" >> $GITHUB_STEP_SUMMARY
86+
echo "**Source:** Pre-installed (GitHub Runner)" >> $GITHUB_STEP_SUMMARY
87+
echo "**Version:** $EXPECTED_VERSION" >> $GITHUB_STEP_SUMMARY
8188
echo "" >> $GITHUB_STEP_SUMMARY
8289
echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY
8390
echo '```' >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)