Refactor resource fixtures to enforce initialization checks #167
Workflow file for this run
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: CI | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - main | |
| - fdv3 | |
| pull_request: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| env: | |
| DOTNET_NOLOGO: 'true' | |
| DOTNET_CLI_TELEMETRY_OPTOUT: 'true' | |
| steps: | |
| - name: Detect environment | |
| id: detect-env | |
| run: | | |
| if [ "$GITHUB_ACTOR" == "nektos/act" ]; then | |
| echo "running_in_act=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "running_in_act=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Echo environment | |
| run: | | |
| echo "Running in act environment: ${{ steps.detect-env.outputs.running_in_act }}" | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Required for GitVersion to work properly | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 10.0.x | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/setup@v1 | |
| with: | |
| versionSpec: '5.x' | |
| - name: Determine version | |
| id: gitversion | |
| uses: gittools/actions/gitversion/execute@v1 | |
| with: | |
| useConfigFile: true | |
| configFilePath: GitVersion.yml | |
| - name: Display GitVersion outputs | |
| run: | | |
| echo "Major: ${{ steps.gitversion.outputs.Major }}" | |
| echo "Minor: ${{ steps.gitversion.outputs.Minor }}" | |
| echo "Patch: ${{ steps.gitversion.outputs.Patch }}" | |
| echo "NuGetVersion: ${{ steps.gitversion.outputs.NuGetVersion }}" | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build solution | |
| run: dotnet build --configuration Release --no-restore /p:Version=${{ steps.gitversion.outputs.NuGetVersion }} /p:AssemblyVersion=${{ steps.gitversion.outputs.AssemblySemVer }} /p:FileVersion=${{ steps.gitversion.outputs.AssemblySemFileVer }} | |
| - name: Run tests (in act) | |
| if: steps.detect-env.outputs.running_in_act == 'true' | |
| env: | |
| TERM: dumb | |
| DOTNET_CLI_UI_LANGUAGE: en-US | |
| run: | | |
| echo "Running in act environment" | |
| dotnet test \ | |
| --no-build \ | |
| --configuration Release \ | |
| --framework net10.0 \ | |
| --filter "Category=Unit" \ | |
| --logger "console;verbosity=detailed" | |
| - name: Run tests with coverage (in GitHub) | |
| if: steps.detect-env.outputs.running_in_act != 'true' | |
| run: > | |
| dotnet test | |
| --no-build | |
| --configuration Release | |
| --framework net10.0 | |
| --filter "Category=Unit" | |
| --collect:"XPlat Code Coverage" | |
| --results-directory ./coverage | |
| --settings coverletArgs.runsettings | |
| - name: Upload coverage reports to Codecov | |
| if: steps.detect-env.outputs.running_in_act != 'true' | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Create NuGet packages | |
| run: | | |
| echo "Creating NuGet packages with version: ${{ steps.gitversion.outputs.NuGetVersion }}" | |
| dotnet pack --configuration Release --no-build --output packages /p:Version=${{ steps.gitversion.outputs.NuGetVersion }} /p:AssemblyVersion=${{ steps.gitversion.outputs.AssemblySemVer }} /p:FileVersion=${{ steps.gitversion.outputs.AssemblySemFileVer }} | |
| - name: List NuGet packages | |
| run: | | |
| echo "Created NuGet packages:" | |
| ls -la packages/*.nupkg | |
| - name: Upload NuGet packages as artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: packages/*.nupkg | |
| retention-days: 7 | |
| continue-on-error: ${{ steps.detect-env.outputs.running_in_act == 'true' }} | |
| - name: Publish NuGet packages | |
| if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' | |
| run: | | |
| echo "Publishing NuGet packages with version: ${{ steps.gitversion.outputs.NuGetVersion }}" | |
| dotnet nuget push "packages/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| continue-on-error: ${{ steps.detect-env.outputs.running_in_act == 'true' }} | |
| - name: Create and push Git tag for release | |
| if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && steps.detect-env.outputs.running_in_act != 'true' | |
| run: | | |
| echo "Creating Git tag for version: ${{ steps.gitversion.outputs.NuGetVersion }}" | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "actions@github.com" | |
| git tag ${{ steps.gitversion.outputs.NuGetVersion }} | |
| git push origin ${{ steps.gitversion.outputs.NuGetVersion }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # CodeQL Security Analysis | |
| codeql: | |
| name: CodeQL Security Analysis | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' | |
| permissions: | |
| security-events: write | |
| actions: read | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Initialize CodeQL | |
| uses: github/codeql-action/init@v3 | |
| with: | |
| languages: csharp | |
| queries: +security-and-quality | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 10.0.x | |
| - name: Build for CodeQL | |
| run: | | |
| dotnet restore | |
| dotnet build --configuration Release | |
| - name: Perform CodeQL Analysis | |
| uses: github/codeql-action/analyze@v3 | |
| with: | |
| category: "/language:csharp" |