@@ -14,146 +14,42 @@ jobs:
1414 python-version : ['3.9', '3.10', '3.11']
1515
1616 steps :
17- - uses : actions/checkout@v3
17+ - uses : actions/checkout@v4
1818
1919 - name : Set up Python ${{ matrix.python-version }}
2020 uses : actions/setup-python@v4
2121 with :
2222 python-version : ${{ matrix.python-version }}
23-
24- - name : Cache pip packages
23+
24+ - name : Install Poetry
25+ uses : snok/install-poetry@v1
26+ with :
27+ version : 1.6.1
28+ virtualenvs-create : true
29+ virtualenvs-in-project : true
30+ virtualenvs-path : .venv
31+ installer-parallel : true
32+
33+ - name : Load cached venv
34+ id : cached-poetry-dependencies
2535 uses : actions/cache@v3
2636 with :
27- path : ~/.cache/pip
28- key : ${{ runner.os }}-pip- ${{ hashFiles('**/pyproject.toml ') }}
37+ path : .venv
38+ key : venv- ${{ runner.os }}-${{ matrix.python-version }}- ${{ hashFiles('**/poetry.lock ') }}
2939 restore-keys : |
30- ${{ runner.os }}-pip-
31-
32- - name : Install system dependencies
33- run : |
34- sudo apt-get update
35- sudo apt-get install -y python3-venv
36-
37- - name : Install Poetry
38- run : |
39- echo "=== Installing Poetry ==="
40- # Uninstall any existing Poetry installations
41- pip uninstall -y poetry || true
42- pip uninstall -y poetry-core || true
43- pip uninstall -y poetry-plugin-export || true
44-
45- # Clear Poetry cache and config
46- rm -rf ~/.cache/pypoetry
47- rm -rf ~/.config/pypoetry
48-
49- # Install specific version of Poetry directly using pipx
50- python -m pip install --user pipx
51- python -m pipx ensurepath
52- pipx install "poetry==1.5.1"
53-
54- # Add Poetry to PATH
55- echo "$(python -m site --user-base)/bin" >> $GITHUB_PATH
56- echo "$HOME/.local/bin" >> $GITHUB_PATH
57-
58- # Verify installation
59- which poetry || { echo "Poetry not found in PATH"; exit 1; }
60- poetry --version || { echo "Poetry version check failed"; exit 1; }
61-
62- - name : Verify pyproject.toml
63- run : |
64- echo "=== Verifying pyproject.toml ==="
65- echo "Current directory: $(pwd)"
66- echo "Directory contents:"
67- ls -la
68-
69- if [ ! -f pyproject.toml ]; then
70- echo "\n=== Creating minimal pyproject.toml ==="
71- cat > pyproject.toml << 'EOL'
72- [build-system]
73- requires = ["poetry-core>=1.0.0"]
74- build-backend = "poetry.core.masonry.api"
75-
76- [tool.poetry]
77- name = "dialogchain"
78- version = "0.1.0"
79- description = "DialogChain Python Package"
80- authors = ["Your Name <your.email@example.com>"]
81-
82- [tool.poetry.dependencies]
83- python = "^3.8"
84- EOL
85- echo "\nCreated pyproject.toml with minimal configuration"
86- else
87- echo "\n=== Existing pyproject.toml ==="
88- cat pyproject.toml
89- fi
90-
91- if [ ! -f pyproject.toml ]; then
92- echo "Error : Failed to create pyproject.toml"
93- exit 1
94- fi
95-
96- - name : Configure Poetry
97- run : |
98- echo "=== Debugging Poetry Configuration ==="
99- echo "Current directory: $(pwd)"
100- echo "Python executable: $(which python)"
101- echo "Python version: $(python --version)"
102-
103- # Verify Python installation
104- python -c "import sys; print(f'Python {sys.version}')" || \
105- { echo "Python verification failed"; exit 1; }
106-
107- # Verify Poetry is installed and in PATH
108- which poetry || { echo "Poetry not found in PATH"; exit 1; }
109- echo "Poetry version: $(poetry --version)"
110-
111- # Set Poetry configuration using environment variables
112- export POETRY_VIRTUALENVS_CREATE=true
113- export POETRY_VIRTUALENVS_IN_PROJECT=true
114-
115- # Debug: Show current directory contents
116- echo "\n=== Directory Contents ==="
117- ls -la
118-
119- # Debug: Show pyproject.toml contents
120- echo "\n=== pyproject.toml Contents ==="
121- cat pyproject.toml || { echo "Failed to read pyproject.toml"; exit 1; }
122-
123- # Configure Poetry
124- echo "\n=== Configuring Poetry ==="
125- poetry config virtualenvs.create true
126- poetry config virtualenvs.in-project true
127-
128- # Verify configuration
129- echo "\n=== Current Poetry Configuration ==="
130- poetry config --list || { echo "Failed to list Poetry configuration"; exit 1; }
131-
132- echo "\n=== Poetry Environment ==="
133- poetry env info || { echo "Failed to get Poetry environment info"; exit 1; }
40+ venv-${{ runner.os }}-${{ matrix.python-version }}-
13441
13542 - name : Install dependencies
136- run : |
137- echo "=== Installing dependencies ==="
138- # Check if poetry.lock exists
139- if [ -f poetry.lock ]; then
140- echo "Using existing poetry.lock"
141- poetry install --no-interaction --no-ansi -v
142- else
143- echo "No poetry.lock found, installing without lock file"
144- poetry install --no-interaction --no-ansi -v --no-lock
145- fi
146- # Verify the environment
147- echo "\n=== Environment information ==="
148- poetry env info
149- echo "\n=== Installed packages ==="
150- poetry show --tree || echo "Failed to show package tree"
43+ if : steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
44+ run : poetry install --no-interaction --no-root
45+
46+ - name : Install project
47+ run : poetry install --no-interaction
15148
15249 - name : Run tests
153- run : |
154- poetry run pytest tests/ -v
50+ run : poetry run pytest tests/ -v --tb=short
15551
15652 - name : Lint with flake8
15753 run : |
15854 poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
159- poetry run flake8 . --count --max-complexity=10 --max-line-length=88 --statistics
55+ poetry run flake8 . --count --max-complexity=10 --max-line-length=88 --statistics
0 commit comments