@@ -228,66 +228,9 @@ jobs:
228228 python-version : ${{ matrix.python-version }}
229229 - name : Set up Poetry
230230 uses : ./setup-poetry
231- - name : Create project
232- run : poetry new test-project --python ">=3.9,<4.0"
233- - name : Add docstrings to source and test files
234- shell : python
235- run : |
236- import os
237- from pathlib import Path
238-
239- def add_docstring_to_file(filepath):
240- """Adds a module docstring to a Python file."""
241- if filepath.suffix != '.py':
242- return
243-
244- with open(filepath, 'r+') as f:
245- content = f.read()
246- # Check if a docstring already exists
247- if not content.startswith(('"""', "'''")):
248- f.seek(0, 0) # Go to the start of the file
249- f.write('"""Module docstring."""\n')
250- f.write(content)
251-
252- # Walk through the project directory to find all Python files
253- for root, _, files in os.walk('.'):
254- for file in files:
255- file_path = Path(root) / file
256- add_docstring_to_file(file_path)
257-
258- def add_docstring_to_file(filepath):
259- """Adds a module docstring to a Python file."""
260- if filepath.suffix != '.py':
261- return
262-
263- with open(filepath, 'r+') as f:
264- content = f.read()
265- # Check if a docstring already exists
266- if not content.startswith(('"""', "'''")):
267- f.seek(0, 0) # Go to the start of the file
268- f.write('"""Module docstring."""\n')
269- f.write(content)
270-
271- # Walk through the project directory to find all Python files
272- for root, _, files in os.walk('.'):
273- for file in files:
274- file_path = Path(root) / file
275- add_docstring_to_file(file_path)
276- - name : Add ni-python-styleguide to the project
277- run : poetry add ni-python-styleguide -C test-project
278- - name : Add mypy to the project
279- run : poetry add mypy -C test-project
280- - name : Show pyproject.toml
281- run : cat test-project/pyproject.toml
282- - name : Create poetry.lock
283- run : poetry lock -C test-project
284- - name : Check that the project was created
231+ - name : Copy test project files
285232 run : |
286- if [ ! -f test-project/pyproject.toml ]; then
287- echo "::error title=Test Failure::The project file does not exist."
288- exit 1
289- fi
290- shell : bash
233+ cp -r ./templates/test-project ./test-project
291234 - name : Analyze Python Project
292235 uses : ./analyze-project
293236 with :
0 commit comments