-
Notifications
You must be signed in to change notification settings - Fork 1
120 lines (117 loc) · 4.06 KB
/
static-code-analysis-and-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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.12
uses: actions/setup-python@v3
with:
python-version: "3.12"
- 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.12
uses: actions/setup-python@v3
with:
python-version: "3.12"
- 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.12
uses: actions/setup-python@v3
with:
python-version: "3.12"
- 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.12
uses: actions/setup-python@v3
with:
python-version: "3.12"
- 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