Skip to content

Commit bf0c51b

Browse files
Simplify github action
1 parent 2dfaf2d commit bf0c51b

File tree

2 files changed

+23
-35
lines changed

2 files changed

+23
-35
lines changed

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

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,74 +10,63 @@ jobs:
1010

1111
steps:
1212
- uses: actions/checkout@v4
13-
- name: Install OS dependencies (Node.js, Tkinter, Xvfb)
13+
14+
- name: Install OS dependencies (Tkinter, Xvfb)
15+
# Node.js might not be strictly needed anymore if all actions are Conda-based
16+
# but keeping it for now in case any underlying GitHub Action mechanism uses it.
1417
run: |
1518
sudo apt-get update -y && \
1619
sudo apt-get install -y nodejs npm tk-dev tcl-dev xvfb
17-
18-
- name: Setup Miniconda
20+
21+
- name: Setup Conda Environment
1922
uses: conda-incubator/setup-miniconda@v3
2023
with:
21-
python-version: "3.10"
24+
activate-environment: text-editor-env # Name from environment.yml
25+
environment-file: environment.yml
26+
python-version: "3.10" # Ensures the created env has this Python if not in yml
2227
auto-update-conda: true
23-
activate-environment: base
2428

25-
- name: Install Conda dependencies
26-
shell: bash -l {0}
27-
run: |
28-
echo "Updating Conda env: base"
29-
conda env update --file environment.yml --name base
30-
echo "Python from Conda env (after update): $(which python)"
31-
echo "Flake8 in Conda env (after update): $(which flake8 || echo 'flake8 not found directly')"
32-
echo "Conda environment PATH: $CONDA_PREFIX/bin"
29+
# All subsequent steps will use the activated Conda environment
30+
# The shell: bash -l {0} ensures the Conda env is sourced for each step.
3331

34-
# Setup specific Python version for testing using actions/setup-python
35-
- name: Set up Python 3.10 for testing
36-
uses: actions/setup-python@v3
37-
with:
38-
python-version: '3.10'
39-
40-
- name: Install test dependencies (pytest, pytest-xdist) into test Python
41-
run: |
42-
echo "Python for installing test tools: $(which python)"
43-
echo "Pip for installing test tools: $(which pip)"
44-
pip install pytest pytest-xdist
45-
46-
- name: Install project into test Python
32+
- name: Install project (editable mode)
33+
shell: bash -l {0}
4734
run: |
4835
echo "Python for pip install -e: $(which python)"
4936
pip install -e . -v
50-
echo "--- Installed packages (pip list) in test Python ---"
37+
echo "--- Installed packages (pip list) ---"
5138
pip list
5239
echo "PYTHONPATH (before explicit set): $PYTHONPATH"
5340
5441
- name: Set PYTHONPATH for tests
42+
# This might still be needed if pytest within Conda has issues with src-layout
43+
shell: bash -l {0}
5544
run: |
5645
echo "Setting PYTHONPATH to ${{ github.workspace }}/src"
5746
echo "PYTHONPATH=${{ github.workspace }}/src:$PYTHONPATH" >> $GITHUB_ENV
5847
59-
- name: Test import before pytest (using test Python)
48+
- name: Test import before pytest
49+
shell: bash -l {0}
6050
run: |
6151
echo "Current PYTHONPATH: $PYTHONPATH"
6252
echo "Python for direct import test: $(which python)"
6353
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')"
6454
65-
- name: Lint with flake8 (using Conda env)
55+
- name: Lint with flake8
6656
shell: bash -l {0}
6757
run: |
6858
echo "Python for flake8: $(which python)"
6959
echo "Flake8 from PATH: $(which flake8 || echo 'flake8 not directly on PATH')"
70-
echo "Attempting to run flake8..."
7160
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics || \
7261
(echo "flake8 direct command failed, trying python -m flake8" && python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics)
7362
74-
echo "Attempting to run flake8 with exit-zero..."
7563
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics || \
7664
(echo "flake8 (exit-zero) direct command failed, trying python -m flake8" && python -m flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics)
7765
78-
- name: Test with pytest (using test Python)
66+
- name: Test with pytest
67+
shell: bash -l {0}
7968
run: |
8069
echo "Current PYTHONPATH: $PYTHONPATH"
81-
echo "Python for pytest step: $(which python)" # Should be actions/setup-python's Python
70+
echo "Python for pytest step: $(which python)"
8271
echo "Pytest from module path: $(python -m pytest --version)"
8372
xvfb-run python -m pytest

environment.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ channels:
44
- defaults
55
dependencies:
66
- python=3.10
7-
# pytest and pytest-xdist will be installed via pip in the GitHub Action
87
- flake8
98
- black
109
- pyyaml
1110
- tomli # For pyproject.toml parsing on Python < 3.11
12-
- pre-commit
11+
- pre-commit
1312
- pytest
1413
- pytest-xdist

0 commit comments

Comments
 (0)