-
-
Notifications
You must be signed in to change notification settings - Fork 19
134 lines (113 loc) · 4.38 KB
/
Copy pathdotnet.yml
File metadata and controls
134 lines (113 loc) · 4.38 KB
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
128
129
130
131
132
133
134
# This workflow builds and tests the FixedMathSharp .NET project.
# Documentation: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: .NET CI
on:
# Run the workflow on all branch pushes and pull requests
push:
branches-ignore:
- 'dependabot/**' #avoid duplicates: only run the PR, not the push
- 'gh-pages' #github pages do not trigger all tests
tags-ignore:
- 'v*' #avoid rerun existing commit on release
pull_request:
branches:
- 'main'
jobs:
build-and-test-linux:
if: |
(github.event_name != 'pull_request' && !github.event.pull_request.head.repo.fork)
|| (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork
|| startsWith(github.head_ref, 'dependabot/')))
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false # Ensure credentials aren't retained
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install Mono (required for .NET Framework tests on Linux)
run: |
sudo apt update
sudo apt install -y mono-complete
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.1.1
with:
versionSpec: '6.0.x'
- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.sln') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Determine Version
id: version_step
run: |
chown -R $(whoami) $(pwd)
dotnet-gitversion /output json > version.json
echo "FULL_SEM_VER=$(grep -oP '"FullSemVer":\s*"\K[^"]+' version.json)" >> $GITHUB_ENV
echo "ASSEMBLY_VERSION=$(grep -oP '"AssemblySemFileVer":\s*"\K[^"]+' version.json)" >> $GITHUB_ENV
- name: Restore dependencies
run: dotnet restore
- name: Build Solution
run: |
echo "Version: ${{ env.FULL_SEM_VER }}"
echo "Assembly Version: ${{ env.ASSEMBLY_VERSION }}"
dotnet build --configuration Debug --no-restore
- name: Test .NET48
run: |
mono ~/.nuget/packages/xunit.runner.console/2.9.3/tools/net48/xunit.console.exe ${{github.workspace}}/tests/FixedMathSharp.Tests/bin/Debug/net48/FixedMathSharp.Tests.dll
- name: Test .NET8
run: |
dotnet test -f net8 --verbosity normal
build-and-test-windows:
if: |
(github.event_name != 'pull_request' && !github.event.pull_request.head.repo.fork)
|| (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork
|| startsWith(github.head_ref, 'dependabot/')))
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.1.1
with:
versionSpec: 6.0.x
- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: '${{ runner.os }}-nuget-${{ hashFiles(''**/*.csproj'', ''**/*.sln'') }}'
restore-keys: |
${{ runner.os }}-nuget-
- name: Determine Version
id: version_step
shell: pwsh
run: |
chown -R $env:USERNAME $(Get-Location)
dotnet-gitversion /output json | Out-File -FilePath version.json
$json = Get-Content version.json | ConvertFrom-Json
echo "FULL_SEM_VER=$($json.FullSemVer)" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "ASSEMBLY_VERSION=$($json.AssemblySemFileVer)" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Restore dependencies
run: dotnet restore
- name: Build Solution
run: |
echo "Version: ${{ env.FULL_SEM_VER }}"
echo "Assembly Version: ${{ env.ASSEMBLY_VERSION }}"
dotnet build --configuration Debug --no-restore
- name: Test .NET48 & .NET8
run: |
dotnet --info
dotnet test --verbosity normal