Skip to content

[pre-commit.ci] pre-commit autoupdate #95

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #95

Workflow file for this run

name: Test
on:
push:
branches:
- master
pull_request:
jobs:
test:
name: Test and generate coverage
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9"]
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 Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install library
run: poetry install --no-interaction
- name: Run tests and generate coverage report
run: poetry run pytest
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: success() && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
fail_ci_if_error: true
verbose: true
# sonarcloud:
# runs-on: ubuntu-latest
# environment: Sonar # set env to use env secret
# steps:
# - uses: actions/checkout@v2
# with:
# # Disabling shallow clone is recommended for improving relevancy of reporting
# fetch-depth: 0
# - name: SonarCloud Scan
# uses: sonarsource/sonarcloud-github-action@master
# with:
# projectBaseDir: .
# args: >
# -Dsonar.organization=shenxiangzhuang
# -Dsonar.projectKey=shenxiangzhuang_toyml
# -Dsonar.python.coverage.reportPaths=coverage.xml
# -Dsonar.tests=tests/
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}