Skip to content

#126: Bring workflow actions up to date #2

#126: Bring workflow actions up to date

#126: Bring workflow actions up to date #2

Workflow file for this run

#
# Copyright 2022 ABSA Group Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: JaCoCo Report
on:
push:
branches: [master ]
pull_request:
types: [ assigned, opened, synchronize, reopened, labeled ]
jobs:
build-test-and-measure:
name: Build, Test and Measure
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: movies
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
SCALA_VERSION: "2.13.12"
SCALA_SHORT_VERSION: "2.13"
COVERAGE_OVERALL_EXPECTATION: 75.0
COVERAGE_CHANGED_EXPECTATION: 80.0
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Scala
uses: olafurpg/setup-scala@v14
with:
java-version: "[email protected]"
- name: Prepare testing database
run: sbt flywayMigrate
- name: Build and run all tests for code coverage
run: sbt ++${{env.SCALA_VERSION}} jacoco # We will need JaCoCo report in second job
- name: Add coverage to PR
id: jacoco-core
uses: madrapps/[email protected]
with:
paths: >
${{ github.workspace }}/core/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: ${{ env.COVERAGE_OVERALL_EXPECTATION }}
min-coverage-changed-files: ${{ env.COVERAGE_CHANGED_EXPECTATION }}
title: JaCoCo core code coverage report - scala ${{ env.SCALA_VERSION }}
update-comment: true
- name: Get the Coverage info
run: |
echo "Total core core coverage ${{ steps.jacoco-core.outputs.coverage-overall }}"
echo "Changed core Files coverage ${{ steps.jacoco-core.outputs.coverage-changed-files }}"
- name: Add coverage to PR
id: jacoco-slick
uses: madrapps/[email protected]
with:
paths: >
${{ github.workspace }}/slick/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: ${{ env.COVERAGE_OVERALL_EXPECTATION }}
min-coverage-changed-files: ${{ env.COVERAGE_CHANGED_EXPECTATION }}
title: JaCoCo slick code coverage report - scala ${{ env.SCALA_VERSION }}
update-comment: true
- name: Get the Coverage info
run: |
echo "Total slick coverage ${{ steps.jacoco-slick.outputs.coverage-overall }}"
echo "Changed slick Files coverage ${{ steps.jacoco-slick.outputs.coverage-changed-files }}"
- name: Add coverage to PR
id: jacoco-doobie
uses: madrapps/[email protected]
with:
paths: >
${{ github.workspace }}/doobie/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: ${{ env.COVERAGE_OVERALL_EXPECTATION }}
min-coverage-changed-files: ${{ env.COVERAGE_CHANGED_EXPECTATION }}
title: JaCoCo doobie code coverage report - scala ${{ env.SCALA_VERSION }}
update-comment: true
- name: Get the Coverage info
run: |
echo "Total doobie coverage ${{ steps.jacoco-doobie.outputs.coverage-overall }}"
echo "Changed doobie Files coverage ${{ steps.jacoco-doobie.outputs.coverage-changed-files }}"
- name: Fail PR if changed files coverage is less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}%
if: ${{ steps.jacoco-core.outputs.coverage-changed-files < 80.0 || steps.jacoco-slick.outputs.coverage-changed-files < 80.0 || steps.jacoco-doobie.outputs.coverage-changed-files < 80.0 }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('Changed files coverage is less than ${{ env.COVERAGE_CHANGED_EXPECTATION }}%!')
- name: Fail PR if total files coverage is less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}%
if: ${{ steps.jacoco-core.outputs.coverage-overall < 75.0 || steps.jacoco-slick.outputs.coverage-overall < 75.0 || steps.jacoco-doobie.outputs.coverage-overall < 75.0 }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('Total files coverage is less than ${{ env.COVERAGE_OVERALL_EXPECTATION }}%!')