-
Notifications
You must be signed in to change notification settings - Fork 3
81 lines (74 loc) · 2.34 KB
/
unit_tests.yml
File metadata and controls
81 lines (74 loc) · 2.34 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
76
77
78
79
80
81
name: Unit Tests
on:
push:
branches:
- main
# filter on files that should trigger this workflow
paths:
- "pyproject.toml"
- "**.py"
- ".github/workflows/unit_tests.yml"
pull_request:
# filter on files that should trigger this workflow
paths:
- "pyproject.toml"
- "**.py"
- ".github/workflows/unit_tests.yml"
workflow_dispatch:
workflow_call:
inputs:
environment:
required: true
default: "testing"
type: string
description: "Environment to run tests in (testing)"
secrets:
WIKIFIER_API_KEY:
required: true
description: "Wikifier API Key"
# Only cancel concurrent runs of the same workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-tests
cancel-in-progress: true
jobs:
unit_tests:
name: Run Unit Tests
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
environment: ${{ inputs.environment }}
env:
WIKIFIER_API_KEY: ${{ secrets.WIKIFIER_API_KEY }}
# necessary for matplotlib to work properly in Windows
# it fails occasionally if we don't set this
MPLBACKEND: "Agg"
steps:
- name: Checkout Repo
uses: actions/checkout@v3.5.2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4.5.0
with:
python-version: ${{ matrix.python-version }}
cache: "pip" # cache dependencies
cache-dependency-path: "pyproject.toml"
- name: Install Project Dependencies
run: |
pip install .[tests]
# Pytest generates an XML report
- name: Execute tests
run: |
# Config in pyproject.toml
# Calling via python adds the current directory to sys path
# Prevents module not found errors
python -m pytest --junitxml=unit_test_report.xml
# Convert the XML report to GitHub annotations
- name: Convert test results to Github Annotations
uses: mikepenz/action-junit-report@v3
# Only produce check run annotations if the tests fail
if: failure()
with:
report_paths: unit_test_report.xml
check_name: "Unit test Report"
detailed_summary: true