General Update: #4
This file contains hidden or 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: default | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| - main | |
| pull_request: | |
| branches: | |
| - develop | |
| - main | |
| workflow_dispatch: | |
| env: | |
| DOTNET_NOLOGO: true | |
| NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v5 | |
| - name: setup dotnet | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| cache: true | |
| cache-dependency-path: ./**/packages.lock.json | |
| global-json-file: global.json | |
| - name: restore | |
| run: dotnet restore --locked-mode | |
| - name: build | |
| run: dotnet build -c Release --no-restore | |
| test: | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v4 | |
| - name: setup dotnet | |
| uses: actions/setup-dotnet@v3 | |
| with: | |
| cache: true | |
| cache-dependency-path: ./**/packages.lock.json | |
| global-json-file: global.json | |
| - name: restore | |
| run: dotnet restore --locked-mode | |
| - name: test | |
| run: foreach( $project in Get-ChildItem "Racoon.*Tests.csproj" -Recurse ) { dotnet test "$($project.FullName)" --results-directory TestResults --logger "trx;logFileName=$($project.BaseName).trx" --collect:"XPlat Code Coverage" /p:WarningLevel=0 -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.DeterministicReport=true } | |
| shell: pwsh | |
| - name: upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: success() || failure() | |
| with: | |
| name: racoon-test-results | |
| path: TestResults | |
| - name: report test results | |
| uses: dorny/test-reporter@v2 | |
| if: success() || failure() | |
| with: | |
| name: test results | |
| path: TestResults/**/*.trx | |
| reporter: dotnet-trx | |
| - name: generate coverage report | |
| uses: danielpalme/ReportGenerator-GitHub-Action@v5 | |
| with: | |
| reports: TestResults/**/coverage.cobertura.xml | |
| reporttypes: "Cobertura;MarkdownSummary" | |
| targetdir: CoverageResults | |
| title: coverage results | |
| - name: upload coverage results | |
| uses: actions/upload-artifact@v4 | |
| if: success() || failure() | |
| with: | |
| name: racoon-coverage-results | |
| path: CoverageResults | |
| - name: report coverage results | |
| uses: cryptoc1/cobertura-action@master | |
| if: success() || failure() | |
| with: | |
| fail_below_threshold: false | |
| link_missing_lines: true | |
| minimum_coverage: 80 | |
| path: CoverageResults/Cobertura.xml | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| report_name: coverage results | |
| show_branch: false | |
| show_class_names: true | |
| show_missing: true | |
| skip_covered: false | |
| pack: | |
| needs: [test] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: setup dotnet | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| cache: true | |
| cache-dependency-path: ./**/packages.lock.json | |
| global-json-file: global.json | |
| - name: restore | |
| run: dotnet restore --locked-mode | |
| - name: pack | |
| run: dotnet pack -c Release -o dist --no-restore /p:WarningLevel=0 | |
| - name: upload packages | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: racoon-packages | |
| path: dist | |
| publish: | |
| if: startsWith(github.ref, 'refs/heads/main') | |
| needs: [pack] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: global.json | |
| - name: setup dotnet | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| cache: false | |
| global-json-file: global.json | |
| - name: download artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: racoon-packages | |
| - name: push packages | |
| run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate |