Experimental: Update to Microsoft Testing Platform v2 #547
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: Cleanup Code | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| - '[0-9]+.x' | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| env: | |
| DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
| DOTNET_NOLOGO: true | |
| SOLUTION_FILE: 'src/Steeltoe.All.sln' | |
| jobs: | |
| verify: | |
| name: Verify Code Style | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: | | |
| 8.0.* | |
| 9.0.* | |
| 10.0.* | |
| - name: Git checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| fetch-depth: 2 | |
| - name: Restore tools | |
| run: dotnet tool restore --verbosity minimal | |
| - name: Restore packages | |
| run: dotnet restore ${{ env.SOLUTION_FILE }} /p:Configuration=Release /p:NuGetAudit=false --verbosity minimal | |
| - name: Build | |
| run: dotnet build ${{ env.SOLUTION_FILE }} --no-restore --configuration Release /p:RunAnalyzers=false | |
| - name: CleanupCode (on PR diff) | |
| if: ${{ github.event_name == 'pull_request' }} | |
| shell: pwsh | |
| run: | | |
| # Not using the environment variables for SHAs, because they may be outdated. This may happen on force-push after the build is queued, but before it starts. | |
| # The below works because HEAD is detached (at the merge commit), so HEAD~1 is at the base branch. When a PR contains no commits, this job will not run. | |
| $headCommitHash = git rev-parse HEAD | |
| $baseCommitHash = git rev-parse HEAD~1 | |
| Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request." | |
| dotnet jb cleanupcode --version | |
| dotnet regitlint -s $env:SOLUTION_FILE --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="Steeltoe Full Cleanup" --jb --no-updates --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --properties:NuGetAudit=false --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff | |
| - name: CleanupCode (on branch) | |
| if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'workflow_dispatch' }} | |
| shell: pwsh | |
| run: | | |
| Write-Output 'Running code cleanup on all files.' | |
| dotnet jb cleanupcode --version | |
| dotnet regitlint -s $env:SOLUTION_FILE --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="Steeltoe Full Cleanup" --jb --no-updates --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --properties:NuGetAudit=false --jb --verbosity=WARN --fail-on-diff --print-diff |