-
Notifications
You must be signed in to change notification settings - Fork 9
/
action.yml
212 lines (194 loc) · 10 KB
/
action.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
# This file needs to be present in this exact folder for the workflow using this action to be able to work with submodules.
name: Spelling
description: Checks for spelling errors in files.
# When updating defaults here also update them in the `spelling` workflow.
inputs:
merge-file-excludes:
description: >
When set to "true", the "excludes.txt" file's contents in Lombiq.GitHub.Actions will be merged into the one in the
workspace repository.
required: false
default: 'true'
merge-forbidden-patterns:
description: >
When set to "true", the "line_forbidden.patterns" file's contents in Lombiq.GitHub.Actions will be merged into the
one in the workspace repository.
required: false
default: 'true'
merge-ignore-patterns:
description: >
When set to "true", the "patterns.txt" file's contents in Lombiq.GitHub.Actions will be merged into the one in the
workspace repository.
required: false
default: 'true'
default-dictionaries:
description: Space delimited list of URLs (or `prefix:`+path) to additional word lists
required: false
default: |
cspell:filetypes/filetypes.txt
cspell:software-terms/dict/softwareTerms.txt
lombiq-lgha:dictionaries/Lombiq.common.txt
additional-configuration-source-prefixes:
description: >
JSON map of prefixes for configuration file (for now, only dictionary) URLs.
required: false
additional-dictionaries:
description: Space delimited list of URLs (or `prefix:`+path) to additional word lists
required: false
configuration-path:
description: Relative path to the spell-checking configuration folder.
required: false
default: .github/actions/spelling
default-configuration-repository:
description: >
Repository with default configuration to use when the workspace repository doesn't have its own configuration. The
default from Check Spelling is ''.
required: false
default: Lombiq/GitHub-Actions@dev
post-comment:
description: Flag for if check-spelling should post comment, the default is 1.
required: false
default: '1'
task:
description: Follow up task for check-spelling, the default is ''.
required: false
default: ''
outputs:
followup:
description: Check Spelling output for followup.
value: ${{ steps.step-check-spelling.outputs.followup }}
runs:
using: composite
steps:
- name: Setup Scripts
shell: pwsh
run: |
'${{ github.action_path }}' >> $Env:GITHUB_PATH
(Resolve-Path '${{ github.action_path }}/../../../Scripts').Path >> $Env:GITHUB_PATH
# If the configuration path doesn't exist in the workspace, then it means that the workspace repository doesn't have
# its own spell-checking configuration. In that case we don't need to copy anything, because the configuration files
# will be used implicitly according to the value of default-configuration-repository.
- name: Check configuration path
id: check-configuration-path
shell: pwsh
run: |
Set-GitHubOutput -Key 'configuration-path-exists' -Value (Test-Path (Join-Path "$Env:GITHUB_WORKSPACE" '${{ inputs.configuration-path }}'))
- name: Copy spell-checking advice
if: steps.check-configuration-path.outputs.configuration-path-exists == 'true'
shell: pwsh
run: |
$targetPath = Join-Path "$Env:GITHUB_WORKSPACE" '${{ inputs.configuration-path }}' 'advice.md'
if (-not (Test-Path $targetPath))
{
Copy-Item (Join-Path '${{ github.action_path }}' 'advice.md') $targetPath
}
- name: Merge "excludes.txt"
if: inputs.merge-file-excludes == 'true' && steps.check-configuration-path.outputs.configuration-path-exists == 'true'
shell: pwsh
run: |
$mergeParameters = @{
Source = Join-Path '${{ github.action_path }}' 'excludes.txt'
Target = Join-Path "$Env:GITHUB_WORKSPACE" '${{ inputs.configuration-path }}' 'excludes.txt'
}
Merge-SpellCheckingDictionaryFile @mergeParameters
- name: Merge "line_forbidden.patterns"
if: inputs.merge-forbidden-patterns == 'true' && steps.check-configuration-path.outputs.configuration-path-exists == 'true'
shell: pwsh
run: |
$mergeParameters = @{
Source = Join-Path '${{ github.action_path }}' 'line_forbidden.patterns'
Target = Join-Path "$Env:GITHUB_WORKSPACE" '${{ inputs.configuration-path }}' 'line_forbidden.patterns'
}
Merge-SpellCheckingDictionaryFile @mergeParameters
- name: Merge "patterns.txt"
if: inputs.merge-ignore-patterns == 'true' && steps.check-configuration-path.outputs.configuration-path-exists == 'true'
shell: pwsh
run: |
$mergeParameters = @{
Source = Join-Path '${{ github.action_path }}' 'patterns.txt'
Target = Join-Path "$Env:GITHUB_WORKSPACE" '${{ inputs.configuration-path }}' 'patterns.txt'
}
Merge-SpellCheckingDictionaryFile @mergeParameters
# The branch name in the 'lombiq-lgha' prefix needs to be wired in to 'dev' (since that's the default branch of this
# repository) and updated manually when working in a different branch, because the referenced branch name (when
# called from a workflow) of this action is not exposed by GitHub, only the branch name of the workflow that
# triggered the run, see https://docs.github.com/en/actions/learn-github-actions/contexts.
- name: Merge configuration source prefixes
id: merge-configuration-source-prefixes
shell: pwsh
run: |
$defaultPrefixes = @{
'lombiq-lgha' = 'https://raw.githubusercontent.com/Lombiq/GitHub-Actions/dev/.github/actions/spelling/'
'cspell' = 'https://raw.githubusercontent.com/check-spelling/cspell-dicts/v20230509/dictionaries/'
}
$additionalPrefixesInput = '${{ inputs.additional-configuration-source-prefixes }}'
$additionalPrefixes = [string]::IsNullOrWhiteSpace($additionalPrefixesInput) ? @{} : (ConvertFrom-Json $additionalPrefixesInput -AsHashtable)
$defaultPrefixes.Keys |
Where-Object { -not $additionalPrefixes.ContainsKey($PSItem) } |
ForEach-Object { $additionalPrefixes[$PSItem] = $defaultPrefixes[$PSItem] }
Set-GitHubOutput -Key 'merged-prefixes' -Value (ConvertTo-Json $additionalPrefixes -Compress)
- name: Merge dictionary lists
id: merge-dictionary-lists
shell: pwsh
run: |
$defaultDictionaries = ConvertFrom-MultiLineStringToStringArray -Lines '${{ inputs.default-dictionaries }}'
$additionalDictionaries = ConvertFrom-MultiLineStringToStringArray -Lines '${{ inputs.additional-dictionaries }}'
Set-GitHubOutput -Key 'merged-dictionary-list' -Value `
((@($additionalDictionaries) + @($defaultDictionaries) | `
Select-Object -Unique) -join ' ')
- name: Check Spelling
id: step-check-spelling
# When updating the check-spelling action to a new release, update the 'cspell' prefix in the "Merge configuration
# source prefixes" step with the dictionary version tag that belongs to the commit of the release. See
# https://github.com/check-spelling/check-spelling/blob/v0.0.22/action.yml#L67 for current version.
# Also update check_extra_dictionaries below as necessary.
uses: check-spelling/check-spelling@67debf50669c7fc76fc8f5d7f996384535a72b77 # v0.0.24
with:
check_file_names: 1
config: ${{ inputs.configuration-path }}
dictionary_source_prefixes: ${{ steps.merge-configuration-source-prefixes.outputs.merged-prefixes }}
experimental_apply_changes_via_bot: 0
extra_dictionaries: ${{ steps.merge-dictionary-lists.outputs.merged-dictionary-list }}
post_comment: ${{ inputs.post-comment }}
spell_check_this: ${{ inputs.default-configuration-repository }}
suppress_push_for_open_pull_request: 1
task: ${{ inputs.task }}
# While extra_dictionaries adds dictionaries that'll be used for spell-checking, the dictionaries under
# check_extra_dictionaries will only be used to provide hints for unrecognized words. You'll see this under the
# check-spelling report (PR comment and workflow run summary) along the lines of "Available dictionaries could
# cover words not in the dictionary". The values here are some of the default dictionaries that we think can
# most possibly be useful and ours. The default dictionaries are under
# https://github.com/check-spelling/cspell-dicts/tree/main/dictionaries. When updating the check-spelling action
# to a new release, consider updating this list too with new entries from
# https://github.com/check-spelling/check-spelling/blob/main/action.yml.
check_extra_dictionaries: |
cspell:aws/aws.txt
cspell:companies/src/companies.txt
cspell:cryptocurrencies/cryptocurrencies.txt
cspell:csharp/csharp.txt
cspell:css/dict/css.txt
cspell:docker/src/docker-words.txt
cspell:dotnet/dict/dotnet.txt
cspell:filetypes/filetypes.txt
cspell:fonts/fonts.txt
cspell:fullstack/dict/fullstack.txt
cspell:html-symbol-entities/entities.txt
cspell:html/dict/html.txt
cspell:html/src/svg.txt
cspell:lorem-ipsum/dictionary.txt
cspell:node/additional_words.txt
cspell:node/dict/node.txt
cspell:npm/dict/npm.txt
cspell:powershell/dict/powershell.txt
cspell:public-licenses/src/additional-licenses.txt
cspell:public-licenses/src/generated/public-licenses.txt
cspell:software-terms/dict/networkingTerms.txt
cspell:software-terms/dict/softwareTerms.txt
cspell:software-terms/dict/webServices.txt
cspell:sql/src/sql.txt
cspell:sql/src/tsql.txt
cspell:typescript/dict/typescript.txt
lombiq-lgha:dictionaries/Liquid.txt
lombiq-lgha:dictionaries/Lombiq.common.txt
lombiq-lgha:dictionaries/Lombiq.people.txt
lombiq-lgha:dictionaries/Security.txt