|
| 1 | +# This workflow will build a .NET project |
| 2 | +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net |
| 3 | + |
| 4 | +name: CI - Main |
| 5 | +permissions: |
| 6 | + contents: read |
| 7 | + issues: read |
| 8 | + checks: write |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: [ "main" ] |
| 12 | + |
| 13 | +env: |
| 14 | + solutionPath: '${{ github.workspace }}/src/Dataverse.ConfigurationMigrationTool/Dataverse.ConfigurationMigrationTool.sln' |
| 15 | + solutionFolder: '${{ github.workspace }}/src/Dataverse.ConfigurationMigrationTool' |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v3 |
| 23 | + - name: Setup .NET |
| 24 | + uses: actions/setup-dotnet@v3 |
| 25 | + with: |
| 26 | + dotnet-version: 8.0.x |
| 27 | + - name: Restore dependencies |
| 28 | + run: dotnet restore ${{ env.solutionPath }} |
| 29 | + - name: Build |
| 30 | + run: dotnet build ${{ env.solutionPath }} --configuration Release --no-restore |
| 31 | + - name: Execute unit tests |
| 32 | + run: dotnet test ${{ env.solutionPath }} --configuration Release --settings ${{ env.solutionFolder }}/Console.Tests/CodeCoverage.runsettings --no-build --logger trx --no-restore --results-directory "TestResults" --collect:"XPlat code coverage" |
| 33 | + - name: Get first subfolder name |
| 34 | + id: get_subfolder |
| 35 | + shell: pwsh |
| 36 | + run: | |
| 37 | + $folderPath = 'TestResults' |
| 38 | + $firstGuidFolder = Get-ChildItem -Path $folderPath -Directory | Where-Object { |
| 39 | + [guid]::TryParse($_.Name, [ref]([guid]::Empty)) |
| 40 | + } | Select-Object -First 1 |
| 41 | + $name = if ($firstGuidFolder) { $firstGuidFolder.Name } else { "" } |
| 42 | + echo "subfolder_name=$name" >> $env:GITHUB_OUTPUT |
| 43 | + - name: Create Test Coverage Badge |
| 44 | + |
| 45 | + id: create_coverage_badge |
| 46 | + with: |
| 47 | + label: Unit Test Coverage |
| 48 | + color: brightgreen |
| 49 | + path: TestResults/${{ steps.get_subfolder.outputs.subfolder_name }}/coverage.opencover.xml |
| 50 | + gist-filename: code-coverage.json |
| 51 | + gist-id: ${{ vars.GIST_REPO_ID }} |
| 52 | + gist-auth-token: ${{ secrets.GIST_AUTH_TOKEN }} |
| 53 | + - name: Print code coverage |
| 54 | + run: echo "Code coverage percentage ${{steps.create_coverage_badge.outputs.percentage}}%" |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
0 commit comments