From 45d33a7ff34533c10c990acf3ba2922fbd12faf7 Mon Sep 17 00:00:00 2001 From: florianschoffke Date: Mon, 19 Feb 2024 08:15:57 +0100 Subject: [PATCH] Add Java validator without firely terminal --- .github/workflows/main.yml | 72 +++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eb17885a..37588f9e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,6 +11,13 @@ on: # 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 @@ -41,21 +48,60 @@ jobs: 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' - - name: Firely.Terminal (GitHub Actions) - uses: FirelyTeam/firely-terminal-pipeline@v0.4.0 - with: - PATH_TO_CONFORMANCE_RESOURCES: './temp_folder' - FIRELY_TERMINAL_VERSION: 3.1.0 - #PATH_TO_EXAMPLES: Examples - #PATH_TO_QUALITY_CONTROL_RULES: qc/custom - DOTNET_VALIDATION_ENABLED: false - JAVA_VALIDATION_ENABLED: true - OUTPUT_FORMAT: RAW - JAVA_VALIDATION_OPTIONS: -allow-example-urls true - JAVA_VALIDATOR_VERSION: 6.0.11 - SUSHI_ENABLED: false + + # --------------------------------------------------------------------------------------------------- # + # 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 \ No newline at end of file