|
| 1 | +name: Steeltoe.All |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + - '[0-9]+.x' |
| 9 | + - 'release/*' |
| 10 | + pull_request: |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + pull-requests: write |
| 19 | + |
| 20 | +env: |
| 21 | + DOTNET_CLI_TELEMETRY_OPTOUT: 1 |
| 22 | + DOTNET_NOLOGO: true |
| 23 | + SOLUTION_FILE: 'src/Steeltoe.All.sln' |
| 24 | + COMMON_TEST_ARGS: >- |
| 25 | + --no-build --configuration Release --collect "XPlat Code Coverage" --logger trx --results-directory ${{ github.workspace }}/dumps |
| 26 | + --settings coverlet.runsettings --blame-crash --blame-hang-timeout 3m |
| 27 | +
|
| 28 | +jobs: |
| 29 | + analyze: |
| 30 | + name: Build and Test |
| 31 | + timeout-minutes: 30 |
| 32 | + strategy: |
| 33 | + matrix: |
| 34 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 35 | + include: |
| 36 | + - os: ubuntu-latest |
| 37 | + runDockerContainers: true |
| 38 | + - os: windows-latest |
| 39 | + skipFilter: Category!=Integration |
| 40 | + - os: macos-latest |
| 41 | + skipFilter: Category!=Integration&Category!=SkipOnMacOS |
| 42 | + runs-on: ${{ matrix.os }} |
| 43 | + continue-on-error: true |
| 44 | + |
| 45 | + services: |
| 46 | + eurekaServer: |
| 47 | + image: ${{ matrix.runDockerContainers && 'steeltoe.azurecr.io/eureka-server' || null }} |
| 48 | + ports: |
| 49 | + - 8761:8761 |
| 50 | + configServer: |
| 51 | + image: ${{ matrix.runDockerContainers && 'steeltoe.azurecr.io/config-server' || null }} |
| 52 | + env: |
| 53 | + eureka.client.enabled: true |
| 54 | + eureka.client.serviceUrl.defaultZone: http://eurekaServer:8761/eureka |
| 55 | + eureka.instance.hostname: localhost |
| 56 | + eureka.instance.instanceId: localhost:configServer:8888 |
| 57 | + ports: |
| 58 | + - 8888:8888 |
| 59 | + |
| 60 | + steps: |
| 61 | + - name: Setup .NET |
| 62 | + uses: actions/setup-dotnet@v4 |
| 63 | + with: |
| 64 | + dotnet-version: | |
| 65 | + 8.0.* |
| 66 | + 9.0.* |
| 67 | +
|
| 68 | + - name: Turn off dev certificate (macOS only) |
| 69 | + if: ${{ matrix.os == 'macos-latest' }} |
| 70 | + # Setting DOTNET_GENERATE_ASPNET_CERTIFICATE to "false" makes it easier to determine which test failed on macOS when it tried to start a web server with https enabled. |
| 71 | + # Without setting this, the following message appears in the logs: |
| 72 | + # The application is trying to access the ASP.NET Core developer certificate key. A prompt might appear to ask for permission to access the key. |
| 73 | + # When that happens, select 'Always Allow' to grant 'dotnet' access to the certificate key in the future. |
| 74 | + # and the test run fails, but without indicating which test caused it. By setting this, the causing test fails with the next message: |
| 75 | + # Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date. |
| 76 | + # To prevent the causing test from failing the test run, disable it on macOS by adding [Trait("Category", "SkipOnMacOS")]. |
| 77 | + shell: bash |
| 78 | + run: echo "DOTNET_GENERATE_ASPNET_CERTIFICATE=false" >> $GITHUB_ENV |
| 79 | + |
| 80 | + - name: Install Nerdbank.GitVersioning (macOS only) |
| 81 | + if: ${{ matrix.os == 'macos-latest' }} |
| 82 | + run: dotnet tool install --global nbgv |
| 83 | + |
| 84 | + - name: Git checkout |
| 85 | + uses: actions/checkout@v4 |
| 86 | + with: |
| 87 | + fetch-depth: 0 |
| 88 | + |
| 89 | + - name: Restore packages |
| 90 | + run: dotnet restore ${{ env.SOLUTION_FILE }} --verbosity minimal |
| 91 | + |
| 92 | + - name: Set package version |
| 93 | + run: nbgv cloud |
| 94 | + |
| 95 | + - name: Build solution |
| 96 | + run: dotnet build ${{ env.SOLUTION_FILE }} --no-restore --configuration Release --verbosity minimal |
| 97 | + |
| 98 | + - name: Set skip filters for tests |
| 99 | + shell: bash |
| 100 | + run: | |
| 101 | + echo SKIP_FILTER_NO_MEMORY_DUMPS="${{ matrix.skipFilter && format('{0}&Category!=MemoryDumps', matrix.skipFilter) || 'Category!=MemoryDumps' }}" >> $GITHUB_ENV |
| 102 | + echo SKIP_FILTER_WITH_MEMORY_DUMPS="${{ matrix.skipFilter && format('{0}&Category=MemoryDumps', matrix.skipFilter) || 'Category=MemoryDumps' }}" >> $GITHUB_ENV |
| 103 | +
|
| 104 | + - name: Test (net8.0) |
| 105 | + run: dotnet test ${{ env.SOLUTION_FILE }} --framework net8.0 --filter "${{ env.SKIP_FILTER_NO_MEMORY_DUMPS }}" ${{ env.COMMON_TEST_ARGS }} |
| 106 | + |
| 107 | + - name: Test (net8.0) (memory dumps) |
| 108 | + run: dotnet test ${{ env.SOLUTION_FILE }} --framework net8.0 --filter "${{ env.SKIP_FILTER_WITH_MEMORY_DUMPS }}" ${{ env.COMMON_TEST_ARGS }} |
| 109 | + |
| 110 | + - name: Test (net9.0) |
| 111 | + run: dotnet test ${{ env.SOLUTION_FILE }} --framework net9.0 --filter "${{ env.SKIP_FILTER_NO_MEMORY_DUMPS }}" ${{ env.COMMON_TEST_ARGS }} |
| 112 | + |
| 113 | + - name: Test (net9.0) (memory dumps) |
| 114 | + run: dotnet test ${{ env.SOLUTION_FILE }} --framework net9.0 --filter "${{ env.SKIP_FILTER_WITH_MEMORY_DUMPS }}" ${{ env.COMMON_TEST_ARGS }} |
| 115 | + |
| 116 | + - name: Upload crash/hang dumps (on failure) |
| 117 | + if: ${{ failure() }} |
| 118 | + uses: actions/upload-artifact@v4 |
| 119 | + with: |
| 120 | + name: FailedTestOutput-${{ matrix.os }} |
| 121 | + path: | |
| 122 | + ${{ github.workspace }}/dumps/**/*.dmp |
| 123 | + ${{ github.workspace }}/dumps/**/Sequence_*.xml |
| 124 | + if-no-files-found: ignore |
| 125 | + |
| 126 | + - name: Report test results |
| 127 | + if: ${{ !cancelled() }} |
| 128 | + uses: dorny/test-reporter@v2 |
| 129 | + with: |
| 130 | + name: ${{ matrix.os }} test results |
| 131 | + reporter: dotnet-trx |
| 132 | + path: '**/*.trx' |
| 133 | + fail-on-empty: 'true' |
| 134 | + fail-on-error: 'false' |
| 135 | + |
| 136 | + - name: Generate code coverage report |
| 137 | + uses: danielpalme/ReportGenerator-GitHub-Action@v5 |
| 138 | + with: |
| 139 | + reports: '**/coverage.opencover.xml' |
| 140 | + targetdir: 'coveragereport' |
| 141 | + reporttypes: 'MarkdownAssembliesSummary;MarkdownSummaryGithub' |
| 142 | + filefilters: '-*.g.cs' |
| 143 | + title: 'All Code Coverage (${{ matrix.os }})' |
| 144 | + tag: '${{ github.run_number }}_${{ github.run_id }}' |
| 145 | + |
| 146 | + - name: Add coverage to build summary |
| 147 | + shell: bash |
| 148 | + run: cat coveragereport/SummaryGithub.md >> $GITHUB_STEP_SUMMARY |
| 149 | + |
| 150 | + - name: Add coverage comment to PR (linux only) |
| 151 | + if: ${{ github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' }} |
| 152 | + run: gh pr comment $PR_NUMBER --edit-last --create-if-none --body-file coveragereport/Summary.md |
| 153 | + env: |
| 154 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 155 | + PR_NUMBER: ${{ github.event.number }} |
0 commit comments