Skip to content

Tests and Quality Analysis triggered by stonedu1011 #264

Tests and Quality Analysis triggered by stonedu1011

Tests and Quality Analysis triggered by stonedu1011 #264

Workflow file for this run

# This is a basic workflow that is manually triggered
name: CI
run-name: Tests and Quality Analysis triggered by ${{ github.actor }}
# Controls when the action will run.
on:
# Workflow runs when manually triggered using the UI or API.
workflow_dispatch:
inputs:
reason:
description: 'Reason of manually triggering this workflow'
default: 'Unspecified'
required: false
type: string
branch:
description: 'Target Branch'
default: 'main'
required: true
type: string
low_cov:
description: 'Coverage percentage to pass'
default: 50
required: false
type: number
high_cov:
description: 'Coverage percentage to warn'
default: 70
required: false
type: number
# Workflow runs on scheduled time
schedule:
- cron: '0 6 * * 1,3,5'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
main:
name: "Test, Analyze Code & Report"
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: "Context"
shell: bash
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: "Checkout Actions"
uses: actions/checkout@v4
with:
# For security reasons, we only uses actions in "main" branch
ref: ${{ github.event.repository.default_branch }}
sparse-checkout: .github/actions
path: .tmp
- name: "Prepare"
uses: ./.tmp/.github/actions/prepare
with:
branch: ${{ github.head_ref || inputs.branch || 'main' }}
- name: "Test & Code Quality"
uses: ./.tmp/.github/actions/verify
- name: "Generate Code Coverage Badge"
if: ${{ !cancelled() && github.event_name != 'pull_request' }}
run: |
export COVERAGE=$(grep -E '([0-9]+[0-9.]+)' -o dist/coverage-func.out | tail -1)
export COVERAGE_COLOR=$( \
( (( $(echo "${COVERAGE} >= ${{ inputs.high_cov }}" | bc) )) && echo "green" ) || \
( (( $(echo "${COVERAGE} < ${{ inputs.low_cov }}" | bc) )) && echo "red" ) || \
echo "yellow" \
)
curl https://img.shields.io/badge/Coverage-${COVERAGE}%25-${COVERAGE_COLOR} > dist/coverage-badge.svg
- name: "Generate Code Coverage Report"
if: ${{ !cancelled() && github.event_name != 'pull_request' }}
uses: irongut/[email protected]
with:
filename: dist/cobertura-coverage.xml
badge: true
fail_below_min: true
indicators: false
hide_complexity: true
format: markdown
output: both
thresholds: "${{ inputs.low_cov }} ${{ inputs.high_cov }}"
- name: "Collect Reports"
if: ${{ !cancelled() && github.event_name != 'pull_request' }}
run: |
cat > dist/code-coverage-results.md <<EOF
---
layout: report
title: "Test Coverage Summary"
report:
source: "irongut/[email protected]"
---
[![Coverage Details](https://img.shields.io/badge/Coverage%20Details-grey?style=flat)](coverage.html)
EOF
cat code-coverage-results.md >> dist/code-coverage-results.md
- name: "Upload Badges and Reports"
if: ${{ !cancelled() && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: dist
destination_dir: reports/${{ github.ref_name }}
exclude_assets: '.github,coverage.out,tests.json'
enable_jekyll: true
keep_files: true
commit_message: "Upload badges & reports from CI - ${{ github.job }}"