Skip to content

Commit 32b77a5

Browse files
committed
ci: switch schema-sync workflow to use main branch
1 parent 6c0aa03 commit 32b77a5

2 files changed

Lines changed: 149 additions & 59 deletions

File tree

.github/workflows/schema-sync.yml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,44 @@ on:
66
workflow_dispatch:
77

88
jobs:
9-
schema-sync:
10-
uses: scanoss/scanoss-devops/.github/workflows/schema-sync-check.yml@feat/SP-4166/schema-sync-ci
11-
with:
12-
source-file: scanoss-settings-schema.json
13-
target-file: src/scanoss/data/scanoss-settings-schema.json
9+
check-schema-sync:
10+
name: Check Schema Sync
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout consumer repo
14+
uses: actions/checkout@v4
15+
16+
- name: Checkout schema repo
17+
uses: actions/checkout@v4
18+
with:
19+
repository: scanoss/schema
20+
ref: main
21+
path: .schema-source
22+
23+
- name: Compare schemas
24+
id: compare
25+
shell: bash
26+
run: |
27+
source_path=".schema-source/scanoss-settings-schema.json"
28+
target_path="src/scanoss/data/scanoss-settings-schema.json"
29+
30+
if [ ! -f "$source_path" ]; then
31+
echo "::error::Source schema not found in scanoss/schema@main"
32+
exit 1
33+
fi
34+
35+
if [ ! -f "$target_path" ]; then
36+
echo "::error::Local vendored schema not found: $target_path"
37+
exit 1
38+
fi
39+
40+
if diff -u "$source_path" "$target_path"; then
41+
echo "Schema is in sync."
42+
else
43+
echo ""
44+
echo "::error::Schema out of sync: $target_path"
45+
echo ""
46+
echo "To fix, run:"
47+
echo " curl -sL https://raw.githubusercontent.com/scanoss/schema/main/scanoss-settings-schema.json -o $target_path"
48+
exit 1
49+
fi

src/scanoss/data/scanoss-settings-schema.json

Lines changed: 108 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"properties": {
3535
"scanning": {
3636
"type": "array",
37-
"description": "List of glob patterns to skip files from scanning",
37+
"description": "List of glob patterns (gitignore format) to exclude files from scanning. Patterns are matched relative to the scan root directory.\n\n- A trailing `/` matches a directory\n- `*` matches anything except `/`\n- `**` matches zero or more directories\n- `[0-9]` matches character ranges\n- `?` matches a single character except `/`\n- Leading `!` negates a pattern",
3838
"items": {
3939
"type": "string",
4040
"examples": [
@@ -44,14 +44,17 @@
4444
"path/to/file.c",
4545
"path/to/another/file.py",
4646
"**/*.ts",
47-
"**/*.json"
47+
"**/*.json",
48+
"!important.log",
49+
"temp/",
50+
"debug[0-9]*.txt"
4851
]
4952
},
5053
"uniqueItems": true
5154
},
5255
"fingerprinting": {
5356
"type": "array",
54-
"description": "List of glob patterns to skip files from fingerprinting",
57+
"description": "List of glob patterns (gitignore format) to exclude files from fingerprinting. Patterns are matched relative to the scan root directory.\n\n- A trailing `/` matches a directory\n- `*` matches anything except `/`\n- `**` matches zero or more directories\n- `[0-9]` matches character ranges\n- `?` matches a single character except `/`\n- Leading `!` negates a pattern",
5558
"items": {
5659
"type": "string",
5760
"examples": [
@@ -61,20 +64,10 @@
6164
"path/to/file.c",
6265
"path/to/another/file.py",
6366
"**/*.ts",
64-
"**/*.json"
65-
]
66-
},
67-
"uniqueItems": true
68-
},
69-
"dependencies": {
70-
"type": "array",
71-
"description": "List of glob patterns to skip dependency files from dependency analysis",
72-
"items": {
73-
"type": "string",
74-
"examples": [
75-
"vendor/**",
76-
"third_party/",
77-
"node_modules/**"
67+
"**/*.json",
68+
"!important.log",
69+
"temp/",
70+
"debug[0-9]*.txt"
7871
]
7972
},
8073
"uniqueItems": true
@@ -87,6 +80,7 @@
8780
"properties": {
8881
"scanning": {
8982
"type": "array",
83+
"description": "Rules for skipping files based on their size during scanning. Each rule combines glob patterns with min/max byte thresholds.",
9084
"items": {
9185
"type": "object",
9286
"properties": {
@@ -115,28 +109,38 @@
115109
"description": "Maximum size of the file in bytes"
116110
}
117111
}
118-
}
112+
},
113+
"examples": [
114+
[
115+
{
116+
"patterns": ["*.log", "!important.log"],
117+
"min": 512,
118+
"max": 5242880
119+
}
120+
]
121+
]
119122
},
120123
"fingerprinting": {
121124
"type": "array",
125+
"description": "Rules for skipping files based on their size during fingerprinting. Each rule combines glob patterns with min/max byte thresholds.",
122126
"items": {
123127
"type": "object",
124128
"properties": {
125129
"patterns": {
126130
"type": "array",
127131
"description": "List of glob patterns to apply the min/max size rule",
128132
"items": {
129-
"type": "string"
130-
},
131-
"examples": [
132-
"path/to/folder",
133-
"path/to/folder/**",
134-
"path/to/folder/**/*",
135-
"path/to/file.c",
136-
"path/to/another/file.py",
137-
"**/*.ts",
138-
"**/*.json"
139-
]
133+
"type": "string",
134+
"examples": [
135+
"path/to/folder",
136+
"path/to/folder/**",
137+
"path/to/folder/**/*",
138+
"path/to/file.c",
139+
"path/to/another/file.py",
140+
"**/*.ts",
141+
"**/*.json"
142+
]
143+
}
140144
},
141145
"min": {
142146
"type": "integer",
@@ -147,7 +151,16 @@
147151
"description": "Maximum size of the file in bytes"
148152
}
149153
}
150-
}
154+
},
155+
"examples": [
156+
[
157+
{
158+
"patterns": ["temp/", "*.tmp"],
159+
"min": 512,
160+
"max": 5242880
161+
}
162+
]
163+
]
151164
}
152165
}
153166
}
@@ -177,7 +190,7 @@
177190
},
178191
"ignore_cert_errors": {
179192
"type": "boolean",
180-
"description": "Whether to ignore certificate errors"
193+
"description": "Whether to ignore TLS/SSL certificate errors. Intended for testing and development environments only; do not enable in production."
181194
}
182195
}
183196
},
@@ -188,7 +201,7 @@
188201
},
189202
"ranking_threshold": {
190203
"type": ["integer", "null"],
191-
"description": "Ranking threshold value. A value of -1 defers to server configuration",
204+
"description": "Ranking threshold for file snippet results (range 0\u201310). A value of `-1` defers to server configuration. Higher values require stronger matches.",
192205
"minimum": -1,
193206
"maximum": 10,
194207
"default": 0
@@ -207,7 +220,7 @@
207220
},
208221
"honour_file_exts": {
209222
"type": ["boolean", "null"],
210-
"description": "Ignores file extensions. When not set, defers to server configuration.",
223+
"description": "When `true`, the server considers file extensions during matching (e.g. a `.c` file only matches other `.c` files). When `false`, file extensions are ignored. When `null`, defers to server configuration.",
211224
"default": true
212225
},
213226
"dependency_analysis": {
@@ -216,27 +229,27 @@
216229
},
217230
"skip_headers": {
218231
"type": "boolean",
219-
"description": "Skip license headers, comments and imports at the beginning of files",
232+
"description": "Skip license headers, comments, and imports at the beginning of files before snippet matching. Works together with `skip_headers_limit` to control how many leading lines are stripped.",
220233
"default": false
221234
},
222235
"skip_headers_limit": {
223236
"type": "integer",
224-
"description": "Maximum number of lines to skip when filtering headers",
237+
"description": "Maximum number of leading lines to strip when `skip_headers` is enabled. A value of `0` means no limit (strip all detected header lines).",
225238
"default": 0
226239
}
227240
}
228241
},
229242
"hpfm": {
230243
"type": "object",
231-
"description": "HPFM (High Precision Folder Matching) configuration",
244+
"description": "HPFM (High Precision Folder Matching) configuration. HPFM detects copied directory structures by comparing folder-level fingerprints.",
232245
"properties": {
233246
"ranking_enabled": {
234247
"type": "boolean",
235-
"description": "Enable ranking for HPFM"
248+
"description": "Enable ranking for HPFM results"
236249
},
237250
"ranking_threshold": {
238251
"type": ["integer", "null"],
239-
"description": "Ranking threshold value. A value of -1 defers to server configuration",
252+
"description": "Ranking threshold for HPFM results (range 0\u201399). Note: this range differs from `file_snippet.ranking_threshold` (0\u201310). A value of `-1` defers to server configuration. Higher values require stronger matches.",
240253
"minimum": -1,
241254
"maximum": 99,
242255
"default": 0
@@ -255,18 +268,18 @@
255268
"properties": {
256269
"include": {
257270
"type": "array",
258-
"description": "Set of rules to be added as context when scanning. This list will be sent as payload to the API.",
271+
"description": "Rules for adding components as scan context. Sent to the SCANOSS API to influence result matching. Requires purl; path is optional for partial matching.",
259272
"items": {
260273
"type": "object",
261274
"properties": {
262275
"path": {
263276
"type": "string",
264-
"description": "File or folder path. Paths ending with '/' are treated as folder rules and match all files under that directory.",
277+
"description": "File or folder path, relative to the scan root. Paths ending with `/` are treated as folder rules and match all files under that directory.",
265278
"examples": ["src/main.c", "src/vendor/"]
266279
},
267280
"purl": {
268281
"type": "string",
269-
"description": "Package URL to be used to match the component",
282+
"description": "Package URL identifying the component. Format: `pkg:<type>/<namespace>/<name>@<version>`. Version is recommended but optional.",
270283
"examples": [
271284
"pkg:npm/vue@2.6.12",
272285
"pkg:golang/github.com/golang/go@1.17.3"
@@ -279,22 +292,35 @@
279292
},
280293
"uniqueItems": true,
281294
"required": ["purl"]
282-
}
295+
},
296+
"examples": [
297+
[
298+
{
299+
"path": "src/lib/component.js",
300+
"purl": "pkg:npm/lodash@4.17.21",
301+
"comment": "Full match: path + purl"
302+
},
303+
{
304+
"purl": "pkg:npm/vue@2.6.12",
305+
"comment": "Partial match: purl only"
306+
}
307+
]
308+
]
283309
},
284310
"remove": {
285311
"type": "array",
286-
"description": "Set of rules that will remove files from the results file after the scan is completed.",
312+
"description": "Rules for removing components from results after scanning (client-side post-processing). Supports full match (both path and purl) or partial match (path only or purl only).",
287313
"items": {
288314
"type": "object",
289315
"properties": {
290316
"path": {
291317
"type": "string",
292-
"description": "File or folder path. Paths ending with '/' are treated as folder rules and match all files under that directory.",
318+
"description": "File or folder path, relative to the scan root. Paths ending with `/` are treated as folder rules and match all files under that directory.",
293319
"examples": ["src/main.c", "src/vendor/"]
294320
},
295321
"purl": {
296322
"type": "string",
297-
"description": "Package URL",
323+
"description": "Package URL identifying the component to remove. Format: `pkg:<type>/<namespace>/<name>@<version>`. Version is recommended but optional.",
298324
"examples": [
299325
"pkg:npm/vue@2.6.12",
300326
"pkg:golang/github.com/golang/go@1.17.3"
@@ -310,22 +336,39 @@
310336
{"required": ["path"]}
311337
],
312338
"uniqueItems": true
313-
}
339+
},
340+
"examples": [
341+
[
342+
{
343+
"path": "src/main.c",
344+
"purl": "pkg:npm/vue@2.6.12",
345+
"comment": "Full match: removes only this purl at this path"
346+
},
347+
{
348+
"purl": "pkg:npm/deprecated-pkg@1.0.0",
349+
"comment": "Partial match: removes this purl wherever it appears"
350+
},
351+
{
352+
"path": "src/vendor/",
353+
"comment": "Partial match: removes all results under this folder"
354+
}
355+
]
356+
]
314357
},
315358
"replace": {
316359
"type": "array",
317-
"description": "Set of rules that will replace components with the specified one after the scan is completed.",
360+
"description": "Rules for replacing components in results after scanning (client-side post-processing). Requires both purl (original component) and replace_with (replacement). Path is optional for scoping.",
318361
"items": {
319362
"type": "object",
320363
"properties": {
321364
"path": {
322365
"type": "string",
323-
"description": "File or folder path. Paths ending with '/' are treated as folder rules and match all files under that directory.",
366+
"description": "File or folder path, relative to the scan root. Paths ending with `/` are treated as folder rules and match all files under that directory.",
324367
"examples": ["src/main.c", "src/vendor/"]
325368
},
326369
"purl": {
327370
"type": "string",
328-
"description": "Package URL to replace",
371+
"description": "Package URL of the original component to replace. Format: `pkg:<type>/<namespace>/<name>@<version>`. Version is recommended but optional.",
329372
"examples": [
330373
"pkg:npm/vue@2.6.12",
331374
"pkg:golang/github.com/golang/go@1.17.3"
@@ -337,21 +380,32 @@
337380
},
338381
"license": {
339382
"type": "string",
340-
"description": "License of the component. Should be a valid SPDX license expression",
383+
"description": "License of the replacement component. Should be a valid SPDX license expression (e.g. `MIT`, `Apache-2.0`, `GPL-3.0-only`).",
341384
"examples": ["MIT", "Apache-2.0"]
342385
},
343386
"replace_with": {
344387
"type": "string",
345-
"description": "Package URL to replace with",
388+
"description": "The replacement Package URL. Format: `pkg:<type>/<namespace>/<name>@<version>`.",
346389
"examples": [
347-
"pkg:npm/vue@2.6.12",
348-
"pkg:golang/github.com/golang/go@1.17.3"
390+
"pkg:npm/vue@2.6.14",
391+
"pkg:npm/new-lib@2.0.0"
349392
]
350393
}
351394
},
352395
"uniqueItems": true,
353396
"required": ["purl", "replace_with"]
354-
}
397+
},
398+
"examples": [
399+
[
400+
{
401+
"path": "src/utils/helper.js",
402+
"purl": "pkg:npm/old-lib@1.0.0",
403+
"replace_with": "pkg:npm/new-lib@2.0.0",
404+
"license": "MIT",
405+
"comment": "Upgrade to newer version"
406+
}
407+
]
408+
]
355409
}
356410
}
357411
}

0 commit comments

Comments
 (0)