forked from UOW-Group17/Onko_MiniProject
-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (64 loc) · 2.62 KB
/
UnitTesting.yml
File metadata and controls
75 lines (64 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Unit Testing Code Base using pytest
on: [pull_request]
jobs:
# Testing to be run on macOS, ubuntu and windows
# Testing on several version of python 3.11, 3.12, 3.13
# Version python version 3.10 was removed due to compatibility issues with macOS
Unit-Test:
# Setting default shell to bash other wise windows will use powershell and the test will fail
defaults:
run:
shell: bash
# Test Strategy for the job which os and what python versions
strategy:
matrix:
os-version: [macos-latest, ubuntu-latest, windows-latest]
python-version: ["3.12"] # Removing 3.11 and 3.13 to reuse the number of tests
runs-on: ${{ matrix.os-version }}
steps:
# Getting git code base
- uses: actions/checkout@v4
# Creating the python environment
- name: Set up Python Environment ${{ matrix.python-version }} on ${{ matrix.os-version }} runner
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# installs EGL library for graphics support on Ubuntu
- name: Install EGL mesa
if: matrix.os-version == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgl1-mesa-dev
# Creating the poetry build system environment
- name: Install Poetry
uses: snok/install-poetry@v1.4.1
with:
version: 2.1.1
virtualenvs-create: true
virtualenvs-in-project: true
# Setting Up Cache
# Taken from sjswerdloff
# https://github.com/sjswerdloff/tdwii_plus_examples/blob/main/.github/workflows/python-app.yml#L38
- name: Poetry Cache
uses: actions/cache@v4
id: poetry-cache
with:
path: .venv
key: venv-${{ hashFiles('**/poetry.lock') }}
# Checking is the cache to see it works fine
# Taken from sjswerdloff
# https://github.com/sjswerdloff/tdwii_plus_examples/blob/main/.github/workflows/python-app.yml#L38
- name: Ensure cache is healthy
if: steps.poetry-cache.outputs.cache-hit == 'true'
shell: bash
run: |
timeout 10s poetry run pip --version || rm -rf .venv
# Installing dependencies
# NOTE: tests would not work if pytest-qt was active
# NOTE: pytest-qt may be disabled
- name: Installing Poetry Dependencies
run: poetry install
# Running the tests required
- name: Running Automated Tests using Pytest
# getting the source files for to the files in the test file was a pain so we doing this on root
run: poetry run pytest