Skip to content

Commit 750c7ee

Browse files
committed
Merge branch 'master' into rel_8_0_mb
2 parents 7bf0379 + a8a6600 commit 750c7ee

File tree

13 files changed

+409
-343
lines changed

13 files changed

+409
-343
lines changed

.github/actions/assemble-test-reports/action.yml

Lines changed: 61 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,66 @@ name: 'Assemble and Publish Test Reports'
22
description: 'Restores Maven cache, compiles test reports, generates Jacoco aggregate report, and publishes results.'
33

44
inputs:
5-
github_token:
6-
description: 'GitHub token to access the repository.'
7-
required: true
8-
CODECOV_TOKEN:
9-
description: 'Codecov token to upload code coverage reports.'
10-
required: true
11-
modules:
12-
description: 'Comma-separated list of Maven modules.'
13-
required: true
5+
github_token:
6+
description: 'GitHub token to access the repository.'
7+
required: true
8+
CODECOV_TOKEN:
9+
description: 'Codecov token to upload code coverage reports.'
10+
required: true
11+
modules:
12+
description: 'Comma-separated list of Maven modules.'
13+
required: true
1414

1515
runs:
16-
using: "composite"
17-
steps:
18-
- name: Checkout repository
19-
uses: actions/checkout@v4
20-
with:
21-
fetch-depth: 1
22-
23-
- name: Restore Maven Cache
24-
uses: ./.github/actions/caching-handler
25-
26-
- name: Compile all previously generated reports
27-
uses: ./.github/actions/compile-test-results
28-
with:
29-
github_token: ${{ inputs.github_token }}
30-
modules: ${{ inputs.modules }}
31-
32-
- name: Generate Jacoco aggregate report
33-
shell: bash
34-
env:
35-
MAVEN_CACHE_FOLDER: $HOME/.m2/repository
36-
MAVEN_OPTS: '-Xmx1024m -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Duser.timezone=America/Toronto'
37-
run: |
38-
mvn jacoco:report-aggregate -P JACOCO -f ${{ github.workspace }}/pom.xml \
39-
-Dmaven.repo.local=$MAVEN_CACHE_FOLDER
40-
41-
- name: Upload coverage to Codecov
42-
shell: bash
43-
run: |
44-
curl -Os https://uploader.codecov.io/latest/linux/codecov
45-
chmod +x codecov
46-
./codecov -t ${{ inputs.CODECOV_TOKEN }} -R ${{ github.workspace }}/hapi-fhir-jacoco/target/site/jacoco-aggregate/
47-
48-
- name: Publish test results
49-
uses: actions/upload-artifact@v4
50-
with:
51-
name: junit-test-results
52-
path: './**/TEST-*.xml'
53-
54-
- name: Publish code coverage report
55-
uses: actions/upload-artifact@v4
56-
with:
57-
name: code-coverage
58-
path: ${{ github.workspace }}/hapi-fhir-jacoco/target/site/jacoco-aggregate/jacoco.xml
59-
fail_if_coverage_empty: true
16+
using: "composite"
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 1
22+
23+
- name: Restore Maven Cache
24+
uses: ./.github/actions/caching-handler
25+
with:
26+
key: ${{ github.ref_name }}-maven-${{ hashFiles('**/pom.xml') }}
27+
28+
- name: Restore HAPI Cache
29+
uses: ./.github/actions/caching-handler
30+
with:
31+
path: "$HOME/.m2/repository/ca/uhn/"
32+
key: ${{ github.ref_name }}-hapi-${{ github.run_id }}
33+
34+
- name: Compile all previously generated reports
35+
uses: ./.github/actions/compile-test-results
36+
with:
37+
github_token: ${{ inputs.github_token }}
38+
modules: ${{ inputs.modules }}
39+
40+
- name: Generate Jacoco aggregate report
41+
shell: bash
42+
env:
43+
MAVEN_CACHE_FOLDER: $HOME/.m2/repository
44+
MAVEN_OPTS: '-Xmx1024m -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Duser.timezone=America/Toronto'
45+
run: |
46+
mvn jacoco:report-aggregate -P JACOCO -f ${{ github.workspace }}/pom.xml \
47+
-Dmaven.repo.local=$MAVEN_CACHE_FOLDER
48+
49+
- name: Upload coverage to Codecov
50+
shell: bash
51+
run: |
52+
curl -Os https://uploader.codecov.io/latest/linux/codecov
53+
chmod +x codecov
54+
./codecov -t ${{ inputs.CODECOV_TOKEN }} -R ${{ github.workspace }}/hapi-fhir-jacoco/target/site/jacoco-aggregate/
55+
56+
- name: Publish test results
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: junit-test-results
60+
path: './**/TEST-*.xml'
61+
62+
- name: Publish code coverage report
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: code-coverage
66+
path: ${{ github.workspace }}/hapi-fhir-jacoco/target/site/jacoco-aggregate/jacoco.xml
67+
fail_if_coverage_empty: true
Lines changed: 69 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,79 @@
11
name: "Build Cache Maven Dependencies"
22
description: "Caches Maven dependencies, resolves plugins, and builds if the cache is not hit."
33
inputs:
4-
java-version:
5-
description: "The Java version to use"
6-
required: false
7-
default: "17"
8-
cache-path:
9-
description: "The path for the Maven cache"
10-
required: false
11-
default: "$HOME/.m2/repository"
4+
java-version:
5+
description: "The Java version to use"
6+
required: false
7+
default: "17"
8+
cache-path:
9+
description: "The path for the Maven cache"
10+
required: false
11+
default: "$HOME/.m2/repository"
1212

1313
runs:
14-
using: "composite"
15-
steps:
16-
- name: Set up JDK ${{ inputs.java-version }}
17-
uses: actions/setup-java@v4
18-
with:
19-
java-version: ${{ inputs.java-version }}
20-
distribution: "temurin"
14+
using: "composite"
15+
steps:
16+
- name: Set up JDK ${{ inputs.java-version }}
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: ${{ inputs.java-version }}
20+
distribution: "temurin"
2121

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

26-
- name: Cache Hit or Miss
27-
shell: bash
28-
run: |
29-
if [[ "${{ steps.load-cache.outputs.cache-hit }}" == "true" ]]; then
30-
echo "Cache hit, skipping dependency resolution.";
31-
else
32-
echo "Cache miss, dependencies have been downloaded.";
33-
fi
28+
- name: Cache Hit or Miss
29+
shell: bash
30+
run: |
31+
if [[ "${{ steps.load-cache.outputs.cache-hit }}" == "true" ]]; then
32+
echo "Cache hit, skipping dependency resolution.";
33+
else
34+
echo "Cache miss, dependencies have been downloaded.";
35+
fi
3436
35-
- name: Populate Cache with Remote Dependencies
36-
shell: bash
37-
if: steps.load-cache.outputs.cache-hit != 'true'
38-
env:
39-
MAVEN_CACHE_FOLDER: ${{ inputs.cache-path }}
40-
run: |
41-
mvn dependency:resolve dependency:resolve-plugins test-compile \
42-
surefire:help jacoco:help \
43-
-Dmaven.repo.local=$MAVEN_CACHE_FOLDER \
44-
-Dstyle.color=always -Djansi.force=true
37+
- name: Populate Cache with Remote Dependencies
38+
shell: bash
39+
if: steps.load-cache.outputs.cache-hit != 'true'
40+
env:
41+
MAVEN_CACHE_FOLDER: ${{ inputs.cache-path }}
42+
run: |
43+
mvn dependency:resolve dependency:resolve-plugins test-compile \
44+
surefire:help jacoco:help \
45+
-Dmaven.repo.local=$MAVEN_CACHE_FOLDER \
46+
-Dstyle.color=always -Djansi.force=true
4547
46-
- name: Build with Maven
47-
shell: bash
48-
if: steps.load-cache.outputs.cache-hit != 'true'
49-
env:
50-
MAVEN_CACHE_FOLDER: ${{ inputs.cache-path }}
51-
MAVEN_OPTS: '-Xmx1024m -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Duser.timezone=America/Toronto'
52-
run: |
53-
mvn clean install -P CI,CHECKSTYLE \
54-
-Dmaven.test.skip=true -e -B \
55-
-Dmaven.javadoc.skip=true \
56-
-Dmaven.wagon.http.pool=false \
57-
-Dmaven.repo.local=$MAVEN_CACHE_FOLDER \
58-
-Dhttp.keepAlive=false \
59-
-Dstyle.color=always -Djansi.force=true
48+
- name: Build with Maven
49+
shell: bash
50+
env:
51+
MAVEN_CACHE_FOLDER: ${{ inputs.cache-path }}
52+
MAVEN_OPTS: '-Xmx1024m -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Duser.timezone=America/Toronto'
53+
run: |
54+
mvn clean install -P CI,CHECKSTYLE \
55+
-Dmaven.test.skip=true -e -B \
56+
-Dmaven.javadoc.skip=true \
57+
-Dmaven.wagon.http.pool=false \
58+
-Dmaven.repo.local=$MAVEN_CACHE_FOLDER \
59+
-Dhttp.keepAlive=false \
60+
-Dstyle.color=always -Djansi.force=true
6061
61-
- name: Cache Maven dependencies
62-
id: save-cache
63-
if: steps.load-cache.outputs.cache-hit != 'true'
64-
uses: ./.github/actions/caching-handler
65-
with:
66-
save: 'true'
62+
# Developers might change HAPI modules during bug fixing or feature implementation, so we want to cache the maven
63+
# dependencies separately from the HAPI dependencies.
64+
- name: Cache HAPI dependencies
65+
id: save-cache-hapi
66+
uses: ./.github/actions/caching-handler
67+
with:
68+
path: "$HOME/.m2/repository/ca/uhn/"
69+
key: ${{ github.ref_name }}-hapi-${{ github.run_id }}
70+
save: 'true'
71+
72+
- name: Cache Maven dependencies
73+
id: save-cache-all
74+
if: steps.load-cache.outputs.cache-hit != 'true'
75+
uses: ./.github/actions/caching-handler
76+
with:
77+
key: ${{ github.ref_name }}-maven-${{ hashFiles('**/pom.xml') }}
78+
save: 'true'
79+
exclude: "$HOME/.m2/repository/ca/uhn/"

.github/actions/build-module/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ runs:
3939

4040
- name: Restore Maven Cache
4141
uses: ./.github/actions/caching-handler
42+
with:
43+
key: ${{ github.ref_name }}-maven-${{ hashFiles('**/pom.xml') }}
44+
45+
- name: Restore HAPI Cache
46+
uses: ./.github/actions/caching-handler
47+
with:
48+
path: "$HOME/.m2/repository/ca/uhn/"
49+
key: ${{ github.ref_name }}-hapi-${{ github.run_id }}
4250

4351
- name: Build Maven Module
4452
shell: bash

.github/actions/caching-handler/action.yml

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,66 @@
22
name: Cache Handler
33
description: Handles Maven cache restoration or saving in GitHub Actions.
44
inputs:
5-
path:
6-
description: The path to the Maven cache.
7-
required: false
8-
default: $HOME/.m2/repository
9-
key:
10-
description: The primary cache key.
11-
required: false
12-
# The glob pattern **/pom.xml will match all pom.xml files in the repository, including the root pom.xml file.
13-
default: |
14-
${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
15-
save:
16-
description: Whether to save the cache (true) or restore it (false).
17-
required: false
18-
default: 'false'
5+
path:
6+
description: The path to the Maven cache.
7+
required: false
8+
default: $HOME/.m2/repository
9+
key:
10+
description: The primary cache key.
11+
required: true
12+
save:
13+
description: Whether to save the cache (true) or restore it (false).
14+
required: false
15+
default: 'false'
16+
exclude:
17+
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.
18+
required: false
19+
default: ''
1920

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

2425
outputs:
25-
cache-hit:
26-
description: Indicates whether an exact match was found for the cache key (only for restore).
27-
value: ${{ steps.restore-cache.outputs.cache-hit }}
26+
cache-hit:
27+
description: Indicates whether an exact match was found for the cache key (only for restore).
28+
value: ${{ steps.restore-cache.outputs.cache-hit }}
2829

2930
runs:
30-
using: "composite"
31-
steps:
32-
- name: Debug save input
33-
shell: bash
34-
run: |
35-
echo "Input -> Save: ${{ inputs.save }}"
31+
using: "composite"
32+
steps:
33+
- name: Debug save input
34+
shell: bash
35+
run: |
36+
echo "Input -> Save: ${{ inputs.save }}"
3637
37-
- name: Restore Cache
38-
id: restore-cache
39-
if: ${{ inputs.save == 'false' }}
40-
uses: actions/cache/restore@v4
41-
with:
42-
path: ${{ inputs.path }}
43-
key: ${{ inputs.key }}
38+
- name: Restore Cache
39+
id: restore-cache
40+
if: ${{ inputs.save == 'false' }}
41+
uses: actions/cache/restore@v4
42+
with:
43+
path: ${{ inputs.path }}
44+
key: ${{ inputs.key }}
4445

45-
- name: Save Cache
46-
id: save-cache
47-
if: ${{ inputs.save == 'true' }}
48-
uses: actions/cache/save@v4
49-
with:
50-
path: ${{ inputs.path }}
51-
key: ${{ inputs.key }}
46+
- name: Exclude Directories from Cache
47+
if: ${{ inputs.save == 'true' }}
48+
shell: bash
49+
run: |
50+
cache_path="${{ inputs.path }}"
51+
exclude_dirs="${{ inputs.exclude }}"
52+
53+
if [ -n "$exclude_dirs" ]; then
54+
IFS=',' read -ra dirs <<< "$exclude_dirs"
55+
for dir in "${dirs[@]}"; do
56+
echo "Excluding directory: $dir"
57+
rm -rf "${cache_path}/$dir"
58+
done
59+
fi
60+
61+
- name: Save Cache
62+
id: save-cache
63+
if: ${{ inputs.save == 'true' }}
64+
uses: actions/cache/save@v4
65+
with:
66+
path: ${{ inputs.path }}
67+
key: ${{ inputs.key }}

0 commit comments

Comments
 (0)