File tree Expand file tree Collapse file tree 3 files changed +87
-0
lines changed Expand file tree Collapse file tree 3 files changed +87
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Check TypeScript Configuration
2
+
3
+ env :
4
+ # See: https://github.com/actions/setup-node/#readme
5
+ NODE_VERSION : 16.x
6
+
7
+ # See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
8
+ on :
9
+ push :
10
+ paths :
11
+ - " .github/workflows/check-tsconfig-task.ya?ml"
12
+ - " **/tsconfig*.json"
13
+ - " Taskfile.ya?ml"
14
+ pull_request :
15
+ paths :
16
+ - " .github/workflows/check-tsconfig-task.ya?ml"
17
+ - " **/tsconfig*.json"
18
+ - " Taskfile.ya?ml"
19
+ schedule :
20
+ # Run every Tuesday at 8 AM UTC to catch breakage from changes to the JSON schema.
21
+ - cron : " 0 8 * * TUE"
22
+ workflow_dispatch :
23
+ repository_dispatch :
24
+
25
+ jobs :
26
+ validate :
27
+ runs-on : ubuntu-latest
28
+
29
+ strategy :
30
+ fail-fast : false
31
+
32
+ matrix :
33
+ file :
34
+ - ./tsconfig.json
35
+
36
+ steps :
37
+ - name : Checkout repository
38
+ uses : actions/checkout@v3
39
+
40
+ - name : Setup Node.js
41
+ uses : actions/setup-node@v3
42
+ with :
43
+ node-version : ${{ env.NODE_VERSION }}
44
+
45
+ - name : Install Task
46
+ uses : arduino/setup-task@v1
47
+ with :
48
+ repo-token : ${{ secrets.GITHUB_TOKEN }}
49
+ version : 3.x
50
+
51
+ - name : Validate ${{ matrix.file }}
52
+ env :
53
+ TSCONFIG_PATH : ${{ matrix.file }}
54
+ run : task --silent ts:validate
Original file line number Diff line number Diff line change 8
8
[ ![ Check Taskfiles status] ( https://github.com/arduino/setup-protoc/actions/workflows/check-taskfiles.yml/badge.svg )] ( https://github.com/arduino/setup-protoc/actions/workflows/check-taskfiles.yml )
9
9
[ ![ Integration Tests status] ( https://github.com/arduino/setup-protoc/actions/workflows/test-integration.yml/badge.svg )] ( https://github.com/arduino/setup-protoc/actions/workflows/test-integration.yml )
10
10
[ ![ Check npm status] ( https://github.com/arduino/setup-protoc/actions/workflows/check-npm-task.yml/badge.svg )] ( https://github.com/arduino/setup-protoc/actions/workflows/check-npm-task.yml )
11
+ [ ![ Check tsconfig status] ( https://github.com/arduino/setup-protoc/actions/workflows/check-tsconfig-task.yml/badge.svg )] ( https://github.com/arduino/setup-protoc/actions/workflows/check-tsconfig-task.yml )
11
12
12
13
This action makes the ` protoc ` compiler available to Workflows.
13
14
Original file line number Diff line number Diff line change @@ -194,6 +194,38 @@ tasks:
194
194
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
195
195
-d "{{.PROJECT_FOLDER}}/{{.INSTANCE_PATH}}"
196
196
197
+ ts:validate :
198
+ desc : Validate TypeScript configuration file against its JSON schema
199
+ vars :
200
+ # Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/tsconfig.json
201
+ SCHEMA_URL : https://json.schemastore.org/tsconfig.json
202
+ SCHEMA_PATH :
203
+ sh : task utility:mktemp-file TEMPLATE="tsconfig-schema-XXXXXXXXXX.json"
204
+ INSTANCE_PATH : ' {{default "./tsconfig.json" .TSCONFIG_PATH}}'
205
+ WORKING_FOLDER :
206
+ sh : task utility:mktemp-folder TEMPLATE="ts-validate-XXXXXXXXXX"
207
+ WORKING_INSTANCE_PATH :
208
+ sh : echo "{{.WORKING_FOLDER}}/$(basename "{{.INSTANCE_PATH}}")"
209
+ cmds :
210
+ - |
211
+ # TypeScript allows comments in tsconfig.json.
212
+ # ajv-cli did not support comments in JSON at the 3.x version in use (support was added in a later version).
213
+ npx strip-json-comments-cli \
214
+ --no-whitespace \
215
+ "{{.INSTANCE_PATH}}" \
216
+ > "{{.WORKING_INSTANCE_PATH}}"
217
+ - |
218
+ wget \
219
+ --quiet \
220
+ --output-document="{{.SCHEMA_PATH}}" \
221
+ {{.SCHEMA_URL}}
222
+ - |
223
+ cd "{{.WORKING_FOLDER}}" # Workaround for https://github.com/npm/cli/issues/3210
224
+ npx ajv-cli@{{.SCHEMA_DRAFT_4_AJV_CLI_VERSION}} validate \
225
+ --all-errors \
226
+ -s "{{.SCHEMA_PATH}}" \
227
+ -d "{{.WORKING_INSTANCE_PATH}}"
228
+
197
229
# Make a temporary file named according to the passed TEMPLATE variable and print the path passed to stdout
198
230
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml
199
231
utility:mktemp-file :
You can’t perform that action at this time.
0 commit comments