Skip to content

Commit a4c9689

Browse files
Fix: Use python venv module first and implement proper platform-specific paths
Co-Authored-By: [email protected] <[email protected]>
1 parent 7029186 commit a4c9689

File tree

1 file changed

+87
-39
lines changed

1 file changed

+87
-39
lines changed

.github/workflows/python-ci.yml

Lines changed: 87 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,93 +18,141 @@ jobs:
1818
steps:
1919
- name: Checkout
2020
uses: actions/checkout@v4
21+
2122
- name: Set up Python
2223
uses: actions/setup-python@v5
2324
with:
2425
python-version: ${{ matrix.python-version }}
25-
- name: Install uv (Unix)
26-
if: runner.os != 'Windows'
26+
27+
- name: Set up Python environment
2728
shell: bash
2829
run: |
30+
python -m venv .venv
31+
if [ "${{ runner.os }}" = "Windows" ]; then
32+
. .venv/Scripts/activate
33+
else
34+
. .venv/bin/activate
35+
fi
2936
python -m pip install --upgrade pip
30-
python -m pip install uv
31-
uv --version
32-
- name: Install uv (Windows)
33-
if: runner.os == 'Windows'
34-
shell: bash
35-
run: |
36-
python -m pip install --upgrade pip
37-
python -m pip install uv
38-
uv --version
37+
pip install uv
38+
3939
- name: selfie-lib - install dependencies
4040
shell: bash
41+
working-directory: python/selfie-lib
4142
run: |
42-
uv venv
43-
. .venv/bin/activate || . .venv/Scripts/activate
44-
python -m pip install uv
43+
if [ "${{ runner.os }}" = "Windows" ]; then
44+
. ../../.venv/Scripts/activate
45+
else
46+
. ../../.venv/bin/activate
47+
fi
4548
uv pip install -r requirements.txt -r dev-requirements.txt
46-
working-directory: python/selfie-lib
49+
4750
- name: selfie-lib - pytest
4851
shell: bash
52+
working-directory: python/selfie-lib
4953
run: |
50-
. .venv/bin/activate || . .venv/Scripts/activate
54+
if [ "${{ runner.os }}" = "Windows" ]; then
55+
. ../../.venv/Scripts/activate
56+
else
57+
. ../../.venv/bin/activate
58+
fi
5159
python -m pytest -vv
52-
working-directory: python/selfie-lib
60+
5361
- name: selfie-lib - pyright
5462
shell: bash
63+
working-directory: python/selfie-lib
5564
run: |
56-
. .venv/bin/activate || . .venv/Scripts/activate
65+
if [ "${{ runner.os }}" = "Windows" ]; then
66+
. ../../.venv/Scripts/activate
67+
else
68+
. ../../.venv/bin/activate
69+
fi
5770
python -m pyright
58-
working-directory: python/selfie-lib
71+
5972
- name: selfie-lib - ruff
6073
shell: bash
74+
working-directory: python/selfie-lib
6175
run: |
62-
. .venv/bin/activate || . .venv/Scripts/activate
76+
if [ "${{ runner.os }}" = "Windows" ]; then
77+
. ../../.venv/Scripts/activate
78+
else
79+
. ../../.venv/bin/activate
80+
fi
6381
python -m ruff format --check && python -m ruff check
64-
working-directory: python/selfie-lib
82+
6583
- name: pytest-selfie - install dependencies
6684
shell: bash
85+
working-directory: python/pytest-selfie
6786
run: |
68-
uv venv
69-
. .venv/bin/activate || . .venv/Scripts/activate
70-
python -m pip install uv
87+
if [ "${{ runner.os }}" = "Windows" ]; then
88+
. ../../.venv/Scripts/activate
89+
else
90+
. ../../.venv/bin/activate
91+
fi
7192
uv pip install -r requirements.txt -r dev-requirements.txt
72-
working-directory: python/pytest-selfie
93+
7394
- name: pytest-selfie - pyright
7495
shell: bash
96+
working-directory: python/pytest-selfie
7597
run: |
76-
. .venv/bin/activate || . .venv/Scripts/activate
98+
if [ "${{ runner.os }}" = "Windows" ]; then
99+
. ../../.venv/Scripts/activate
100+
else
101+
. ../../.venv/bin/activate
102+
fi
77103
python -m pyright
78-
working-directory: python/pytest-selfie
104+
79105
- name: pytest-selfie - ruff
80106
shell: bash
107+
working-directory: python/pytest-selfie
81108
run: |
82-
. .venv/bin/activate || . .venv/Scripts/activate
109+
if [ "${{ runner.os }}" = "Windows" ]; then
110+
. ../../.venv/Scripts/activate
111+
else
112+
. ../../.venv/bin/activate
113+
fi
83114
python -m ruff format --check && python -m ruff check
84-
working-directory: python/pytest-selfie
115+
85116
- name: example-pytest-selfie - install dependencies
86117
shell: bash
118+
working-directory: python/example-pytest-selfie
87119
run: |
88-
uv venv
89-
. .venv/bin/activate || . .venv/Scripts/activate
90-
python -m pip install uv
120+
if [ "${{ runner.os }}" = "Windows" ]; then
121+
. ../../.venv/Scripts/activate
122+
else
123+
. ../../.venv/bin/activate
124+
fi
91125
uv pip install -r requirements.txt -r dev-requirements.txt
92-
working-directory: python/example-pytest-selfie
126+
93127
- name: example-pytest-selfie - pytest
94128
shell: bash
129+
working-directory: python/example-pytest-selfie
95130
run: |
96-
. .venv/bin/activate || . .venv/Scripts/activate
131+
if [ "${{ runner.os }}" = "Windows" ]; then
132+
. ../../.venv/Scripts/activate
133+
else
134+
. ../../.venv/bin/activate
135+
fi
97136
python -m pytest -vv
98-
working-directory: python/example-pytest-selfie
137+
99138
- name: example-pytest-selfie - pyright
100139
shell: bash
140+
working-directory: python/example-pytest-selfie
101141
run: |
102-
. .venv/bin/activate || . .venv/Scripts/activate
142+
if [ "${{ runner.os }}" = "Windows" ]; then
143+
. ../../.venv/Scripts/activate
144+
else
145+
. ../../.venv/bin/activate
146+
fi
103147
python -m pyright
104-
working-directory: python/example-pytest-selfie
148+
105149
- name: example-pytest-selfie - ruff
106150
shell: bash
151+
working-directory: python/example-pytest-selfie
107152
run: |
108-
. .venv/bin/activate || . .venv/Scripts/activate
153+
if [ "${{ runner.os }}" = "Windows" ]; then
154+
. ../../.venv/Scripts/activate
155+
else
156+
. ../../.venv/bin/activate
157+
fi
109158
python -m ruff format --check && python -m ruff check
110-
working-directory: python/example-pytest-selfie

0 commit comments

Comments
 (0)