1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Github Actionsのactions/setup-pythonをv1からv2に上げたらエラーになった。

Posted at

前置き

個人的なメモです。

Github ActionsでDjangoのテストをpytestで実行しています。
先日下記のようにactions/setup-python@v1でエラーが発生しました。

main.yml
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v1
        with:
          python-version: 3.8.2
      - run: python -m pip install --upgrade pip
      - run: pip install pipenv
      - run: pipenv install -d
      - run: pipenv run pytest -n auto --cov

エラーの内容はこちらです。

console.log
## [error]Version 3.8.2 with arch x64 not found
Available versions:

2.7.18 (x64)
3.5.9 (x64)
3.6.10 (x64)
3.7.7 (x64)
3.8.3 (x64)

本題

actions/setup-python@v2では3.8.2が使用できそうだったので、
とりあえずバージョンを変更して実行してみました。

その結果、pytestのテストでエラーが発生しました。
エラーの内容はこんな感じです。

console.log
==================================== ERRORS ====================================
_ ERROR collecting 6e684b56-631b-4b6c-932f-7229ff10dace/lib/python3.8/ctypes/test/test_anon.py _
import file mismatch:
imported module 'ctypes.test.test_anon' has this __file__ attribute:
  /opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/ctypes/test/test_anon.py
which is not the same as the test file we want to collect:
  /home/runner/work/xxxx/xxxx/6e684b56-631b-4b6c-932f-7229ff10dace/lib/python3.8/ctypes/test/test_anon.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
(省略)

原因

調べた所、ワークディレクトリにライブラリがダウンロードされており、
そのディレクトリがテスト対象に含めているのが原因でした。

解決方法

とりあえず、pytestの設定(pytest.ini)でuuidっぽいディレクトリはテスト対象外にして解決しました。

pytest.ini
[pytest]
norecursedirs = *-*-*-*-*

もっと良い方法もありそうです。。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?