-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Python3.9 and Django 2.2 support, drop Python2.7 and Django 1.11support #13
Changes from all commits
1c7ce2f
d1fd47f
62b696c
804876d
fb40940
3838514
9897f35
6ce6c6b
f66940e
8fcfc5f
1b33848
ebc3d14
3ea2674
96079fb
e699981
f537538
7888314
a1ce88e
aa6ebde
733479d
e40af11
6979781
ed5c025
76d2427
fecf1ae
76b6b17
fbe6534
46d2807
848e7f6
22a2dd6
411ef07
a1a425a
6b9b31c
ba0fbfe
2063bf7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Tests | ||
|
||
# push と pull request イベント毎にGtihubのWorkflowを起動する | ||
on: | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
# ジョブの名称 | ||
test_with_tox: | ||
runs-on: ubuntu-latest | ||
|
||
# 並列して実行する各ジョブのPythonバージョン | ||
strategy: | ||
matrix: | ||
python-version: ['3.6', '3.9'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3.6はすでにEOLです。3.7に修正して良さそう There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kemu3007 このbpmailerを使いたいプロジェクトがまだPython3.6を使っているため、現時点ではPython3.6対応は残したい感じです。 |
||
django-version: ['2.2'] | ||
|
||
steps: | ||
# ソースコードをチェックアウト | ||
- uses: actions/checkout@v2 | ||
|
||
# ジョブのPython環境を設定 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
# Github Actionsからtoxを実行するために必要なパッケージをインストール | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install tox tox-gh-actions | ||
|
||
# Github Actionsからtoxを実行 | ||
- name: Test with tox | ||
run: | | ||
tox |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.. image:: https://github.com/beproud/bpmailer/actions/workflows/tests.yml/badge.svg | ||
:target: https://github.com/beproud/bpmailer/actions | ||
:alt: GitHub Actions | ||
|
||
Requirements | ||
============ | ||
|
||
* Python (3.6, 3.9) | ||
* Celery (4.1) | ||
* Django (2.2) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# toxを使用せず、直接 python tests.py で単体テスト実行する際に pip installするパッケージ一覧です。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO: この後Django3.2対応もあると思うので、Django2.2固定のこのファイルは削除することになると思います。なのでこのPRでは一旦よいかもしれませんが、後々は削除したほうが第三者が混乱しなくてよさそうです。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. なるほどです。ryです。今回は残しておきます。 |
||
celery==4.1.0 | ||
Django==2.2.27 | ||
mock==4.0.3 | ||
six==1.15.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,11 +56,15 @@ def main(): | |
django.setup() | ||
|
||
from django.test.utils import get_runner | ||
test_runner = get_runner(global_settings) | ||
|
||
test_runner = test_runner() | ||
tests = ['beproud.django.mailer'] | ||
failures = test_runner.run_tests(tests) | ||
# Djangoのtest runnerクラスを取得 | ||
TestRunner = get_runner(global_settings) | ||
|
||
# test runnerオブジェクトを生成 | ||
test_runner = TestRunner() | ||
|
||
# test runnerにbpmailerの単体テストのPathを渡して、bpmailerの単体テストを実行する | ||
failures = test_runner.run_tests(['beproud.django.mailer.tests']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Djangoのバージョンが変わったためか?) toxが通らなくなっていたので、Djangoのrun_tests()メソッドのドキュメントを参考に、テストモジュールへのPathを修正しました。
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 原因はsetuptoolsの更新のためのようです。 変更自体はまずはこれでよさそう。
このPRで対応するかは任せますが、 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MUST: レビューのために、この修正の妥当性の説明が欲しいです。
確信はないけどこうしたら動いた、ということでしょうか。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 現在 bpmailerのtoxがfailする原因について
※ この改修がsetuptoolsの51.1.2の次のバージョンである51.2.0でマージされたことも確認しました このことから、今回の作業でbpmailerのtoxがfailしている原因は、setuptoolsが、bpmailerをpy36対応した時の作業の時と比べてバージョンアップしていて、動作が変わっていたことが原因と思いました。
|
||
|
||
sys.exit(failures) | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,29 +1,21 @@ | ||||||||||||||||||||||
# Requires tox > 1.8 | ||||||||||||||||||||||
|
||||||||||||||||||||||
[tox] | ||||||||||||||||||||||
envlist = py27-django111, py36-django{111,22} | ||||||||||||||||||||||
envlist = py{36,39}-django22 | ||||||||||||||||||||||
|
||||||||||||||||||||||
[testenv] | ||||||||||||||||||||||
basepython = | ||||||||||||||||||||||
py27: python2.7 | ||||||||||||||||||||||
py36: python3.6 | ||||||||||||||||||||||
py39: python3.9 | ||||||||||||||||||||||
deps = | ||||||||||||||||||||||
six | ||||||||||||||||||||||
django111: Django>=1.11,<2.0 | ||||||||||||||||||||||
django111: celery>=4.0,<4.2 | ||||||||||||||||||||||
django22: Django>=2.2,<3.0 | ||||||||||||||||||||||
django22: celery>=4.0,<4.2 | ||||||||||||||||||||||
mock>=0.7.2 | ||||||||||||||||||||||
commands=python setup.py test | ||||||||||||||||||||||
|
||||||||||||||||||||||
[travis] | ||||||||||||||||||||||
os = | ||||||||||||||||||||||
linux: py27-django111, py36-django{111,22} | ||||||||||||||||||||||
# tox-gh-actionsパッケージの設定 | ||||||||||||||||||||||
[gh-actions] | ||||||||||||||||||||||
python = | ||||||||||||||||||||||
2.7: py27 | ||||||||||||||||||||||
3.6: py36 | ||||||||||||||||||||||
|
||||||||||||||||||||||
[travis:env] | ||||||||||||||||||||||
DJANGO = | ||||||||||||||||||||||
1.11: django111 | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MUST: 1.11をドロップしたのであれば、setup.pyも更新してください。 Line 63 in e44f6b4
以下、ついでに依頼です。 Lines 51 to 59 in e44f6b4
参考記述 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. setup.pyの記述内容を修正しました。 |
||||||||||||||||||||||
2.2: django22 | ||||||||||||||||||||||
3.6: py36 | ||||||||||||||||||||||
3.9: py39 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ASK: djangoはmatrixにしないんですか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ASKの回答
tox-gh-actionsパッケージの仕様と、bpmailerのtox.iniの記述内容から、bpmailerのworkflow/tests.pyには、djangoのmatrixを記述する必要はないと判断しました。
理由
作業の際、Workflowが実行したジョブのログを確認したところ、自動でtox.iniに記述した各djangoバージョンのバリエーションテストを実行してくれていたので、matrixには記述しませんでした。
この辺の挙動をよく理解できていなかったため、再調査しました。
再調査でわかったこと
tox-gh-actionsパッケージの仕様で、tox.ini の
gh-actions
の項目にPythonバージョンを記述すると、Github Actionのジョブから実行するtoxでは、gh-actions
に記述した各Pythonバージョンに絞った状態で実行ができる仕様があるようです。次のドキュメントの例だと、
Python3.9のジョブを実行する際には、py39環境にてtoxを実行してくれるようです。
考察
試しに、workflows/tests.ymlに次のように記述して見たところ
Github Actionsは、tox-gh-actionsのドキュメントの通り、そのジョブで指定されたPythonバージョンに関するテストのバリエーションを実行していることを確認しました。
https://github.com/beproud/bpmailer/runs/5492233415?check_suite_focus=true
備考
workflowに追加した、tox -lのコマンドは今後コードを確認する人が動作を把握するのに役立つと思ったので、一旦そのまま残しました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@imaxyz matrix化することによって順次実行ではなく並列実行になります。また Python x Django の組合せ名でテスト実行記録が残るためエラー発生時に原因が追いやすくなります。この機会にそのように構成したほうが良いとおもいますが、どうでしょうか?
具体的には以下の様になります。
現在のこのPRのテスト
別プロジェクトでの例
https://github.com/jazzband/django-redshift-backend/runs/5347475991?check_suite_focus=true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
並列化しました。
Python 2.7とDjango 1.11をdropしたため、このPRでは並列化の効果が高くありませんが、今後のPRで恩恵を受けられるので、workflowを並列化する記述に修正しました。