Skip to content

[Release fhirr4 1.4.0] Prepare for next dev cycle #484

[Release fhirr4 1.4.0] Prepare for next dev cycle

[Release fhirr4 1.4.0] Prepare for next dev cycle #484

Workflow file for this run

name: CI
on:
pull_request:
types:
- opened
- synchronize
env:
R4_PATTERN: '*/*'
UTILS_PATTERN: 'utils/*/*'
AU_PATTERN: 'au/*/*'
GITHUB_WORKFLOWS_DIR: '.github'
BALLERINA_VERSION: 2201.10.2
jobs:
setup:
runs-on: ubuntu-latest
outputs:
project-matrix: ${{ steps.unique-project-paths.outputs.BALLERINA_PROJECT_PATHS }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Extract Unique Ballerina Project Paths from Changed Files
id: unique-project-paths
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get changed files of PR from github API
CHANGED_FILES=$(gh api graphql -f query='
query($owner: String!, $repo: String!, $pr: Int!, $endCursor: String) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pr) {
files(first: 100, after: $endCursor) {
pageInfo{ hasNextPage, endCursor }
nodes {
path
}
}
}
}
}' -F owner='ballerina-platform' -F repo='module-ballerinax-health.fhir.r4' -F pr=${{ github.event.pull_request.number }} --paginate --jq '.data.repository.pullRequest.files.nodes.[].path')
echo "Changed Files: "
echo "${CHANGED_FILES}"
# Convert CHANGED_FILES to an array
readarray -t CHANGED_FILES_ARRAY <<<"${CHANGED_FILES}"
# Remove duplicates from the CHANGED_FILES_ARRAY
declare -A UNIQUE_PATHS_MAP
for file in "${CHANGED_FILES_ARRAY[@]}"; do
if [[ $file == $UTILS_PATTERN ]]; then
EXTRACTED_PATH=$(echo "$file" | cut -d '/' -f 1-2)
elif [[ $file == $AU_PATTERN ]]; then
EXTRACTED_PATH=$(echo "$file" | cut -d '/' -f 1-2)
elif [[ $file == $R4_PATTERN ]]; then
EXTRACTED_PATH=$(echo "$file" | cut -d '/' -f 1)
fi
if [[ $EXTRACTED_PATH && $EXTRACTED_PATH != $GITHUB_WORKFLOWS_DIR ]]; then
UNIQUE_PATHS_MAP[$EXTRACTED_PATH]=1
fi
done
# Print the unique ballerina project paths
echo "Extracted Unique Ballerina Project Paths: "
for EXTRACTED_PATH in "${!UNIQUE_PATHS_MAP[@]}"; do
echo "$EXTRACTED_PATH"
done
# Create the JSON array with elements enclosed in double quotes
UNIQUE_PATHS_JSON=$(for key in "${!UNIQUE_PATHS_MAP[@]}"; do echo "\"$key\""; done | jq -s -c .)
echo "UNIQUE_PATHS_JSON: "
echo "${UNIQUE_PATHS_JSON}"
echo "BALLERINA_PROJECT_PATHS=${UNIQUE_PATHS_JSON}" >> $GITHUB_OUTPUT
build:
needs: [ setup ]
runs-on: ubuntu-latest
env:
JAVA_OPTS: -Xmx4G
if: ${{ needs.setup.outputs.project-matrix != '[]' }}
strategy:
matrix:
path: ${{ fromJson(needs.setup.outputs.project-matrix) }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set Up Ballerina
uses: ballerina-platform/[email protected]
with:
version: $BALLERINA_VERSION
- name: Ballerina Build
if: ${{ matrix.path != 'fhirr4' }}
run: |
pushd "${{ matrix.path }}"
bal pack
popd
- name: Setup Maven
if: ${{ matrix.path == 'fhirr4' }}
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: Create settings.xml
if: ${{ matrix.path == 'fhirr4' }}
run: echo '<settings>
<servers>
<server>
<id>ballerina-language-repo</id>
<username>${{ github.actor }}</username>
<password>${{ secrets.GITHUB_TOKEN }}</password>
</server>
</servers>
</settings>' > ~/.m2/settings.xml
- name: Run maven build
if: ${{ matrix.path == 'fhirr4' }}
run: |
mvn clean install -f fhirr4
test:
needs: [ setup ]
runs-on: ubuntu-latest
env:
JAVA_OPTS: -Xmx4G
if: ${{ needs.setup.outputs.project-matrix != '[]' }}
strategy:
matrix:
path: ${{ fromJson(needs.setup.outputs.project-matrix) }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set Up Ballerina
uses: ballerina-platform/[email protected]
with:
version: $BALLERINA_VERSION
- name: Ballerina Test
if: ${{ matrix.path != 'fhirr4' }}
run: |
pushd "${{ matrix.path }}"
bal test --code-coverage
popd
- name: Setup Maven
if: ${{ matrix.path == 'fhirr4' }}
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: Create settings.xml
if: ${{ matrix.path == 'fhirr4' }}
run: echo '<settings>
<servers>
<server>
<id>ballerina-language-repo</id>
<username>${{ github.actor }}</username>
<password>${{ secrets.GITHUB_TOKEN }}</password>
</server>
</servers>
</settings>' > ~/.m2/settings.xml
- name: Run maven build
if: ${{ matrix.path == 'fhirr4' }}
run: |
mvn clean install -PrunBalTest -f fhirr4
- name: Read Ballerina Test Results
if: ${{ matrix.path != 'fhirr4' }}
id: test_results
run: |
if [ -f "./${{ matrix.path }}/target/report/test_results.json" ]; then
content=`cat ./${{ matrix.path }}/target/report/test_results.json`
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
echo "Covered Code Lines : $(echo "$content" | jq -r '.coveredLines')"
echo "Total Code Lines : $(echo "$content" | jq -r '.missedLines') + $(echo "$content" | jq -r '.coveredLines')"
echo "Code Coverage Percentage : $(echo "$content" | jq -r '.coveragePercentage')"
else
# echo "TEST_RESULTS_JSON=" >> $GITHUB_OUTPUT
echo "No test results file found."
fi