: nply/minci

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 
111 
112 
113 
114 
115 
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147 
148 
149 
150 
151 
152 
153 
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
183 
184 
185 
186 
187 
188 
189 
190 
191 
192 
193 
194 
195 
196 
197 
198 
199 
200 
201 
202 
203 
204 
205 
206 
207 
208 
209 
210 
211 
212 
213 
214 
215 
216 
217 
218 
219 
220 
221 
222 
roles {
	role producer;
	role consumer;
};

struct project {
	field name text limit gt 0 limit lt 64 unique
		comment "The project name.  This is assumed to have some
			 sort of meaning between testers and backend.
			 As-is, the name is assumed to be the name of a
			 GitHub repository in my (kristapsdz) repo.  It
			 can be set as a compile-time value.";
	field id int rowid;

	search name: name byname;

	roles producer {
		search byname;
	};
};

struct user {
	comment "Users can be totally anonymous and are just used for
	 	 authenticating reports.
		 To create a user, you can `echo $RANDOM` for the apikey
		 and `jot -r -c 32 'A' '{' | rs -g0` for the secret.";

	field email email
		comment "Only used for logging purposes.";
	field apikey int limit gt 0 unique
		comment "Unique user identifier.";
	field apisecret text limit eq 32
		comment "Secret known to the database and the user, but
			 not transmitted between.  This is used for
			 authenticating reports.";
	field ctime epoch
		comment "When the user was created.";
	field id int rowid;

	search apikey: name bykey;

	roles producer {
		search bykey;
	};
};

struct run {
	comment "A single integration run for a project revision and target.";

	field project struct projectid;
	field projectid:project.id;
	field ref text limit le 128 default ""
		comment "Git ref or other event ref that selected the run.";
	field rev text limit le 40 default ""
		comment "Revision under test.";
	field target text limit le 128 default ""
		comment "Target triplet or environment name.";
	field runhash text limit eq 32 unique
		comment "Client-computed grouping key for idempotently finding a run.";
	field ctime epoch
		comment "When the run was recorded.";
	field id int rowid;

	insert;
	list: name dash order ctime desc;
	iterate project.name: limit 50 name byproject order ctime desc;
	search id: name byid;
	search runhash: name byhash;

	roles consumer {
		list dash;
		iterate byproject;
		search byid;
	};

	roles producer {
		insert;
		search byhash;
	};
};

struct job {
	comment "A named step within a run.";

	field run struct runid;
	field runid:run.id;
	field name text limit gt 0 limit le 64;
	field status text limit gt 0 limit le 16;
	field start epoch;
	field finish epoch;
	field log text;
	field id int rowid;

	insert;
	list: limit 50 name dash order finish desc;
	iterate run.project.name: limit 50 name byproject order finish desc;
	iterate runid: name byrun order id;
	search id: name byid;

	roles consumer {
		list dash;
		iterate byproject;
		iterate byrun;
		search byid;
	};

	roles producer {
		insert;
	};
};

struct artifact {
	comment "A published output attached to a job.";

	field job struct jobid;
	field jobid:job.id;
	field name text limit gt 0 limit le 128;
	field url text limit gt 0 limit le 1024;
	field sha256 text limit le 64 default "";
	field id int rowid;

	insert;
	iterate jobid: name byjob order id;

	roles consumer {
		iterate byjob;
	};

	roles producer {
		insert;
	};
};

struct report {
	comment "Test runner results for a single repository.  The epoch
		 fields are sequential, so they're either a time of
		 completion of zero on failure.  On failure, all
		 subsequent fields (e.g., build after depend) must fail
		 as well.
		 The log should be the standard error and output of
		 everything that has happened in the sequence---not just
		 the last failure.";

	field project struct projectid;

	field projectid:project.id;
	field userid:user.id;

	field start epoch
		comment "When the test runner started processing the
			 repository.";
	field env epoch
		comment "When the repository has been cloned/updated (ge
			 start or zero on failure.";
	field depend epoch
		comment "When dependencies have been checked (ge env or
			 equal or zero on failure or env failure).";
	field build epoch
		comment "When `make` has completed (ge depend or equal
			 to zero on failure or depend failure).";
	field test epoch
		comment "When `make regress` has completed (ge build or
			 equal to zero on failure or build failure).";
	field install epoch
		comment "When `make install` has completed (ge test or
			 equal to zero on failure or test failure).)";
	field distcheck epoch
		comment "When `make distcheck` has completed (ge install
			 or equal to zero on failure or install
			 failure).";
	field ctime epoch
		comment "When the report row was creatd.";
	field log text
		comment "If distcheck is zero, this is optionally set to
			 the full build log.  If distcheck is not zero,
			 this must be the empty string.";
	field unamem text limit le 128
		comment "Output of uname -m.";
	field unamen text limit le 128
		comment "Output of uname -n.";
	field unamer text limit le 128
		comment "Output of uname -r.";
	field unames text limit le 128
		comment "Output of uname -s.";
	field unamev text limit le 128
		comment "Output of uname -v.";
	field unamehash text limit eq 32
		comment "Hash of uname[mnrsv].  This is used to quickly
			 establish a kind of machine identity.";
	field projunamehash text limit eq 32 default ""
		comment "Hash of uname[mnrsv] and project identifier.  This is
			 used to group recent submissions from a given machine
			 for a given project.";
	field fetchhead text limit le 40 default ""
		comment "Git hash for branch master.  May be empty.";
			 

	field id int rowid;

	insert;

	iterate ctime ge, ctime le: limit 50 name lastdate order ctime desc;
	iterate project.name: name dashname order ctime desc grouprow projunamehash maxrow ctime;
	iterate unamehash: name dashuname order ctime desc grouprow projunamehash maxrow ctime;

	list: name dash order projectid,ctime desc grouprow projunamehash maxrow ctime;

	search id: name byid;

	roles consumer {
		list dash;
		iterate dashname;
		iterate dashuname;
		iterate lastdate;
		noexport userid;
		search byid;
	};

	roles producer {
		insert;
	};
};