Skip to content

Commit

Permalink
Merge branch 'main' into issue-2151
Browse files Browse the repository at this point in the history
  • Loading branch information
GalRabin authored Jul 25, 2023
2 parents f0aa42b + 29ecb71 commit fbd3bdd
Show file tree
Hide file tree
Showing 22 changed files with 572 additions and 289 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/dotnet-build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#
# This workflow will build and run all unit tests using dotnet docker containers,
# each targeting a single version of the dotnet SDK.
#

name: dotnet-build-and-test

on:
workflow_dispatch:
schedule:
- cron: '0 7 * * *'
pull_request:
branches: [ "main", "feature*" ]
paths:
- 'dotnet/**'
- 'samples/dotnet/**'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
include:
- { os: 'ubuntu', dotnet: '6.0-jammy', configuration: Debug }
- { os: 'ubuntu', dotnet: '7.0-jammy', configuration: Release }
- { os: 'ubuntu', dotnet: '8.0-preview-jammy', configuration: Release }
- { os: 'windows', dotnet: '6.0', configuration: Release }
- { os: 'windows', dotnet: '7.0', configuration: Debug }
- { os: 'windows', dotnet: '8.0-preview', configuration: Release }

runs-on: ubuntu-latest
env:
NUGET_CERT_REVOCATION_MODE: offline
DOTNET_DOCKER_IMG: mcr.microsoft.com/dotnet/sdk:${{ matrix.dotnet }}
steps:
- uses: actions/checkout@v3
with:
clean: true

- name: Pull container dotnet/sdk:${{ matrix.dotnet }}
run: docker pull mcr.microsoft.com/dotnet/sdk:${{ matrix.dotnet }}

- name: Build dotnet solutions
run: |
export SOLUTIONS=$(find ./dotnet/ -type f -name "*.sln" | tr '\n' ' ')
for solution in $SOLUTIONS; do
docker run --rm -v $(pwd):/app -w /app -e GITHUB_ACTIONS='true' $DOTNET_DOCKER_IMG /bin/sh -c "dotnet build -c ${{ matrix.configuration }} /warnaserror /app/$solution"
done
- name: Run Unit Tests
run: |
export UT_PROJECTS=$(find ./dotnet -type f -name "*.UnitTests.csproj" | tr '\n' ' ')
for project in $UT_PROJECTS; do
docker run --rm -v $(pwd):/app -w /app $DOTNET_DOCKER_IMG /bin/sh -c "dotnet test -c ${{ matrix.configuration }} /app/$project --no-build -v Normal --logger trx"
done
68 changes: 0 additions & 68 deletions .github/workflows/dotnet-ci-docker.yml

This file was deleted.

110 changes: 0 additions & 110 deletions .github/workflows/dotnet-ci-windows.yml

This file was deleted.

129 changes: 129 additions & 0 deletions .github/workflows/dotnet-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#
# This workflow will build and run all tests using dotnet docker containers,
# each targeting a single version of the dotnet SDK.
#

name: dotnet-ci

on:
workflow_dispatch:
schedule:
- cron: '0 7 * * *'

permissions:
contents: read

jobs:
build-and-test-docker:
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, dotnet: '6.0', configuration: Debug }
- { os: ubuntu-latest, dotnet: '6.0', configuration: Release }
- { os: ubuntu-latest, dotnet: '7.0', configuration: Release }
- { os: ubuntu-latest, dotnet: '8.0-preview', configuration: Release }

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
clean: true

- name: Find solutions
shell: bash
run: echo "solutions=$(find ./ -type f -name "*.sln" | tr '\n' ' ')" >> $GITHUB_ENV

- name: Pull container dotnet/sdk:${{ matrix.dotnet }}
run: |
docker pull mcr.microsoft.com/dotnet/sdk:${{ matrix.dotnet }}
- name: Build
run: |
for solution in ${{ env.solutions }}; do
docker run --rm -v $(pwd):/app -w /app -e GITHUB_ACTIONS='true' mcr.microsoft.com/dotnet/sdk:${{ matrix.dotnet }} /bin/sh -c "dotnet build -c ${{ matrix.configuration }} /app/$solution"
done
- name: Find test projects
shell: bash
run: echo "testprojects=$(find ./dotnet -type f -name "*UnitTests.csproj" | tr '\n' ' ')" >> $GITHUB_ENV

- name: Run Tests
shell: bash
run: |
for project in ${{ env.testprojects }}; do
docker run --rm -v $(pwd):/app -w /app mcr.microsoft.com/dotnet/sdk:${{ matrix.dotnet }} /bin/sh -c "dotnet test -c ${{ matrix.configuration }} /app/$project --no-build -v Normal --logger trx"
done
- name: Upload dotnet test results
uses: actions/upload-artifact@v3
with:
name: dotnet-testresults-${{ matrix.configuration }}
path: ./TestResults
if: ${{ always() }}

build-and-test-windows:
strategy:
fail-fast: false
matrix:
os: [windows-latest]
configuration: [Release, Debug]
dotnet-version: ['7.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: 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 test projects
shell: bash
run: echo "testprojects=$(find ./dotnet -type f -name "*Tests.csproj" | tr '\n' ' ')" >> $GITHUB_ENV

- name: Run Tests
shell: bash
run: |
for project in ${{ env.testprojects }}; do
dotnet test $project --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() }}
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Find projects
shell: bash
if: ${{ github.event_name != 'pull_request' }}
run: echo "projects=$(find ./dotnet -type f -name "*IntegrationTests.csproj" | tr '\n' ' ')" >> $GITHUB_ENV
run: echo "projects=$(find ./dotnet -type f -name "*Tests.csproj" | tr '\n' ' ')" >> $GITHUB_ENV

- name: Integration Tests
shell: bash
Expand Down
Loading

0 comments on commit fbd3bdd

Please sign in to comment.