Skip to content

Commit 7cab177

Browse files
committed
Move implementations into JSON file
This should make the data easier to manage and enables more automated checks.
1 parent 679d376 commit 7cab177

File tree

5 files changed

+2313
-1212
lines changed

5 files changed

+2313
-1212
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ This is the repo for Raft website: https://raft.github.io
66
Please contribute to the website by submitting pull requests or creating
77
issues.
88

9-
The website is hosted as a GitHub static page.
9+
The website is hosted as a GitHub static page. To run it locally, start a local
10+
static webserver:
11+
```
12+
python3 -m http.server 8000 --bind localhost
13+
```
14+
and open <http://localhost:8080/>. The server is needed to allow `index.html` to
15+
pull down `implementations.json`.
16+
1017

1118
This work is licensed under a Creative Commons Attribution 3.0 Unported License.
1219
See http://creativecommons.org/licenses/by/3.0/deed.en_US for details.

check.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python3
2+
3+
import json
4+
import jsonschema
5+
6+
schema = json.load(open('implementation.schema.json'))
7+
8+
raw_data = open('implementations.json').read()
9+
if not raw_data.endswith(']\n'):
10+
raise ValueError('implementations.json should end in one \\n')
11+
data = json.loads(raw_data)
12+
13+
for impl in data:
14+
jsonschema.validate(impl, schema)
15+
16+
sorted_data = sorted(data, key=lambda impl: impl['repoURL'])
17+
for expected, actual in zip(sorted_data, data):
18+
if expected['repoURL'] != actual['repoURL']:
19+
print('Expected:', expected['repoURL'])
20+
print('Found: ', actual['repoURL'])
21+
raise ValueError('Implementations should be sorted by repoURL')
22+

implementation.schema.json

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://raft.github.io/implementation.schema.json",
4+
"title": "Implementation",
5+
"description": "...",
6+
"type": "object",
7+
"properties": {
8+
"repoURL": {
9+
"type": "string",
10+
"pattern": "^https://github.com/([^/]+)/([^/]+)(?<!.git)$",
11+
"format": "uri"
12+
},
13+
"directory": {
14+
"type": "string",
15+
"pattern": "^[^/].*/$"
16+
},
17+
"name": {
18+
"type": "string",
19+
"pattern": "^.+(?<!^[Rr][Aa][Ff][Tt])$"
20+
},
21+
"authors": {
22+
"type": "array",
23+
"items": {
24+
"type": "object",
25+
"properties": {
26+
"name": {
27+
"type": "string"
28+
},
29+
"twitter": {
30+
"type": "string",
31+
"pattern": "^https://twitter.com/([^/]+)$",
32+
"format": "uri"
33+
},
34+
"github": {
35+
"type": "string",
36+
"pattern": "^https://github.com/([^/]+)$",
37+
"format": "uri"
38+
},
39+
"homepage": {
40+
"type": "string",
41+
"format": "uri"
42+
}
43+
}
44+
},
45+
"maxItems": 7
46+
},
47+
"language": {
48+
"type": "string",
49+
"description": "SPDX license expression. See https://spdx.org/licenses/"
50+
},
51+
"license": {
52+
"type": "string"
53+
},
54+
"features": {
55+
"type": "object",
56+
"properties": {
57+
"basic": {
58+
"type": "boolean",
59+
"description": "Leader election and log replication"
60+
},
61+
"persistence": {
62+
"type": "boolean",
63+
"description": "Term and log are persisted to disk"
64+
},
65+
"logCompaction": {
66+
"type": "boolean"
67+
},
68+
"membershipChanges": {
69+
"type": "boolean"
70+
}
71+
}
72+
}
73+
},
74+
"required": [
75+
"name",
76+
"repoURL",
77+
"language"
78+
],
79+
"additionalProperties": false
80+
}

0 commit comments

Comments
 (0)