-
Notifications
You must be signed in to change notification settings - Fork 9
167 lines (146 loc) · 7.06 KB
/
check-npm.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
name: Check npm
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/check-npm.ya?ml"
- "**/package.json"
- "**/package-lock.json"
pull_request:
paths:
- ".github/workflows/check-npm.ya?ml"
- "**/package.json"
- "**/package-lock.json"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:
permissions:
contents: read
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download JSON schema for package.json
id: download-schema
uses: carlosperate/download-file-action@v2
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/package.json
file-url: https://json.schemastore.org/package.json
location: ${{ runner.temp }}/json-schema
file-name: package-json-schema.json
# This schema is referenced by the package.json schema, so must also be accessible.
- name: Download JSON schema for ava.json
id: download-ava-schema
uses: carlosperate/download-file-action@v2
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/ava.json
file-url: https://json.schemastore.org/ava.json
location: ${{ runner.temp }}/json-schema
file-name: ava.json
# This schema is referenced by the package.json schema, so must also be accessible.
- name: Download base JSON schema
id: download-base-schema
uses: carlosperate/download-file-action@v2
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/base.json
file-url: https://json.schemastore.org/base.json
location: ${{ runner.temp }}/json-schema
file-name: base.json
# This schema is referenced by the package.json schema, so must also be accessible.
- name: Download JSON schema for eslintrc.json
id: download-eslintrc-schema
uses: carlosperate/download-file-action@v2
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/eslintrc.json
file-url: https://json.schemastore.org/eslintrc.json
location: ${{ runner.temp }}/json-schema
file-name: eslintrc-schema.json
# This schema is referenced by the package.json schema, so must also be accessible.
- name: Download JSON schema for jscpd configuration file
id: download-jscpd-schema
uses: carlosperate/download-file-action@v2
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/jscpd.json
file-url: https://json.schemastore.org/jscpd.json
location: ${{ runner.temp }}/json-schema
file-name: jscpd-schema.json
# This schema is referenced by the package.json schema, so must also be accessible.
- name: Download JSON schema for Prettier configuration file
id: download-npm-badges-schema
uses: carlosperate/download-file-action@v2
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/npm-badges.json
file-url: https://json.schemastore.org/npm-badges.json
location: ${{ runner.temp }}/json-schema
file-name: npm-badges-schema.json
# This schema is referenced by the package.json schema, so must also be accessible.
- name: Download JSON schema for ESLint plugins
id: download-partial-eslint-plugins-schema
uses: carlosperate/download-file-action@v2
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/partial-eslint-plugins.json
file-url: https://json.schemastore.org/partial-eslint-plugins.json
location: ${{ runner.temp }}/json-schema
file-name: partial-eslint-plugins.json
# This schema is referenced by the package.json schema, so must also be accessible.
- name: Download JSON schema for Prettier configuration file
id: download-prettierrc-schema
uses: carlosperate/download-file-action@v2
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/prettierrc.json
file-url: https://json.schemastore.org/prettierrc.json
location: ${{ runner.temp }}/json-schema
file-name: prettierrc-schema.json
# This schema is referenced by the package.json schema, so must also be accessible.
- name: Download JSON schema for semantic-release
id: download-semantic-release-schema
uses: carlosperate/download-file-action@v2
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/semantic-release.json
file-url: https://json.schemastore.org/semantic-release.json
location: ${{ runner.temp }}/json-schema
file-name: semantic-release-schema.json
# This schema is referenced by the package.json schema, so must also be accessible.
- name: Download JSON schema for .stylelintrc
id: download-stylelintrc-schema
uses: carlosperate/download-file-action@v2
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/stylelintrc.json
file-url: https://json.schemastore.org/stylelintrc.json
location: ${{ runner.temp }}/json-schema
file-name: stylelintrc-schema.json
- name: Install JSON schema validator
# package.json schema is draft-04, which is not supported by ajv-cli >=4.
run: sudo npm install --global [email protected]
- name: Validate package.json
run: |
# See: https://github.com/ajv-validator/ajv-cli#readme
ajv validate \
-s "${{ steps.download-schema.outputs.file-path }}" \
-r "${{ steps.download-ava-schema.outputs.file-path }}" \
-r "${{ steps.download-base-schema.outputs.file-path }}" \
-r "${{ steps.download-eslintrc-schema.outputs.file-path }}" \
-r "${{ steps.download-jscpd-schema.outputs.file-path }}" \
-r "${{ steps.download-npm-badges-schema.outputs.file-path }}" \
-r "${{ steps.download-partial-eslint-plugins-schema.outputs.file-path }}" \
-r "${{ steps.download-prettierrc-schema.outputs.file-path }}" \
-r "${{ steps.download-semantic-release-schema.outputs.file-path }}" \
-r "${{ steps.download-stylelintrc-schema.outputs.file-path }}" \
-d "./**/package.json"
check-sync:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: package.json
- name: Install dependencies
run: npm install
- name: Check package-lock.json
run: git diff --color --exit-code package-lock.json