CI on Github for Python

So I finally thought it was time to start doing some continuous integration testing as well as testing with multiple versions of Python.

I had been looking at using things such as CircleCI or Travis-ci. But I finally decided I would try to use Github’s workflow actions.

I did some searching and found some guides. As part of that I evenutally came a cross this link on Github’s own docs.

Based on these examples. I started working on my own workflow. This is a very lightly modified version of one found on Github. So it’s not at all original.

name: Python package

on:
  push:
    branches: [ development ]

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [3.5, 3.6, 3.7, 3.8]

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        # Add modules required for testing.
        pip install pytest pyscaffold==3.2.3 coverage pytest-cov
        # Add modules required for functionality.
        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
        pip install -e .        
    - name: Test with pytest
      run: |
        pytest        

Basically this will test the module running under several virtual machines running the four versions of python listed. Note that I am not running the code through a linter at this stage. You can see examples of that in the Github guide.


See also