Day 3 v2: GitHub Action CI for wsblib Python

Gabor Szabo - Dec 3 '22 - - Dev Community

After the failure to create GitHub configuration for farmworld
I did not know if I should call it a day or try to find something else where I manage to set up GitHub Actions. I went back to PyDigger and found the wsblib Python package where the name stands for Web Server Base Library.

It had some tests in the tests/ folder.

After looking at the test files I saw that they are using BuPyTest.
I have not hear about it. I saw that both files were prepared to be executed directly using the following:

if __name__ == '__main__':
    bupytest.this()
Enter fullscreen mode Exit fullscreen mode

so I went on running them as python tests/test_server.py.

Later, when I went and looked at the documentation of BuPyTest and saw that it can be also used as a command-line tool.

Stages

First I only configured the CI to run on Ubuntu using Python 3.11.

Then I extended it to run the tests on all 3 operating systems and 3 different versions of Python. That's when I found out that one of the test files consistently fails on Windows and OSX. So I configured the CI that on of the tests files will always run and the other one only when the operating system is Ubuntu Linux.

Finally I switched from running the tests with python to running them using bupytest.

GitHub Actions configuration file

This is the most recent version of the file:

name: CI

on:
  push:
  pull_request:
  workflow_dispatch:
  schedule:
    - cron: '42 5 * * *'

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        runner: [ubuntu-latest, macos-latest, windows-latest]
        python-version: ["3.9", "3.10", "3.11"]

    runs-on: ${{matrix.runner}}
    name: OS ${{matrix.runner}} Python ${{matrix.python-version}}

    steps:
    - name: Checkout
      uses: actions/checkout@v3

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install dependencies
      run: |
        pip install -r requirements.txt

    - name: Run tests on every platform
      run: |
        bupytest test  tests/test_server.py

    - name: Run tests only on Linux
      if:  ${{ failure() && matrix.runner == 'ubuntu-latest' }}
      run: |
        bupytest test tests/test_socket.py
Enter fullscreen mode Exit fullscreen mode

Conclusion

Sometimes it is simple to set up GitHub Actions, even with testing frameworks that I don't know yet.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .