blob: 86cccd52c27582f8ce723b9d3c17c9105395656a (
plain)
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
|
{ lib, ... }:
let
ports = {
turborepo-remote-cache = 8080;
};
token = "myrandomtoken";
team = "nixos-team";
# require('crypto').randomBytes(20).toString('hex');
artifactid = "82286e93a6f84e18a8fe4770c5a88b24653e7f59";
in
{
name = "turborepo-remote-cache";
nodes.machine = {
services.turborepo-remote-cache = {
enable = true;
environment = {
PORT = ports.turborepo-remote-cache;
TURBO_TEAM = team;
TURBO_TOKEN = token;
};
};
};
testScript = ''
import json
machine.wait_for_unit("turborepo-remote-cache.service")
machine.wait_for_open_port(${toString ports.turborepo-remote-cache})
def read_json(input):
try:
return json.loads(input)
except Exception as e:
print(input)
raise e
out = read_json(machine.succeed("""curl 127.0.0.1:${toString ports.turborepo-remote-cache}/v8/artifacts/status? \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer ${token}"
"""))
if out["status"] != "enabled":
raise Exception(f"status is not enabled in response: {out}")
out = read_json(machine.succeed("""curl -X PUT "127.0.0.1:${toString ports.turborepo-remote-cache}/v8/artifacts/${artifactid}?teamId=${team}" \
-H "Authorization: Bearer ${token}" \
-H "Content-Type: application/octet-stream" \
-d 'myartifact'"""))
if "urls" not in out:
raise Exception(f"'urls' not in response: {out}")
out = machine.succeed("""curl 127.0.0.1:${toString ports.turborepo-remote-cache}/v8/artifacts/${artifactid}?teamId=${team} \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer ${token}"
""")
if out != "myartifact":
raise Exception(f"reponse in not 'myartifact': {out}")
'';
meta.maintainers = [ lib.maintainers.ibizaman ];
}
|