Skip to content

Commit a0194c1

Browse files
ci(schema): add cuelange example schema job
1 parent 3a0f8cc commit a0194c1

File tree

3 files changed

+51
-22
lines changed

3 files changed

+51
-22
lines changed

.gitlab-ci.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
only_branch_master_parent_repo: &only_branch_master_parent_repo
1010
- 'master@saltstack-formulas/template-formula'
1111
# `stage`
12-
stage_constraints: &stage_constraints 'constraints'
12+
stage_schema: &stage_schema 'schema'
1313
stage_lint: &stage_lint 'lint'
1414
stage_release: &stage_release 'release'
1515
stage_test: &stage_test 'test'
1616
# `image`
1717
image_commitlint: &image_commitlint 'myii/ssf-commitlint:11'
18+
image_cuelang: &image_cuelang
19+
name: 'myii/ssf-cue:0.3.2' # instead of cuelang/cue
20+
entrypoint: ['/bin/ash', '-c']
1821
image_dindruby: &image_dindruby 'myii/ssf-dind-ruby:2.7.1-r3'
1922
image_dindrubybionic: &image_dindrubybionic 'myii/ssf-dind-ruby-bionic:1_2.5.1'
2023
image_precommit: &image_precommit
@@ -42,6 +45,7 @@
4245
###############################################################################
4346
stages:
4447
- *stage_lint
48+
- *stage_schema
4549
- *stage_test
4650
- *stage_release
4751
variables:
@@ -101,6 +105,16 @@ rubocop:
101105
script:
102106
- 'rubocop -d -P -S --enable-pending-cops'
103107

108+
cue:
109+
allow_failure: true
110+
stage: *stage_schema
111+
image: *image_cuelang
112+
variables:
113+
DIR: 'TEMPLATE/parameters'
114+
RULES: 'schema.cue'
115+
script:
116+
- 'cue vet -v $(find ${DIR} -name "*.yaml") ${DIR}/{RULES} --schema "#Values"'
117+
104118
###############################################################################
105119
# Define `test` template
106120
###############################################################################

TEMPLATE/parameters/os/Fedora.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
---
1414
values:
1515
pkg:
16-
name: TEMPLATE-fedora
16+
name: 11
17+
# TEMPLATE-fedora
1718
service:
1819
name: service-fedora
1920
...

TEMPLATE/parameters/schema.cue

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
// -*- coding: utf-8 -*-
22
// vim: ft=yaml
3+
4+
//
5+
// Data Constaints - Example from Saltstack-formulas
36
//
4-
// Constraints Schema:
5-
// This is not a prescriptive or forced schema! Many variants of
6-
// formula (and yaml data) exist in the salt user community.
7-
// Therefore the use of cue '?' and "aliases" is recommended.
87

9-
// template-formula
10-
#template: {
11-
pkg?: name?: string
8+
#Schema: #Values
9+
10+
//
11+
// Rule
12+
//
13+
#Optional: {
14+
pkg?:
15+
name?: string
1216
rootgroup?: string
1317
hide_output?: bool
1418
dir_mode?: =~"^0?[124567]{3}$" // any mode of length 3, with 0 prefix optional
@@ -27,21 +31,31 @@
2731
winner?: string
2832
...
2933
}
30-
values?: {...#template} // probable yaml namespace
3134

3235
//
33-
// support formula diversity :-)
36+
// Schema Name
3437
//
38+
#Values: {
39+
values?: {...#Optional}
40+
}
41+
values?: {...#Values} // Namespace
42+
3543

36-
template?: {...#template} // another probable namespace
44+
//
45+
// Older schema
46+
//
47+
#TEMPLATE: {
48+
TEMPLATE?: {...#Optional}
49+
}
50+
TEMPLATE?: {...#Optional}
3751

38-
Debian?: #template
39-
Suse?: #template
40-
Gentoo?: #template
41-
Arch?: #template
42-
Alpine?: #template
43-
FreeBSD?: #template
44-
OpenBSD?: #template
45-
Solaris?: #template
46-
Windows?: #template
47-
MacOS?: #template
52+
Debian?: #Optional
53+
Suse?: #Optional
54+
Gentoo?: #Optional
55+
Arch?: #Optional
56+
Alpine?: #Optional
57+
FreeBSD?: #Optional
58+
OpenBSD?: #Optional
59+
Solaris?: #Optional
60+
Windows?: #Optional
61+
MacOS?: #Optional

0 commit comments

Comments
 (0)