From caf370da31cda005c0d5f6a84edb3e12fcff159d Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Wed, 24 Aug 2022 12:55:00 -0400 Subject: [PATCH] Azure Pipelines Overhaul (#3948) This PR changes the way HAPI is built by Azure pipelines. Instead of a FIFO queue for all tests in the project, the entire project is quickly built and cached without testing, then the individual modules are built and tested in separate jobs which can be run in parallel from each other. Each of these jobs then uploads the test coverage for that module as a build artifact. Finally, a last stage downloads all the archived tests results and aggregates them using jacoco so they can be uploaded to codecov. This has two key benefits: If there is a failing test because of an intermittent, the individual failing module can be re-run instead of having to re-run the whole project build. The build time is decreased substantially (90min -> 45min). This is the first run at this, I will be iterating to further reduce build times going forward. --- azure-pipelines.yml | 216 ++++++++++-------- hapi-fhir-base/pom.xml | 15 -- hapi-fhir-batch/pom.xml | 14 -- hapi-fhir-client-okhttp/pom.xml | 22 -- hapi-fhir-client/pom.xml | 15 -- hapi-fhir-converter/pom.xml | 17 -- hapi-fhir-jaxrsserver-base/pom.xml | 23 -- hapi-fhir-jpaserver-base/pom.xml | 15 -- .../pom.xml | 15 -- hapi-fhir-jpaserver-mdm/pom.xml | 12 - hapi-fhir-jpaserver-model/pom.xml | 14 -- hapi-fhir-jpaserver-searchparam/pom.xml | 12 - hapi-fhir-jpaserver-subscription/pom.xml | 14 -- hapi-fhir-jpaserver-test-utilities/pom.xml | 15 -- hapi-fhir-server-mdm/pom.xml | 12 - hapi-fhir-server/pom.xml | 15 -- hapi-fhir-sql-migrate/pom.xml | 16 -- hapi-fhir-storage-batch2/pom.xml | 14 -- hapi-fhir-storage/pom.xml | 14 -- hapi-fhir-structures-dstu2.1/pom.xml | 15 -- hapi-fhir-structures-dstu2/pom.xml | 15 -- hapi-fhir-structures-hl7org-dstu2/pom.xml | 15 -- hapi-fhir-structures-r4/pom.xml | 15 -- hapi-fhir-structures-r5/pom.xml | 15 -- hapi-fhir-validation/pom.xml | 15 -- hapi-tinder-test/pom.xml | 15 -- test-job-template.yml | 147 ++++++++++++ 27 files changed, 271 insertions(+), 471 deletions(-) create mode 100644 test-job-template.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 415f83bc367..f98108103af 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -2,100 +2,132 @@ variables: MAVEN_CACHE_FOLDER: $(Pipeline.Workspace)/.m2/repository - #MAVEN_CACHE_FOLDER: $(Agent.TempDirectory)/.m2/repository - #MAVEN_OPTS: '-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)' MAVEN_OPTS: '' + NEW_RELEASE_VERSION: + BRANCH: -trigger: - - master +trigger: none pool: - vmImage: 'ubuntu-latest' - -jobs: - - job: Build - timeoutInMinutes: 360 - container: maven:3.8-openjdk-17 - steps: - - task: Cache@2 - inputs: - key: 'maven | "$(Agent.OS)" | ./pom.xml' - path: $(MAVEN_CACHE_FOLDER) - - task: Maven@3 - env: - JAVA_HOME_11_X64: /usr/java/openjdk-17 - displayName: Checkstyle Build - inputs: - mavenPomFile: 'hapi-fhir-checkstyle/pom.xml' - goals: 'clean install' - options: '-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)' - jdkVersionOption: 1.11 - - task: DockerInstaller@0 - displayName: Docker Installer - inputs: - dockerVersion: 17.09.0-ce - releaseType: stable - - task: Bash@3 - inputs: - targetType: 'inline' - script: mkdir -p $(MAVEN_CACHE_FOLDER); pwd; ls -al $(MAVEN_CACHE_FOLDER) - - task: Maven@3 - env: - JAVA_HOME_11_X64: /usr/java/openjdk-17 - inputs: - goals: 'clean install' - # These are Maven CLI options (and show up in the build logs) - "-nsu"=Don't update snapshots. We can remove this when Maven OSS is more healthy - options: '-P ALLMODULES,JACOCO,CI,ERRORPRONE -e -B -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER) -Dmaven.wagon.http.pool=false -Dhttp.keepAlive=false -Dstyle.color=always -Djansi.force=true' - # These are JVM options (and don't show up in the build logs) - mavenOptions: '-Xmx2048m $(MAVEN_OPTS) -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Duser.timezone=America/Toronto' - jdkVersionOption: 1.11 - - task: CopyFiles@2 - condition: always() - inputs: - sourceFolder: '$(System.DefaultWorkingDirectory)/' - contents: '**/target/*-reports/*.txt' - targetFolder: '$(Build.ArtifactStagingDirectory)' - - task: PublishPipelineArtifact@1 - displayName: 'Publish Full Test Output' - condition: always() - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)/' - artifactName: 'full_logs_$(Build.BuildId)_$(Build.BuildNumber)_$(System.JobId).zip' - - script: bash <(curl https://codecov.io/bash) -t $(CODECOV_TOKEN) - displayName: 'codecov' - - task: PublishTestResults@2 - inputs: - testResultsFormat: 'JUnit' - testResultsFiles: '**/TEST-*.xml' - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: 'JaCoCo' - summaryFileLocation: $(System.DefaultWorkingDirectory)/hapi-fhir-jacoco/target/site/jacoco-report/jacoco.xml - reportDirectory: $(System.DefaultWorkingDirectory)/hapi-fhir-jacoco/target/site/jacoco-report/ - failIfCoverageEmpty: false - -# Potential Additional Maven3 Options: -#publishJUnitResults: true -#testResultsFiles: '**/surefire-reports/TEST-*.xml' # Required when publishJUnitResults == True -#testRunTitle: # Optional -#codeCoverageToolOption: 'None' # Optional. Options: none, cobertura, jaCoCo. Enabling code coverage inserts the `clean` goal into the Maven goals list when Maven runs. -#codeCoverageClassFilter: # Optional. Comma-separated list of filters to include or exclude classes from collecting code coverage. For example: +:com.*,+:org.*,-:my.app*.* -#codeCoverageClassFilesDirectories: # Optional -#codeCoverageSourceDirectories: # Optional -#codeCoverageFailIfEmpty: false # Optional -#javaHomeOption: 'JDKVersion' # Options: jDKVersion, path -#jdkVersionOption: 'default' # Optional. Options: default, 1.11, 1.10, 1.9, 1.8, 1.7, 1.6 -#jdkDirectory: # Required when javaHomeOption == Path -#jdkArchitectureOption: 'x64' # Optional. Options: x86, x64 -#mavenVersionOption: 'Default' # Options: default, path -#mavenDirectory: # Required when mavenVersionOption == Path -#mavenSetM2Home: false # Required when mavenVersionOption == Path -#mavenAuthenticateFeed: false -#effectivePomSkip: false -#sonarQubeRunAnalysis: false -#sqMavenPluginVersionChoice: 'latest' # Required when sonarQubeRunAnalysis == True# Options: latest, pom -#checkStyleRunAnalysis: false # Optional -#pmdRunAnalysis: false # Optional -#findBugsRunAnalysis: false # Optional - + vmImage: ubuntu-latest +stages: + - stage: + displayName: "module-tests" + jobs: + - template: test-job-template.yml + parameters: + modules: + - name: hapi_fhir_jpaserver_test_utilities + module: hapi-fhir-jpaserver-test-utilities + - name: hapi_fhir_structures_r4 + module: hapi-fhir-structures-r4 + - name: hapi_fhir_jpaserver_base + module: hapi-fhir-jpaserver-base + - name: hapi_deployable_pom + module: hapi-deployable-pom + - name: hapi_fhir_android + module: hapi-fhir-android + - name: hapi_fhir_base + module: hapi-fhir-base + - name: hapi_fhir_batch + module: hapi-fhir-batch + - name: hapi_fhir_bom + module: hapi-fhir-bom + - name: hapi_fhir_checkstyle + module: hapi-fhir-checkstyle + - name: hapi_fhir_cli + module: hapi-fhir-cli + - name: hapi_fhir_client + module: hapi-fhir-client + - name: hapi_fhir_client_okhttp + module: hapi-fhir-client-okhttp + - name: hapi_fhir_converter + module: hapi-fhir-converter + - name: hapi_fhir_dist + module: hapi-fhir-dist + - name: hapi_fhir_docs + module: hapi-fhir-docs + - name: hapi_fhir_jaxrsserver_base + module: hapi-fhir-jaxrsserver-base + - name: hapi_fhir_jpa + module: hapi-fhir-jpa +# Put to top, but kept in order here +# - name: hapi_fhir_jpaserver_base +# module: hapi-fhir-jpaserver-base + - name: hapi_fhir_jpaserver_cql + module: hapi-fhir-jpaserver-cql + - name: hapi_fhir_jpaserver_elastic_test_utilities + module: hapi-fhir-jpaserver-elastic-test-utilities + - name: hapi_fhir_jpaserver_mdm + module: hapi-fhir-jpaserver-mdm + - name: hapi_fhir_jpaserver_model + module: hapi-fhir-jpaserver-model + - name: hapi_fhir_jpaserver_searchparam + module: hapi-fhir-jpaserver-searchparam + - name: hapi_fhir_jpaserver_subscription + module: hapi-fhir-jpaserver-subscription +# Put to top, but kept in order here +# - name: hapi_fhir_jpaserver_test_utilities +# module: hapi-fhir-jpaserver-test-utilities + - name: hapi_fhir_jpaserver_uhnfhirtest + module: hapi-fhir-jpaserver-uhnfhirtest + - name: hapi_fhir_server + module: hapi-fhir-server + - name: hapi_fhir_server_mdm + module: hapi-fhir-server-mdm + - name: hapi_fhir_server_openapi + module: hapi-fhir-server-openapi + - name: hapi_fhir_spring_boot + module: hapi-fhir-spring-boot + - name: hapi_fhir_sql_migrate + module: hapi-fhir-sql-migrate + - name: hapi_fhir_storage + module: hapi-fhir-storage + - name: hapi_fhir_storage_batch2 + module: hapi-fhir-storage-batch2 + - name: hapi_fhir_storage_batch2_jobs + module: hapi-fhir-storage-batch2-jobs + - name: hapi_fhir_storage_mdm + module: hapi-fhir-storage-mdm + - name: hapi_fhir_storage_test_utilities + module: hapi-fhir-storage-test-utilities + - name: hapi_fhir_structures_dstu2 + module: hapi-fhir-structures-dstu2 + - name: hapi_fhir_structures_dstu2_1 + module: hapi-fhir-structures-dstu2.1 + - name: hapi_fhir_structures_dstu3 + module: hapi-fhir-structures-dstu3 + - name: hapi_fhir_structures_hl7org_dstu2 + module: hapi-fhir-structures-hl7org-dstu2 +# Put to top, but kept in order here +# - name: hapi_fhir_structures_r4 +# module: hapi-fhir-structures-r4 + - name: hapi_fhir_structures_r5 + module: hapi-fhir-structures-r5 + - name: hapi_fhir_test_utilities + module: hapi-fhir-test-utilities + - name: hapi_fhir_testpage_overlay + module: hapi-fhir-testpage-overlay + - name: hapi_fhir_validation + module: hapi-fhir-validation + - name: hapi_fhir_validation_resources_dstu2 + module: hapi-fhir-validation-resources-dstu2 + - name: hapi_fhir_validation_resources_dstu2_1 + module: hapi-fhir-validation-resources-dstu2.1 + - name: hapi_fhir_validation_resources_dstu3 + module: hapi-fhir-validation-resources-dstu3 + - name: hapi_fhir_validation_resources_r4 + module: hapi-fhir-validation-resources-r4 + - name: hapi_fhir_validation_resources_r5 + module: hapi-fhir-validation-resources-r5 + - name: hapi_tinder_plugin + module: hapi-tinder-plugin + - name: hapi_tinder_test + module: hapi-tinder-test + - name: tests_hapi_fhir_base_test_jaxrsserver_kotlin + module: tests/hapi-fhir-base-test-jaxrsserver-kotlin + - name: tests_hapi_fhir_base_test_mindeps_client + module: tests/hapi-fhir-base-test-mindeps-client + - name: tests_hapi_fhir_base_test_mindeps_server + module: tests/hapi-fhir-base-test-mindeps-server diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml index fd53ff6a40a..60ab5ed2025 100644 --- a/hapi-fhir-base/pom.xml +++ b/hapi-fhir-base/pom.xml @@ -136,21 +136,6 @@ - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - org.apache.maven.plugins maven-surefire-plugin diff --git a/hapi-fhir-batch/pom.xml b/hapi-fhir-batch/pom.xml index 5d0edf0fece..bf925417e9c 100644 --- a/hapi-fhir-batch/pom.xml +++ b/hapi-fhir-batch/pom.xml @@ -69,19 +69,5 @@ - - - org.jacoco - jacoco-maven-plugin - - - default-prepare-agent - - prepare-agent - - - - - diff --git a/hapi-fhir-client-okhttp/pom.xml b/hapi-fhir-client-okhttp/pom.xml index 36d9f538800..53b8814b629 100644 --- a/hapi-fhir-client-okhttp/pom.xml +++ b/hapi-fhir-client-okhttp/pom.xml @@ -96,27 +96,5 @@ ${project.version} test - - - - - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - - - - diff --git a/hapi-fhir-client/pom.xml b/hapi-fhir-client/pom.xml index d1078f4a7f4..4e7265236b8 100644 --- a/hapi-fhir-client/pom.xml +++ b/hapi-fhir-client/pom.xml @@ -39,21 +39,6 @@ - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - org.apache.maven.plugins maven-surefire-plugin diff --git a/hapi-fhir-converter/pom.xml b/hapi-fhir-converter/pom.xml index 1b7d0fadb4c..e9c2da3c078 100644 --- a/hapi-fhir-converter/pom.xml +++ b/hapi-fhir-converter/pom.xml @@ -215,23 +215,6 @@ - - - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - diff --git a/hapi-fhir-jaxrsserver-base/pom.xml b/hapi-fhir-jaxrsserver-base/pom.xml index 83e1d045e44..a1086a8adbc 100644 --- a/hapi-fhir-jaxrsserver-base/pom.xml +++ b/hapi-fhir-jaxrsserver-base/pom.xml @@ -167,27 +167,4 @@ - - - - - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - - - - - diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml index 109fe3700b3..78dace5cd44 100644 --- a/hapi-fhir-jpaserver-base/pom.xml +++ b/hapi-fhir-jpaserver-base/pom.xml @@ -437,21 +437,6 @@ - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - ca.uhn.hapi.fhir hapi-tinder-plugin diff --git a/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml b/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml index 8a4caf5c7c7..d81277e00df 100644 --- a/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml +++ b/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml @@ -243,21 +243,6 @@ ${skipFailsafe} - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - org.apache.maven.plugins maven-checkstyle-plugin diff --git a/hapi-fhir-jpaserver-mdm/pom.xml b/hapi-fhir-jpaserver-mdm/pom.xml index 2216fe1fb07..e3dfa61fe52 100644 --- a/hapi-fhir-jpaserver-mdm/pom.xml +++ b/hapi-fhir-jpaserver-mdm/pom.xml @@ -117,18 +117,6 @@ - - org.jacoco - jacoco-maven-plugin - - - default-prepare-agent - - prepare-agent - - - - diff --git a/hapi-fhir-jpaserver-model/pom.xml b/hapi-fhir-jpaserver-model/pom.xml index 938aeeac348..68ac96aee79 100644 --- a/hapi-fhir-jpaserver-model/pom.xml +++ b/hapi-fhir-jpaserver-model/pom.xml @@ -155,19 +155,5 @@ - - - org.jacoco - jacoco-maven-plugin - - - default-prepare-agent - - prepare-agent - - - - - diff --git a/hapi-fhir-jpaserver-searchparam/pom.xml b/hapi-fhir-jpaserver-searchparam/pom.xml index 84e19aae6bb..2b4a5637a36 100755 --- a/hapi-fhir-jpaserver-searchparam/pom.xml +++ b/hapi-fhir-jpaserver-searchparam/pom.xml @@ -159,18 +159,6 @@ - - org.jacoco - jacoco-maven-plugin - - - default-prepare-agent - - prepare-agent - - - - org.apache.maven.plugins maven-surefire-plugin diff --git a/hapi-fhir-jpaserver-subscription/pom.xml b/hapi-fhir-jpaserver-subscription/pom.xml index 1804f25f751..b2daa2d8cd1 100644 --- a/hapi-fhir-jpaserver-subscription/pom.xml +++ b/hapi-fhir-jpaserver-subscription/pom.xml @@ -135,19 +135,5 @@ - - - org.jacoco - jacoco-maven-plugin - - - default-prepare-agent - - prepare-agent - - - - - diff --git a/hapi-fhir-jpaserver-test-utilities/pom.xml b/hapi-fhir-jpaserver-test-utilities/pom.xml index 5f60feb9bf1..f4af4d7db7e 100644 --- a/hapi-fhir-jpaserver-test-utilities/pom.xml +++ b/hapi-fhir-jpaserver-test-utilities/pom.xml @@ -243,21 +243,6 @@ ${skipFailsafe} - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - org.apache.maven.plugins maven-checkstyle-plugin diff --git a/hapi-fhir-server-mdm/pom.xml b/hapi-fhir-server-mdm/pom.xml index c1769414d1e..740e9c2d109 100644 --- a/hapi-fhir-server-mdm/pom.xml +++ b/hapi-fhir-server-mdm/pom.xml @@ -131,18 +131,6 @@ - - org.jacoco - jacoco-maven-plugin - - - default-prepare-agent - - prepare-agent - - - - org.apache.felix maven-bundle-plugin diff --git a/hapi-fhir-server/pom.xml b/hapi-fhir-server/pom.xml index 2fa785fc8e0..4a0fe9d0231 100644 --- a/hapi-fhir-server/pom.xml +++ b/hapi-fhir-server/pom.xml @@ -114,21 +114,6 @@ - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - org.apache.maven.plugins maven-surefire-plugin diff --git a/hapi-fhir-sql-migrate/pom.xml b/hapi-fhir-sql-migrate/pom.xml index e0d07ecfc82..f90d1d4d078 100644 --- a/hapi-fhir-sql-migrate/pom.xml +++ b/hapi-fhir-sql-migrate/pom.xml @@ -107,22 +107,6 @@ - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - - org.apache.maven.plugins diff --git a/hapi-fhir-storage-batch2/pom.xml b/hapi-fhir-storage-batch2/pom.xml index f4bdde6a784..15de78d1463 100644 --- a/hapi-fhir-storage-batch2/pom.xml +++ b/hapi-fhir-storage-batch2/pom.xml @@ -103,19 +103,5 @@ - - - org.jacoco - jacoco-maven-plugin - - - default-prepare-agent - - prepare-agent - - - - - diff --git a/hapi-fhir-storage/pom.xml b/hapi-fhir-storage/pom.xml index 38be169a643..55d5518e637 100644 --- a/hapi-fhir-storage/pom.xml +++ b/hapi-fhir-storage/pom.xml @@ -169,19 +169,5 @@ - - - org.jacoco - jacoco-maven-plugin - - - default-prepare-agent - - prepare-agent - - - - - diff --git a/hapi-fhir-structures-dstu2.1/pom.xml b/hapi-fhir-structures-dstu2.1/pom.xml index 54cbf3e0315..8a4dbc5c69a 100644 --- a/hapi-fhir-structures-dstu2.1/pom.xml +++ b/hapi-fhir-structures-dstu2.1/pom.xml @@ -250,21 +250,6 @@ - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - org.apache.maven.plugins maven-surefire-plugin diff --git a/hapi-fhir-structures-dstu2/pom.xml b/hapi-fhir-structures-dstu2/pom.xml index db35dfb5d16..fc4238840e4 100644 --- a/hapi-fhir-structures-dstu2/pom.xml +++ b/hapi-fhir-structures-dstu2/pom.xml @@ -209,21 +209,6 @@ - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - org.apache.maven.plugins maven-surefire-plugin diff --git a/hapi-fhir-structures-hl7org-dstu2/pom.xml b/hapi-fhir-structures-hl7org-dstu2/pom.xml index 3783ca9a3b1..51f73f49770 100644 --- a/hapi-fhir-structures-hl7org-dstu2/pom.xml +++ b/hapi-fhir-structures-hl7org-dstu2/pom.xml @@ -261,21 +261,6 @@ - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - org.apache.maven.plugins maven-surefire-plugin diff --git a/hapi-fhir-structures-r4/pom.xml b/hapi-fhir-structures-r4/pom.xml index e294a1fdf9a..8b41368803a 100644 --- a/hapi-fhir-structures-r4/pom.xml +++ b/hapi-fhir-structures-r4/pom.xml @@ -331,21 +331,6 @@ - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - org.apache.maven.plugins maven-surefire-plugin diff --git a/hapi-fhir-structures-r5/pom.xml b/hapi-fhir-structures-r5/pom.xml index 1618c8b46c7..5d149b71712 100644 --- a/hapi-fhir-structures-r5/pom.xml +++ b/hapi-fhir-structures-r5/pom.xml @@ -316,21 +316,6 @@ - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - org.apache.maven.plugins maven-surefire-plugin diff --git a/hapi-fhir-validation/pom.xml b/hapi-fhir-validation/pom.xml index 9ee8e1c89e0..eabbfed08a1 100644 --- a/hapi-fhir-validation/pom.xml +++ b/hapi-fhir-validation/pom.xml @@ -333,21 +333,6 @@ - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - org.apache.maven.plugins maven-surefire-plugin diff --git a/hapi-tinder-test/pom.xml b/hapi-tinder-test/pom.xml index 7f797007c40..81331a1a006 100644 --- a/hapi-tinder-test/pom.xml +++ b/hapi-tinder-test/pom.xml @@ -415,21 +415,6 @@ - - org.jacoco - jacoco-maven-plugin - - true - - - - default-prepare-agent - - prepare-agent - - - - diff --git a/test-job-template.yml b/test-job-template.yml new file mode 100644 index 00000000000..52790b11e87 --- /dev/null +++ b/test-job-template.yml @@ -0,0 +1,147 @@ +# HAPI FHIR Build Pipeline + +parameters: + param: [ ] + +jobs: + - job: setup + displayName: setup-and-cache-build + timeoutInMinutes: 60 + container: maven:3.8-openjdk-17 + pool: + vmImage: ubuntu-latest + steps: + - task: Cache@2 + inputs: + key: 'maven | "$(Agent.OS)" | ./pom.xml' + path: $(MAVEN_CACHE_FOLDER) + - task: Bash@3 + inputs: + targetType: 'inline' + script: mkdir -p $(MAVEN_CACHE_FOLDER); pwd; ls -al $(MAVEN_CACHE_FOLDER) + - task: Maven@3 + env: + JAVA_HOME_11_X64: /usr/java/openjdk-17 + inputs: + goals: 'install' + # These are Maven CLI options (and show up in the build logs) - "-nsu"=Don't update snapshots. We can remove this when Maven OSS is more healthy + options: '-P ALLMODULES,CI,FASTINSTALL -e -B -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER) -Dmaven.javadoc.skip=true -Dmaven.wagon.http.pool=false -Dhttp.keepAlive=false -Dstyle.color=always -Djansi.force=true' + # These are JVM options (and don't show up in the build logs) + mavenOptions: '-Xmx1024m $(MAVEN_OPTS) -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Duser.timezone=America/Toronto' + jdkVersionOption: 1.11 + - ${{ each p in parameters.modules }}: + - job: ${{ p.name }} + timeoutInMinutes: 60 + displayName: ${{ p.name }} + dependsOn: [ 'setup' ] + container: maven:3.8-openjdk-17 + pool: + vmImage: ubuntu-latest + steps: + - script: echo testing module ${{ p.module }} + - task: DockerInstaller@0 + displayName: Docker Installer + inputs: + dockerVersion: 17.09.0-ce + releaseType: stable + - task: Cache@2 + inputs: + key: 'maven | "$(Agent.OS)" | ./pom.xml' + path: $(MAVEN_CACHE_FOLDER) +# - task: Maven@3 +# env: +# JAVA_HOME_11_X64: /usr/java/openjdk-17 +# displayName: Checkstyle Build +# inputs: +# mavenPomFile: 'hapi-fhir-checkstyle/pom.xml' +# goals: 'clean install' +# options: '-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)' +# jdkVersionOption: 1.11 + - task: Maven@3 + env: + JAVA_HOME_11_X64: /usr/java/openjdk-17 + inputs: + mavenPomFile: '$(System.DefaultWorkingDirectory)/pom.xml' + goals: 'clean test jacoco:report -pl ${{ p.module }}' + # These are Maven CLI options (and show up in the build logs) - "-nsu"=Don't update snapshots. We can remove this when Maven OSS is more healthy + options: '-P ALLMODULES,JACOCO,CI -e -B -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER) -Dmaven.wagon.http.pool=false -Dhttp.keepAlive=false -Dstyle.color=always -Djansi.force=true' + # These are JVM options (and don't show up in the build logs) + mavenOptions: '-Xmx1024m $(MAVEN_OPTS) -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Duser.timezone=America/Toronto' + jdkVersionOption: 1.11 + # Copy testing log files and publish to pipeline run on Azure. + - task: CopyFiles@2 + condition: always() + inputs: + sourceFolder: '$(System.DefaultWorkingDirectory)/' + contents: '**/target/*-reports/*.txt' + targetFolder: '$(Build.ArtifactStagingDirectory)' + - task: PublishPipelineArtifact@1 + displayName: 'Publish Full Test Output' + condition: always() + inputs: + targetPath: '$(Build.ArtifactStagingDirectory)/' + artifactName: '${{p.name}}_full_logs_$(Build.BuildId)_$(Build.BuildNumber)_$(System.JobId).zip' + # Publish target directory + - task: PublishBuildArtifacts@1 + displayName: 'Publish generated build files' + continueOnError: true + inputs: + pathToPublish: '$(System.DefaultWorkingDirectory)/${{ p.module }}/target/' + parallel: true + artifactName: '${{ p.name }}_target' + - job: + pool: + vmImage: ubuntu-latest + timeoutInMinutes: 60 + displayName: generate_test_reports + container: maven:3.8-openjdk-17 + dependsOn: + - ${{ each p in parameters.modules }}: + - ${{ p.name }} + steps: + - ${{ each p in parameters.modules }}: + - task: Bash@3 + inputs: + targetType: 'inline' + script: mkdir -p $(System.DefaultWorkingDirectory)/${{ p.module }}/target/ + - task: DownloadBuildArtifacts@0 + displayName: 'Download jacoco test coverage result exec file for ${{ p.name }}' + continueOnError: true + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: '${{ p.name }}_target' + downloadPath: '$(System.DefaultWorkingDirectory)/' + # Copy contents from downloaded artifact directory to final target directory. + - task: CopyFiles@2 + condition: always() + inputs: + sourceFolder: '$(System.DefaultWorkingDirectory)/${{ p.name }}_target/' + contents: '**' + targetFolder: '$(System.DefaultWorkingDirectory)/${{ p.module }}/target/' + - task: Maven@3 + env: + JAVA_HOME_11_X64: /usr/java/openjdk-17 + inputs: + mavenPomFile: '$(System.DefaultWorkingDirectory)/pom.xml' + goals: 'jacoco:report-aggregate' + # These are Maven CLI options (and show up in the build logs) - "-nsu"=Don't update snapshots. We can remove this when Maven OSS is more healthy + options: '-P ALLMODULES,JACOCO' + # These are JVM options (and don't show up in the build logs) + mavenOptions: '-Xmx1024m $(MAVEN_OPTS) -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Duser.timezone=America/Toronto' + jdkVersionOption: 1.11 + - bash: | + curl -Os https://uploader.codecov.io/latest/linux/codecov + chmod +x codecov + ./codecov -t $(CODECOV_TOKEN) -R hapi-fhir-jacoco/target/site/jacoco-aggregate/ + displayName: 'codecov' + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'JUnit' + testResultsFiles: '**/TEST-*.xml' + - task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: 'JaCoCo' + summaryFileLocation: $(System.DefaultWorkingDirectory)/hapi-fhir-jacoco/target/site/jacoco-aggregate/jacoco.xml + reportDirectory: $(System.DefaultWorkingDirectory)/hapi-fhir-jacoco/target/site/jacoco-report/ + failIfCoverageEmpty: true