ci(github): add unit tests

!43
This commit is contained in:
2024-08-02 04:43:14 +09:30
parent fed0c5c3e5
commit 366579c12b
2 changed files with 103 additions and 0 deletions

34
.github/workflows/unit-test-report.yaml vendored Normal file
View File

@ -0,0 +1,34 @@
---
name: 'Process Unit Test Artifact'
on:
workflow_run:
workflows:
- 'Unit Test'
types:
- completed
permissions:
contents: read
actions: read
checks: write
jobs:
report:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ['3.10', '3.11', '3.12']
steps:
- name: Test Report
uses: dorny/test-reporter@v1
with:
artifact: unit-test-results-${{ matrix.python-version }}
name: Unit Test Report [Python ${{ matrix.python-version }}]
path: '*.xml'
reporter: java-junit

69
.github/workflows/unit-test.yaml vendored Normal file
View File

@ -0,0 +1,69 @@
name: 'Unit Test'
on:
push:
branches:
- "development"
tags:
- '*'
pull_request:
branches:
- "development"
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_test.txt
- name: Run Tests
run: |
cd app;
pytest --cov --cov-report term --cov-report xml:../coverage.xml --cov-report html:../coverage/ --junit-xml=../unit.JUnit.xml **/tests/unit;
- name: Upload Test Report
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: unit-test-results-${{ matrix.python-version }}
path: unit.JUnit.xml
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: coverage-report-${{ matrix.python-version }}
path: coverage.xml
- name: Upload Coverage
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: coverage-${{ matrix.python-version }}
path: coverage/*