0
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 3 years have passed since last update.

[Github Actions] Python + Poetry

Last updated at Posted at 2021-09-09

こちらのコードを使って GitHub Actions を試す。

ソースを持ってくる

mkdir -p /tmp/$(date +%Y%m%d) && cd $_
git clone https://github.com/mykysyk/zip-code.git
cd /tmp/$(date +%Y%m%d)/zip-code

こんな感じになる

/tmp/$(date +%Y%m%d)/zip-code
├── LICENSE
├── README.rst
├── poetry.lock
├── pyproject.toml
├── src
│   └── zip_code_app
│       ├── __init__.py
│       └── core.py
└── tests
    ├── __init__.py
    └── test_zip_code_app.py

テンプレート作成

git switch feat/github_actions
mkdir -p  /tmp/$(date +%Y%m%d)/zip_code_app.github/workflows
vi /tmp/$(date +%Y%m%d)/zip_code_app/.github/workflows/sample.yaml
sample.yaml
name: Python Lint & Test
on: push
jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        python-version: [3.9]
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
      - name: Update pip
        run: |
          python -m pip install --upgrade pip
      - name: Install Poetry
        run: |
          pip install poetry
          poetry install --no-interaction
      - name: Lint with flake8
        run: |
          pip install flake8
          flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
          flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
      - name: Test with pytest
        run: poetry run pytest -vv

github に push する

git push origin feat/github_actions

Python の Lint と TEST が完了するのを確認

https://github.com/mykysyk/zip-code/actions/
image.png

参考

0
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
0
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?