Skip to content

code-maven-QA-mutation-[develop]=>[main] #46

code-maven-QA-mutation-[develop]=>[main]

code-maven-QA-mutation-[develop]=>[main] #46

---
# The name of the workflow
name: code-maven-QA-mutation
# The name of the workflow run
run-name: "${{ github.workflow }}-[${{ github.head_ref || github.ref_name }}]=>[${{ github.base_ref }}]"
# Concurrency configuration
concurrency:
# The concurrency group for this workflow
group: "${{ github.workflow }}-[${{ github.head_ref || github.ref_name }}]=>[${{ github.base_ref }}]"
# Cancel all previous runs in progress
cancel-in-progress: true
# Events that trigger the workflow
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
MUTATION_COVERAGE_THRESHOLD:
description: |
The minimum coverage threshold to pass the mutation tests, for example 80
'DEFAULT' uses the value set in github_config.yml "mutation.coverage.threshold".
required: false
default: DEFAULT
# Automatically run the workflow on pull_request events
pull_request:
types: [ opened, edited, labeled, synchronize, ready_for_review, reopened ]
paths:
- 'code/**'
- '.github/workflows/code*'
# Environment variables available to all jobs and steps in this workflow
env:
WORKFLOW_VERSION: 1.0.0
MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# mutation-tests
mutation-tests:
# The name of the job
name: mutation-tests
# The type of runner that the job will run on
runs-on: ubuntu-20.04
# Conditions to run the job
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.draft == false }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# checkout
- name: checkout
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# config
- name: config
id: config
uses: ./.github/actions/config-resolver
with:
create-annotations: true
files: |
github_config.yml
input-vars: "${{ toJSON(github.event.inputs) }}" # it injects all workflows inputs
# setup-maven-cache
- name: setup-maven-cache
uses: actions/cache@v4
continue-on-error: true
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# setup-asdf-cache
- name: setup-asdf-cache
uses: actions/cache@v4
continue-on-error: true
with:
path: ~/.asdf/data
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
restore-keys: |
${{ runner.os }}-asdf-
# save-tool-versions-content
- name: save-tool-versions-content
run: |
{
echo "TOOL_VERSIONS<<EOF"
cat code/.tool-versions
echo "EOF"
} >> "$GITHUB_ENV"
# asdf-install
- name: asdf-install
id: asdf-install
uses: asdf-vm/actions/install@v3
with:
tool_versions: ${{ env.TOOL_VERSIONS }}
# set-java-home
- name: set-java-home
id: set-java-home
run: |
# set-java-home
echo "::group::+++ set-java-home +++"
# Set JAVA_HOME
JAVA_HOME="$(asdf where java)"
echo "JAVA_HOME=$JAVA_HOME"
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
echo "::endgroup::"
# mvn-clean-verify
- name: mvn-clean-verify
id: mvn-clean-verify
working-directory: code
run: |
# mvn-clean-verify
echo "::group::+++ mvn-clean-verify +++"
# Maven Properties
MVN_PROPERTIES="pitest:mutationCoverage pitest:report-aggregate-module -DskipITs"
echo "MVN_PROPERTIES=${MVN_PROPERTIES}"
# mvn clean verify
mvn -B -ntp clean verify $MVN_PROPERTIES
echo "::endgroup::"
# pitest-results-verification
- name: pitest-results-verification
id: pitest-results-verification
if: ${{ always() && !cancelled() && steps.mvn-clean-verify.conclusion != 'skipped' }}
uses: ./.github/actions/test-results-verification
with:
# type: The type of results. Supported types: 'surefire', 'failsafe', 'jacoco', 'karate' and 'pitest'.
type: pitest
# results_folder: The folder of the results. For example:
# 'surefire/failsafe': code/target/reports
# 'jacoco': code/jacoco-report-aggregate/target/site/jacoco-aggregate or code/jacoco-report-aggregate/target/site/jacoco-aggregate-it
# 'pitest': code/target/pit-reports
# 'karate': e2e/karate/target/karate-reports
results_folder: ${{ fromJSON(steps.config.outputs.config).mutation.report.folder }}
# threshold: the threshold to verify, For example: 'coverage %' for 'jacoco' and 'pitest', 'success rate %' for 'surefire', 'failsafe' and 'karate'
threshold: ${{ fromJSON(steps.config.outputs.config).mutation.coverage.threshold || 80 }}
# pitest-report-upload
- name: pitest-report-upload
id: pitest-report-upload
if: ${{ always() && !cancelled() && steps.mvn-clean-verify.conclusion != 'skipped' }}
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-mutation-${{ github.run_number }}-pitest-report
path: ${{ fromJSON(steps.config.outputs.config).mutation.report.folder }}
# execution-logs-upload
- name: execution-logs-upload
id: execution-logs-upload
if: ${{ always() && !cancelled() && steps.mvn-clean-verify.conclusion != 'skipped' }}
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-karate-${{ github.run_number }}-logs
path: |
code/**/*.log