Skip to content

Commit

Permalink
Merge branch 'master' into rel_8_0_mb
Browse files Browse the repository at this point in the history
  • Loading branch information
tadgh committed Feb 12, 2025
2 parents 7bf0379 + a8a6600 commit 750c7ee
Show file tree
Hide file tree
Showing 13 changed files with 409 additions and 343 deletions.
114 changes: 61 additions & 53 deletions .github/actions/assemble-test-reports/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,66 @@ name: 'Assemble and Publish Test Reports'
description: 'Restores Maven cache, compiles test reports, generates Jacoco aggregate report, and publishes results.'

inputs:
github_token:
description: 'GitHub token to access the repository.'
required: true
CODECOV_TOKEN:
description: 'Codecov token to upload code coverage reports.'
required: true
modules:
description: 'Comma-separated list of Maven modules.'
required: true
github_token:
description: 'GitHub token to access the repository.'
required: true
CODECOV_TOKEN:
description: 'Codecov token to upload code coverage reports.'
required: true
modules:
description: 'Comma-separated list of Maven modules.'
required: true

runs:
using: "composite"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Restore Maven Cache
uses: ./.github/actions/caching-handler

- name: Compile all previously generated reports
uses: ./.github/actions/compile-test-results
with:
github_token: ${{ inputs.github_token }}
modules: ${{ inputs.modules }}

- name: Generate Jacoco aggregate report
shell: bash
env:
MAVEN_CACHE_FOLDER: $HOME/.m2/repository
MAVEN_OPTS: '-Xmx1024m -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Duser.timezone=America/Toronto'
run: |
mvn jacoco:report-aggregate -P JACOCO -f ${{ github.workspace }}/pom.xml \
-Dmaven.repo.local=$MAVEN_CACHE_FOLDER
- name: Upload coverage to Codecov
shell: bash
run: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -t ${{ inputs.CODECOV_TOKEN }} -R ${{ github.workspace }}/hapi-fhir-jacoco/target/site/jacoco-aggregate/
- name: Publish test results
uses: actions/upload-artifact@v4
with:
name: junit-test-results
path: './**/TEST-*.xml'

- name: Publish code coverage report
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: ${{ github.workspace }}/hapi-fhir-jacoco/target/site/jacoco-aggregate/jacoco.xml
fail_if_coverage_empty: true
using: "composite"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Restore Maven Cache
uses: ./.github/actions/caching-handler
with:
key: ${{ github.ref_name }}-maven-${{ hashFiles('**/pom.xml') }}

- name: Restore HAPI Cache
uses: ./.github/actions/caching-handler
with:
path: "$HOME/.m2/repository/ca/uhn/"
key: ${{ github.ref_name }}-hapi-${{ github.run_id }}

- name: Compile all previously generated reports
uses: ./.github/actions/compile-test-results
with:
github_token: ${{ inputs.github_token }}
modules: ${{ inputs.modules }}

- name: Generate Jacoco aggregate report
shell: bash
env:
MAVEN_CACHE_FOLDER: $HOME/.m2/repository
MAVEN_OPTS: '-Xmx1024m -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Duser.timezone=America/Toronto'
run: |
mvn jacoco:report-aggregate -P JACOCO -f ${{ github.workspace }}/pom.xml \
-Dmaven.repo.local=$MAVEN_CACHE_FOLDER
- name: Upload coverage to Codecov
shell: bash
run: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -t ${{ inputs.CODECOV_TOKEN }} -R ${{ github.workspace }}/hapi-fhir-jacoco/target/site/jacoco-aggregate/
- name: Publish test results
uses: actions/upload-artifact@v4
with:
name: junit-test-results
path: './**/TEST-*.xml'

- name: Publish code coverage report
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: ${{ github.workspace }}/hapi-fhir-jacoco/target/site/jacoco-aggregate/jacoco.xml
fail_if_coverage_empty: true
125 changes: 69 additions & 56 deletions .github/actions/build-cache/action.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,79 @@
name: "Build Cache Maven Dependencies"
description: "Caches Maven dependencies, resolves plugins, and builds if the cache is not hit."
inputs:
java-version:
description: "The Java version to use"
required: false
default: "17"
cache-path:
description: "The path for the Maven cache"
required: false
default: "$HOME/.m2/repository"
java-version:
description: "The Java version to use"
required: false
default: "17"
cache-path:
description: "The path for the Maven cache"
required: false
default: "$HOME/.m2/repository"

runs:
using: "composite"
steps:
- name: Set up JDK ${{ inputs.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.java-version }}
distribution: "temurin"
using: "composite"
steps:
- name: Set up JDK ${{ inputs.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.java-version }}
distribution: "temurin"

- name: Restore Cached Maven dependencies
id: load-cache
uses: ./.github/actions/caching-handler
- name: Restore Cached Maven dependencies
id: load-cache
uses: ./.github/actions/caching-handler
with:
key: ${{ github.ref_name }}-maven-${{ hashFiles('**/pom.xml') }}

- name: Cache Hit or Miss
shell: bash
run: |
if [[ "${{ steps.load-cache.outputs.cache-hit }}" == "true" ]]; then
echo "Cache hit, skipping dependency resolution.";
else
echo "Cache miss, dependencies have been downloaded.";
fi
- name: Cache Hit or Miss
shell: bash
run: |
if [[ "${{ steps.load-cache.outputs.cache-hit }}" == "true" ]]; then
echo "Cache hit, skipping dependency resolution.";
else
echo "Cache miss, dependencies have been downloaded.";
fi
- name: Populate Cache with Remote Dependencies
shell: bash
if: steps.load-cache.outputs.cache-hit != 'true'
env:
MAVEN_CACHE_FOLDER: ${{ inputs.cache-path }}
run: |
mvn dependency:resolve dependency:resolve-plugins test-compile \
surefire:help jacoco:help \
-Dmaven.repo.local=$MAVEN_CACHE_FOLDER \
-Dstyle.color=always -Djansi.force=true
- name: Populate Cache with Remote Dependencies
shell: bash
if: steps.load-cache.outputs.cache-hit != 'true'
env:
MAVEN_CACHE_FOLDER: ${{ inputs.cache-path }}
run: |
mvn dependency:resolve dependency:resolve-plugins test-compile \
surefire:help jacoco:help \
-Dmaven.repo.local=$MAVEN_CACHE_FOLDER \
-Dstyle.color=always -Djansi.force=true
- name: Build with Maven
shell: bash
if: steps.load-cache.outputs.cache-hit != 'true'
env:
MAVEN_CACHE_FOLDER: ${{ inputs.cache-path }}
MAVEN_OPTS: '-Xmx1024m -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Duser.timezone=America/Toronto'
run: |
mvn clean install -P CI,CHECKSTYLE \
-Dmaven.test.skip=true -e -B \
-Dmaven.javadoc.skip=true \
-Dmaven.wagon.http.pool=false \
-Dmaven.repo.local=$MAVEN_CACHE_FOLDER \
-Dhttp.keepAlive=false \
-Dstyle.color=always -Djansi.force=true
- name: Build with Maven
shell: bash
env:
MAVEN_CACHE_FOLDER: ${{ inputs.cache-path }}
MAVEN_OPTS: '-Xmx1024m -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Duser.timezone=America/Toronto'
run: |
mvn clean install -P CI,CHECKSTYLE \
-Dmaven.test.skip=true -e -B \
-Dmaven.javadoc.skip=true \
-Dmaven.wagon.http.pool=false \
-Dmaven.repo.local=$MAVEN_CACHE_FOLDER \
-Dhttp.keepAlive=false \
-Dstyle.color=always -Djansi.force=true
- name: Cache Maven dependencies
id: save-cache
if: steps.load-cache.outputs.cache-hit != 'true'
uses: ./.github/actions/caching-handler
with:
save: 'true'
# Developers might change HAPI modules during bug fixing or feature implementation, so we want to cache the maven
# dependencies separately from the HAPI dependencies.
- name: Cache HAPI dependencies
id: save-cache-hapi
uses: ./.github/actions/caching-handler
with:
path: "$HOME/.m2/repository/ca/uhn/"
key: ${{ github.ref_name }}-hapi-${{ github.run_id }}
save: 'true'

- name: Cache Maven dependencies
id: save-cache-all
if: steps.load-cache.outputs.cache-hit != 'true'
uses: ./.github/actions/caching-handler
with:
key: ${{ github.ref_name }}-maven-${{ hashFiles('**/pom.xml') }}
save: 'true'
exclude: "$HOME/.m2/repository/ca/uhn/"
8 changes: 8 additions & 0 deletions .github/actions/build-module/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ runs:

- name: Restore Maven Cache
uses: ./.github/actions/caching-handler
with:
key: ${{ github.ref_name }}-maven-${{ hashFiles('**/pom.xml') }}

- name: Restore HAPI Cache
uses: ./.github/actions/caching-handler
with:
path: "$HOME/.m2/repository/ca/uhn/"
key: ${{ github.ref_name }}-hapi-${{ github.run_id }}

- name: Build Maven Module
shell: bash
Expand Down
90 changes: 53 additions & 37 deletions .github/actions/caching-handler/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,66 @@
name: Cache Handler
description: Handles Maven cache restoration or saving in GitHub Actions.
inputs:
path:
description: The path to the Maven cache.
required: false
default: $HOME/.m2/repository
key:
description: The primary cache key.
required: false
# The glob pattern **/pom.xml will match all pom.xml files in the repository, including the root pom.xml file.
default: |
${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
save:
description: Whether to save the cache (true) or restore it (false).
required: false
default: 'false'
path:
description: The path to the Maven cache.
required: false
default: $HOME/.m2/repository
key:
description: The primary cache key.
required: true
save:
description: Whether to save the cache (true) or restore it (false).
required: false
default: 'false'
exclude:
description: A list of directories to exclude from the cache (comma-separated). If you choose to exclude them, they are deleted before the parent directory is cached.
required: false
default: ''

# The key is the primary identifier for a cache. It uniquely defines a cache entry. If the key matches an
# existing cache entry exactly, that cache will be restored. The default way we use it here is generating
# based on the inputs or dependencies that define the cache's contents, in our case, the pom files.

outputs:
cache-hit:
description: Indicates whether an exact match was found for the cache key (only for restore).
value: ${{ steps.restore-cache.outputs.cache-hit }}
cache-hit:
description: Indicates whether an exact match was found for the cache key (only for restore).
value: ${{ steps.restore-cache.outputs.cache-hit }}

runs:
using: "composite"
steps:
- name: Debug save input
shell: bash
run: |
echo "Input -> Save: ${{ inputs.save }}"
using: "composite"
steps:
- name: Debug save input
shell: bash
run: |
echo "Input -> Save: ${{ inputs.save }}"
- name: Restore Cache
id: restore-cache
if: ${{ inputs.save == 'false' }}
uses: actions/cache/restore@v4
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}
- name: Restore Cache
id: restore-cache
if: ${{ inputs.save == 'false' }}
uses: actions/cache/restore@v4
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}

- name: Save Cache
id: save-cache
if: ${{ inputs.save == 'true' }}
uses: actions/cache/save@v4
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}
- name: Exclude Directories from Cache
if: ${{ inputs.save == 'true' }}
shell: bash
run: |
cache_path="${{ inputs.path }}"
exclude_dirs="${{ inputs.exclude }}"
if [ -n "$exclude_dirs" ]; then
IFS=',' read -ra dirs <<< "$exclude_dirs"
for dir in "${dirs[@]}"; do
echo "Excluding directory: $dir"
rm -rf "${cache_path}/$dir"
done
fi
- name: Save Cache
id: save-cache
if: ${{ inputs.save == 'true' }}
uses: actions/cache/save@v4
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}
Loading

0 comments on commit 750c7ee

Please sign in to comment.