Update mstest monorepo to v4 (major) #1478
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 | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize] | |
| merge_group: | |
| types: [checks_requested] | |
| push: | |
| branches: | |
| - main | |
| release: | |
| types: [published] | |
| jobs: | |
| formatting: | |
| name: Check formatting | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 | |
| with: | |
| dotnet-version: 10.0.100 | |
| - name: Install tools | |
| run: dotnet tool restore | |
| - name: Check formatting | |
| run: dotnet csharpier check . | |
| coverage: | |
| name: Check code coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 | |
| with: | |
| dotnet-version: 10.0.100 | |
| - name: Run tests | |
| run: dotnet test -c Debug --collect:"XPlat Code Coverage" --settings coverlet.runsettings ArchUnitNETTests/ | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/[email protected] | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| run-tests: | |
| name: Run tests | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 | |
| with: | |
| dotnet-version: 10.0.100 | |
| - name: Run tests | |
| run: dotnet test -c Debug | |
| publish-docs: | |
| name: Publish documentation | |
| runs-on: ubuntu-latest | |
| needs: | |
| - formatting | |
| - coverage | |
| - run-tests | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | |
| with: | |
| path: ./current | |
| - name: Checkout gh-pages branch | |
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | |
| with: | |
| ref: gh-pages | |
| path: ./docs | |
| - name: Setup doxygen | |
| run: sudo apt-get install doxygen graphviz | |
| - name: Setup environment | |
| run: | | |
| if [[ "$GITHUB_REF" =~ ^"refs/tags/"[0-9]+.[0-9]+.[0-9]+$ ]]; then | |
| docs_subpath="stable" | |
| else | |
| if [[ "$GITHUB_REF" =~ ^"refs/tags/"[0-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+$ ]]; then | |
| docs_subpath="preview" | |
| else | |
| docs_subpath="latest" | |
| fi | |
| fi | |
| echo "DOCS_TEMP_DIR_SUBPATH=$docs_subpath" >> "$GITHUB_ENV" | |
| echo "DOCS_OUTPUT_DIR=$GITHUB_WORKSPACE/docs/$docs_subpath" >> "$GITHUB_ENV" | |
| - name: Generate documentation | |
| working-directory: ./current/documentation | |
| run: | | |
| set -eo pipefail | |
| rm -rf "${{ env.DOCS_OUTPUT_DIR }}" | |
| doxygen | |
| touch .nojekyll | |
| - name: Check release conditions | |
| run: | | |
| if [[ "$GITHUB_REF" =~ ^"refs/tags/"[0-9]+.[0-9]+.[0-9]+(-[a-z]+.[0-9]+)?|"refs/heads/main"$ ]]; then | |
| echo "CREATE_RELEASE=true" >> "$GITHUB_ENV" | |
| else | |
| echo "CREATE_RELEASE=false" >> "$GITHUB_ENV" | |
| fi | |
| - name: Commit and push changes | |
| if: env.CREATE_RELEASE == 'true' | |
| working-directory: ./docs | |
| run: | | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "[email protected]" | |
| git add -A | |
| if [[ "$(git status --porcelain)" ]]; then | |
| git commit -m "Update documentation for $GITHUB_REF_NAME" | |
| git push | |
| else | |
| echo "No changes to commit" | |
| fi | |
| - name: Update readthedocs preview | |
| if: env.CREATE_RELEASE == 'true' && env.DOCS_TEMP_DIR_SUBPATH == 'preview' | |
| working-directory: ./docs | |
| run: | | |
| git fetch origin preview | |
| git checkout preview | |
| git reset --hard "$GITHUB_REF" | |
| git push origin --force-with-lease | |
| publish-packages: | |
| name: Publish packages | |
| if: github.event_name == 'release' | |
| runs-on: windows-latest | |
| environment: deploy | |
| needs: | |
| - formatting | |
| - coverage | |
| - run-tests | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 | |
| with: | |
| dotnet-version: 10.0.100 | |
| - name: Build | |
| run: dotnet build -c Release | |
| - name: Pack | |
| run: | | |
| $semver = "$env:GITHUB_REF_NAME" | |
| if ($semver -match '^(\d+)\.(\d+)\.\d+') { | |
| $major = $matches[1] | |
| $minor = $matches[2] | |
| $packageVersion = "$env:GITHUB_REF_NAME" | |
| $assemblyVersion = "$major.$minor.$env:GITHUB_RUN_NUMBER.0" | |
| Write-Host "Package version: $packageVersion" | |
| Write-Host "Assembly version: $assemblyVersion" | |
| dotnet pack -c Release --output nupkgs -p:PackageVersion=$packageVersion -p:AssemblyVersion=$assemblyVersion | |
| } else { | |
| throw "Invalid semver format" | |
| } | |
| - name: Check release conditions | |
| shell: bash | |
| run: | | |
| if [[ "$GITHUB_REF" =~ ^"refs/tags/"[0-9]+.[0-9]+.[0-9]+(-[a-z]+.[0-9]+)?|"refs/heads/main"$ ]]; then | |
| echo "CREATE_RELEASE=true" >> "$GITHUB_ENV" | |
| else | |
| echo "CREATE_RELEASE=false" >> "$GITHUB_ENV" | |
| fi | |
| - name: Push | |
| if: env.CREATE_RELEASE == 'true' | |
| run: dotnet nuget push .\nupkgs\*.nupkg --source https://api.nuget.org/v3/index.json --api-key "$env:NUGET_API_KEY" | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |