-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (60 loc) · 3 KB
/
python-package-conda.yml
File metadata and controls
72 lines (60 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Run Pytests and linting
on: [push]
jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5
steps:
- uses: actions/checkout@v4
- name: Install OS dependencies (Tkinter, Xvfb)
# Node.js might not be strictly needed anymore if all actions are Conda-based
# but keeping it for now in case any underlying GitHub Action mechanism uses it.
run: |
sudo apt-get update -y && \
sudo apt-get install -y nodejs npm tk-dev tcl-dev xvfb
- name: Setup Conda Environment
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: text-editor-env # Name from environment.yml
environment-file: environment.yml
python-version: "3.10" # Ensures the created env has this Python if not in yml
auto-update-conda: true
# All subsequent steps will use the activated Conda environment
# The shell: bash -l {0} ensures the Conda env is sourced for each step.
- name: Install project (editable mode)
shell: bash -l {0}
run: |
echo "Python for pip install -e: $(which python)"
pip install -e . -v
echo "--- Installed packages (pip list) ---"
pip list
echo "PYTHONPATH (before explicit set): $PYTHONPATH"
- name: Set PYTHONPATH for tests
# This might still be needed if pytest within Conda has issues with src-layout
shell: bash -l {0}
run: |
echo "Setting PYTHONPATH to ${{ github.workspace }}/src"
echo "PYTHONPATH=${{ github.workspace }}/src:$PYTHONPATH" >> $GITHUB_ENV
- name: Test import before pytest
shell: bash -l {0}
run: |
echo "Current PYTHONPATH: $PYTHONPATH"
echo "Python for direct import test: $(which python)"
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')"
- name: Lint with flake8
shell: bash -l {0}
run: |
echo "Python for flake8: $(which python)"
echo "Flake8 from PATH: $(which flake8 || echo 'flake8 not directly on PATH')"
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics || \
(echo "flake8 direct command failed, trying python -m flake8" && python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics)
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics || \
(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)
- name: Test with pytest
shell: bash -l {0}
run: |
echo "Current PYTHONPATH: $PYTHONPATH"
echo "Python for pytest step: $(which python)"
echo "Pytest from module path: $(python -m pytest --version)"
xvfb-run python -m pytest