github actions에서 pytest를 실행하려고 workflow.yml을 작성함.
pytest 실행부분에서 에러가 발생함
Run pytest .
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.11.1/x64/bin/pytest", line 8, in <module>
sys.exit(console_main())
^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/_pytest/config/__init__.py", line 190, in console_main
code = main()
^^^^^^
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/_pytest/config/__init__.py", line 148, in main
config = _prepareconfig(args, plugins)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/_pytest/config/__init__.py", line 329, in _prepareconfig
config = pluginmanager.hook.pytest_cmdline_parse(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/pluggy/_hooks.py", line 265, in __call__
return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/pluggy/_manager.py", line 80, in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/pluggy/_callers.py", line 55, in _multicall
gen.send(outcome)
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/_pytest/helpconfig.py", line 103, in pytest_cmdline_parse
config: Config = outcome.get_result()
^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/pluggy/_result.py", line 60, in get_result
raise ex[1].with_traceback(ex[2])
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/pluggy/_callers.py", line 39, in _multicall
res = hook_impl.function(*args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1058, in pytest_cmdline_parse
self.parse(args)
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1346, in parse
self._preparse(args, addopts=addopts)
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1248, in _preparse
self.hook.pytest_load_initial_conftests(
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/pluggy/_hooks.py", line 265, in __call__
return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/pluggy/_manager.py", line 80, in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/pluggy/_callers.py", line 60, in _multicall
return outcome.get_result()
^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/pluggy/_result.py", line 60, in get_result
raise ex[1].with_traceback(ex[2])
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/pluggy/_callers.py", line 39, in _multicall
res = hook_impl.function(*args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.1/x64/lib/python3.11/site-packages/pytest_django_dotenv/plugin.py", line 17, in pytest_load_initial_conftests
dotenv.read_dotenv(os.path.join(virtual_env_path, f'../{early_config.getini("env_path")[0]}'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen posixpath>", line 76, in join
TypeError: expected str, bytes or os.PathLike object, not NoneType
github actions runner에는 이미 파이썬이 설치됨. 이미 설치된 파이썬에는 pytest가 설치되지 않았던 것 같음. 가상환경을 생성하고 activate하고 pip install을 한 뒤 pytest를 했더니 성공함
name: Django CI
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
env:
SERVER_ENV: "test"
DEBUG: ${{secrets.SECRET_KEY}}
jobs:
test_project:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
pip install --upgrade pip
python3.8 -m venv env
source env/bin/activate
pip install -r requirements.txt
pytest .