LoginSignup
2

More than 1 year has passed since last update.

【GitHub】Actions で pytest を実行する

Last updated at Posted at 2021-08-29

actions で python の実行環境を用意するには、actions/setup-pythonを使用する。あとは、pytest を含む必要なモジュールをインストールすれば、pytest が実行できる。

github/workflows/pytest.yaml
name: Pytest

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.8'
          architecture: x64
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
      - name: Test with pytest
        run: |
          python -m pytest

参考

Python のビルドとテスト
https://docs.github.com/ja/actions/guides/building-and-testing-python

actions/setup-python
https://github.com/actions/setup-python

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
What you can do with signing up
2