1- # This workflow builds and tests the FixedMathSharp .NET project.
2- # Documentation: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3-
41name : .NET CI
52
63on :
7- # Run the workflow on all branch pushes and pull requests
84 push :
95 branches-ignore :
10- - ' dependabot/**' # avoid duplicates: only run the PR, not the push
11- - ' gh-pages' # github pages do not trigger all tests
6+ - ' dependabot/**'
7+ - ' gh-pages'
128 tags-ignore :
13- - ' v*' # avoid rerun existing commit on release
9+ - ' v*'
1410 pull_request :
1511 branches :
1612 - ' main'
1713
1814jobs :
19- build-and-test-linux :
20- if : |
21- (github.event_name != 'pull_request' && !github.event.pull_request.head.repo.fork)
22- || (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork
23- || startsWith(github.head_ref, 'dependabot/')))
24- runs-on : ubuntu-latest
15+ build-and-test :
16+ runs-on : ${{ matrix.os }}
17+
18+ strategy :
19+ matrix :
20+ os : [ ubuntu-latest, windows-latest]
2521
2622 steps :
2723 - name : Checkout repository
2824 uses : actions/checkout@v4
2925 with :
3026 fetch-depth : 0
31- persist-credentials : false # Ensure credentials aren't retained
27+ persist-credentials : false
3228
3329 - name : Setup .NET
3430 uses : actions/setup-dotnet@v4
3531 with :
3632 dotnet-version : 8.0.x
37-
38- - name : Install Mono (required for .NET Framework tests on Linux)
39- run : |
40- sudo apt update
41- sudo apt install -y mono-complete
42-
33+
4334 - name : Install GitVersion
4435 uses : gittools/actions/gitversion/setup@v3.1.1
4536 with :
@@ -54,12 +45,13 @@ jobs:
5445 ${{ runner.os }}-nuget-
5546
5647 - name : Determine Version
57- id : version_step
48+ shell : bash
5849 run : |
59- chown -R $(whoami) $(pwd)
6050 dotnet-gitversion /output json > version.json
61- echo "FULL_SEM_VER=$(grep -oP '"FullSemVer":\s*"\K[^"]+' version.json)" >> $GITHUB_ENV
62- echo "ASSEMBLY_VERSION=$(grep -oP '"AssemblySemFileVer":\s*"\K[^"]+' version.json)" >> $GITHUB_ENV
51+ FULL_SEM_VER=$(jq -r .FullSemVer version.json)
52+ ASSEMBLY_VERSION=$(jq -r .AssemblySemFileVer version.json)
53+ echo "FULL_SEM_VER=$FULL_SEM_VER" >> $GITHUB_ENV
54+ echo "ASSEMBLY_VERSION=$ASSEMBLY_VERSION" >> $GITHUB_ENV
6355
6456 - name : Restore dependencies
6557 run : dotnet restore
7062 echo "Assembly Version: ${{ env.ASSEMBLY_VERSION }}"
7163 dotnet build --configuration Debug --no-restore
7264
73- - name : Test .NET48
74- run : |
75- 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
76-
77- - name : Test .NET8
78- run : |
79- dotnet test -f net8 --verbosity normal
80-
81- build-and-test-windows :
82- if : |
83- (github.event_name != 'pull_request' && !github.event.pull_request.head.repo.fork)
84- || (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork
85- || startsWith(github.head_ref, 'dependabot/')))
86- runs-on : windows-latest
87- steps :
88- - name : Checkout repository
89- uses : actions/checkout@v4
90- with :
91- fetch-depth : 0
92- persist-credentials : false
93-
94- - name : Setup .NET
95- uses : actions/setup-dotnet@v4
96- with :
97- dotnet-version : 8.0.x
98-
99- - name : Install GitVersion
100- uses : gittools/actions/gitversion/setup@v3.1.1
101- with :
102- versionSpec : 6.0.x
103-
104- - name : Cache NuGet packages
105- uses : actions/cache@v3
106- with :
107- path : ~/.nuget/packages
108- key : ' ${{ runner.os }}-nuget-${{ hashFiles('' **/*.csproj'' , '' **/*.sln'' ) }}'
109- restore-keys : |
110- ${{ runner.os }}-nuget-
111-
112- - name : Determine Version
113- id : version_step
114- shell : pwsh
115- run : |
116- chown -R $env:USERNAME $(Get-Location)
117- dotnet-gitversion /output json | Out-File -FilePath version.json
118- $json = Get-Content version.json | ConvertFrom-Json
119- echo "FULL_SEM_VER=$($json.FullSemVer)" | Out-File -FilePath $env:GITHUB_ENV -Append
120- echo "ASSEMBLY_VERSION=$($json.AssemblySemFileVer)" | Out-File -FilePath $env:GITHUB_ENV -Append
121-
122- - name : Restore dependencies
123- run : dotnet restore
124-
125- - name : Build Solution
126- run : |
127- echo "Version: ${{ env.FULL_SEM_VER }}"
128- echo "Assembly Version: ${{ env.ASSEMBLY_VERSION }}"
129- dotnet build --configuration Debug --no-restore
130-
131- - name : Test .NET48 & .NET8
132- run : |
133- dotnet --info
134- dotnet test --verbosity normal
65+ - name : Run Tests (net8.0)
66+ run : dotnet test --configuration Debug --no-build --verbosity normal
0 commit comments