Merge with latest main #93
This file contains 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
# | |
# This workflow will build and run all unit tests. | |
# | |
name: dotnet-ci-windows | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ "main", "feature*" ] | |
paths: | |
- 'dotnet/**' | |
- 'samples/dotnet/**' | |
permissions: | |
contents: read | |
jobs: | |
dotnet-build-and-test: | |
strategy: | |
matrix: | |
os: [windows-latest] | |
configuration: [Release, Debug] | |
dotnet-version: ['6.0.x'] | |
runs-on: ${{ matrix.os }} | |
env: | |
NUGET_CERT_REVOCATION_MODE: offline | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
clean: true | |
- name: Setup .NET SDK ${{ matrix.dotnet-version }} | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ matrix.dotnet-version }} | |
env: | |
NUGET_AUTH_TOKEN: ${{ secrets.GPR_READ_TOKEN }} | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.nuget/packages | |
# Look to see if there is a cache hit for the corresponding requirements file | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-nuget | |
- name: Update project versions | |
shell: bash | |
run: | | |
allProjectFiles=$(find ./dotnet -type f -name "*.csproj" | tr '\n' ' '); | |
if [ $? -ne 0 ]; then exit 1; fi | |
echo "$allProjectFiles" | |
propsFile="./dotnet/nuget/nuget-package.props" | |
buildAndRevisionNumber="${{ github.run_number }}.${{ github.run_attempt }}" | |
echo "buildAndRevisionNumber: $buildAndRevisionNumber" | |
for file in $allProjectFiles; do | |
./.github/workflows/update-version.sh --file $file --propsFile $propsFile --buildAndRevisionNumber $buildAndRevisionNumber | |
done | |
- name: Find solutions | |
shell: bash | |
run: echo "solutions=$(find ./dotnet -type f -name "*.sln" | tr '\n' ' ')" >> $GITHUB_ENV | |
- name: Restore dependencies | |
shell: bash | |
run: | | |
for solution in ${{ env.solutions }}; do | |
dotnet restore $solution | |
done | |
- name: Build | |
shell: bash | |
run: | | |
for solution in ${{ env.solutions }}; do | |
dotnet build $solution --no-restore --configuration ${{ matrix.configuration }} | |
done | |
- name: Find unit test projects | |
shell: bash | |
run: echo "projects=$(find ./dotnet -type f -name "*.UnitTests.csproj" | tr '\n' ' ')" >> $GITHUB_ENV | |
- name: Test | |
shell: bash | |
run: | | |
for project in ${{ env.projects }}; do | |
dotnet test $project --no-build --verbosity normal --logger trx --results-directory ./TestResults --configuration ${{ matrix.configuration }} | |
done | |
- name: Upload dotnet test results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dotnet-testresults-${{ matrix.configuration }} | |
path: ./TestResults | |
if: ${{ always() }} | |
- name: Stage artifacts | |
shell: bash | |
run: mkdir ./out; find . | grep "/bin/" | xargs cp -r --parents -t ./out | |
if: ${{ github.event_name == 'push' }} | |
- name: Archive artifacts ${{ matrix.os }}-${{ matrix.configuration }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: drop-${{ matrix.os }}-${{ matrix.configuration }} | |
path: ./out | |
if: ${{ github.event_name == 'push' }} |