Skip to content

Instantly share code, notes, and snippets.

@ocharles
Created December 8, 2017 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ocharles/4ba647bcf8cb4a0dc20637544fab2619 to your computer and use it in GitHub Desktop.
Save ocharles/4ba647bcf8cb4a0dc20637544fab2619 to your computer and use it in GitHub Desktop.
From a030bb7f34caf74a9cb4bc580063637795aab370 Mon Sep 17 00:00:00 2001
From: Oliver Charles <ollie@ocharles.org.uk>
Date: Fri, 8 Dec 2017 11:09:48 +0000
Subject: [PATCH] Build pull requests
---
hydra-jobsets.nix | 55 +++++++++++++++++++++++++++++++++++++++++-------------
hydra-project.json | 7 ++++++-
2 files changed, 48 insertions(+), 14 deletions(-)
diff --git a/hydra-jobsets.nix b/hydra-jobsets.nix
index f58ba4728..a179c925e 100644
--- a/hydra-jobsets.nix
+++ b/hydra-jobsets.nix
@@ -1,13 +1,17 @@
-{ nixpkgs ? <nixpkgs>, declInput ? {} }:
+{ nixpkgs ? <nixpkgs>
+, declInput ? {}
+, pullRequests
+}:
let
pkgs = import nixpkgs {};
- jobsetAttrs = {
- master = {
+ build-client =
+ { description, github }:
+ {
+ inherit description;
enabled = 1;
hidden = false;
- description = "master branch";
nixexprpath = "jobs.nix";
nixexprinput = "client";
checkinterval = 5;
@@ -18,7 +22,7 @@ let
inputs = {
client = {
type = "git";
- value = "https://XXX:x-oauth-basic@github.com/circuithub/circuithub-client";
+ value = "https://XXX:x-oauth-basic@github.com/${github.owner}/${github.repo} ${github.ref}";
emailresponsible = false;
};
nixpkgs = {
@@ -28,14 +32,39 @@ let
};
};
};
- };
- jobsetJson = pkgs.writeText "spec.json" (builtins.toJSON jobsetAttrs);
+ build-pull-request =
+ num: info:
+ {
+ name = "client-pr-${num}";
+ value =
+ build-client
+ {
+ description = "PR #${num}: ${info.title}";
+ github = {
+ owner = info.head.repo.owner.login;
+ repo = info.head.repo.name;
+ ref = info.head.ref;
+ };
+ };
+ };
+
+ prJobsets =
+ pkgs.lib.listToAttrs
+ ( pkgs.lib.mapAttrsToList build-pull-request
+ (builtins.fromJSON (builtins.readFile pullRequests)));
-in
-{
+ jobsetAttrs = {
+ master =
+ build-client {
+ description = "master";
+ github = {
+ owner = "circuithub";
+ repo = "circuithub-client";
+ ref = "";
+ };
+ };
+ } // prJobsets;
- jobsets = with pkgs.lib; pkgs.runCommand "spec.json" {} ''
- cp ${jobsetJson} $out
- '';
-}
+in
+{ jobsets = pkgs.writeText "spec.json" (builtins.toJSON jobsetAttrs); }
diff --git a/hydra-project.json b/hydra-project.json
index 762b4fbc8..463c17bba 100644
--- a/hydra-project.json
+++ b/hydra-project.json
@@ -15,10 +15,15 @@
"value": "https://XXX:x-oauth-basic@github.com/circuithub/circuithub-client",
"emailresponsible": false
},
- "nixpkgs": {
+ "nixpkgs": {
"type": "git",
"value": "git://github.com/NixOS/nixpkgs.git release-17.09",
"emailresponsible": false
+ },
+ "pullRequests": {
+ "type": "githubpulls",
+ "value": "circuithub circuithub-client",
+ "emailresponsible": false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment