CircleCI의 PythonOrbs를 사용하세요.
7122 단어 pythoncircleciorbscircleci
작업리포지트리
유타고토 / python_ci_testing
python_ci_testing
View on GitHub
やったこと
Pipfileを用意
今回は mypy と pytest と pycodestyle を使います.
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[dev-packages]
mypy = "*"
pytest = "*"
pycodestyle = "*"
[requires]
python_version = "3.8"
산프루를 사용하다
# app.py
def greeting(name: str) -> str:
return 'hello ' + name
print(greeting('name'))
테스트파일을용도
# test_app.py
import app
def test_greeting():
assert app.greeting('name') == 'hello name'
ファイルを用意したら pushします.
CircleCI의 準備
https://app.circleci.com
CircleCI에 악세스하고, 左menu-のProjects에서 리포지트리를 択하고 셋트할 수 있습니다.
(브라우자상으로 .circleci/config.yml
を編集できるの便利)
데포르트데셋트されている
orbs:
python: circleci/[email protected]
はorbのバージョンは結構古いので,Orbsのページを見て最新バージョンに書き換えます(2021/03/31時点では 1.3.3
が最new)
https://circleci.com/developer/orbs/orb/circleci/python
steps内にある load-cache
, save-cache
は今は1.3.3では使えない(라이브러리의 Instorl 時にAutomotive でキッシュしてくれる)ので削除します.
ライブラリのインストールは、今回作った三プルではpipenvを使うのでネストさせた要素の pkg-manager:
に pipenv
を書きます(CI環境なので引数に --dev
ゑをま付)
사용 예には、Testを実行させるために python/test
を使うような記述がありますが、stepsでは使わずにjobsに直接指定します.
できあがった.circleci/config.yml
が以下입니다.
# .circleci/config.yml
version: 2.1
orbs:
python: circleci/[email protected]
jobs:
build-and-test:
executor: python/default
steps:
- checkout
- python/install-packages:
args: --dev
pkg-manager: pipenv
- run:
name: mypy
command: pipenv run mypy .
- run:
name: pycodestyle
command: pipenv run pycodestyle .
workflows:
main:
jobs:
- build-and-test
- python/test:
args: --dev
test-tool: pytest
pkg-manager: pipenv
Testを実行する部分で python/install-packages
とほぼ同じ記述になってしまうのはどうにかしたい部分はあります..
Circleci 프로젝트 설정
#2
YutaGoto
에 게시됨
View on GitHub
Reference
이 문제에 관하여(CircleCI의 PythonOrbs를 사용하세요.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://dev.to/yutagoto/circleci-pythonorbs-737
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[dev-packages]
mypy = "*"
pytest = "*"
pycodestyle = "*"
[requires]
python_version = "3.8"
# app.py
def greeting(name: str) -> str:
return 'hello ' + name
print(greeting('name'))
# test_app.py
import app
def test_greeting():
assert app.greeting('name') == 'hello name'
orbs:
python: circleci/[email protected]
# .circleci/config.yml
version: 2.1
orbs:
python: circleci/[email protected]
jobs:
build-and-test:
executor: python/default
steps:
- checkout
- python/install-packages:
args: --dev
pkg-manager: pipenv
- run:
name: mypy
command: pipenv run mypy .
- run:
name: pycodestyle
command: pipenv run pycodestyle .
workflows:
main:
jobs:
- build-and-test
- python/test:
args: --dev
test-tool: pytest
pkg-manager: pipenv
YutaGoto
에 게시됨
View on GitHub
Reference
이 문제에 관하여(CircleCI의 PythonOrbs를 사용하세요.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/yutagoto/circleci-pythonorbs-737텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)