on an-autorun-selftests help sign in
obelisk/jobsets.nix
71 lines 1.9 kB history raw
1{ prs }:
3let
4 self = import ./. {};
5 pkgs = self.nixpkgs;
6 mkFetchGithub = value: {
7 inherit value;
8 type = "git";
9 emailresponsible = false;
10 };
11in
12with pkgs.lib;
13let
14 defaults = jobs: {
15 inherit (jobs) description;
16 enabled = 1;
17 hidden = false;
18 keepnr = 10;
19 schedulingshares = 100;
20 checkinterval = 120;
21 enableemail = false;
22 emailoverride = "";
23 nixexprinput = "obelisk";
24 nixexprpath = "test.nix";
25 inputs = jobs.inputs // {
26 nixpkgs = {
27 type = "git";
28 value = "https://github.com/NixOS/nixpkgs-channels nixos-unstable";
29 emailresponsible = false;
30 };
31 };
32 self-args = {
33 type = "nix";
34 value = "{ config.android_sdk.accept_license = true; }";
35 emailresponsible = false;
36 };
37 };
38 branchJobset = branch: defaults {
39 description = "obelisk-${branch}";
40 inputs = {
41 obelisk = {
42 value = "https://github.com/obsidiansystems/obelisk ${branch}";
43 type = "git";
44 emailresponsible = false;
45 };
46 };
47 };
48 makePr = num: info: {
49 name = "obelisk-pr-${num}";
50 value = defaults {
51 description = "#${num}: ${info.title}";
52 inputs = {
53 obelisk = {
54 #NOTE: This should really use "pull/${num}/merge"; however, GitHub's
55 #status checks only operate on PR heads. This creates a race
56 #condition, which can currently only be solved by requiring PRs to be
57 #up to date before they're merged. See
58 #https://github.com/isaacs/github/issues/1002
59 value = "https://github.com/obsidiansystems/obelisk pull/${num}/head";
60 type = "git";
61 emailresponsible = false;
62 };
63 };
64 };
65 };
66 processedPrs = mapAttrs' makePr (builtins.fromJSON (builtins.readFile prs));
67 jobsetsAttrs = processedPrs //
68 genAttrs ["master"] branchJobset;
69in {
70 jobsets = pkgs.writeText "spec.json" (builtins.toJSON jobsetsAttrs);