1
1
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
2
2
3
- name : napi-dotnet build and test
3
+ name : PR Verification
4
4
5
5
on :
6
- push :
7
- branches : [ "main" ]
8
6
pull_request :
9
7
branches : [ "main" ]
10
8
workflow_dispatch : # Enable manually starting a build
11
9
12
- permissions :
13
- checks : write
14
- pull-requests : write
15
- statuses : write
16
-
17
10
jobs :
18
11
build :
19
-
20
- runs-on : ${{ matrix.os }}
21
-
22
12
strategy :
23
13
matrix :
24
14
os : [ windows-latest, macos-latest, ubuntu-latest ]
25
15
node-version : [ 18.x ]
16
+ configuration : [ Release ]
26
17
fail-fast : false # Don't cancel other jobs when one job fails
27
18
19
+ runs-on : ${{ matrix.os }}
20
+
28
21
steps :
29
22
- uses : actions/checkout@v3
30
23
with :
@@ -49,11 +42,12 @@ jobs:
49
42
with :
50
43
node-version : ${{ matrix.node-version }}
51
44
52
- - name : Build
53
- run : dotnet build --configuration Release
45
+ - name : Build ${{ matrix.configuration }}
46
+ run : dotnet build --configuration ${{ matrix.configuration }}
54
47
55
48
- name : Build packages
56
- run : dotnet pack --configuration Release
49
+ id : pack
50
+ run : dotnet pack --configuration ${{ matrix.configuration }}
57
51
58
52
# Uncomment to enable an SSH session for debugging
59
53
# - name: Setup tmate session
@@ -64,46 +58,50 @@ jobs:
64
58
- name : Upload build artifacts
65
59
uses : actions/upload-artifact@v3
66
60
with :
67
- name : ${{ runner .os }}-packages
61
+ name : ${{ matrix .os }}-${{ matrix.configuration }}-packages
68
62
path : |
69
63
out/pkg/*.nupkg
70
64
out/pkg/*.tgz
71
65
72
66
- name : Test .NET 4.7.2
73
- if : matrix.os == 'windows-latest'
67
+ if : matrix.os == 'windows-latest' && steps.pack.conclusion == 'success' && !cancelled()
74
68
env :
75
69
TRACE_NODE_API_HOST : 1
76
- run : dotnet test -f net472 --configuration Release --logger trx --results-directory "test-netfx47-node${{ matrix.node-version }}"
70
+ run : >
71
+ dotnet test -f net472
72
+ --configuration ${{ matrix.configuration }}
73
+ --logger trx
74
+ --results-directory "out/test/netfx47-node${{ matrix.node-version }}-${{ matrix.configuration }}"
77
75
78
76
- name : Test .NET 6
77
+ if : steps.pack.conclusion == 'success' && !cancelled()
79
78
env :
80
79
TRACE_NODE_API_HOST : 1
81
- run : dotnet test -f net6.0 --configuration Release --logger trx --results-directory "test-dotnet6-node${{ matrix.node-version }}"
80
+ run : >
81
+ dotnet test -f net6.0
82
+ --configuration ${{ matrix.configuration }}
83
+ --logger trx
84
+ --results-directory "out/test/dotnet6-node${{ matrix.node-version }}-${{ matrix.configuration }}"
82
85
83
86
- name : Test .NET 7
87
+ if : steps.pack.conclusion == 'success' && !cancelled()
84
88
env :
85
89
TRACE_NODE_API_HOST : 1
86
- run : dotnet test -f net7.0 --configuration Release --logger trx --results-directory "test-dotnet7-node${{ matrix.node-version }}"
90
+ run : >
91
+ dotnet test -f net7.0
92
+ --configuration ${{ matrix.configuration }}
93
+ --logger trx
94
+ --results-directory "out/test/dotnet7-node${{ matrix.node-version }}-${{ matrix.configuration }}"
87
95
88
96
- name : Upload test logs
97
+ if : always() # Update artifacts regardless if code succeeded, failed, or cancelled
89
98
uses : actions/upload-artifact@v3
90
99
with :
91
- name : test-logs-${{ runner.os }}-node${{ matrix.node-version }}
92
- path : out/obj/Release/**/*.log
93
- if : ${{ always() }}
94
-
95
- - name : Publish test results
96
- uses : dorny/test-reporter@v1
97
- with :
98
- name : test (${{ runner.os }}, node${{ matrix.node-version }})
99
- path : test-dotnet*-node${{ matrix.node-version }}/*.trx
100
- reporter : dotnet-trx
101
- if : ${{ always() }} # Run this step even when there are test failures
100
+ name : test-logs-${{ matrix.os }}-node${{ matrix.node-version }}-${{ matrix.configuration }}
101
+ path : |
102
+ out/obj/${{ matrix.configuration }}/**/*.log
103
+ out/test/**/*.trx
102
104
103
105
- name : Check formatting
106
+ if : ${{ !cancelled() }} # Run this step even when there are build failures but not when cancelled
104
107
run : dotnet format --no-restore --severity info --verbosity detailed --verify-no-changes
105
- if : ${{ always() }} # Run this step even when there are build failures
106
-
107
- # TODO: Publish packages
108
- # - name: Publish packages
109
- # run: dotnet nuget push out/pkg/*.nupkg
0 commit comments