Skip to content

Commit

Permalink
Azure Pipelines Overhaul (#3948)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
markiantorno committed Aug 24, 2022
1 parent b5f5cd3 commit caf370d
Show file tree
Hide file tree
Showing 27 changed files with 271 additions and 471 deletions.
216 changes: 124 additions & 92 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 0 additions & 15 deletions hapi-fhir-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,6 @@

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<dumpOnExit>true</dumpOnExit>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
14 changes: 0 additions & 14 deletions hapi-fhir-batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,5 @@
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
22 changes: 0 additions & 22 deletions hapi-fhir-client-okhttp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,5 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<dumpOnExit>true</dumpOnExit>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
15 changes: 0 additions & 15 deletions hapi-fhir-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,6 @@

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<dumpOnExit>true</dumpOnExit>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
17 changes: 0 additions & 17 deletions hapi-fhir-converter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -215,23 +215,6 @@
</additionalDependencies>
</configuration>
</plugin>


<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<dumpOnExit>true</dumpOnExit>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
23 changes: 0 additions & 23 deletions hapi-fhir-jaxrsserver-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,27 +167,4 @@
</plugin>
</plugins>
</reporting>

<build>
<plugins>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<dumpOnExit>true</dumpOnExit>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>

</project>
15 changes: 0 additions & 15 deletions hapi-fhir-jpaserver-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -437,21 +437,6 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<dumpOnExit>true</dumpOnExit>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
Expand Down
Loading

0 comments on commit caf370d

Please sign in to comment.