mirror of
https://github.com/ditkrg/DIT.Workflower.git
synced 2026-01-22 22:06:42 +00:00
85 lines
2.0 KiB
YAML
85 lines
2.0 KiB
YAML
name: Run Tests
|
|
|
|
on:
|
|
push:
|
|
branches-ignore:
|
|
- main
|
|
|
|
paths-ignore:
|
|
- "**.md"
|
|
|
|
- ".github/**"
|
|
- "!.github/workflows/tests-base.yaml"
|
|
|
|
workflow_call:
|
|
inputs:
|
|
sonarqube:
|
|
type: boolean
|
|
required: false
|
|
default: false
|
|
|
|
sonarqube_host:
|
|
type: string
|
|
required: false
|
|
|
|
secrets:
|
|
SONARQUBE_TOKEN:
|
|
required: false
|
|
|
|
jobs:
|
|
run-tests:
|
|
name: Run Tests
|
|
timeout-minutes: 10
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
ASPNETCORE_ENVIRONMENT: Testing
|
|
|
|
steps:
|
|
- uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: "8.0.x"
|
|
|
|
- uses: actions/checkout@v4
|
|
if: ${{ !inputs.sonarqube }}
|
|
|
|
- name: Run tests
|
|
if: ${{ !inputs.sonarqube }}
|
|
run: dotnet test
|
|
|
|
###############################
|
|
########## SONARQUBE ##########
|
|
###############################
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@v4
|
|
if: ${{ inputs.sonarqube }}
|
|
with:
|
|
distribution: "zulu"
|
|
java-version: "17"
|
|
|
|
- uses: actions/checkout@v4
|
|
if: ${{ inputs.sonarqube }}
|
|
with:
|
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
|
|
|
- name: Restore tools
|
|
if: ${{ inputs.sonarqube }}
|
|
run: dotnet tool restore
|
|
|
|
- name: Run tests (SonarQube)
|
|
if: ${{ inputs.sonarqube }}
|
|
env:
|
|
PROJECT_KEY: ditkrg_DIT.Workflower_AYF14rjSb80e2b0bns3t
|
|
SONARQUBE_HOST: ${{ inputs.sonarqube_host }}
|
|
SONARQUBE_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
|
|
run: |
|
|
dotnet tool run dotnet-sonarscanner begin -k:"$PROJECT_KEY" \
|
|
-d:sonar.login="$SONARQUBE_TOKEN" \
|
|
-d:sonar.host.url="$SONARQUBE_HOST" \
|
|
-d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
|
|
|
|
dotnet build --no-incremental
|
|
dotnet dotnet-coverage collect "dotnet test" -f xml -o "coverage.xml"
|
|
|
|
dotnet tool run dotnet-sonarscanner end -d:sonar.login="$SONARQUBE_TOKEN"
|