Skip to content

Commit d0cfac4

Browse files
authored
Merge pull request #34 from per1234/check-tsconfig
Add CI workflow to validate tsconfig.json files
2 parents 59da273 + 01b0129 commit d0cfac4

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

.github/workflows/check-npm.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
id: download-schema
3333
uses: carlosperate/[email protected]
3434
with:
35-
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
35+
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/package.json
3636
file-url: https://json.schemastore.org/package.json
3737
location: ${{ runner.temp }}/package-json-schema
3838
file-name: package-json-schema.json

.github/workflows/check-tsconfig.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Check TypeScript Configuration
2+
3+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
4+
on:
5+
push:
6+
paths:
7+
- ".github/workflows/check-tsconfig.yml"
8+
- "**/tsconfig*.json"
9+
pull_request:
10+
paths:
11+
- ".github/workflows/check-tsconfig.yml"
12+
- "**/tsconfig*.json"
13+
schedule:
14+
# Run every Tuesday at 8 AM UTC to catch breakage from changes to the JSON schema.
15+
- cron: "0 8 * * TUE"
16+
workflow_dispatch:
17+
repository_dispatch:
18+
19+
jobs:
20+
validate:
21+
runs-on: ubuntu-latest
22+
23+
strategy:
24+
fail-fast: false
25+
26+
matrix:
27+
file:
28+
- ./tsconfig.json
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v2
33+
34+
- name: Install strip-json-comments-cli
35+
run: sudo npm install --global strip-json-comments-cli
36+
37+
# TypeScript allows comments in tsconfig.json. So does ajv-cli, but it didn't back at the 3.x version in use.
38+
- name: Convert ${{ matrix.file }} to valid JSON
39+
id: convert
40+
run: |
41+
OUTPUT_FOLDER="${{ runner.temp }}/staging"
42+
mkdir -p "$OUTPUT_FOLDER"
43+
OUTPUT_PATH="${OUTPUT_FOLDER}/$(basename ${{ matrix.file }})"
44+
strip-json-comments --no-whitespace "${{ matrix.file }}" > "$OUTPUT_PATH"
45+
echo "::set-output name=output-path::$OUTPUT_PATH"
46+
47+
- name: Download JSON schema for tsconfig.json
48+
id: download-schema
49+
uses: carlosperate/[email protected]
50+
with:
51+
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/tsconfig.json
52+
file-url: https://json.schemastore.org/tsconfig.json
53+
location: ${{ runner.temp }}/tsconfig-json-schema
54+
file-name: tsconfig-json-schema.json
55+
56+
- name: Install JSON schema validator
57+
# tsconfig.json schema is draft-04, which is not supported by ajv-cli >=4.
58+
run: sudo npm install --global [email protected]
59+
60+
- name: Validate ${{ matrix.file }}
61+
# See: https://github.com/ajv-validator/ajv-cli#readme
62+
run: |
63+
ajv validate \
64+
-s "${{ steps.download-schema.outputs.file-path }}" \
65+
-d "${{ steps.convert.outputs.output-path }}"

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# `arduino/setup-taskfile`
22

33
[![Check TypeScript status](https://github.com/arduino/setup-taskfile/actions/workflows/check-typescript-task.yml/badge.svg)](https://github.com/arduino/setup-taskfile/actions/workflows/check-typescript-task.yml)
4+
[![Check TypeScript Configuration status](https://github.com/arduino/setup-taskfile/actions/workflows/check-tsconfig.yml/badge.svg)](https://github.com/arduino/setup-taskfile/actions/workflows/check-tsconfig.yml)
45
[![Integration Tests status](https://github.com/arduino/setup-taskfile/actions/workflows/test-integration.yml/badge.svg)](https://github.com/arduino/setup-taskfile/actions/workflows/test-integration.yml)
56
[![Check Action Metadata status](https://github.com/arduino/setup-taskfile/actions/workflows/check-action-metadata-task.yml/badge.svg)](https://github.com/arduino/setup-taskfile/actions/workflows/check-action-metadata-task.yml)
67
[![Spell Check status](https://github.com/arduino/setup-taskfile/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino/setup-taskfile/actions/workflows/spell-check.yml)

0 commit comments

Comments
 (0)