diff --git a/.github/workflows/Build-Test-Coverage.yml b/.github/workflows/Build-Test-Coverage.yml index 62533e2..dc309a2 100644 --- a/.github/workflows/Build-Test-Coverage.yml +++ b/.github/workflows/Build-Test-Coverage.yml @@ -2,20 +2,10 @@ name: Build-Test-Coverage on: push: - branches: [ main ] + branches: [ main, develop, feature* ] pull_request: - branches: [ main ] - workflow_dispatch: - inputs: - input: - description: "Execute tests" - required: false - default: "Execute tests manually" - -env: - TESTS_PROJECT_PATH: ./src/Test - PROJECT_PATH: ./src/Test/Mttechne.Test.csproj - + branches: [ main, develop, feature* ] + jobs: Build-Test: runs-on: ubuntu-latest @@ -23,42 +13,20 @@ jobs: strategy: matrix: dotnet-version: ['7.0.x'] + + steps: - uses: actions/checkout@v3 - - name: Setup .NET 7 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 7.0.x - - - name: Restore Dependencies - run: dotnet restore ${{ env.PROJECT_PATH }} - - - name: Build - run: dotnet build ${{ env.PROJECT_PATH }} --no-restore - - - name: MSTest+Coverlet + + - name: echo env: - IMDB_API_KEY: ${{ secrets.IMDB_API_KEY }} - run: dotnet test ${{ env.TESTS_PROJECT_PATH }} --logger:"html;LogFileName=resultado-testes.html" --collect:"XPlat Code Coverage" - - - name: Install ReportGenerator - if: always() - run: dotnet tool install --global dotnet-reportgenerator-globaltool --version 4.8.4 + LATEST_TAG: ${{ github.ref == 'refs/heads/main' && 'latest' || format('latest-{0}', github.ref_name) }} + run: echo "today is ${{env.LATEST_TAG}}" - - name: Generate cover tests reports with ReportGenerator - if: success() - run: | - cd ${{ env.TESTS_PROJECT_PATH }}/TestResults - cd $(ls -d */|head -n 1) - reportgenerator "-reports:coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:Html - - - name: Upload UnitTest and Cover Reports as Artifacts - uses: actions/upload-artifact@v2.2.2 + - name: test env: - TESTS_PROJECT_PATH: ${{ env.TESTS_PROJECT_PATH }}/TestResults/ - if: always() - with: - name: resultado-testes - path: ${{ env.TESTS_PROJECT_PATH }} - retention-days: 30 \ No newline at end of file + LATEST_TAG: ${{ github.ref == 'refs/heads/main' && 'latest' || format('latest-{0}', github.ref_name) }} + if: ${{ success() && (github.ref == 'refs/heads/main' || github.ref_name == 'refs/heads/develop' || startsWith(github.ref_name, 'hotfix') || startsWith(github.ref_name, 'release')) }} + run: | + echo "today is ${{env.LATEST_TAG}}"