Skip to content

Commit cba4442

Browse files
authored
feat(schema): update schema and add script to do it (#1309)
1 parent d7e97dd commit cba4442

File tree

2 files changed

+119
-22
lines changed

2 files changed

+119
-22
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"test-except-dind": "npm run build && jest --testTimeout 60000 --testPathIgnorePatterns=dind",
2020
"coverage": "jest --coverage --testTimeout 60000",
2121
"start": "ts-node --log-error src/index.ts --cwd examples/docker-compose-nodejs",
22-
"dev": "touch .gitlab-ci.yml && nodemon -e ts --watch src --watch .gitlab-ci.yml --exec ts-node src/index.ts"
22+
"dev": "touch .gitlab-ci.yml && nodemon -e ts --watch src --watch .gitlab-ci.yml --exec ts-node src/index.ts",
23+
"fetch-and-patch-schema": "curl https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json -sf | jq 'del(.. | .pattern?)' > src/schema/schema.json"
2324
},
2425
"dependencies": {
2526
"ajv": "8.x.x",

src/schema/schema.json

Lines changed: 117 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
},
143143
{
144144
"type": "array",
145-
"minLength": 1,
145+
"minItems": 1,
146146
"items": {
147147
"type": "string"
148148
}
@@ -386,8 +386,7 @@
386386
{
387387
"description": "Will infer the method based on the value. E.g. `https://...` strings will be of type `include:remote`, and `/templates/...` or `templates/...` will be of type `include:local`.",
388388
"type": "string",
389-
"format": "uri-reference",
390-
"pattern": "^(https?://|/?.?-?(?!\\w+://)\\w).+\\.ya?ml$"
389+
"format": "uri-reference"
391390
},
392391
{
393392
"type": "object",
@@ -874,6 +873,49 @@
874873
}
875874
]
876875
},
876+
"steps": {
877+
"type": "array",
878+
"items": {
879+
"oneOf": [
880+
{
881+
"required": [
882+
"step"
883+
]
884+
},
885+
{
886+
"required": [
887+
"script"
888+
]
889+
}
890+
],
891+
"properties": {
892+
"name": {
893+
"type": "string",
894+
"description": "Unique identifier for this step."
895+
},
896+
"step": {
897+
"type": "string",
898+
"description": "Reference to the step to invoke."
899+
},
900+
"env": {
901+
"$ref": "#/definitions/globalVariables"
902+
},
903+
"inputs": {
904+
"$ref": "#/definitions/inputs"
905+
},
906+
"script": {
907+
"type": "string",
908+
"description": "Shell script to evaluate."
909+
}
910+
},
911+
"additionalProperties": false,
912+
"type": "object",
913+
"required": [
914+
"name"
915+
],
916+
"description": "A single step invocation."
917+
}
918+
},
877919
"optional_script": {
878920
"oneOf": [
879921
{
@@ -952,7 +994,7 @@
952994
},
953995
{
954996
"type": "array",
955-
"minLength": 1,
997+
"minItems": 1,
956998
"items": {
957999
"type": "string"
9581000
}
@@ -1004,7 +1046,7 @@
10041046
},
10051047
{
10061048
"type": "array",
1007-
"minLength": 1,
1049+
"minItems": 1,
10081050
"items": {
10091051
"type": "string"
10101052
}
@@ -1084,8 +1126,7 @@
10841126
"additionalProperties": false
10851127
}
10861128
]
1087-
},
1088-
"additionalProperties": false
1129+
}
10891130
}
10901131
},
10911132
"jobVariables": {
@@ -1115,8 +1156,7 @@
11151156
"additionalProperties": false
11161157
}
11171158
]
1118-
},
1119-
"additionalProperties": false
1159+
}
11201160
}
11211161
},
11221162
"rulesVariables": {
@@ -1129,8 +1169,7 @@
11291169
"number",
11301170
"string"
11311171
]
1132-
},
1133-
"additionalProperties": false
1172+
}
11341173
}
11351174
},
11361175
"if": {
@@ -1169,11 +1208,60 @@
11691208
]
11701209
},
11711210
"exists": {
1172-
"type": "array",
11731211
"markdownDescription": "Additional attributes will be provided to job if any of the provided paths matches an existing file in the repository. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#rulesexists).",
1174-
"items": {
1175-
"type": "string"
1176-
}
1212+
"anyOf": [
1213+
{
1214+
"type": "array",
1215+
"items": {
1216+
"type": "string"
1217+
}
1218+
},
1219+
{
1220+
"type": "object",
1221+
"additionalProperties": false,
1222+
"required": [
1223+
"paths"
1224+
],
1225+
"properties": {
1226+
"paths": {
1227+
"type": "array",
1228+
"description": "List of file paths.",
1229+
"items": {
1230+
"type": "string"
1231+
}
1232+
},
1233+
"project": {
1234+
"type": "string",
1235+
"description": "Path of the project to search in."
1236+
}
1237+
}
1238+
},
1239+
{
1240+
"type": "object",
1241+
"additionalProperties": false,
1242+
"required": [
1243+
"paths",
1244+
"project"
1245+
],
1246+
"properties": {
1247+
"paths": {
1248+
"type": "array",
1249+
"description": "List of file paths.",
1250+
"items": {
1251+
"type": "string"
1252+
}
1253+
},
1254+
"project": {
1255+
"type": "string",
1256+
"description": "Path of the project to search in."
1257+
},
1258+
"ref": {
1259+
"type": "string",
1260+
"description": "Ref of the project to search in."
1261+
}
1262+
}
1263+
}
1264+
]
11771265
},
11781266
"timeout": {
11791267
"type": "string",
@@ -1615,7 +1703,7 @@
16151703
},
16161704
{
16171705
"const": "archived_failure",
1618-
"description": "Retry if the job is archived and can't be run."
1706+
"description": "Retry if the job is archived and cant be run."
16191707
},
16201708
{
16211709
"const": "unmet_prerequisites",
@@ -1688,6 +1776,10 @@
16881776
"$ref": "#/definitions/script",
16891777
"markdownDescription": "Shell scripts executed by the Runner. The only required property of jobs. Be careful with special characters (e.g. `:`, `{`, `}`, `&`) and use single or double quotes to avoid issues. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#script)"
16901778
},
1779+
"run": {
1780+
"$ref": "#/definitions/steps",
1781+
"markdownDescription": "Specifies a list of steps to execute in the job. The `run` keyword is an alternative to `script` and allows for more advanced job configuration. Each step is an object that defines a single task or command. Use either `run` or `script` in a job, but not both, otherwise the pipeline will error out."
1782+
},
16911783
"stage": {
16921784
"description": "Define what stage the job will run in.",
16931785
"anyOf": [
@@ -1697,7 +1789,7 @@
16971789
},
16981790
{
16991791
"type": "array",
1700-
"minLength": 1,
1792+
"minItems": 1,
17011793
"items": {
17021794
"type": "string"
17031795
}
@@ -1825,6 +1917,10 @@
18251917
"start_in": {
18261918
"$ref": "#/definitions/start_in"
18271919
},
1920+
"manual_confirmation": {
1921+
"markdownDescription": "Describes the Custom confirmation message for a manual job [Learn More](https://docs.gitlab.com/ee/ci/yaml/#when).",
1922+
"type": "string"
1923+
},
18281924
"dependencies": {
18291925
"type": "array",
18301926
"description": "Specify a list of job names from earlier stages from which artifacts should be loaded. By default, all previous artifacts are passed. Use an empty array to skip downloading artifacts.",
@@ -1928,7 +2024,7 @@
19282024
},
19292025
"ref": {
19302026
"type": "string",
1931-
"description": "If the release: tag_name doesn't exist yet, the release is created from ref. ref can be a commit SHA, another tag name, or a branch name."
2027+
"description": "If the release: tag_name doesnt exist yet, the release is created from ref. ref can be a commit SHA, another tag name, or a branch name."
19322028
},
19332029
"milestones": {
19342030
"type": "array",
@@ -2241,7 +2337,7 @@
22412337
"properties": {
22422338
"path_prefix": {
22432339
"type": "string",
2244-
"markdownDescription": "The GitLab Pages URL path prefix used in this version of pages."
2340+
"markdownDescription": "The GitLab Pages URL path prefix used in this version of pages. The given value is converted to lowercase, shortened to 63 bytes, and everything except alphanumeric characters is replaced with a hyphen. Leading and trailing hyphens are not permitted."
22452341
}
22462342
}
22472343
}
@@ -2275,7 +2371,7 @@
22752371
},
22762372
"tags": {
22772373
"type": "array",
2278-
"minLength": 1,
2374+
"minItems": 1,
22792375
"markdownDescription": "Used to select runners from the list of available runners. A runner must have all tags listed here to run the job. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#tags).",
22802376
"items": {
22812377
"anyOf": [
@@ -2285,7 +2381,7 @@
22852381
},
22862382
{
22872383
"type": "array",
2288-
"minLength": 1,
2384+
"minItems": 1,
22892385
"items": {
22902386
"type": "string"
22912387
}

0 commit comments

Comments
 (0)