-
Notifications
You must be signed in to change notification settings - Fork 6
137 lines (115 loc) · 4.42 KB
/
test.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
128
129
130
131
132
133
134
135
136
name: Test
on:
pull_request: {}
push:
branches:
- main
jobs:
dotnet:
name: dotnet
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install nats-server
shell: bash
run: |
mkdir tools && cd tools
branch="main"
for i in 1 2 3
do
curl -sf https://binaries.nats.dev/nats-io/nats-server/v2@$branch | PREFIX=. sh && break || sleep 30
done
case "${{ matrix.os }}" in
ubuntu-latest|macos-latest)
sudo mv nats-server /usr/local/bin
;;
windows-latest)
mv nats-server nats-server.exe
cygpath -w "$(pwd)" | tee -a "$GITHUB_PATH"
;;
esac
- name: Check nats-server
run: nats-server -v
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.x
8.x
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --no-restore -p:ContinuousIntegrationBuild=true
- name: Test
# Collect code coverage
# https://github.com/MarcoRossignoli/coverlet/blob/master/Documentation/KnownIssues.md#tests-fail-if-assembly-is-strong-named
run: dotnet test --no-build --logger:"console;verbosity=normal" --collect:"XPlat Code Coverage" --settings Default.runsettings -- RunConfiguration.DisableAppDomain=true
- name: Upload coverage reports to Codecov
# PRs from external contributors fail: https://github.com/codecov/feedback/issues/301
# Only upload coverage reports for PRs from the same repo (not forks)
if: github.event.pull_request.head.repo.full_name == github.repository || github.ref == 'refs/heads/main'
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Test Native AOT
shell: bash
run: |
echo ">> Set up for AOT compilation..."
export exe_file=NATS.Jwt.TestNativeAot
export exe_type=ELF
export dotnet_runtime_id=linux-x64
echo ">> Checking OS..."
if [ "${{ matrix.os }}" = "windows-latest" ]; then
export exe_file=NATS.Jwt.TestNativeAot.exe
export exe_type=PE32
export dotnet_runtime_id=win-x64
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
export dotnet_runtime_id=osx-x64
export exe_type=Mach-O
fi
echo ">> Publishing..."
cd NATS.Jwt.TestNativeAot
rm -rf bin obj
dotnet publish -r $dotnet_runtime_id -c Release -o dist | tee output.txt
echo ">> Checking for warnings..."
grep -i warning output.txt && exit 1
echo ">> Executable sanity checks..."
cd dist
ls -lh
echo ">> Executable is of type $exe_type..."
file $exe_file
file $exe_file | grep $exe_type || exit 1
echo ">> Executable size checks..."
# Can't be less than a meg and not more than 10 megs.
# Fairly arbitrary, but we want to make sure executable size
# is reasonable so we can be somewhat sure AOT compilation
# happened correctly.
export filesize=0
if [ "${{ matrix.os }}" = "windows-latest" ]; then
export filesize=$(stat -c %s $exe_file)
elif [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
export filesize=$(stat -c %s $exe_file)
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
export filesize=$(stat -f %z $exe_file)
fi
echo ">> File size: $filesize bytes"
if [ $filesize -lt 1048576 ]; then
echo ">> Error: File is less than 1MB."
exit 1
fi
if [ $filesize -gt 10485760 ]; then
echo ">> Error: File is more than 10MB."
exit 1
fi
echo ">> File size is within acceptable range."
echo ">> Running executable..."
./$exe_file | tee | grep PASS || exit 1
echo ">> Run complete."