Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for GitHub Actions for Python Development
Wael Ramadan
Wael Ramadan

Posted on

     

GitHub Actions for Python Development

If you are developing your application on GitHub, then you might want to consider using GitHub Actions for your CI/CD. In this tutorial we will cover how to use GitHub actions for testing multiple version of python and on different platforms.

Our example will include a FastAPI application, using pytest to run our tests, pylint for linting check, on python versions (3.8, 3.9, 3.10, 3.11) with (Windows, Mac, Linux) platforms. You can find this example on GitHubhere.

First thing you will notice is under the.github/workflows directory there is a file namedpython-app.yml which is the YAML file that will be used for our GitHub Actions Pipeline.

Image description

In this file you will find the below break-down.

Image description

You will see that the keyruns-on uses the variablematrix.os which has the array of operating systems to use. While the keypython-versions uses the variablematrix.python-version that takes the array of python versions.

    runs-on: ${{ matrix.os }}    strategy:      matrix:        os: [ubuntu-latest, windows-latest, macos-latest]        python-version: ["3.8", "3.9", "3.10", "3.11"]
Enter fullscreen modeExit fullscreen mode

Underneath you will see multiple keys namedrun each for installing dependencies, linting and testing.

    - name: Install dependencies      run: |        python -m pip install --upgrade pip        pip install -r requirements.txt    - name: Lint with pylint      run: |        pylint --recursive=y api --rcfile=.pylintrc    - name: Test with pytest      run: |        pytest api/
Enter fullscreen modeExit fullscreen mode

Every time you push a change to your repository this action will run.

Image description

To learn more about Python automation and testing using GitHub Actions you can visit thislink.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Writing about open source dev tools!
  • Joined

More fromWael Ramadan

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp