-
Notifications
You must be signed in to change notification settings - Fork 194
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
Github Actions とpre-commitにpoetry exportを適用 #716
Changes from 3 commits
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 |
---|---|---|
@@ -1,6 +1,21 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/python-poetry/poetry | ||
rev: '1.3.1' | ||
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. ここもバージョン不一致になっちゃう可能性がありますね! 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. pip install -r requirements.txtしてからpoetry exportを叩くように変更しました |
||
hooks: | ||
- id: poetry-export | ||
name: poetry-export | ||
args: ["--without-hashes", "-o", "requirements.txt" ] | ||
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. 実際に これ実際にエクスポートしているので 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. 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. なるほどです!! ちょっと1点だけ、環境によってはpythonではなくpython3コマンドとしてPythonスクリプトを実行している人もいるはずで、そういう人にとってはエラーが出てしまうなと思いました! 特に初学者の方がpython3コマンドを使っていた場合、なぜエラーが出るのかわからずにちょっと戸惑ってしまうかもです。 (せっかく書いていただいたのに申し訳ないです 🙇 ) 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. >pythonではなくpython3 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.
これで問題なさそうだったので poetry_export_check.py にリネームして、git diffだけPythonスクリプトで呼び出すようにしました 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. なるほどです!! 提案ありがとうございます!! まあでも、「 どの環境でも動く方法があればという感じかなと・・・! 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. 差分のチェックは bash コマンドから poetry_export_check.shを実行する方針にしました 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. bashもwindowsだと動かないんですよね・・・・・・・。 ChatGPT君に聞いてみた感じ、なんか良い感じの方法はなさそうでした。 せっかくチャレンジしてくださったのに申し訳ないです 🙇 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. Windows10からbashが正式サポートされた認識でした…… |
||
- id: poetry-export | ||
name: poetry-export-dev | ||
args: ["--without-hashes", "--with", "dev", "-o", "requirements-dev.txt" ] | ||
- id: poetry-export | ||
name: poetry-export-test | ||
args: ["--without-hashes", "--with", "test", "-o", "requirements-test.txt" ] | ||
- id: poetry-export | ||
name: poetry-export-license | ||
args: ["--without-hashes", "--with", "license", "-o", "requirements-license.txt" ] | ||
- repo: local | ||
hooks: | ||
- id: pysen-lint | ||
|
@@ -10,3 +25,8 @@ repos: | |
types: [file, python] | ||
stages: [push] | ||
pass_filenames: false | ||
- id: poetry-export-check | ||
name: poetry-export-check | ||
entry: python poetry_export_check.py | ||
language: python | ||
stages: [commit] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import subprocess | ||
|
||
|
||
def main(): | ||
return subprocess.run(["git", "diff", "--exit-code", "--quiet"], shell=True) | ||
|
||
|
||
if __name__ == "__main__": | ||
if main().returncode == 1: | ||
print("Please add requirement files") |
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.
未使用な気がします!
バージョンはrequirements.txtにて固定しているので、ここに書いちゃうとバージョン不一致になってしまうかもです。