Merge pull request #72 from gematik/feature/diga_communication #176
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Validate Examples | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on push or pull request events but only for the master branch | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
env: | |
REFERENZVALIDATOR_VERSION: 2.5.0 | |
PATH_TO_EXAMPLES: './temp_folder/' | |
FHIR_VERSION: "4.0" | |
INPUT_JAVA_VALIDATION_OPTIONS: "-tx http://tx.fhir.org -debug -allow-example-urls true" | |
IG_DEPENDENCIES: "-ig de.basisprofil.r4#1.4.0 -ig hl7.fhir.r4.core#4.0.1 -ig kbv.ita.for#1.1.0 -ig kbv.ita.erp#1.1.x -ig de.gematik.erezept-workflow.r4" | |
jobs: | |
CI_EXAMPLES_VALIDATION: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
# Identify and Copy Changed .json and .xml Files | |
- name: Identify and Copy Changed .json and .xml Files | |
run: | | |
mkdir -p $PATH_TO_EXAMPLES # Create a temp folder | |
# git fetch origin main:main | |
git diff --name-only origin/main | grep -E '\.(json|xml)$' | xargs -I {} cp {} $PATH_TO_EXAMPLES/ | |
echo "Number of changed files to validate: " && ls -1 $PATH_TO_EXAMPLES | wc -l | |
# Install Java runtime (only needed if you want to run the offical HL7 Java validator) | |
- name: Setup Java JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'microsoft' | |
java-version: '17' | |
# --------------------------------------------------------------------------------------------------- # | |
# JAVA Validator # | |
# --------------------------------------------------------------------------------------------------- # | |
- name: Check if Java is installed | |
run: | | |
if ! command -v java &> /dev/null | |
then | |
echo "java could not be found. Please see actions/setup-java to set it up before running this action." | |
exit 1 | |
fi | |
shell: bash | |
- name: Download Java Validator | |
run: | | |
CHECK_JAVA_VERSION=$(java -version 2>&1 | head -1 | cut -d'"' -f2) | |
echo "JAVA_VERSION: $CHECK_JAVA_VERSION" | |
wget -q https://github.com/gematik/app-referencevalidator/releases/download/$REFERENZVALIDATOR_VERSION/referencevalidator-cli-$REFERENZVALIDATOR_VERSION.jar | |
echo "REFERENZVALIDATOR_VERSION: $REFERENZVALIDATOR_VERSION" | |
shell: bash | |
- name: Install jq | |
run: | | |
sudo apt-get update > /dev/null | |
sudo apt-get install --no-install-recommends -y jq findutils curl ca-certificates > /dev/null | |
shell: bash | |
- name: Validate all example resources in scope of the repository | |
run: | | |
for p in $PATH_TO_EXAMPLES; | |
do | |
# Ensure directory ends with "/" | |
if [[ ! "$p" =~ .*/$ ]]; then | |
p="$p/" | |
fi | |
for f in $p*; | |
do | |
java -jar referencevalidator-cli-$REFERENZVALIDATOR_VERSION.jar erp $f --accepted-encodings xml --accepted-encodings json --no-profile-validity-period-check | |
done | |
done | |
- name: Cleanup | |
if: always() | |
run: rm -rf temp_folder |