-
Notifications
You must be signed in to change notification settings - Fork 64
231 lines (224 loc) · 9.54 KB
/
main.yaml
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
name: Singleton CSharp(C#)-Client CI
on:
push:
branches: [ g11n-csharp-client ]
pull_request:
branches: [ g11n-csharp-client ]
jobs:
pre-process:
name: Pre process
runs-on: ubuntu-latest
outputs:
were-only-docs-updated: ${{ steps.were-only-docs-updated-action.outputs.were-only-docs-updated }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2.
- name: Get commit range
id: get-commit-range-action
uses: ./.github/actions/get-commit-range-action
- name: Were only docs updated
id: were-only-docs-updated-action
uses: ./.github/actions/were-only-docs-updated-action
with:
commit-range: ${{ steps.get-commit-range-action.outputs.commit-range }}
check-header:
name: Check Header
runs-on: ubuntu-latest
needs: pre-process
if: needs.pre-process.outputs.were-only-docs-updated != 'yes'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2.
- name: Get commit range
id: get-commit-range-action
uses: ./.github/actions/get-commit-range-action
- name: Get Python
uses: actions/setup-python@v2
- name: Check header
shell: bash
run: |
git clone --branch=devops https://github.com/vmware/singleton.git devops
git diff ${{ steps.get-commit-range-action.outputs.commit-range }} --stat
git diff --name-only --diff-filter=d ${{ steps.get-commit-range-action.outputs.commit-range }}
python devops/check_headers.py -f "$(git diff --name-only --diff-filter=d ${{ steps.get-commit-range-action.outputs.commit-range }})"
run-unit-test:
name: Run Unit Test
runs-on: windows-2019
defaults:
run:
shell: bash
needs: [pre-process]
if: needs.pre-process.outputs.were-only-docs-updated != 'yes'
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: PreFlight Check for Unit Tests
run: |
choco install --no-progress opencover.portable
choco install --no-progress codecov
cd $GITHUB_WORKSPACE/singletonclient && nuget restore SingletonClient.sln
- name: Run ICU Unit Tests
run: |
export VSTEST="/c/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/Common7/IDE/Extensions/TestPlatform"
export PATH="$PATH:$VSTEST"
cd $GITHUB_WORKSPACE/singletonclient/UnitTestSingletonIcu
MSBuild.exe UnitTestSingletonIcu.csproj -t:rebuild
cd $GITHUB_WORKSPACE/singletonclient/UnitTestSingletonIcu/bin/Debug
OpenCover.Console.exe -register -target:"/c/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/Common7/IDE/Extensions/TestPlatform/vstest.console.exe" -targetargs:".\UnitTestSingletonIcu.dll --logger:trx /Parallel " -filter:"+[SingletonIcu*]* -[UnitTestSingletonIcu*]*" -output:".\UnitTestSingletonIcu.xml"
cp UnitTestSingletonIcu.xml $GITHUB_WORKSPACE
- name: Run Unit Tests
run: |
export VSTEST="/c/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/Common7/IDE/Extensions/TestPlatform"
export PATH="$PATH:$VSTEST"
cd $GITHUB_WORKSPACE/singletonclient/UnitTestSingleton && MSBuild.exe UnitTestSingleton.csproj -t:rebuild
cd $GITHUB_WORKSPACE/singletonclient/UnitTestSingleton/bin/Debug
OpenCover.Console.exe -register:path32 -target:"/c/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/Common7/IDE/Extensions/TestPlatform/vstest.console.exe" -targetargs:".\UnitTestSingleton.dll --logger:trx /Parallel " -filter:"+[SingletonClient*]* -[UnitTestSingleton*]*" -output:".\UnitTestSingleton.xml"
cp UnitTestSingleton.xml $GITHUB_WORKSPACE
- name: Upload CodeCov Reports
uses: codecov/codecov-action@v2
with:
files: ./UnitTestSingleton.xml,./UnitTestSingletonIcu.xml
flags: unittests
security-analysis:
name: CodeQL Scan
runs-on: windows-2019
defaults:
run:
shell: bash
needs: pre-process
if: needs.pre-process.outputs.were-only-docs-updated != 'yes'
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: csharp
debug: true
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: Creat Build Script for Auto Build
run: |-
cat <<EOF > build.bat
cd singletonclient
nuget restore SingletonClient.sln
cd SingletonClient
MSBuild.exe SingletonClient.csproj -t:rebuild -p:UseSharedCompilation=false
EOF
ls -al
- name: Autobuild
uses: github/codeql-action/autobuild@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
codacy-analysis-cli:
name: Codacy Analysis CLI
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@master
with:
output: results.sarif
format: sarif
# Adjust severity of non-security issues
gh-code-scanning-compat: true
# Force 0 exit code to allow SARIF file generation
# This will handover control about PR rejection to the GitHub side
max-allowed-issues: 2147483647
# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@main
with:
sarif_file: results.sarif
preflight-smoke-test-check:
name: Preflight Check for Smoke Test
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: pre-process
if: needs.pre-process.outputs.were-only-docs-updated != 'yes'
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'
- name: Package Singleton Service
run: |
git clone --branch=master https://github.com/vmware/singleton.git service
git clone --branch=devops https://github.com/vmware/singleton.git devops
cp -r devops/autotest/client/jscoresdk/resources/bundles/JSCoreSDKTest service/g11n-ws/vip-manager-i18n/src/main/resources/l10n/bundles/
echo "source.cache.flag = true" >> service/g11n-ws/vip-manager-i18n/src/main/resources/application-bundle.properties
cd $GITHUB_WORKSPACE/service/g11n-ws && ./gradlew build -x test
find $GITHUB_WORKSPACE/service/publish/ -name 'singleton-[0~9]*.jar' -exec mv '{}' $GITHUB_WORKSPACE/service/publish/singleton.jar \;
- uses: actions/upload-artifact@v2
with:
name: singleton-service
path: ./service/publish/singleton.jar
run-smoke-test:
name: Run Smoke Test
runs-on: windows-2019
defaults:
run:
shell: bash
needs: [pre-process,preflight-smoke-test-check]
if: needs.pre-process.outputs.were-only-docs-updated != 'yes'
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'
- uses: actions/download-artifact@v2
with:
name: singleton-service
- name: Start Singleton Service
run: |
nohup java -jar singleton.jar > singletonService.log 2>&1 &
until [ -d l10n/bundles ] ; do sleep 2; echo waiting for bundles. . . ; done
git clone --branch=devops https://github.com/vmware/singleton.git devops
cp -r devops/autotest/client/csharp/l10n/bundles/CSharpClient l10n/bundles
ls -la $GITHUB_WORKSPACE/l10n/bundles
- name: Run Smoke Test
run: |
export VSTEST="/c/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/Common7/IDE/Extensions/TestPlatform"
export PATH="$PATH:$VSTEST"
cd $GITHUB_WORKSPACE/singletonclient && nuget restore SingletonClient.sln
cd SingletonClient && MSBuild.exe SingletonClient.csproj -t:rebuild -p:WarningLevel=0
cp bin/Debug/netstandard2.0/SingletonClient.dll $GITHUB_WORKSPACE/devops/autotest/client/csharp/SingletonClient.dll
cd $GITHUB_WORKSPACE/devops/autotest/client/csharp && nuget restore csharp.sln
cd $GITHUB_WORKSPACE/devops/autotest/client/csharp/CSharp && MSBuild.exe CSharp.csproj -t:rebuild -p:WarningLevel=0
cd bin/Debug && pwd && ls -la
curl -X GET 'http://localhost:8091/i18n/api/v2/formatting/patterns?language=en®ion=TW&scope=dates'
powershell -Command 'vstest.console CSharp.dll /TestCaseFilter:"Priority=0" /Logger:trx'
powershell -Command 'Get-Process -Name java | Stop-Process'
- uses: actions/upload-artifact@v2
with:
name: client.dll
path: ./devops/autotest/client/csharp/SingletonClient.dll
- uses: actions/upload-artifact@v2
with:
name: Singleton Service Log
path: ./singletonService.log
- uses: actions/upload-artifact@v2
with:
name: TestResults
path: ./devops/autotest/client/csharp/CSharp/bin/Debug/TestResults