-
Notifications
You must be signed in to change notification settings - Fork 440
141 lines (125 loc) Β· 5.37 KB
/
CI_build.yml
File metadata and controls
141 lines (125 loc) Β· 5.37 KB
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
name: CI_build
on:
# was [push, pull_request, workflow_dispatch]
# separated because want to add schedule, which needs a
# normal conditions
push:
pull_request:
# on demand, from Actions tab
workflow_dispatch:
# on schedule (using cron syntax)
# 16:00 UTC (8:00am PST) on 6=Saturday
schedule:
- cron: "0 16 * * 6"
jobs:
validate:
runs-on: windows-latest
steps:
- name: π Checkout repo
uses: actions/checkout@v6
- name: π‘ Set up Python 3.13
uses: actions/setup-python@v6
with:
python-version: '3.13' # Uses the latest patch version of the given
- name: π‘ Install python modules
working-directory: .
run: python -m pip install -r requirements.txt
- name: π Validate folders of XML types (UDLs, autoCompletion, functionList)
working-directory: .
run: python .validators\validator_xml.py
- name: π Validate json and rebuild udl-list.md
working-directory: .
run: python .validators\validator_json.py --output-md
- name: π¨ Generate autoCompletion for all UDLs that don't already have one, and revalidate (primary repo + branch only)
working-directory: .
if: ${{ contains('push workflow_dispatch', github.event_name) && github.ref == 'refs/heads/master' && github.repository == 'notepad-plus-plus/userDefinedLanguages' }}
run: |
python .validators\generate_ac.py
# since AC XML may have been added, re-validate XML
python .validators\validator_xml.py
# since AC may have been added to JSON, need to revalidate JSON and re-generate md
python .validators\validator_json.py --output-md
- name: β
Sort JSON
working-directory: .
if: ${{ contains('push workflow_dispatch', github.event_name) && github.ref == 'refs/heads/master' && github.repository == 'notepad-plus-plus/userDefinedLanguages' }}
run: |
# sort JSON back into string
$file = "udl-list.json"
$a = Get-Content $file | ConvertFrom-Json
$a.'UDLs' = $a.'UDLs' | sort -Property 'id-name'
$content = $a | ConvertTo-Json -Depth 5
#
# reformat JSON
$content = $content -replace ': ', ": "
$content = $content -replace ' ', " "
$content = $content -replace ' ', " "
$content = $content -replace ' ', " "
#
# save sorted JSON text
$content > $file
- name: π Update repo with automated changes for the UDL list and autoCompletions
uses: stefanzweifel/git-auto-commit-action@v7
if: contains('push workflow_dispatch', github.event_name)
with:
commit_message: Automatically re-build udl-list.md and add new autoCompletions
unitTest:
name: FunctionList Unit Tests
runs-on: windows-latest
needs: validate
steps:
- name: π Checkout repo
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: π Check for Changes in functionList Files
id: get_changes
working-directory: .
run: |
# start assuming no changed FL files
$any_changed = $false
#
# validate event IDs before passing them to git diff:
git rev-parse --quiet --verify "${{ github.event.before }}^{commit}" >$null 2>&1
$invalid1 = $LASTEXITCODE -ne 0
git rev-parse --quiet --verify "${{ github.event.after }}^{commit}" >$null 2>&1
$invalid2 = $LASTEXITCODE -ne 0
# grab the changes
if("${{ github.event_name }}" -eq "workflow_dispatch" -or
"${{ github.event.before }}" -eq "0000000000000000000000000000000000000000" -or
"${{ github.event.after }}" -eq "0000000000000000000000000000000000000000" -or
$invalid1 -or $invalid2 ) {
#Write-Output "non-push or invalid object: use HEAD~1..HEAD, which isn't as specific, but better than nothing"
$changed_files = @( git diff --name-only HEAD~1..HEAD )
} else {
#Write-Output "for-push: use before/after"
$changed_files = @( git diff --name-only ${{ github.event.before }} ${{ github.event.after }} )
}
#
# check if each file is in functionList/ directory
foreach ($this_file in $changed_files) {
#Write-Output "the following is different: $this_file"
if ($this_file.Contains("functionList/")) {
Write-Output "+ Saw FunctionList changes in: $this_file"
$any_changed = $true
}
}
#
# set the output
if ($any_changed) {
echo "is_fl_changed=True" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
}
- name: π¦ Install Notepad++
if: ${{ steps.get_changes.outputs.is_fl_changed }}
uses: crazy-max/ghaction-chocolatey@v4
with:
args: install -y notepadplusplus
- name: π Run FunctionList Unit Tests
if: ${{ steps.get_changes.outputs.is_fl_changed }}
working-directory: .\Test
run: |
$PowerEditorSource = "C:\Program Files\Notepad++\"
$PowerEditorLocal = ".\PowerEditor"
Copy-Item "$PowerEditorSource" -Destination "$PowerEditorLocal\bin" -Recurse -Force
New-Item "$PowerEditorLocal\bin\doLocalConf.xml" > $nul
New-Item "$PowerEditorLocal\bin\userDefineLangs" -ItemType Directory -ea 0 > $nul
python doUnitTests.py $PowerEditorLocal\bin