Forked from renatogroffe/dotnet5-tests-coverlet-nuget.yml
Created
June 25, 2021 01:48
-
-
Save lucasapoena/bc18b099e6fc0ee7b11d7b304a29bcf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: dotnet5_tests_coverlet_nuget | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
CAMINHO_PROJETO_TESTES: ./Groffe.Distancias.Testes | |
CAMINHO_PROJETO: ./Groffe.Distancias/Groffe.Distancias.csproj | |
NUGET_SERVER: https://api.nuget.org/v3/index.json | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup .NET 5 | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 5.0.102 | |
- name: Testes com .NET 5 + xUnit + Fluent Assertions + Coverlet | |
run: dotnet test ${{ env.CAMINHO_PROJETO_TESTES }} --verbosity minimal --logger:"html;LogFileName=resultado-testes.html" --collect:"XPlat Code Coverage" | |
- name: Instalar ReportGenerator | |
if: success() | |
run: dotnet tool install --global dotnet-reportgenerator-globaltool --version 4.8.4 | |
- name: Gerar relatório de cobertura de testes com ReportGenerator | |
if: success() | |
run: | | |
cd ${{ env.CAMINHO_PROJETO_TESTES }}/TestResults | |
# Acessar diretório gerado com o XML de Cobertura de código | |
cd $(ls -d */|head -n 1) | |
reportgenerator "-reports:coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:Html | |
- name: Upload como Artifact dos Reports de Resultado de Testes Executados com Sucesso + Cobertura de Código | |
uses: actions/[email protected] | |
env: | |
CAMINHO_RESULTADO_TESTES: ${{ env.CAMINHO_PROJETO_TESTES }}/TestResults/ | |
if: success() | |
with: | |
name: resultado-testes | |
path: ${{ env.CAMINHO_RESULTADO_TESTES }} | |
retention-days: 30 | |
- name: Upload como Artifact do Report de Testes com Falhas | |
uses: actions/[email protected] | |
if: failure() | |
env: | |
CAMINHO_RELATORIO_ERROS: ${{ env.CAMINHO_PROJETO_TESTES }}/TestResults/resultado-testes.html | |
with: | |
name: resultado-erros-testes | |
path: ${{ env.CAMINHO_RELATORIO_ERROS }} | |
retention-days: 30 | |
pack-push: | |
needs: [tests] | |
env: | |
CAMINHO_PROJETO: ./Groffe.Distancias/Groffe.Distancias.csproj | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup .NET 5 | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 5.0.101 | |
- name: Geração do package | |
run: dotnet pack ${{ env.CAMINHO_PROJETO }} -c Release -o out | |
- name: Push no NuGet | |
run: | | |
cd out | |
dotnet nuget push *.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source ${{ env.NUGET_SERVER }} --skip-duplicate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment