Merge pull request #8 from DARC-e-V/ci/pytest

ci: run pytest in CI
This commit is contained in:
Tim Grelka
2025-07-05 01:31:59 +02:00
committed by GitHub
5 changed files with 45 additions and 2 deletions
+32
View File
@@ -0,0 +1,32 @@
name: Pytest
on: pull_request
permissions:
contents: read
checks: write
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
Test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
cache: "pip"
- name: Install dependencies
run: pip install -r requirements.txt
- name: Install failure annotation plugin
run: pip install pytest-github-actions-annotate-failures
- name: Test with pytest
run: |
set -o pipefail
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov-report=html --cov | tee pytest-coverage.txt
- name: Comment pytest code coverage
uses: MishaKav/pytest-coverage-comment@main
if: ${{ always() }}
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
+6 -2
View File
@@ -4,13 +4,17 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
ruff: Check:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3 - uses: astral-sh/ruff-action@v3
with: with:
args: check --output-format=github args: check --output-format=github
Format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3 - uses: astral-sh/ruff-action@v3
with: with:
args: format --diff args: format --check --diff
+3
View File
@@ -1,5 +1,6 @@
import json import json
import pytest
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
from mistletoe import Document from mistletoe import Document
@@ -76,6 +77,8 @@ def include_stub(include):
return includes.get(include) return includes.get(include)
@pytest.mark.skip("Requires special files")
@pytest.mark.html
def test_html(capsys): def test_html(capsys):
with capsys.disabled(): with capsys.disabled():
with open("test/acceptanceTest.md") as file: with open("test/acceptanceTest.md") as file:
+3
View File
@@ -1,6 +1,7 @@
import json import json
import random import random
import pytest
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
from mistletoe import Document from mistletoe import Document
@@ -88,6 +89,8 @@ slide_template = env.get_template("slide/slide.html")
questions = parse_katalog() questions = parse_katalog()
@pytest.mark.skip("Requires special files")
@pytest.mark.slide
def test_html_slides(capsys): def test_html_slides(capsys):
with capsys.disabled(): with capsys.disabled():
with open("test/acceptanceTestSlides.md") as file: with open("test/acceptanceTestSlides.md") as file:
+1
View File
@@ -25,6 +25,7 @@ def test_question_html():
assert renderer.render(Document(assertion)) == assertions[assertion] assert renderer.render(Document(assertion)) == assertions[assertion]
@pytest.mark.skip("Requires special files")
@pytest.mark.html @pytest.mark.html
def test_question_translation_html(): def test_question_translation_html():
assertions = { assertions = {