diff --git a/.github/workflows/render-readme.yaml b/.github/workflows/render-readme.yaml index 4015c1aa..cea33e1b 100644 --- a/.github/workflows/render-readme.yaml +++ b/.github/workflows/render-readme.yaml @@ -1,19 +1,19 @@ -on: - push: - paths: - - README.md - name: Render README +on: + push: + paths: + - README.md + jobs: - render: - name: Render README - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Render README - run: tools/render-readme.sh - - name: Commit results - run: | - git commit README.md -m 'Render README.md' || echo "No changes to commit" - git push origin || echo "No changes to commit" + render: + name: Render README + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Render README + run: tools/render-readme.sh + - name: Commit results + run: | + git commit README.md -m 'Render README.md' || echo "No changes to commit" + git push origin || echo "No changes to commit" diff --git a/.github/workflows/requirements.txt b/.github/workflows/requirements.txt new file mode 100644 index 00000000..e079f8a6 --- /dev/null +++ b/.github/workflows/requirements.txt @@ -0,0 +1 @@ +pytest diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 17966c57..3744952d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,26 +1,31 @@ -on: push - name: Run tests +on: + push: + branches: + - master + pull_request: + jobs: tests: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - name: Use Python 3.8 - uses: actions/setup-python@v2 + - name: Use Python 3.11 + uses: actions/setup-python@v4 with: - python-version: '3.8' - - - name: Update package index - run: sudo apt-get update + python-version: '3.11' + cache: pip + cache-dependency-path: .github/workflows/requirements.txt - name: Install xmllint - run: sudo apt-get install -y libxml2-utils + run: | + sudo apt install --yes libxml2-utils + xmllint --version - name: Install requirements - run: pip install pytest + run: pip install -r .github/workflows/requirements.txt - name: Run tests run: pytest diff --git a/tests/test_xml.py b/tests/test_xml.py index b8f3ac60..c0627ff0 100644 --- a/tests/test_xml.py +++ b/tests/test_xml.py @@ -1,12 +1,12 @@ -import os import xml.etree.ElementTree as ET from pathlib import Path from subprocess import check_call import pytest -PATHS = ["rdmorganiser", "shared"] -TAGS = [ +PATHS = ("rdmorganiser", "shared") +PATHS = (Path(p) for p in PATHS) +TAGS = { "condition", "attribute", "optionset", @@ -17,16 +17,12 @@ "question", "task", "view", -] +} def walk_xml_files(): for path in PATHS: - for root, dirs, files in os.walk(path): - for file in files: - file_path = Path(root) / file - if file_path.suffix == ".xml": - yield file_path + yield from path.rglob("*.xml") @pytest.mark.parametrize("xml_file", walk_xml_files())