forked from pieter-edelman-nictiz/hl7-fhir-validator-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
97 lines (97 loc) · 4.42 KB
/
action.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
name: HL7 Validator
description: Run the HL7 Java validator and analyze the results.
inputs:
version:
description: The FHIR version to use
ig:
description: An IG or profile definition to load (multiple ig's seperated by spaces may be defined)
recurse:
description: Look in subfolders when 'ig' refers to a folder
default: "true"
tx:
description: The [base] url of a FHIR terminology server
profile:
desciption: the canonical URL to validate against
language:
description: The language to use when validating coding displays - same value as for xml:lang
source:
description: a file, url, directory or pattern for resources to validate
required: true
fail-at:
description: The level at which issues are considered fatal (fatal, error, warning or information).
default: error
verbosity-level:
description: Only show issues at this level or more severe (error, warning or information).
default: information
ignored-issues:
description: A YAML file listing issues that should be ignored.
outputs:
was-skipped:
description: Indicate whether the check was skipped
value: ${{ steps.check_run.outputs.run != 'run' }}
stats-file:
description: The location of the JSON file containing statistics about the check.
value: ${{ steps.analyze-results.outputs.stats-file }}
runs:
using: composite
steps:
- run: |
do_run=false
for source in ${{inputs.source}}; do
if [[ -f $source ]]; then
do_run=true
fi
done
if $do_run; then
echo "::set-output name=run::run"
else
echo "No input, skipping"
echo "::set-output name=run::"
fi
id: check_run
shell: bash
- run: |
if [ ${{ steps.check_run.outputs.run }} ]; then
echo "::group::Echo getting the validator"
if [ ! -f ~/validator/validator_cli.jar ]; then
mkdir -p ~/validator
wget -nv -O ~/validator/validator_cli.jar https://github.com/hapifhir/org.hl7.fhir.core/releases/latest/download/validator_cli.jar
else
echo "Validator already present"
fi
echo "::endgroup::"
fi
shell: bash
- run: |
echo "::set-output name=opt_version::$(if [ ! -z ${{inputs.version}} ]; then echo -version ${{ inputs.version }};fi)"
echo "::set-output name=opt_ig::$(for ig in ${{inputs.ig}}; do echo -n "-ig $ig ";done)"
echo "::set-output name=opt_recurse::$(if [ ! -z ${{inputs.recurse}} ]; then echo -recurse;fi)"
echo "::set-output name=opt_tx::$(if [ ! -z ${{inputs.tx}} ]; then echo -tx ${{ inputs.tx }};fi)"
echo "::set-output name=opt_profile::$(if [ ! -z ${{inputs.profile}} ]; then echo -profile ${{ inputs.profile }};fi)"
echo "::set-output name=opt_language::$(if [ ! -z ${{inputs.language}} ]; then echo -language ${{ inputs.language }};fi)"
echo "::set-output name=opt_ignored_issues::$(if [ ! -z ${{inputs.ignored-issues}} ]; then echo --ignored-issues=${{ inputs.ignored-issues }};fi)"
id: set_options
shell: bash
- run: |
if [ ${{ steps.check_run.outputs.run }} ]; then
echo "::group::Run the validator"
out_file=$(mktemp --suffix=.xml)
echo "::set-output name=out-file::$(echo $out_file)"
java -jar ~/validator/validator_cli.jar ${{ steps.set_options.outputs.opt_version }} ${{ steps.set_options.outputs.opt_ig }} ${{ steps.set_options.outputs.opt_recurse }} ${{ steps.set_options.outputs.opt_tx }} ${{ steps.set_options.outputs.opt_profile }} ${{ steps.set_options.outputs.opt_language }} -output $out_file ${{ inputs.source }} | cat
echo "::endgroup::"
fi
id: run_validator
shell: bash --noprofile --norc {0}
- id: analyze-results
run: |
stats_file=$(mktemp --suffix=.json)
echo "::set-output name=stats-file::$(echo $stats_file)"
if [ ${{ steps.check_run.outputs.run }} ]; then
if [[ -f ${{ steps.run_validator.outputs.out-file }} ]]; then
python3 ${{ github.action_path }}/analyze_results.py -a ${{ inputs.fail-at }} -v ${{ inputs.verbosity-level }} ${{ steps.set_options.outputs.opt_ignored_issues }} --colorize --stats-file=$stats_file ${{ steps.run_validator.outputs.out-file }}
else
echo "::error::The HL7 Validator didn't produce any output!"
echo "{}" >> $stats_file
fi
fi
shell: bash