From 3409710a0e0c57534c116de2b4f2b6822e5ff545 Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Fri, 4 Jul 2025 00:07:30 +0200 Subject: [PATCH 01/13] ci: run pytest in CI --- .github/workflows/pytest.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/pytest.yml diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..681e970 --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,23 @@ +name: Pytest +on: [push, pull_request] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + ruff: + runs-on: ubuntu-latest + steps: + - name: Concurrency Group + env: + GROUP: ${{ github.workflow }}-${{ github.ref }} + run: echo "$GROUP" + - 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: Test with pytest + run: pytest ./test --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + \ No newline at end of file From c72b382ee3ffba451d1b6c240804dd948c9510ad Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Fri, 4 Jul 2025 00:30:29 +0200 Subject: [PATCH 02/13] test: skip tests dependent on external files --- test/test_html.py | 3 +++ test/test_html_slides.py | 3 +++ test/test_question.py | 1 + 3 files changed, 7 insertions(+) diff --git a/test/test_html.py b/test/test_html.py index 714bb34..0190342 100644 --- a/test/test_html.py +++ b/test/test_html.py @@ -1,5 +1,6 @@ import json +import pytest from bs4 import BeautifulSoup from jinja2 import Environment, FileSystemLoader from mistletoe import Document @@ -76,6 +77,8 @@ def include_stub(include): return includes.get(include) +@pytest.mark.skip("Requires special files") +@pytest.mark.html def test_html(capsys): with capsys.disabled(): with open("test/acceptanceTest.md") as file: diff --git a/test/test_html_slides.py b/test/test_html_slides.py index 291e528..5d8b9d3 100644 --- a/test/test_html_slides.py +++ b/test/test_html_slides.py @@ -1,6 +1,7 @@ import json import random +import pytest from jinja2 import Environment, FileSystemLoader from mistletoe import Document @@ -88,6 +89,8 @@ slide_template = env.get_template("slide/slide.html") questions = parse_katalog() +@pytest.mark.skip("Requires special files") +@pytest.mark.slides def test_html_slides(capsys): with capsys.disabled(): with open("test/acceptanceTestSlides.md") as file: diff --git a/test/test_question.py b/test/test_question.py index e4e4ceb..344692a 100644 --- a/test/test_question.py +++ b/test/test_question.py @@ -25,6 +25,7 @@ def test_question_html(): assert renderer.render(Document(assertion)) == assertions[assertion] +@pytest.mark.skip("Requires special files") @pytest.mark.html def test_question_translation_html(): assertions = { From 41f69e71d53e342003c4c2d89d4fb456166edba9 Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Fri, 4 Jul 2025 00:30:50 +0200 Subject: [PATCH 03/13] ci: only run on push --- .github/workflows/pytest.yml | 5 ++--- .github/workflows/ruff.yml | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 681e970..fe81693 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -1,5 +1,5 @@ name: Pytest -on: [push, pull_request] +on: push concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -15,9 +15,8 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - cache: 'pip' + cache: "pip" - name: Install dependencies run: pip install -r requirements.txt - name: Test with pytest run: pytest ./test --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html - \ No newline at end of file diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 1f323b2..dfbd008 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -1,5 +1,5 @@ name: Ruff -on: pull_request +on: push concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -13,4 +13,4 @@ jobs: args: check --output-format=github - uses: astral-sh/ruff-action@v3 with: - args: format --diff \ No newline at end of file + args: format --diff From 70e12c2409887195ef2abf1aca52a40dee3953d7 Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Fri, 4 Jul 2025 00:33:29 +0200 Subject: [PATCH 04/13] ci: rename pytest job --- .github/workflows/pytest.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index fe81693..dc54632 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -4,13 +4,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: - ruff: + pytest: runs-on: ubuntu-latest steps: - - name: Concurrency Group - env: - GROUP: ${{ github.workflow }}-${{ github.ref }} - run: echo "$GROUP" - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 From 92a03ca763d01b54c93c07df6cce9a673a080318 Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Sat, 5 Jul 2025 00:56:42 +0200 Subject: [PATCH 05/13] ci: split ruff jobs --- .github/workflows/ruff.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index dfbd008..ecf9671 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -4,13 +4,17 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: - ruff: + Check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: astral-sh/ruff-action@v3 with: args: check --output-format=github + Format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - uses: astral-sh/ruff-action@v3 with: - args: format --diff + args: format --check --diff From eba7bdbea310cd3b4efc3b46367db790d5c78cea Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Sat, 5 Jul 2025 00:56:57 +0200 Subject: [PATCH 06/13] ci: improve pytest integration --- .github/workflows/pytest.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index dc54632..6c48be0 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -4,7 +4,7 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: - pytest: + Test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -14,5 +14,12 @@ jobs: 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: pytest ./test --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + run: 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 + with: + pytest-coverage-path: ./pytest-coverage.txt + junitxml-path: ./pytest.xml From e6f373ced43ecaf342365886a993fb3fc82e36a7 Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Sat, 5 Jul 2025 01:05:56 +0200 Subject: [PATCH 07/13] ci: fix pytest action permissions --- .github/workflows/pytest.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 6c48be0..c583175 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -1,5 +1,9 @@ name: Pytest -on: push +on: pull_request +permissions: + contents: read + checks: write + pull-requests: write concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true From 3f626a814c8e4bcfa2bfcdd0a6ad0d9f1947255f Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Sat, 5 Jul 2025 01:07:17 +0200 Subject: [PATCH 08/13] ci: test error output --- renderer/fifty_ohm_html_renderer.py | 2 +- test/test_dash.py | 2 +- test/test_table.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/renderer/fifty_ohm_html_renderer.py b/renderer/fifty_ohm_html_renderer.py index b53d4e8..f6b6d10 100644 --- a/renderer/fifty_ohm_html_renderer.py +++ b/renderer/fifty_ohm_html_renderer.py @@ -155,7 +155,7 @@ class FiftyOhmHtmlRenderer(HtmlRenderer): def render_qso(self, token): self.margin_id += 1 - qso = "" + qso = '' for child in token.children: direction = "other" if child.received else "own" qso += f'
{self.render_inner(child)}
\n' diff --git a/test/test_dash.py b/test/test_dash.py index 0a571e4..ea03894 100644 --- a/test/test_dash.py +++ b/test/test_dash.py @@ -9,7 +9,7 @@ from test.util import paragraph @pytest.mark.html def test_dash_html(): assertions = { - "Foo - Bar": "Foo – Bar", + "Foo - Bar": "Foo – Ba", } for assertion in assertions: diff --git a/test/test_table.py b/test/test_table.py index deaba13..08a37dd 100644 --- a/test/test_table.py +++ b/test/test_table.py @@ -11,7 +11,7 @@ def test_table_html(): "| l: a |": '\n\n\n\n
a
\n', "| r: a |": '\n\n\n\n
a
\n', "| c: a |": '\n\n\n\n
a
\n', - "| l: a |\n| b |": '\n\n\n\n\n\n\n
a
b
\n', # noqa: E501 + "| l: a |\n| b |": '\n\n\n\n\n\n\n
a
b
\n', "| l: a |\n| b |\n| c |": '\n\n\n\n\n\n\n\n\n\n
a
b
c
\n', # noqa: E501 "| a |\n| b |\n| c |": "\n\n\n\n\n\n\n\n\n\n
a
b
c
\n", # noqa: E501 "| l: a |\n| *b* |": '\n\n\n\n\n\n\n
a
b
\n', # noqa: E501 From 83ddeb7d7dcdae9ab80c06604198e21babaea6a5 Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Sat, 5 Jul 2025 01:16:12 +0200 Subject: [PATCH 09/13] ci: fail pytest job on test failure --- .github/workflows/pytest.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index c583175..c7cef8f 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -21,9 +21,12 @@ jobs: - name: Install failure annotation plugin run: pip install pytest-github-actions-annotate-failures - name: Test with pytest - run: pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov-report=html --cov | tee pytest-coverage.txt + 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 From 52ba988d23aa32d49e460fcece33c3e6e30fdd44 Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Sat, 5 Jul 2025 01:18:23 +0200 Subject: [PATCH 10/13] fix: file errors --- renderer/fifty_ohm_html_renderer.py | 2 +- test/test_dash.py | 2 +- test/test_html_slides.py | 2 +- test/test_table.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/renderer/fifty_ohm_html_renderer.py b/renderer/fifty_ohm_html_renderer.py index f6b6d10..b53d4e8 100644 --- a/renderer/fifty_ohm_html_renderer.py +++ b/renderer/fifty_ohm_html_renderer.py @@ -155,7 +155,7 @@ class FiftyOhmHtmlRenderer(HtmlRenderer): def render_qso(self, token): self.margin_id += 1 - qso = '' + qso = "" for child in token.children: direction = "other" if child.received else "own" qso += f'
{self.render_inner(child)}
\n' diff --git a/test/test_dash.py b/test/test_dash.py index ea03894..0a571e4 100644 --- a/test/test_dash.py +++ b/test/test_dash.py @@ -9,7 +9,7 @@ from test.util import paragraph @pytest.mark.html def test_dash_html(): assertions = { - "Foo - Bar": "Foo – Ba", + "Foo - Bar": "Foo – Bar", } for assertion in assertions: diff --git a/test/test_html_slides.py b/test/test_html_slides.py index 5d8b9d3..adbba4a 100644 --- a/test/test_html_slides.py +++ b/test/test_html_slides.py @@ -90,7 +90,7 @@ questions = parse_katalog() @pytest.mark.skip("Requires special files") -@pytest.mark.slides +@pytest.mark.slide def test_html_slides(capsys): with capsys.disabled(): with open("test/acceptanceTestSlides.md") as file: diff --git a/test/test_table.py b/test/test_table.py index 08a37dd..deaba13 100644 --- a/test/test_table.py +++ b/test/test_table.py @@ -11,7 +11,7 @@ def test_table_html(): "| l: a |": '\n\n\n\n
a
\n', "| r: a |": '\n\n\n\n
a
\n', "| c: a |": '\n\n\n\n
a
\n', - "| l: a |\n| b |": '\n\n\n\n\n\n\n
a
b
\n', + "| l: a |\n| b |": '\n\n\n\n\n\n\n
a
b
\n', # noqa: E501 "| l: a |\n| b |\n| c |": '\n\n\n\n\n\n\n\n\n\n
a
b
c
\n', # noqa: E501 "| a |\n| b |\n| c |": "\n\n\n\n\n\n\n\n\n\n
a
b
c
\n", # noqa: E501 "| l: a |\n| *b* |": '\n\n\n\n\n\n\n
a
b
\n', # noqa: E501 From a3116830f780be734a0b76916c7a1aa0967c27ae Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Sat, 5 Jul 2025 01:25:30 +0200 Subject: [PATCH 11/13] ci: run ruff on pull_request --- .github/workflows/ruff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index ecf9671..ebd4763 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -1,5 +1,5 @@ name: Ruff -on: push +on: pull_request concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true From c03d847c3c33a4dc444c7b65319d97dd7d83ab8f Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Sat, 5 Jul 2025 01:30:35 +0200 Subject: [PATCH 12/13] ci: test pytest failure bypass --- test/test_dash.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_dash.py b/test/test_dash.py index 0a571e4..ea03894 100644 --- a/test/test_dash.py +++ b/test/test_dash.py @@ -9,7 +9,7 @@ from test.util import paragraph @pytest.mark.html def test_dash_html(): assertions = { - "Foo - Bar": "Foo – Bar", + "Foo - Bar": "Foo – Ba", } for assertion in assertions: From 38ac1fc9ab78455b7c40ab3b8968df1ff4792788 Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Sat, 5 Jul 2025 01:31:19 +0200 Subject: [PATCH 13/13] Revert "ci: test pytest failure bypass" This reverts commit c03d847c3c33a4dc444c7b65319d97dd7d83ab8f. --- test/test_dash.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_dash.py b/test/test_dash.py index ea03894..0a571e4 100644 --- a/test/test_dash.py +++ b/test/test_dash.py @@ -9,7 +9,7 @@ from test.util import paragraph @pytest.mark.html def test_dash_html(): assertions = { - "Foo - Bar": "Foo – Ba", + "Foo - Bar": "Foo – Bar", } for assertion in assertions: