Skip to content

Commit

Permalink
Fixing a bug with the code coverage result when the unit and integrat…
Browse files Browse the repository at this point in the history
…ion tests are run in parallel on two different machines in CI. To calculate the total coverage, both the unit and the integration tests results' data/exec files be available (which is fine in case of sequential execution on one machine). Made a fix for that.
  • Loading branch information
faisalazam committed Jun 22, 2023
1 parent 3c60637 commit 6ecfefb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/actions/run-tests-and-upload-results/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ runs:
shell: bash
- name: 'Runs the integration tests'
if: ${{ inputs.RUN_UNIT_TESTS == 'false' }}
run: mvn -Djacoco.haltOnFailure=false verify -P it --file ${{ inputs.MODULE_DIR }}/pom.xml
run: mvn -Djacoco.haltOnFailure=false integration-test -P it --file ${{ inputs.MODULE_DIR }}/pom.xml
shell: bash
- name: 'Set environment variables'
run: |
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/parent-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ jobs:
run: cp README.md ${{ env.STAGING_DIR }}
- name: 'Copy the `LICENSE` file to `${{ env.STAGING_DIR }}` folder'
run: cp LICENSE ${{ env.STAGING_DIR }}
- name: 'Log ${{ env.UPLOADED_ARTIFACTS_DIR }} folder'
run: ls -lart ${{ env.UPLOADED_ARTIFACTS_DIR }}
- name: 'Log ${{ env.STAGING_DIR }} folder'
run: ls -lart ${{ env.STAGING_DIR }}
- name: 'Deploy to GitHub Pages'
if: ${{ github.ref == 'refs/heads/master' }}
uses: JamesIves/github-pages-deploy-action@v4
Expand Down
42 changes: 34 additions & 8 deletions .github/workflows/putting-all-together.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,45 @@ jobs:
UPLOADED_ARTIFACTS_DIR: ${{ env.UPLOADED_ARTIFACTS_DIR }}
MODULE_DIR: ${{ env.MODULE_DIR }}

generate-project-site:
generate-combined-coverage-report:
runs-on: ubuntu-latest
needs:
- unit-tests
- integration-tests

steps:
- name: 'Get the latest code from the `${{ github.repository }}` repository'
uses: actions/checkout@v3
- name: 'Set up the Oracle JDK `${{ env.JAVA_VERSION }}`'
uses: './.github/actions/install-java'
with:
JAVA_VERSION_TO_INSTALL: ${{ env.JAVA_VERSION }}
- name: 'Download the ut and it test results to generate the combined coverage report'
# this step should be in a separate job which should depend on both ut and it
# so both of them are available to generate the combine coverage report
uses: actions/download-artifact@v3
with:
path: ${{ env.MODULE_DIR }}/target }}
- name: 'Echo download path'
run: echo ${{steps.download.outputs.download-path}}
- name: Display structure of downloaded files
run: ls -R
working-directory: ${{ env.MODULE_DIR }}/target }}
- name: 'Log files in target directory'
run: ls -lart ${{ env.MODULE_DIR }} }}
- name: 'Generate the merged code coverage report'
run: mvn -Djacoco.haltOnFailure=false post-integration-test -P nt --file ${{ env.MODULE_DIR }}/pom.xml
- name: 'Uploads the results to ${{ env.UPLOAD_DIR }} folder'
uses: actions/upload-artifact@v3
with:
name: ${{ env.UPLOAD_DIR }}
retention-days: 1
path: ${{ inputs.MODULE_DIR }}/target

generate-project-site:
runs-on: ubuntu-latest
needs: generate-combined-coverage-report

steps:
- name: 'Get the latest code from the `${{ github.repository }}` repository'
uses: actions/checkout@v3
Expand Down Expand Up @@ -142,13 +175,6 @@ jobs:
mkdir -p ${{ env.SITE_DIR }}/jacoco-merged/jacoco-resources/badges
cp ${{ env.UPLOADED_ARTIFACTS_DIR }}/svgs/* ${{ env.SITE_DIR }}/jacoco-merged/jacoco-resources/badges
rm -rf ${{ env.UPLOADED_ARTIFACTS_DIR }}/svgs
# - name: 'Create `INDIVIDUAL_MODULES` folder and place it in `${{ env.SITE_DIR }}` with site contents'
# #Adding a new `INDIVIDUAL_MODULES` folder inside `site` folder to contain individual modules deployed site.
# #It's just to avoid the overwriting of the contents deployed by the `parent pom` in the `gh-pages` branch.
# run: |
# mkdir -p INDIVIDUAL_MODULES/${{ env.MODULE_DIR }}
# mv ${{ env.SITE_DIR }}/* INDIVIDUAL_MODULES/${{ env.MODULE_DIR }}
# mv INDIVIDUAL_MODULES ${{ env.SITE_DIR }}
- name: 'Deploy to GitHub Pages'
if: ${{ github.ref == 'refs/heads/master' }}
uses: JamesIves/github-pages-deploy-action@v4
Expand Down

0 comments on commit 6ecfefb

Please sign in to comment.