6464 runs-on : ubuntu-latest
6565 outputs :
6666 matrix : ${{ steps.set-matrix.outputs.matrix }}
67+ cache-key : ${{ steps.cache-key.outputs.key }}
6768 steps :
6869 - uses : actions/checkout@v4
6970 - uses : actions/setup-node@v4
@@ -75,10 +76,86 @@ jobs:
7576 PACKAGES=$(node scripts/list-parity-packages.js "${{ inputs.packages }}")
7677 echo "matrix=$PACKAGES" >> "$GITHUB_OUTPUT"
7778 echo "Packages to test: $PACKAGES"
79+ - name : Compute shared cache key
80+ id : cache-key
81+ run : |
82+ KEY="fhir-generated-${{ hashFiles('src/test/pipelineParity.test.ts', 'src/generator/**/*.ts', 'src/generator/fhir/**/*.json') }}-v1"
83+ echo "key=$KEY" >> "$GITHUB_OUTPUT"
84+
85+ # ── Generate all packages once (shared prep job) ───────────────────────────
86+ generate :
87+ needs : setup
88+ runs-on : ubuntu-latest
89+ permissions :
90+ contents : read
91+ steps :
92+ - name : Checkout code
93+ uses : actions/checkout@v4
94+
95+ - name : Setup Node.js
96+ uses : actions/setup-node@v4
97+ with :
98+ node-version : ' 22'
99+ cache : ' npm'
100+
101+ - name : Install dependencies
102+ run : npm ci || (npm cache clean --force && npm ci)
103+
104+ - name : Restore FHIR packages cache
105+ id : cache-restore
106+ uses : actions/cache/restore@v4
107+ with :
108+ path : .cache/.fhir/packages
109+ key : ${{ needs.setup.outputs.cache-key }}
110+
111+ - name : Cache tx-server ValueSet expansions
112+ uses : actions/cache@v4
113+ with :
114+ path : .cache/tx-expansions
115+ key : tx-expansions-v2
116+ restore-keys : tx-expansions-v2
117+
118+ - name : Cache FHIR resources (StructureDefinitions)
119+ uses : actions/cache@v4
120+ with :
121+ path : .cache/fhir-resources
122+ key : fhir-resources-v4
123+ restore-keys : fhir-resources-v4
124+
125+ - name : Seed FHIR resources cache
126+ run : bash scripts/seed-fhir-cache.sh
127+
128+ - name : Build zod-r4 runtime package
129+ run : |
130+ cd packages/zod-r4
131+ npm ci || (npm cache clean --force && npm ci)
132+ npm run build
133+
134+ - name : Clear generated code to force regeneration
135+ if : steps.cache-restore.outputs.cache-hit != 'true'
136+ run : |
137+ if [ -d ".cache/.fhir/packages" ]; then
138+ find .cache/.fhir/packages -type d -name "generated" -exec rm -rf {} + 2>/dev/null || true
139+ fi
140+
141+ - name : Generate all packages
142+ if : steps.cache-restore.outputs.cache-hit != 'true'
143+ run : npm run test:parity
144+ env :
145+ CI : true
146+ PIPELINE_PACKAGES : ${{ inputs.packages }}
147+ TYPECHECK_ONLY : ' 1'
148+
149+ - name : Save FHIR packages cache (with generated output)
150+ if : steps.cache-restore.outputs.cache-hit != 'true'
151+ uses : actions/cache/save@v4
152+ with :
153+ path : .cache/.fhir/packages
154+ key : ${{ needs.setup.outputs.cache-key }}
78155
79156 # ── Firely (.NET) — one job per IG ─────────────────────────────────────────
80157 firely :
81- needs : [setup, resolve-versions]
158+ needs : [setup, resolve-versions, generate ]
82159 runs-on : ubuntu-latest
83160 permissions :
84161 contents : read
@@ -118,11 +195,11 @@ jobs:
118195 rm -rf /tmp/FhirArtifactCache-* 2>/dev/null || true
119196 rm -rf /tmp/fhir-spec-cache-* 2>/dev/null || true
120197
121- - name : Cache FHIR packages
122- uses : actions/cache@v4
198+ - name : Restore pre-generated FHIR packages
199+ uses : actions/cache/restore @v4
123200 with :
124201 path : .cache/.fhir/packages
125- key : fhir-packages- ${{ matrix.package }}-${{ hashFiles('src/test/pipelineParity.test.ts', 'src/generator/**/*.ts', 'src/generator/fhir/**/*.json') }}-v8
202+ key : ${{ needs.setup.outputs.cache-key }}
126203
127204 - name : Cache tx-server ValueSet expansions
128205 uses : actions/cache@v4
@@ -131,33 +208,18 @@ jobs:
131208 key : tx-expansions-v2
132209 restore-keys : tx-expansions-v2
133210
134- - name : Cache FHIR resources (StructureDefinitions)
135- uses : actions/cache@v4
136- with :
137- path : .cache/fhir-resources
138- key : fhir-resources-v4
139- restore-keys : fhir-resources-v4
140-
141- - name : Seed FHIR resources cache
142- run : bash scripts/seed-fhir-cache.sh
143-
144211 - name : Build zod-r4 runtime package
145212 run : |
146213 cd packages/zod-r4
147214 npm ci || (npm cache clean --force && npm ci)
148215 npm run build
149216
150- - name : Clear generated code to force regeneration
151- run : |
152- if [ -d ".cache/.fhir/packages" ]; then
153- find .cache/.fhir/packages -type d -name "generated" -exec rm -rf {} + 2>/dev/null || true
154- fi
155-
156217 - name : Run Firely parity test (${{ matrix.package }})
157218 id : firely-test
158219 run : npm run test:parity
159220 env :
160221 CI : true
222+ SKIP_GENERATION : ' 1'
161223 PIPELINE_PACKAGES : ${{ matrix.package }}
162224 FIRELY_SDK_VERSION : ${{ needs.resolve-versions.outputs.firely_version }}
163225 continue-on-error : true
@@ -224,7 +286,7 @@ jobs:
224286
225287 # ── HL7 Java Validator — one job per IG ────────────────────────────────────
226288 hl7 :
227- needs : [setup, resolve-versions]
289+ needs : [setup, resolve-versions, generate ]
228290 runs-on : ubuntu-latest
229291 permissions :
230292 contents : read
@@ -264,11 +326,11 @@ jobs:
264326 VALIDATOR_VERSION=${{ needs.resolve-versions.outputs.hl7_version }} \
265327 scripts/hl7-validator/validate.sh --download-only
266328
267- - name : Cache FHIR packages
268- uses : actions/cache@v4
329+ - name : Restore pre-generated FHIR packages
330+ uses : actions/cache/restore @v4
269331 with :
270332 path : .cache/.fhir/packages
271- key : fhir-packages- ${{ matrix.package }}-${{ hashFiles('src/test/pipelineParity.test.ts', 'src/generator/**/*.ts', 'src/generator/fhir/**/*.json') }}-v8
333+ key : ${{ needs.setup.outputs.cache-key }}
272334
273335 - name : Cache tx-server ValueSet expansions
274336 uses : actions/cache@v4
@@ -277,33 +339,18 @@ jobs:
277339 key : tx-expansions-v2
278340 restore-keys : tx-expansions-v2
279341
280- - name : Cache FHIR resources (StructureDefinitions)
281- uses : actions/cache@v4
282- with :
283- path : .cache/fhir-resources
284- key : fhir-resources-v4
285- restore-keys : fhir-resources-v4
286-
287- - name : Seed FHIR resources cache
288- run : bash scripts/seed-fhir-cache.sh
289-
290342 - name : Build zod-r4 runtime package
291343 run : |
292344 cd packages/zod-r4
293345 npm ci || (npm cache clean --force && npm ci)
294346 npm run build
295347
296- - name : Clear generated code to force regeneration
297- run : |
298- if [ -d ".cache/.fhir/packages" ]; then
299- find .cache/.fhir/packages -type d -name "generated" -exec rm -rf {} + 2>/dev/null || true
300- fi
301-
302348 - name : Run HL7 parity test (${{ matrix.package }})
303349 id : hl7-test
304350 run : npm run test:parity
305351 env :
306352 CI : true
353+ SKIP_GENERATION : ' 1'
307354 PIPELINE_PACKAGES : ${{ matrix.package }}
308355 FHIR_VALIDATOR : hl7
309356 HL7_VALIDATOR_VERSION : ${{ needs.resolve-versions.outputs.hl7_version }}
@@ -371,6 +418,7 @@ jobs:
371418
372419 # ── Internal (validate) — single job, all IGs sequentially ──────────
373420 internal :
421+ needs : [setup, generate]
374422 runs-on : ubuntu-latest
375423 permissions :
376424 contents : read
@@ -388,11 +436,11 @@ jobs:
388436 - name : Install dependencies
389437 run : npm ci || (npm cache clean --force && npm ci)
390438
391- - name : Cache FHIR packages
392- uses : actions/cache@v4
439+ - name : Restore pre-generated FHIR packages
440+ uses : actions/cache/restore @v4
393441 with :
394442 path : .cache/.fhir/packages
395- key : fhir-packages-all- ${{ hashFiles('src/test/pipelineParity.test.ts', 'src/generator/**/*.ts', 'src/generator/fhir/**/*.json') }}-v8
443+ key : ${{ needs.setup.outputs.cache-key }}
396444
397445 - name : Cache tx-server ValueSet expansions
398446 uses : actions/cache@v4
@@ -401,33 +449,18 @@ jobs:
401449 key : tx-expansions-v2
402450 restore-keys : tx-expansions-v2
403451
404- - name : Cache FHIR resources (StructureDefinitions)
405- uses : actions/cache@v4
406- with :
407- path : .cache/fhir-resources
408- key : fhir-resources-v4
409- restore-keys : fhir-resources-v4
410-
411- - name : Seed FHIR resources cache
412- run : bash scripts/seed-fhir-cache.sh
413-
414452 - name : Build zod-r4 runtime package
415453 run : |
416454 cd packages/zod-r4
417455 npm ci || (npm cache clean --force && npm ci)
418456 npm run build
419457
420- - name : Clear generated code to force regeneration
421- run : |
422- if [ -d ".cache/.fhir/packages" ]; then
423- find .cache/.fhir/packages -type d -name "generated" -exec rm -rf {} + 2>/dev/null || true
424- fi
425-
426458 - name : Run internal parity tests (all packages)
427459 id : internal-test
428460 run : npm run test:parity
429461 env :
430462 CI : true
463+ SKIP_GENERATION : ' 1'
431464 PIPELINE_PACKAGES : ${{ inputs.packages }}
432465 FHIR_VALIDATOR : internal
433466 continue-on-error : true
0 commit comments