forked from microsoft/semantic-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (107 loc) · 3.76 KB
/
dotnet-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#
# 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: '8.0', configuration: Debug }
- { os: ubuntu-latest, dotnet: '8.0', configuration: Release }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
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@v4
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: ['8.0.x']
runs-on: ${{ matrix.os }}
env:
NUGET_CERT_REVOCATION_MODE: offline
steps:
- uses: actions/checkout@v4
with:
clean: true
- name: Setup .NET SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}
env:
NUGET_AUTH_TOKEN: ${{ secrets.GPR_READ_TOKEN }}
- uses: actions/cache@v4
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@v4
with:
name: dotnet-testresults-${{ matrix.configuration }}
path: ./TestResults
if: ${{ always() }}