Build and Test #167
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: Build and Test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v[0-9]+.[0-9]+.[0-9]+' | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 2 15-21 * 3" # Runs at 02:00 UTC on the 3rd Wednesday of every month | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| timeout-minutes: 10 | |
| outputs: | |
| VERSION: ${{ steps.get_version.outputs.VERSION }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Setup .NET Core SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.0.x' | |
| dotnet-quality: 'preview' | |
| - name: Set version | |
| id: get_version | |
| shell: pwsh | |
| run: | | |
| $TAG = if ($env:GITHUB_REF -like "refs/tags/v*") { | |
| $env:GITHUB_REF -replace 'refs/tags/v', '' | |
| } else { | |
| "" | |
| } | |
| if ($TAG -ne "") { | |
| $VERSION = $TAG | |
| } else { | |
| # Fallback to commit hash if no tag | |
| $COMMIT_HASH = git rev-parse --short HEAD | |
| $VERSION = "0.0.1-$COMMIT_HASH" | |
| } | |
| echo "VERSION=$VERSION" >> $env:GITHUB_OUTPUT | |
| - name: Build AggregateConfigBuildTask solution in Release mode | |
| run: dotnet build src/AggregateConfigBuildTask.sln --configuration Release -warnaserror -p:Version=${{ steps.get_version.outputs.VERSION }} | |
| - name: Run tests for AggregateConfigBuildTask solution | |
| run: dotnet test src/AggregateConfigBuildTask.sln --configuration Release -warnaserror -p:Version=${{ steps.get_version.outputs.VERSION }} -p:CollectCoverage=true | |
| - name: Upload NuGetPackage artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: NuGetPackage | |
| path: | | |
| src/Task/bin/Release/AggregateConfigBuildTask.${{ steps.get_version.outputs.VERSION }}.nupkg | |
| src/Task/bin/Release/AggregateConfigBuildTask.${{ steps.get_version.outputs.VERSION }}.snupkg | |
| integration_tests: | |
| needs: build | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Setup .NET Core SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.0.x' | |
| dotnet-quality: 'preview' | |
| - name: Download NuGetPackage artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: NuGetPackage | |
| path: ./nuget/local | |
| - name: Add local NuGet source | |
| run: dotnet nuget add source ${{ github.workspace }}/nuget/local --name AggregateConfigBuildTask | |
| - name: Build IntegrationTests in Release mode | |
| run: dotnet build test/IntegrationTests.sln --configuration Release -warnaserror -p:Version=${{ needs.build.outputs.VERSION }} | |
| - name: Run IntegrationTests | |
| run: dotnet test test/IntegrationTests.sln --configuration Release -warnaserror -p:Version=${{ needs.build.outputs.VERSION }} -p:CollectCoverage=true | |
| - name: Upload integration results artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: IntegrationTestResults-${{ matrix.os }} | |
| path: test/IntegrationTests/out/ |