-
Notifications
You must be signed in to change notification settings - Fork 3
194 lines (190 loc) · 9.53 KB
/
pull_request.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: Pull request
on:
pull_request:
branches:
- main
jobs:
compare-version:
name: Compare versions in current branch and main
runs-on: ubuntu-latest
if: ${{ !contains(github.event.commits[0].message, '[skip ci]') }}
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
steps:
- name: Checkout source branch
uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- name: Get source branch version
shell: bash
run: |
version_prefix=$(cat ./src/Directory.Build.props | grep "<VersionPrefix>" | sed -e "s/ *<\/*VersionPrefix>//g")
version_suffix=$(cat ./src/Directory.Build.props | grep "<VersionSuffix>" | sed -e "s/ *<\/*VersionSuffix>//g")
echo "Package version prefix: $version_prefix"
echo "Package version suffix: $version_suffix"
if [ -z "${version_prefix// }" ]; then exit 1; fi
version_with_suffix="${version_prefix}"
has_suffix="false"
if [ ! -z "${version_suffix// }" ]
then
version_with_suffix="${version_prefix}-${version_suffix}"
has_suffix="true"
fi
echo "version_with_suffix_src=${version_with_suffix}" >> $GITHUB_ENV
echo "has_suffix_src=${has_suffix}" >> $GITHUB_ENV
- name: Checkout target branch
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
- name: Get target branch version
shell: bash
run: |
version_prefix=$(cat ./src/Directory.Build.props | grep "<VersionPrefix>" | sed -e "s/ *<\/*VersionPrefix>//g")
version_suffix=$(cat ./src/Directory.Build.props | grep "<VersionSuffix>" | sed -e "s/ *<\/*VersionSuffix>//g")
echo "Package version prefix: $version_prefix"
echo "Package version suffix: $version_suffix"
if [ -z "${version_prefix// }" ]; then exit 1; fi
version_with_suffix="${version_prefix}"
has_suffix="false"
if [ ! -z "${version_suffix// }" ]
then
version_with_suffix="${version_prefix}-${version_suffix}"
has_suffix="true"
fi
echo "version_with_suffix_dst=${version_with_suffix}" >> $GITHUB_ENV
echo "has_suffix_dst=${has_suffix}" >> $GITHUB_ENV
- name: Setup .NET Core SDK 8.0.101
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.101
- name: Checkout source branch back
uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- name: Compare versions
env:
source_version: ${{ env.version_with_suffix_src }}
target_version: ${{ env.version_with_suffix_dst }}
shell: bash
run: |
dotnet publish -c Release ./tools/Dodo.Primitives.Tools.CompareVersions/Dodo.Primitives.Tools.CompareVersions.csproj
source_more_than_target=$(dotnet ./tools/Dodo.Primitives.Tools.CompareVersions/bin/Release/net8.0/publish/Dodo.Primitives.Tools.CompareVersions.dll "${source_version}" "${target_version}")
last_exit_code=$(printf "%d" $?)
source_more_than_target=$(printf "%s" $source_more_than_target)
if [ "$last_exit_code" -ne 0 ]
then
echo "dotnet run status code is ${last_exit_code}"
exit 1
fi
if (( "$source_more_than_target" >= -1 && "$source_more_than_target" <=1 ))
then
if (( "$source_more_than_target" == 1 ))
then
echo "Version check passed"
elif (( "$source_more_than_target" == 0 ))
then
echo "Source and target versions are same! Expect that source version will be greater than target."
exit 1
else
echo "Target version is bigger than source! Expect that source version will be greater than target."
exit 1
fi
else
echo "Unexpected range result from version tool. Result is: ${source_more_than_target}"
exit 1
fi
run-tests:
name: Run tests
needs: compare-version
runs-on: ubuntu-latest
if: ${{ !contains(github.event.commits[0].message, '[skip ci]') }}
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- name: Setup .NET Core SDK 6.0.418
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.418
- name: Setup .NET Core SDK 8.0.101
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.101
- name: Create coverage directory and promote absolute paths to env
shell: bash
run: |
mkdir coverage
PATH_TO_COVERAGE_DIRECTORY=$(realpath coverage)
echo "coverage_directory=${PATH_TO_COVERAGE_DIRECTORY}" >> $GITHUB_ENV
PATH_NET6_NOHW="${PATH_TO_COVERAGE_DIRECTORY}/cover_net6nohw"
echo "cover_net6_nohw=${PATH_NET6_NOHW}" >> $GITHUB_ENV
echo "cover_net6_nohw_merge=${PATH_NET6_NOHW}.net6.0.json" >> $GITHUB_ENV
PATH_NET6_HW="${PATH_TO_COVERAGE_DIRECTORY}/cover_net6hw"
echo "cover_net6_hw=${PATH_NET6_HW}" >> $GITHUB_ENV
echo "cover_net6_hw_merge=${PATH_NET6_HW}.net6.0.json" >> $GITHUB_ENV
PATH_NET8_NOHW="${PATH_TO_COVERAGE_DIRECTORY}/cover_net8nohw"
echo "cover_net8_nohw=${PATH_NET8_NOHW}" >> $GITHUB_ENV
echo "cover_net8_nohw_merge=${PATH_NET8_NOHW}.net8.0.json" >> $GITHUB_ENV
PATH_NET8_HW="${PATH_TO_COVERAGE_DIRECTORY}/cover_net8hw"
echo "cover_net8_hw=${PATH_NET8_HW}" >> $GITHUB_ENV
echo "cover_net8_hw_merge=${PATH_NET8_HW}.net8.0.info" >> $GITHUB_ENV
echo "cover_net8_hw_merge_lcov=${PATH_NET8_HW}.net8.0.lcov" >> $GITHUB_ENV
- name: Run .NET 6 tests without Hardware Intrinsics
shell: bash
run: |
export COMPlus_EnableHWIntrinsic=0
export DOTNET_EnableHWIntrinsic=0
export COMPlus_ReadyToRun=0
export DOTNET_ReadyToRun=0
export CollectCoverage=true
export CoverletOutputFormat=json
export CoverletOutput=${{ env.cover_net6_nohw }}
dotnet test -c Release ./src/Dodo.Primitives.Tests/Dodo.Primitives.Tests.csproj -f net6.0
- name: Run .NET 6 tests with Hardware Intrinsics
shell: bash
run: |
export COMPlus_EnableHWIntrinsic=1
export DOTNET_EnableHWIntrinsic=1
unset COMPlus_ReadyToRun
unset DOTNET_ReadyToRun
export CollectCoverage=true
export CoverletOutputFormat=json
export CoverletOutput=${{ env.cover_net6_hw }}
export MergeWith=${{ env.cover_net6_nohw_merge }}
dotnet test -c Release ./src/Dodo.Primitives.Tests/Dodo.Primitives.Tests.csproj -f net6.0
- name: Run .NET 8 tests without Hardware Intrinsics
shell: bash
run: |
export COMPlus_EnableHWIntrinsic=0
export DOTNET_EnableHWIntrinsic=0
export COMPlus_ReadyToRun=0
export DOTNET_ReadyToRun=0
export CollectCoverage=true
export CoverletOutputFormat=json
export CoverletOutput=${{ env.cover_net8_nohw }}
export MergeWith=${{ env.cover_net6_hw_merge }}
dotnet test -c Release ./src/Dodo.Primitives.Tests/Dodo.Primitives.Tests.csproj -f net8.0
- name: Run .NET 8 tests with Hardware Intrinsics
shell: bash
run: |
export COMPlus_EnableHWIntrinsic=1
export DOTNET_EnableHWIntrinsic=1
unset COMPlus_ReadyToRun
unset DOTNET_ReadyToRun
export CollectCoverage=true
export CoverletOutputFormat=lcov
export CoverletOutput=${{ env.cover_net8_hw }}
export MergeWith=${{ env.cover_net8_nohw_merge }}
dotnet test -c Release ./src/Dodo.Primitives.Tests/Dodo.Primitives.Tests.csproj -f net8.0
mv '${{ env.cover_net8_nohw_merge }}' '${{ env.cover_net8_hw_merge_lcov }}'
- name: Publish coverage report to coveralls.io
uses: coverallsapp/[email protected]
with:
file: ${{ env.cover_net8_hw_merge_lcov }}
format: lcov
github-token: ${{ secrets.COVERALLS_SECRET }}