Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validator Lauf für neue Beispiele #33

Closed
wants to merge 11 commits into from
107 changes: 107 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
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:
JAVA_VALIDATOR_VERSION: 6.0.15
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.3.2 -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 1.x.x"

jobs:
CI_EXAMPLES_VALIDATION:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '20'

# Install .NET runtime
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x

# Install Java runtime (only needed if you want to run the offical HL7 Java validator)
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: 'microsoft'
java-version: '17'

- name: Identify and Copy Changed .json and .xml Files
run: |
mkdir -p temp_folder # Create a temp folder
git diff --name-only origin/main...HEAD | grep -E '\.(json|xml)$' | xargs -I {} cp {} temp_folder/
ls -l './temp_folder'


# --------------------------------------------------------------------------------------------------- #
# 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/hapifhir/org.hl7.fhir.core/releases/download/$JAVA_VALIDATOR_VERSION/validator_cli.jar
echo "JAVA_VALIDATOR_VERSION: $JAVA_VALIDATOR_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 $INPUT_PATH_TO_CONFORMANCE_RESOURCES; # Get combined path to conformance resources, we want to validate against the current version of the conformance resources
do
COMBINED_IG_PARAMETERS+="-ig $GITHUB_WORKSPACE/$p "
done

for p in $PATH_TO_EXAMPLES;

do

# Ensure directory ends with "/"
if [[ ! "$p" =~ .*/$ ]]; then
p="$p/"
fi

UNESCPAED_IG_DEPENDENCIES=$(echo $IG_DEPENDENCIES | tr -d '"')

java -jar validator_cli.jar temp_folder/$p*.xml temp_folder/$p*.json -version $FHIR_VERSION $INPUT_JAVA_VALIDATION_OPTIONS $UNESCPAED_IG_DEPENDENCIES $COMBINED_IG_PARAMETERS

fi

done

- name: Cleanup
if: always()
run: rm -rf temp_folder
Loading
Loading