Skip to content

Move mypy package to dev dependencies group #4

Move mypy package to dev dependencies group

Move mypy package to dev dependencies group #4

name: Static Code Analysis and Tests
on:
push:
branches: ["main"]
permissions:
contents: read
jobs:
run-static-code-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Run static code analysis with Ruff
run: poetry run ruff check fhir_py_types/ tests/
- name: Run typecheck with Mypy
run: poetry run mypy fhir_py_types/ tests/
run-unit-tests:
runs-on: ubuntu-latest
needs: [run-static-code-analysis]
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Test with pytest
run: poetry run pytest tests/
run-spec-regression-tests:
runs-on: ubuntu-latest
needs: [run-unit-tests]
strategy:
matrix:
spec_version: ["r4", "r5"]
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Cache spec StructureDefinition bundle
id: spec-download
uses: actions/cache@v3
with:
key: ${{ runner.os }}-spec-download-${{ hashFiles(format('./spec/{0}.bundle.checksumfile', matrix.spec_version)) }}
path: |
./spec/fhir.types.json
./spec/fhir.resources.json
- name: Download spec StructureDefinition bundle
if: steps.spec-download.outputs.cache-hit != 'true'
run: |
cd ./spec/
bash download_spec_bundle.sh ${{ matrix.spec_version }}
cd ..
- name: Build resource models from the spec StructureDefinition bundle
run: |
poetry run typegen --from-bundles spec/fhir.types.json --from-bundles spec/fhir.resources.json --outfile generated/resources.py
- name: Typecheck generated resource models
run: poetry run mypy generated/resources.py
run-synthea-models-regression-tests:
runs-on: ubuntu-latest
needs: [run-spec-regression-tests]
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Cache spec generated resource models
id: spec-download
uses: actions/cache@v3
with:
key: ${{ runner.os }}-spec-generated-${{ hashFiles('./spec/r4.bundle.checksumfile') }}
path: ./generated/resources.py
- name: Download R4 spec and build resource models
if: steps.spec-download.outputs.cache-hit != 'true'
run: |
cd ./spec/
bash download_spec_bundle.sh
cd ..
poetry run typegen --from-bundles spec/fhir.types.json --from-bundles spec/fhir.resources.json --outfile generated/resources.py
- name: Cache Synthea samples
id: synthea-samples-download
uses: actions/cache@v3
with:
key: ${{ runner.os }}-synthea-samples-download-${{ hashFiles('./regression/synthea/r4.bundle.checksumfile') }}
path: ./regression/synthea/fhir/
- name: Download Synthea samples
if: steps.synthea-samples-download.outputs.cache-hit != 'true'
run: |
cd ./regression/synthea/
bash download_sample_bundle.sh
cd ../../
- name: Test Synthea samples can be parsed
run: poetry run pytest regression/synthea/test_synthea_samples.py -vv