16
16
- ' main'
17
17
18
18
jobs :
19
- build :
20
- 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/')))
21
- # Use an Ubuntu-based container to build the project
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/')))
22
24
runs-on : ubuntu-latest
23
25
24
- container :
25
- image : unityci/editor:ubuntu-2022.3.20f1-windows-mono-3.1.0
26
-
27
26
steps :
28
27
- name : Checkout repository
29
28
uses : actions/checkout@v4
35
34
uses : actions/setup-dotnet@v4
36
35
with :
37
36
dotnet-version : 8.0.x
38
-
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
+
39
43
- name : Install GitVersion
40
44
uses : gittools/actions/gitversion/setup@v3.1.1
41
45
with :
@@ -50,42 +54,81 @@ jobs:
50
54
${{ runner.os }}-nuget-
51
55
52
56
- name : Determine Version
57
+ id : version_step
53
58
run : |
54
59
chown -R $(whoami) $(pwd)
55
- dotnet-gitversion /output json
60
+ 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
56
63
57
64
- name : Restore dependencies
58
65
run : dotnet restore
59
66
60
67
- name : Build Solution
61
- env :
62
- UnityManagedPath : \opt\unity\Editor\Data\Managed
63
68
run : |
64
- echo "Version:${{ env.GitVersion_FullSemVer }}\nAssembley Version:${{ env.GitVersion_AssemblySemFileVer }}"
65
- dotnet build --configuration Release --no-restore
69
+ echo "Version: ${{ env.FULL_SEM_VER }}"
70
+ echo "Assembly Version: ${{ env.ASSEMBLY_VERSION }}"
71
+ dotnet build --configuration Debug --no-restore
66
72
67
- - name : Upload Test Artifacts
68
- uses : actions/upload-artifact@v4
69
- with :
70
- name : BuildOutputTest
71
- path : ./tests/FixedMathSharp.Tests/bin/Release
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
72
80
73
- test :
74
- # Use a Windows runner to execute the .NET Framework tests
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/')))
75
86
runs-on : windows-latest
76
- needs : build
77
-
78
87
steps :
79
88
- name : Checkout repository
80
89
uses : actions/checkout@v4
81
-
82
- - name : Download Test Artifacts
83
- uses : actions/download-artifact@v4
84
90
with :
85
- name : BuildOutputTest
86
- path : ./tests/FixedMathSharp.Tests/bin/Release
87
-
88
- - name : Test
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
89
132
run : |
90
133
dotnet --info
91
- dotnet test ${{ github.workspace }}\tests\FixedMathSharp.Tests\bin\Release\net48\FixedMathSharp.Tests.dll --verbosity normal
134
+ dotnet test --verbosity normal
0 commit comments