Skip to content

ci: publish static code analysis report to code climate #44

ci: publish static code analysis report to code climate

ci: publish static code analysis report to code climate #44

Workflow file for this run

name: .NET
# Save energy - only build main branch updates
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-and-test:
runs-on: ubuntu-latest
name: Build and test
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install dotnet global tools (coverlet, reportgenerator)
run: |
dotnet tool install --global coverlet.console
dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Debug --no-restore
- name: Run tests
run: dotnet test --configuration Debug --no-restore --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput='./TestResults/coverage.cobertura.xml'
- name: Generate coverage reports
run: reportgenerator "-reports:src/SaveEnergy.Tests/TestResults/*.xml;src/SaveEnergy.Specs/TestResults/*.xml" \
"-targetdir:report" \
"-reporttypes:Html;lcov" \
"-title:Save Energy"
- name: Attach coverage reports to build artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: report
publish-reports:
runs-on: ubuntu-latest
name: Publish coverage reports
needs: build-and-test
# Only publish coverage reports when building the main branch.
#
# This avoids exposing the secrets to attackers who debug print the
# secrets during the pull request verification build.
if: github.ref == 'refs/heads/main'
steps:
# the repository is required by codeclimate-action
- uses: actions/checkout@v4
- name: Download coverage reports
uses: actions/download-artifact@v4
with:
name: coverage-reports
path: coverage-reports
- name: Publish coverage report to CodeClimate
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: coverage-reports/lcov.info:lcov