Skip to content

Commit 9ca1182

Browse files
committed
Actions: Simplify venv usage for pip install
1 parent abcfa7f commit 9ca1182

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

.github/workflows/main.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,18 @@ jobs:
274274
python-version: ${{ matrix.python-version }}
275275

276276
- name: Setup Python Virtual Environment
277-
working-directory: ${{ github.workspace }}
278277
shell: bash
279-
run: python -m venv venv
278+
# The second command puts the venv bin directory on the PATH for
279+
# subsequent steps in the job, which ensures that the correct Python
280+
# version and installed packages are used.
281+
run: |
282+
python -m venv venv
283+
echo "$PWD/venv/bin" >> $GITHUB_PATH
280284
281285
- name: Set up Git repository
282-
working-directory: ${{ github.workspace }}
283286
uses: actions/checkout@v6
284287

285288
- name: Download data from artifact
286-
working-directory: ${{ github.workspace }}
287289
uses: actions/download-artifact@v4
288290
with:
289291
name: data
@@ -297,39 +299,30 @@ jobs:
297299
sudo apt-get install -y libhdf5-dev libnetcdf-dev
298300
299301
- name: Update and install packages
300-
working-directory: ${{ github.workspace }}
301302
shell: bash
302303
run: |
303-
source venv/bin/activate
304304
python -m pip install --upgrade pip wheel
305305
pip install -e ".[all,dev]"
306306
307307
- name: Reinstall h5py and netCDF4 with system libraries
308-
working-directory: ${{ github.workspace }}
309308
if: runner.os == 'Linux'
310309
shell: bash
311310
run: |
312-
source venv/bin/activate
313311
pip install --force-reinstall --no-binary=:all: h5py netCDF4
314312
315313
- name: Install setuptools for Python 3.12
316-
working-directory: ${{ github.workspace }}
317314
if: matrix.python-version == '3.12'
318315
shell: bash
319316
run: |
320-
source venv/bin/activate
321317
pip install setuptools
322318
323319
- name: Run pytest & generate coverage report
324-
working-directory: ${{ github.workspace }}
325320
shell: bash
326321
run: |
327-
source venv/bin/activate
328322
coverage run --rcfile=.github/workflows/.coveragerc --source=./mhkit/ -m pytest -c .github/workflows/pytest.ini
329323
coverage lcov
330324
331325
- name: Upload coverage data to coveralls.io
332-
working-directory: ${{ github.workspace }}
333326
uses: coverallsapp/github-action@v2
334327
with:
335328
github-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)