Skip to content

Commit 9a2eec1

Browse files
authored
Merge pull request #198 from mschoettle/mschoettle/fix-workflow
Fix CI workflow and add steps to run tests
2 parents aaacbb0 + 15bff6c commit 9a2eec1

4 files changed

Lines changed: 38 additions & 15 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,41 @@ jobs:
2222
fail-fast: true
2323
max-parallel: 4
2424
matrix:
25-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
25+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
2626
steps:
2727
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2828
with:
2929
persist-credentials: false
30-
- name: Setup Python ${{ matrix.python-version }}
31-
id: setup-python
32-
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
32+
id: setup-uv
3333
with:
3434
python-version: ${{ matrix.python-version }}
35+
activate-environment: true
3536
- name: Install dependencies
3637
run: |
37-
pip install -e .[dev]
38-
- run: make lint
39-
- run: black --check fhir/resources/
38+
uv run python --version
39+
uv pip install -e .[test]
40+
- run: uv run flake8 ./fhir/resources/
41+
- run: uv run black --check fhir/resources/
42+
# monthly cache updates
43+
- run: echo "cache_id=$(date --utc '+%m')" >> "$GITHUB_ENV"
44+
- uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
45+
with:
46+
key: fhir-resources-${{ env.cache_id }}
47+
path: .cache
48+
restore-keys: |
49+
fhir-resources-
50+
- name: Run main tests with Python ${{ matrix.python-version }}
51+
run: |
52+
which pytest
53+
uv run pytest tests
54+
- name: Run STU3 tests with Python ${{ matrix.python-version }}
55+
run: |
56+
uv run pytest fhir/resources/STU3/tests
57+
- name: Run R4B tests with Python ${{ matrix.python-version }}
58+
run: |
59+
uv run pytest -s --cov=fhir/resources/R4B/tests -s --tb=native -v --cov-report term-missing --cov-append fhir/resources/R4B/tests
60+
- name: Run R5 tests with Python ${{ matrix.python-version }}
61+
run: |
62+
uv run pytest -s --cov=fhir/resources/tests -s --tb=native -v --cov-report term-missing --cov-append fhir/resources/tests

setup.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
"coverage",
3333
"pytest>5.4.0;python_version>='3.6'",
3434
"pytest-cov>=2.10.0;python_version>='3.6'",
35-
"flake8" + (PY_VERSION_10_OR_LATER and "==6.0" or "==5.0.4;python_version<'3.10'"),
35+
"flake8" + (PY_VERSION_10_OR_LATER and "==7.3.0" or "==5.0.4;python_version<'3.10'"),
3636
"flake8-isort"
3737
+ (PY_VERSION_10_OR_LATER and ">=6.0.0" or "==4.2.0;python_version<'3.10'"),
3838
"flake8-bugbear"
3939
+ (PY_VERSION_10_OR_LATER and ">=22.12.6" or "==20.1.4;python_version<'3.10'"),
40-
"requests==2.23.0;python_version<'3.10'",
40+
"requests==2.32.4",
4141
"isort" + (PY_VERSION_10_OR_LATER and ">=5.11.4" or "==4.3.21"),
4242
"black>=23.0,<24.0; python_version >= '3.7'",
4343
"mypy",
@@ -48,8 +48,6 @@
4848
]
4949
if PY_VERSION_10_OR_LATER:
5050
test_requirements.append("importlib-metadata>=5.2.0")
51-
if PY_VERSION_11_OR_LATER:
52-
test_requirements.append("typed-ast>=1.5.4")
5351

5452
development_requirements = [
5553
"Jinja2==3.1.6",

tests/test_xml_validate_and_dump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from http import client
33

4-
import lxml.etree # type: ignore
4+
import lxml.etree
55
from fhir_core import xml_utils
66

77
from fhir.resources.R4B.observation import Observation

tests/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import subprocess
33
import sys
44
from http import client
5-
from typing import Union
5+
from typing import Optional, Union
66

77
from fhir_core import xml_utils
88
from fhir_core.fhirabstractmodel import FHIRAbstractModel
@@ -21,9 +21,9 @@ def has_internet_connection():
2121
return False
2222

2323

24-
def post_xml_resource( # type: ignore
24+
def post_xml_resource(
2525
conn: client.HTTPConnection, resource: Union[xml_utils.Node, FHIRAbstractModel]
26-
) -> client.HTTPResponse:
26+
) -> Optional[client.HTTPResponse]:
2727
""" """
2828
if isinstance(resource, FHIRAbstractModel):
2929
resource_str = resource.model_dump_xml(return_bytes=True, pretty_print=False)
@@ -48,3 +48,5 @@ def post_xml_resource( # type: ignore
4848
return response
4949
except client.HTTPException as exc:
5050
sys.stderr.write(f"{exc}\n")
51+
52+
return None

0 commit comments

Comments
 (0)