Refactor PR Pipeline (#1133)

* WIP start refactor

* Build target jar in OS

* Build target jar in OS 2

* Fix codecov and jacoco condition

* Shuffle codecov test reporting

---------

Co-authored-by: dotasek <david.otasek@smilecdr.com>
This commit is contained in:
dotasek 2023-02-24 09:23:45 -05:00 committed by GitHub
parent 3c0fb89cd7
commit 70f7d77fba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 18 deletions

View File

@ -1,7 +1,7 @@
jobs:
- ${{ each image in parameters.images }}:
- job:
dependsOn: [ 'setup' ]
displayName: ${{image.displayName}}
pool:
@ -9,23 +9,44 @@ jobs:
variables:
currentImage: ${{image.vmImage}}
currentName: ${{image.displayName}}
codecov: $(CODECOV_TOKEN)
VERSION:
JAVA_TOOL_OPTIONS: ${{image.javaToolOptions}}
steps:
# Runs 'mvn clean install'
- task: Cache@2
inputs:
key: maven | $(Build.BuildId)
path: $(MAVEN_CACHE_FOLDER)
# Runs 'mvn test'
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
options: '-pl "!org.hl7.fhir.validation.cli" -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '${{image.jdkVersion}}'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'install'
goals: 'test'
# Upload test results to codecov
- script: bash <(curl https://codecov.io/bash) -t $(codecov)
displayName: 'codecov Bash Uploader'
condition: eq(variables.currentName, 'ubuntu-latest-java-11')
# Publishes the test results to build artifacts.
- task: PublishCodeCoverageResults@1
displayName: 'Publish JaCoCo test results'
condition: eq(variables.currentName, 'ubuntu-latest-java-11')
inputs:
codeCoverageTool: 'JaCoCo'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/org.hl7.fhir.report/target/site/jacoco-aggregate/jacoco.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/org.hl7.fhir.report/target/site/jacoco-aggregate/'
# Builds the CLI jar
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
@ -33,21 +54,19 @@ jobs:
javaHomeOption: 'JDKVersion'
jdkVersionOption: '${{image.jdkVersion}}'
jdkArchitectureOption: 'x64'
options: '-pl org.hl7.fhir.validation.cli'
options: '-pl org.hl7.fhir.validation.cli -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
publishJUnitResults: false
goals: 'install'
# Executes the CLI jar
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '${{image.jdkVersion}}'
jdkArchitectureOption: 'x64'
options: '-pl org.hl7.fhir.validation.cli -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
publishJUnitResults: false
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'exec:exec'
# Upload test results to codecov
- script: bash <(curl https://codecov.io/bash) -t $(codecov)
displayName: 'codecov Bash Uploader'
condition: eq(variables.currentImage, 'ubuntu-latest')
# Publishes the test results to build artifacts.
- task: PublishCodeCoverageResults@1
displayName: 'Publish JaCoCo test results'
condition: eq(variables.currentImage, 'ubuntu-latest')
inputs:
codeCoverageTool: 'JaCoCo'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/org.hl7.fhir.report/target/site/jacoco-aggregate/jacoco.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/org.hl7.fhir.report/target/site/jacoco-aggregate/'

View File

@ -1,3 +1,6 @@
variables:
MAVEN_CACHE_FOLDER: $(Pipeline.Workspace)/.m2/repository
trigger: none
pr:
@ -7,6 +10,31 @@ pr:
# Different users have different machine setups, we run the build three times, on ubuntu, osx, and windows.
# Azure doesn't always have the same Java versions on each system, so they are enumerated for each system independently.
jobs:
- job: setup
displayName: setup-and-cache-build
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
fetchDepth: 1
- task: Cache@2
inputs:
key: maven | $(Build.BuildId)
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
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
options: '-pl "!org.hl7.fhir.validation.cli" -DskipTests -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
jdkArchitectureOption: 'x64'
publishJUnitResults: false
goals: 'install'
- template: pull-request-pipeline-parameterized.yml
parameters:
images: