Skip to content

Commit e818c53

Browse files
Fix action set up
1 parent 5721d0c commit e818c53

File tree

1 file changed

+45
-27
lines changed

1 file changed

+45
-27
lines changed

.github/workflows/python-package-conda.yml

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,64 @@ jobs:
1414
run: |
1515
sudo apt-get update -y && \
1616
sudo apt-get install -y nodejs npm tk-dev tcl-dev xvfb
17-
- name: Set up Python 3.10
17+
18+
# Setup Conda and cache its environment
19+
- name: Setup Miniconda
20+
uses: conda-incubator/setup-miniconda@v3
21+
with:
22+
python-version: "3.10" # Specify Python version for Conda base if needed
23+
auto-update-conda: true
24+
# channels: conda-forge,defaults # Handled by environment.yml
25+
26+
- name: Install Conda dependencies
27+
run: |
28+
conda env update --file environment.yml --name base
29+
echo "Python from Conda env (after update): $(which python)"
30+
echo "Conda environment PATH: $CONDA_PREFIX/bin"
31+
32+
# Setup specific Python version for testing using actions/setup-python
33+
# This Python will be used for installing test tools and running tests.
34+
- name: Set up Python 3.10 for testing
1835
uses: actions/setup-python@v3
1936
with:
2037
python-version: '3.10'
21-
- name: Install test dependencies (pytest, pytest-xdist)
38+
39+
- name: Install test dependencies (pytest, pytest-xdist) into test Python
2240
run: |
23-
echo "Pip for pytest install: $(which pip)"
41+
echo "Python for installing test tools: $(which python)"
42+
echo "Pip for installing test tools: $(which pip)"
2443
pip install pytest pytest-xdist
25-
- name: Add conda to system path
26-
run: |
27-
# $CONDA is an environment variable pointing to the root of the miniconda directory
28-
echo "CONDA PATH: $CONDA/bin" # Debugging $CONDA
29-
echo $CONDA/bin >> $GITHUB_PATH
30-
- name: Install Conda dependencies
31-
run: |
32-
conda env update --file environment.yml --name base
33-
echo "Python from Conda env update: $(which python)" # Debug which python conda uses
34-
echo "Pip from Conda env update: $(which pip)" # Debug which pip conda uses
35-
- name: Install project
44+
45+
- name: Install project into test Python
3646
run: |
37-
echo "Python for pip install -e: $(which python)" # Debug which python is used for editable install
47+
echo "Python for pip install -e: $(which python)"
3848
pip install -e . -v
39-
echo "--- Installed packages after pip install -e . ---"
49+
echo "--- Installed packages (pip list) in test Python ---"
4050
pip list
41-
echo "--- PYTHONPATH after pip install -e . ---"
42-
echo "PYTHONPATH IS: $PYTHONPATH"
43-
- name: Test import before pytest
51+
echo "PYTHONPATH (before explicit set): $PYTHONPATH"
52+
53+
- name: Set PYTHONPATH for tests
4454
run: |
55+
echo "Setting PYTHONPATH to ${{ github.workspace }}/src"
56+
echo "PYTHONPATH=${{ github.workspace }}/src:$PYTHONPATH" >> $GITHUB_ENV
57+
58+
- name: Test import before pytest (using test Python)
59+
run: |
60+
echo "Current PYTHONPATH: $PYTHONPATH"
4561
echo "Python for direct import test: $(which python)"
46-
# Test basic Tkinter functionality with Xvfb for early feedback
4762
xvfb-run python -c "import sys; print(f'Python sys.path: {sys.path}'); import editor; print('Successfully imported editor module'); import tkinter; root = tkinter.Tk(); print(f'Tkinter root: {root}'); root.destroy(); print('Successfully imported and initialized/destroyed tkinter root')"
48-
- name: Lint with flake8
63+
64+
- name: Lint with flake8 (using Conda env Python)
65+
shell: bash -l {0} # Ensure Conda env is activated for this step
4966
run: |
50-
# flake8 should be available from the conda env
5167
echo "Flake8 from: $(which flake8)"
68+
echo "Python for flake8: $(which python)"
5269
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
5370
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
54-
- name: Test with pytest
71+
72+
- name: Test with pytest (using test Python)
5573
run: |
56-
echo "Pytest from module path: $(python -m pytest --version)" # Check if pytest module is found by this python
57-
echo "Python for pytest step: ${{ env.pythonLocation }}/bin/python"
58-
# Run pytest under Xvfb
59-
xvfb-run ${{ env.pythonLocation }}/bin/python -m pytest
74+
echo "Current PYTHONPATH: $PYTHONPATH"
75+
echo "Python for pytest step: $(which python)" # Should be actions/setup-python's Python
76+
echo "Pytest from module path: $(python -m pytest --version)"
77+
xvfb-run python -m pytest

0 commit comments

Comments
 (0)