PHP Classes

File: .github/workflows/coverage.yml

Recommend this page to a friend!
  Classes of Carlos Artur Curvelo da Matos   Desired Patterns   .github/workflows/coverage.yml   Download  
File: .github/workflows/coverage.yml
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Desired Patterns
Implements of several modern design patterns
Author: By
Last change:
Date: 10 days ago
Size: 2,293 bytes
 

Contents

Class file image Download
name: Code Coverage on: push: branches: [ main ] pull_request: branches: [ main ] jobs: coverage: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: '8.2' coverage: pcov - name: Install dependencies run: composer install --prefer-dist --no-progress - name: Generate coverage report run: | vendor/bin/phpunit --coverage-clover clover.xml COVERAGE=$(php -r ' $xml = new SimpleXMLElement(file_get_contents("clover.xml")); $metrics = $xml->xpath("//metrics"); $totalElements = 0; $checkedElements = 0; foreach ($metrics as $metric) { $totalElements += (int)$metric["elements"]; $checkedElements += (int)$metric["coveredelements"]; } echo round(($checkedElements / $totalElements) * 100); ') echo "coverage=$COVERAGE" >> $GITHUB_ENV - name: Create initial Gist content if: success() uses: actions/github-script@v6 with: github-token: ${{ secrets.GIST_SECRET }} script: | try { await github.rest.gists.update({ gist_id: '664fd72a90f996481f161d1d3a2f7285', files: { 'coverage.json': { content: JSON.stringify({ schemaVersion: 1, label: 'coverage', message: process.env.coverage + '%', color: process.env.coverage >= 80 ? 'success' : process.env.coverage >= 60 ? 'yellow' : 'critical' }) } } }); } catch (error) { console.log('Error updating gist:', error); throw error; } - name: Create Coverage Badge if: success() uses: schneegans/dynamic-badges-action@v1.6.0 with: auth: ${{ secrets.GIST_SECRET }} gistID: 664fd72a90f996481f161d1d3a2f7285 filename: coverage.json label: coverage message: ${{ env.coverage }}% color: ${{ env.coverage >= 80 && 'success' || env.coverage >= 60 && 'yellow' || 'critical' }}