96 lines
2.6 KiB
YAML
96 lines
2.6 KiB
YAML
name: tests
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
- dev
|
|
|
|
jobs:
|
|
test:
|
|
name: Build and test on ${{ matrix.operating-system }} with Python ${{ matrix.python-version }}
|
|
|
|
strategy:
|
|
matrix:
|
|
python-version: ["3.8", "3.9", "3.10"]
|
|
operating-system: [windows-latest, ubuntu-latest]
|
|
|
|
runs-on: ${{ matrix.operating-system }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python3 -m pip install --upgrade pip
|
|
pip install --upgrade './[dev]'
|
|
|
|
- name: Check code and formatting
|
|
run: scripts/check-python.sh great_ai tests
|
|
|
|
- name: Run tests
|
|
run: python3 -m pytest --doctest-modules --cov=. --cov-report=xml --junit-xml pytest.xml --asyncio-mode=strict || true
|
|
|
|
- name: Upload results
|
|
if: always()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: Unit test coverage (Python ${{ matrix.python-version }} - ${{ matrix.operating-system }})
|
|
path: "*.xml"
|
|
|
|
sonar:
|
|
name: Analyse Python project with SonarQube
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install --upgrade .
|
|
rm -rf build
|
|
|
|
- name: Download test results
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
path: artifacts
|
|
|
|
- uses: sonarsource/sonarqube-scan-action@master
|
|
env:
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
|
with:
|
|
args: >
|
|
-Dsonar.projectKey=great-ai
|
|
-Dsonar.login=${{ secrets.SONAR_TOKEN }}
|
|
-Dsonar.verbose=true
|
|
-Dsonar.python.coverage.reportPaths=artifacts/*/coverage.xml
|
|
-Dsonar.coverage.exclusions=**/external/**/*
|
|
-Dsonar.exclusions=**/external/**/*,artifacts/**/*
|
|
|
|
publish-test-results:
|
|
name: Publish unit test results
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
if: always()
|
|
steps:
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Publish results
|
|
uses: EnricoMi/publish-unit-test-result-action@v2
|
|
with:
|
|
files: artifacts/*/pytest.xml
|