forked from notepad-plus-plus/notepad-plus-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
387 lines (327 loc) · 15.9 KB
/
CI_build.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
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
name: CI_build
on: [push, pull_request]
env:
PYTHON_ALLOW_CACHE: true
PYTHON_DIR_CACHE: D:\.cache\python
jobs:
before_build:
runs-on: windows-latest
outputs:
result: ${{ steps.filter.outputs.result }}
matrix: ${{ steps.filter.outputs.matrix }}
title: ${{ steps.filter.outputs.title }}
python: ${{ steps.filter.outputs.python }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- name: Commit filtering
id: filter
run: |
$allowMaster = $true
$folders_onejob = "PowerEditor/(Test|(installer/(filesForTesting|functionList)))/"
$folders_nowork = "\.github/ISSUE_TEMPLATE"
$files_nowork = "md|txt|log|ini"
$files_needwork = "CMakeLists\.txt"
$matrix_all = 'matrix={"build_configuration": ["Release", "Debug"], "build_platform": ["x64", "Win32", "ARM64"]}'
$matrix_onejob = 'matrix={"build_configuration": ["Debug"], "build_platform": ["Win32"]}'
Write-Output $matrix_all >> $env:GITHUB_OUTPUT
$isPush = "${{github.event_name }}" -eq "push" ? $true : $false
$isMaster = $isPush -and $${{ github.ref_name == github.event.repository.master_branch }}
$commit_message = $isPush ? (git show -s --format=%B) : (git log -1 --no-merges --pretty=%B)
$commit_title = ($commit_message -split "[\r\n]+")[0]
Write-Output "title=$commit_title" >> $env:GITHUB_OUTPUT
$files_modified = @(git diff --name-only HEAD~1)
$files_needwork_all = @($files_modified | Where-Object {$_ -notmatch "\.(xml|$files_nowork)$|$folders_nowork|$folders_onejob" -or $_ -match "($files_needwork)$"})
if ($allowMaster -or !$isMaster) {
if ($commit_title -match "\[force all\]") {
Write-Output "Run standard jobs"
}
elseif ($commit_title -match "\[force one\]") {
Write-Output "Run only one Win32/Debug job"
Write-Output "result=ONEJOB" >> $env:GITHUB_OUTPUT
Write-Output $matrix_onejob >> $env:GITHUB_OUTPUT
}
elseif (($files_modified.length -gt 0 -and $files_needwork_all.length -eq 0) -or $commit_title -match "\[force (xml|none)\]") {
if (@($files_modified | Where-Object {$_ -notmatch "\.($files_nowork)$|$folders_nowork"}).length -eq 0 -or $commit_title -match "\[force none\]") {
Write-Output "Changed files on this commit don't require any additional tasks.`n"
Write-Output "result=OK" >> $env:GITHUB_OUTPUT
Write-Output "PYTHON_ALLOW_CACHE=false" >> $env:GITHUB_ENV
Exit
}
else {
Write-Output "Run only XML validation step"
if (@($files_modified | Where-Object {$_ -match $folders_onejob}).length -eq 0) {
Write-Output "result=XML" >> $env:GITHUB_OUTPUT
}
else {
Write-Output "Run only one Win32/Debug job"
Write-Output "result=ONEJOB" >> $env:GITHUB_OUTPUT
Write-Output $matrix_onejob >> $env:GITHUB_OUTPUT
}
}
}
else {
Write-Output "Run standard jobs"
}
}
else {
Write-Output "Run standard jobs"
}
if ($commit_title -match "\[force nopythoncache\]") {
$env:PYTHON_ALLOW_CACHE = "false"
Write-Output "PYTHON_ALLOW_CACHE=false" >> $env:GITHUB_ENV
}
if ($Env:PYTHON_ALLOW_CACHE -eq "true") {
$python = ((python -V) -split " ")[1]
$requests = (Invoke-RestMethod https://pypi.org/pypi/requests/json).info.version
$rfc3987 = (Invoke-RestMethod https://pypi.org/pypi/rfc3987/json).info.version
$pywin32 = (Invoke-RestMethod https://pypi.org/pypi/pywin32/json).info.version
$lxml = (Invoke-RestMethod https://pypi.org/pypi/lxml/json).info.version
$key = "${{ runner.os }}-python_$python-requests_$requests-rfc3987_$rfc3987-pywin32_$pywin32-lxml_$lxml"
Write-Output "python=$key" >> $env:GITHUB_OUTPUT
}
- name: (cache) Lookup Python modules
if: env.PYTHON_ALLOW_CACHE == 'true'
uses: actions/cache/restore@v4
id: cache-lookup
with:
path: ${{ env.PYTHON_DIR_CACHE }}
key: ${{ steps.filter.outputs.python }}
lookup-only: true
- name: (cache) Restore Python modules
if: env.PYTHON_ALLOW_CACHE == 'true' && steps.filter.outputs.result == 'XML' && steps.cache-lookup.outputs.cache-hit == 'true'
uses: actions/cache/restore@v4
with:
path: ${{ env.PYTHON_DIR_CACHE }}
key: ${{ steps.filter.outputs.python }}
- name: (cache) Install Python modules
if: env.PYTHON_ALLOW_CACHE == 'true' && steps.cache-lookup.outputs.cache-hit != 'true'
run: |
python -m pip install --target ${{ env.PYTHON_DIR_CACHE }} requests rfc3987 pywin32 lxml
- name: (cache) Save Python modules
if: env.PYTHON_ALLOW_CACHE == 'true' && steps.cache-lookup.outputs.cache-hit != 'true' && github.event_name == 'push'
uses: actions/cache/save@v4
with:
path: ${{ env.PYTHON_DIR_CACHE }}
key: ${{ steps.filter.outputs.python }}
- name: XML validation
if: steps.filter.outputs.result == 'XML'
run: |
if ($Env:PYTHON_ALLOW_CACHE -eq "true" -and (Test-Path -Path ${{ env.PYTHON_DIR_CACHE }})) {
$Env:PYTHONPATH = "${{ env.PYTHON_DIR_CACHE }}"
}
else {
python -m pip install requests rfc3987 pywin32 lxml
}
python PowerEditor\Test\xmlValidator\validator_xml.py
if ($LastExitCode -eq 0) {
Write-Output "`nAll XML files are valid.`n"
}
else {
Write-Output "`nSome XML files are invalid.`n"
$host.SetShouldExit($LastExitCode)
}
build_windows:
runs-on: windows-latest
needs: before_build
if: needs.before_build.outputs.result == '' || needs.before_build.outputs.result == 'ONEJOB'
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.before_build.outputs.matrix) }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Modify resource.h N++ version to avoid confusion
working-directory: PowerEditor\src\
run: |
$content = Get-Content -Path 'resource.h'
$newContent = $content -replace 'TEXT\(\"Notepad\+\+ v.*\"\)', 'TEXT("Notepad++ GH_BUILD")'
$newContent | Set-Content -Path 'resource.h'
- name: MSBuild of n++ exe
working-directory: PowerEditor\visual.net\
run: msbuild notepadPlus.sln /m /p:configuration="${{ matrix.build_configuration }}" /p:platform="${{ matrix.build_platform }}" /p:PlatformToolset="v143"
- name: Archive artifacts for x64 / Release
if: matrix.build_platform == 'x64' && matrix.build_configuration == 'Release'
uses: actions/upload-artifact@v4
with:
name: Notepad++.MSVC.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
path: PowerEditor\bin64\Notepad++.exe
- name: Archive artifacts for Win32 / Release
if: matrix.build_platform == 'Win32' && matrix.build_configuration == 'Release'
uses: actions/upload-artifact@v4
with:
name: Notepad++.MSVC.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
path: PowerEditor\bin\Notepad++.exe
- name: Archive artifacts for ARM64 / Release
if: matrix.build_platform == 'ARM64' && matrix.build_configuration == 'Release'
uses: actions/upload-artifact@v4
with:
name: Notepad++.MSVC.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
path: PowerEditor\binarm64\Notepad++.exe
- name: Archive artifacts for ARM64|x64 / Debug
if: (matrix.build_platform == 'ARM64' || matrix.build_platform == 'x64') && matrix.build_configuration == 'Debug'
uses: actions/upload-artifact@v4
with:
name: Notepad++.MSVC.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
path: PowerEditor\visual.net\${{ matrix.build_platform}}\${{ matrix.build_configuration}}\Notepad++.exe
- name: Archive artifacts for Win32 / Debug
if: matrix.build_platform == 'Win32' && matrix.build_configuration == 'Debug'
uses: actions/upload-artifact@v4
with:
name: Notepad++.MSVC.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
path: PowerEditor\visual.net\${{ matrix.build_configuration}}\Notepad++.exe
- name: (cache) Restore Python modules for Win32 / Debug
if: matrix.build_platform == 'Win32' && matrix.build_configuration == 'Debug' && env.PYTHON_ALLOW_CACHE == 'true' && contains(needs.before_build.outputs.title, '[force nopythoncache]') != true
uses: actions/cache/restore@v4
with:
path: ${{ env.PYTHON_DIR_CACHE }}
key: ${{ needs.before_build.outputs.python }}
- name: Run xml validation test for Win32 / Debug only
if: matrix.build_platform == 'Win32' && matrix.build_configuration == 'Debug'
working-directory: .\
run: |
if ($Env:PYTHON_ALLOW_CACHE -eq "true" -and $${{ !contains(needs.before_build.outputs.title, '[force nopythoncache]') }} -and (Test-Path -Path ${{ env.PYTHON_DIR_CACHE }})) {
$Env:PYTHONPATH = "${{ env.PYTHON_DIR_CACHE }}"
}
else {
python -m pip install requests rfc3987 pywin32 lxml
}
python PowerEditor\Test\xmlValidator\validator_xml.py
- name: Run FunctionList and UrlDetection Tests for Win32 / Debug only
if: matrix.build_platform == 'Win32' && matrix.build_configuration == 'Debug'
working-directory: .\
run: |
Copy-Item "PowerEditor\visual.net\Debug\Notepad++.exe" -Destination "PowerEditor\bin"
Copy-Item "PowerEditor\src\langs.model.xml" -Destination "PowerEditor\bin"
Copy-Item "PowerEditor\src\stylers.model.xml" -Destination "PowerEditor\bin"
Copy-Item "PowerEditor\src\shortcuts.xml" -Destination "PowerEditor\bin"
Copy-Item "PowerEditor\src\contextMenu.xml" -Destination "PowerEditor\bin"
Copy-Item "PowerEditor\installer\functionList" -Destination "PowerEditor\bin" -Recurse
Copy-Item "PowerEditor\installer\filesForTesting\regexGlobalTest.xml" -Destination "PowerEditor\bin\functionList"
Copy-Item "PowerEditor\installer\filesForTesting\overrideMap.xml" -Destination "PowerEditor\bin\functionList"
cd .\PowerEditor\Test\FunctionList\
.\unitTestLauncher.ps1
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
cd ..\UrlDetection
.\verifyUrlDetection.ps1
# build_windows_clang:
# runs-on: windows-latest
#needs: before_build
#if: needs.before_build.outputs.result == ''
# strategy:
# matrix:
# build_configuration: [Release]
# build_platform: [x64]
# steps:
# - name: Checkout repo
# uses: actions/checkout@v4
# - name: Add msbuild to PATH
# uses: microsoft/setup-msbuild@v2
# - name: Modify resource.h N++ version to avoid confusion
# working-directory: PowerEditor\src\
# run: |
# $content = Get-Content -Path 'resource.h'
# $newContent = $content -replace 'TEXT\(\"Notepad\+\+ v.*\"\)', 'TEXT("Notepad++ GH_BUILD")'
# $newContent | Set-Content -Path 'resource.h'
# - name: MSBuild of n++ exe
# working-directory: PowerEditor\visual.net\
# run: msbuild notepadPlus.sln /m /p:configuration="${{ matrix.build_configuration }}" /p:platform="${{ matrix.build_platform }}" /p:PlatformToolset="ClangCL"
build_windows_cmake:
runs-on: windows-latest
needs: before_build
if: needs.before_build.outputs.result == ''
strategy:
matrix:
include:
- build_configuration: Release
build_platform: x64
arch: amd64
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Modify resource.h N++ version to avoid confusion
working-directory: PowerEditor\src\
run: |
$content = Get-Content -Path 'resource.h'
$newContent = $content -replace 'TEXT\(\"Notepad\+\+ v.*\"\)', 'TEXT("Notepad++ GH_BUILD")'
$newContent | Set-Content -Path 'resource.h'
- name: Add nmake to PATH
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: build scintilla
working-directory: scintilla/win32/
run: |
nmake -f scintilla.mak
- name: build lexilla
working-directory: lexilla/src/
run: |
nmake -f lexilla.mak
- name: generate cmake
working-directory: PowerEditor/src
run: |
mkdir _build
cd _build
cmake -G "Visual Studio 17 2022" -A ${{ matrix.build_platform }} -T "v143" ..
- name: build cmake
working-directory: PowerEditor/src
run: |
cd _build
cmake --build . --config ${{ matrix.build_configuration }}
build_windows_msys2:
runs-on: windows-latest
needs: before_build
if: needs.before_build.outputs.result == ''
strategy:
fail-fast: false
matrix:
build_configuration: [Release, Debug]
build_platform: [x86_64, i686]
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Modify resource.h N++ version to avoid confusion
working-directory: PowerEditor\src\
shell: pwsh
run: |
$content = Get-Content -Path 'resource.h'
$newContent = $content -replace 'TEXT\(\"Notepad\+\+ v.*\"\)', 'TEXT("Notepad++ GH_BUILD")'
$newContent | Set-Content -Path 'resource.h'
- name: Make n++ exe
working-directory: .\
run: |
Write-host "${{ matrix.build_platform }}"
Write-host "${{ matrix.build_configuration }}"
$Env:Path = 'C:\msys64\usr\bin' + [IO.Path]::PathSeparator + $Env:Path
if ( $${{ matrix.build_platform == 'i686'}} ) {$Env:MSYSTEM = 'MINGW32'}
if ( $${{ matrix.build_platform == 'i686'}} ) {$Env:Path = 'C:\msys64\mingw32\bin' + [IO.Path]::PathSeparator + $Env:Path}
if ( $${{ matrix.build_platform == 'x86_64'}} ) {$Env:MSYSTEM = 'MINGW64'}
if ( $${{ matrix.build_platform == 'x86_64'}} ) {$Env:Path = 'C:\msys64\mingw64\bin' + [IO.Path]::PathSeparator + $Env:Path}
if ( $${{ matrix.build_configuration == 'Debug'}} ) {$Env:DEBUG = '1'}
bash -lc "pacman --noconfirm -Syuu"
bash -lc "pacman --noconfirm -Syuu"
if ( $${{ matrix.build_platform == 'i686'}} ) {bash -lc "pacman --noconfirm -S mingw-w64-i686-gcc mingw-w64-i686-make"}
if ( $${{ matrix.build_platform == 'x86_64'}} ) {bash -lc "pacman --noconfirm -S mingw-w64-x86_64-gcc mingw-w64-x86_64-make"}
Write-Output "Tools version:"
Write-Output (((gcc --version) | select-object -first 1) + " " + (gcc -dumpmachine))
Write-Output (mingw32-make --version) | select-object -first 1
Write-Output (sh --version) | select-object -first 1
mingw32-make -f PowerEditor\gcc\makefile
- name: Archive artifacts for ${{ matrix.build_platform}} / Release
if: matrix.build_configuration == 'Release'
uses: actions/upload-artifact@v4
with:
name: Notepad++.GCC.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
path: bin.${{ matrix.build_platform}}\notepad++.exe
- name: Archive artifacts for ${{ matrix.build_platform}} / Debug
if: matrix.build_configuration == 'Debug'
uses: actions/upload-artifact@v4
with:
name: Notepad++.GCC.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
path: bin.${{ matrix.build_platform}}-debug\notepad++.exe