summaryrefslogtreecommitdiff
path: root/lib/spack/spack/schema/gitlab_ci.py
blob: dc7b16fb21c397282034d4f131dbbecf5766b0a0 (plain) (blame)
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
# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

"""Schema for gitlab-ci.yaml configuration file.

.. literalinclude:: ../spack/schema/gitlab_ci.py
   :lines: 13-
"""


#: Properties for inclusion in other schemas
properties = {
    'gitlab-ci': {
        'type': 'object',
        'additionalProperties': False,
        'required': ['mappings'],
        'patternProperties': {
            'bootstrap': {
                'type': 'array',
                'items': {
                    'anyOf': [
                        {
                            'type': 'string',
                        }, {
                            'type': 'object',
                            'additionalProperties': False,
                            'required': ['name'],
                            'properties': {
                                'name': {
                                    'type': 'string',
                                },
                                'compiler-agnostic': {
                                    'type': 'boolean',
                                    'default': False,
                                },
                            },
                        },
                    ],
                },
            },
            'mappings': {
                'type': 'array',
                'items': {
                    'type': 'object',
                    'additionalProperties': False,
                    'required': ['match', 'runner-attributes'],
                    'properties': {
                        'match': {
                            'type': 'array',
                            'items': {
                                'type': 'string',
                            },
                        },
                        'runner-attributes': {
                            'type': 'object',
                            'additionalProperties': True,
                            'required': ['tags'],
                            'properties': {
                                'image': {
                                    'oneOf': [
                                        {
                                            'type': 'string'
                                        }, {
                                            'type': 'object',
                                            'properties': {
                                                'name': {'type': 'string'},
                                                'entrypoint': {
                                                    'type': 'array',
                                                    'items': {
                                                        'type': 'string',
                                                    },
                                                },
                                            },
                                        },
                                    ],
                                },
                                'tags': {
                                    'type': 'array',
                                    'default': [],
                                    'items': {'type': 'string'}
                                },
                                'variables': {
                                    'type': 'object',
                                    'default': {},
                                    'patternProperties': {
                                        r'[\w\d\-_\.]+': {
                                            'type': 'string',
                                        },
                                    },
                                },
                            },
                        },
                    },
                },
            },
        },
    },
}


#: Full schema with metadata
schema = {
    '$schema': 'http://json-schema.org/schema#',
    'title': 'Spack gitlab-ci configuration file schema',
    'type': 'object',
    'additionalProperties': False,
    'properties': properties,
}