Skip to content

Revised GitHub Actions workflow for matrix testing CLI mode #377

Revised GitHub Actions workflow for matrix testing CLI mode

Revised GitHub Actions workflow for matrix testing CLI mode #377

Workflow file for this run

name: build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
unit-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Run Python unit tests
run: python3 -u -B -m unittest tests/tests.py
cli-mode-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Integration test of CLI use-case
id: integrationCLI
run: |
export PYTHONPATH=$PWD/src
echo $PYTHONPATH
python3 -B -m jacoco_badge_generator --jacoco-csv-file tests/jacoco.csv --badges-directory tests/cli/badges --generate-branches-badge true
python3 -B -m jacoco_badge_generator --jacoco-csv-file tests/multi1.csv tests/multi2.csv --badges-directory tests/cli/badges --generate-branches-badge true --coverage-badge-filename coverageMulti.svg --branches-badge-filename branchesMulti.svg
python3 -B -m jacoco_badge_generator --jacoco-csv-file tests/jacoco.csv --badges-directory tests/cli/badgesJSON --generate-coverage-badge false --generate-coverage-endpoint true --generate-branches-endpoint true
python3 -B -m jacoco_badge_generator --jacoco-csv-file tests/summaryReportTest.csv --badges-directory tests/cli/summary --generate-coverage-badge false --generate-summary true
python3 -B -m jacoco_badge_generator --jacoco-csv-file tests/jacoco.csv --badges-directory tests/cli/badges --generate-branches-badge true --generate-coverage-endpoint true --generate-branches-endpoint true --coverage-badge-filename customCoverage.svg --branches-badge-filename customBranches.svg --coverage-endpoint-filename customCoverage.json --branches-endpoint-filename customBranches.json --coverage-label "custom coverage label one" --branches-label "custom coverage label two"
python3 -B -m jacoco_badge_generator --jacoco-csv-file **/multi*.csv --badges-directory tests/glob/badges --generate-branches-badge true --coverage-badge-filename coverageMultiCLI.svg --branches-badge-filename branchesMultiCLI.svg
- name: Verify integration test results
run: python3 -u -B -m unittest tests/integration-cli-mode.py
actions-mode-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Verify that the Docker image for the action builds
run: docker build . --file Dockerfile
- name: Integration test with a single jacoco.csv
id: integration1
uses: ./
with:
jacoco-csv-file: tests/jacoco.csv
badges-directory: tests/badges
generate-branches-badge: true
- name: Log integration test outputs with a single jacoco.csv
run: |
echo "coverage = ${{ steps.integration1.outputs.coverage }}"
echo "branch coverage = ${{ steps.integration1.outputs.branches }}"
- name: Integration test with multiple jacoco.csv files
id: integration2
uses: ./
with:
jacoco-csv-file: >
tests/multi1.csv
tests/multi2.csv
badges-directory: tests/badges
generate-branches-badge: true
coverage-badge-filename: coverageMulti.svg
branches-badge-filename: branchesMulti.svg
workflow-summary-heading: "JaCoCo Test Coverage Summary: Multimodule Testcase"
- name: Log integration test outputs with multiple jacoco.csv files
run: |
echo "coverage = ${{ steps.integration2.outputs.coverage }}"
echo "branch coverage = ${{ steps.integration2.outputs.branches }}"
- name: Integration endpoints test
id: integration3
uses: ./
with:
jacoco-csv-file: tests/jacoco.csv
badges-directory: tests/endpoints
generate-coverage-badge: false
generate-branches-badge: false
generate-coverage-endpoint: true
generate-branches-endpoint: true
workflow-summary-heading: "JaCoCo Test Coverage Summary: Endpoints Testcase"
- name: Log integration endpoints test outputs
run: |
echo "coverage = ${{ steps.integration3.outputs.coverage }}"
echo "branch coverage = ${{ steps.integration3.outputs.branches }}"
- name: Integration test for summary report
id: integration4
uses: ./
with:
jacoco-csv-file: tests/summaryReportTest.csv
badges-directory: tests/summary
generate-coverage-badge: false
generate-branches-badge: false
generate-coverage-endpoint: false
generate-branches-endpoint: false
generate-summary: true
workflow-summary-heading: "JaCoCo Test Coverage Summary: Summary Report Testcase"
- name: Log integration summary report test outputs
run: |
echo "coverage = ${{ steps.integration4.outputs.coverage }}"
echo "branch coverage = ${{ steps.integration4.outputs.branches }}"
- name: Integration test with custom labels
id: integration5
uses: ./
with:
jacoco-csv-file: tests/jacoco.csv
badges-directory: tests/badges
generate-branches-badge: true
generate-coverage-endpoint: true
generate-branches-endpoint: true
coverage-badge-filename: customCoverage.svg
branches-badge-filename: customBranches.svg
coverage-endpoint-filename: customCoverage.json
branches-endpoint-filename: customBranches.json
coverage-label: custom coverage label one
branches-label: custom coverage label two
workflow-summary-heading: "JaCoCo Test Coverage Summary: Custom Labels Testcase"
- name: Log integration test outputs with custom labels
run: |
echo "coverage = ${{ steps.integration5.outputs.coverage }}"
echo "branch coverage = ${{ steps.integration5.outputs.branches }}"
- name: Integration test with multiple csv files with glob
id: integration6
uses: ./
with:
jacoco-csv-file: "**/multi*.csv"
badges-directory: tests/glob/badges
generate-branches-badge: true
coverage-badge-filename: coverageMulti.svg
branches-badge-filename: branchesMulti.svg
workflow-summary-heading: "JaCoCo Test Coverage Summary: Glob Testcase"
- name: Log integration test outputs with multiple csv files with glob
run: |
echo "coverage = ${{ steps.integration6.outputs.coverage }}"
echo "branch coverage = ${{ steps.integration6.outputs.branches }}"
- name: Verify integration test results
run: python3 -u -B -m unittest tests/integration-actions-mode.py
# This test can be used to test failing the workflow run on decrease.
# Uncomment to use. Success is if this fails the workflow.
# - name: Integration test for fail on decrease
# id: integrationFailures
# uses: ./
# with:
# jacoco-csv-file: tests/summaryReportTest.csv
# badges-directory: tests
# generate-coverage-badge: false
# generate-branches-badge: false
# generate-coverage-endpoint: false
# generate-branches-endpoint: false
# generate-summary: true
# summary-filename: reportTestFail.json
# fail-on-coverage-decrease: true
# fail-on-branches-decrease: true