Skip to content

Commit

Permalink
ci(schema): add cuelange example schema job
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmcloughlin committed Apr 15, 2021
1 parent 3a0f8cc commit 8e4635f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 22 deletions.
15 changes: 14 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
only_branch_master_parent_repo: &only_branch_master_parent_repo
- 'master@saltstack-formulas/template-formula'
# `stage`
stage_constraints: &stage_constraints 'constraints'
stage_schema: &stage_schema 'schema'
stage_lint: &stage_lint 'lint'
stage_release: &stage_release 'release'
stage_test: &stage_test 'test'
# `image`
image_commitlint: &image_commitlint 'myii/ssf-commitlint:11'
image_cuelang: &image_cuelang
name: 'myii/ssf-cue:0.3.2' # instead of cuelang/cue
entrypoint: ['/bin/ash', '-c']
image_dindruby: &image_dindruby 'myii/ssf-dind-ruby:2.7.1-r3'
image_dindrubybionic: &image_dindrubybionic 'myii/ssf-dind-ruby-bionic:1_2.5.1'
image_precommit: &image_precommit
Expand Down Expand Up @@ -42,6 +45,7 @@
###############################################################################
stages:
- *stage_lint
- *stage_schema
- *stage_test
- *stage_release
variables:
Expand Down Expand Up @@ -101,6 +105,15 @@ rubocop:
script:
- 'rubocop -d -P -S --enable-pending-cops'

cue:
allow_failure: true
stage: *stage_schema
image: *image_cuelang
variables:
RULES: 'TEMPLATE/parameters/schema.cue'
script:
- 'cue vet -v $(find . -name "*.yaml") ${RULES} --schema "#Values"'

###############################################################################
# Define `test` template
###############################################################################
Expand Down
3 changes: 2 additions & 1 deletion TEMPLATE/parameters/os/Fedora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
---
values:
pkg:
name: TEMPLATE-fedora
name: 11
# TEMPLATE-fedora
service:
name: service-fedora
...
54 changes: 34 additions & 20 deletions TEMPLATE/parameters/schema.cue
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
// -*- coding: utf-8 -*-
// vim: ft=yaml

//
// Data Constaints - Example from Saltstack-formulas
//
// Constraints Schema:
// This is not a prescriptive or forced schema! Many variants of
// formula (and yaml data) exist in the salt user community.
// Therefore the use of cue '?' and "aliases" is recommended.

// template-formula
#template: {
pkg?: name?: string
#Schema: #Values

//
// Rule
//
#Optional: {
pkg?:
name?: string
rootgroup?: string
hide_output?: bool
dir_mode?: =~"^0?[124567]{3}$" // any mode of length 3, with 0 prefix optional
Expand All @@ -27,21 +31,31 @@
winner?: string
...
}
values?: {...#template} // probable yaml namespace

//
// support formula diversity :-)
// Schema Name
//
#Values: {
values?: {...#Optional}
}
values?: {...#Values} // Namespace


template?: {...#template} // another probable namespace
//
// Older schema
//
#TEMPLATE: {
TEMPLATE?: {...#Optional}
}
TEMPLATE?: {...#Optional}

Debian?: #template
Suse?: #template
Gentoo?: #template
Arch?: #template
Alpine?: #template
FreeBSD?: #template
OpenBSD?: #template
Solaris?: #template
Windows?: #template
MacOS?: #template
Debian?: #Optional
Suse?: #Optional
Gentoo?: #Optional
Arch?: #Optional
Alpine?: #Optional
FreeBSD?: #Optional
OpenBSD?: #Optional
Solaris?: #Optional
Windows?: #Optional
MacOS?: #Optional

0 comments on commit 8e4635f

Please sign in to comment.