Skip to content

Coverage

Coverage #35

Workflow file for this run

name: Coverage
on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches: [main]
workflow_dispatch:
schedule:
- cron: '45 2 * * 1' # Mondays 02:45 UTC
jobs:
coverage:
name: Scoverage + Codecov (unit modules)
runs-on: ubuntu-22.04
# Only run on successful CI completion or manual/scheduled runs
if: |
github.event_name == 'workflow_dispatch' ||
github.event_name == 'schedule' ||
github.event.workflow_run.conclusion == 'success'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Java 17
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
- name: Coursier cache
uses: coursier/cache-action@v7
- name: Download coverage artifacts from CI
if: github.event_name == 'workflow_run'
uses: actions/download-artifact@v6
with:
pattern: coverage-*
path: coverage-downloads
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Restore coverage data from CI
if: github.event_name == 'workflow_run'
id: restore-coverage
continue-on-error: true
run: |
echo "Restoring coverage data from CI artifacts..."
if [ -d "coverage-downloads" ]; then
# Merge all coverage artifacts into workspace
find coverage-downloads -type d -name "coverage-*" | while IFS= read -r dir; do
if [ -d "$dir/target" ]; then
cp -rv "$dir/target" . 2>/dev/null || true
fi
if [ -d "$dir/modules" ]; then
cp -rv "$dir/modules" . 2>/dev/null || true
fi
done
# Verify coverage data exists
if find . -path "*/target/scala-*/scoverage-data/*" -o -path "*/target/scala-*/scoverage-report/*" | grep -q .; then
echo "✅ Coverage data restored successfully"
echo "success=true" >> "$GITHUB_OUTPUT"
else
echo "⚠️ No coverage data found in artifacts"
echo "success=false" >> "$GITHUB_OUTPUT"
fi
else
echo "⚠️ No coverage artifacts downloaded"
echo "success=false" >> "$GITHUB_OUTPUT"
fi
- name: Aggregate coverage from CI
if: |
github.event_name == 'workflow_run' &&
steps.restore-coverage.outputs.success == 'true'
continue-on-error: true
id: aggregate-coverage
run: |
echo "Aggregating coverage from CI test runs..."
sbt -batch coverageAggregate
- name: Run tests with coverage (fallback)
if: |
github.event_name != 'workflow_run' ||
steps.restore-coverage.outputs.success != 'true' ||
steps.aggregate-coverage.outcome == 'failure'
run: |
echo "Running fresh tests with coverage..."
sbt -batch clean coverage \
"core/test" "infrastructure/test" "connectors/test" "contracts/test" \
coverageReport coverageAggregate
- name: Upload coverage (umbrella)
if: ${{ !env.ACT && env.CODECOV_TOKEN != '' }}
uses: codecov/codecov-action@v5
with:
files: |
./target/scala-2.13/scoverage-report/scoverage.xml
./modules/*/target/scala-2.13/scoverage-report/scoverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
name: umbrella
fail_ci_if_error: false
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# Per-module uploads with flags for README badges
- name: Upload coverage (core flag)
if: ${{ !env.ACT && env.CODECOV_TOKEN != '' }}
uses: codecov/codecov-action@v5
with:
files: ./modules/core/target/scala-2.13/scoverage-report/scoverage.xml
flags: core
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
handle_no_reports_found: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage (contracts flag)
if: ${{ !env.ACT && env.CODECOV_TOKEN != '' }}
uses: codecov/codecov-action@v5
with:
files: ./modules/contracts/target/scala-2.13/scoverage-report/scoverage.xml
flags: contracts
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
handle_no_reports_found: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage (connectors flag)
if: ${{ !env.ACT && env.CODECOV_TOKEN != '' }}
uses: codecov/codecov-action@v5
with:
files: ./modules/connectors/target/scala-2.13/scoverage-report/scoverage.xml
flags: connectors
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
handle_no_reports_found: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage (infrastructure flag)
if: ${{ !env.ACT && env.CODECOV_TOKEN != '' }}
uses: codecov/codecov-action@v5
with:
files: ./modules/infrastructure/target/scala-2.13/scoverage-report/scoverage.xml
flags: infrastructure
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
handle_no_reports_found: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}