diff options
Diffstat (limited to 'krebs')
-rw-r--r-- | krebs/1systems/hotdog/config.nix | 2 | ||||
-rw-r--r-- | krebs/1systems/puyak/config.nix | 1 | ||||
-rw-r--r-- | krebs/1systems/wolf/config.nix | 1 | ||||
-rw-r--r-- | krebs/2configs/repo-sync.nix | 4 | ||||
-rw-r--r-- | krebs/2configs/shared-buildbot.nix | 191 | ||||
-rw-r--r-- | krebs/3modules/buildbot/master.nix | 21 | ||||
-rw-r--r-- | krebs/3modules/buildbot/slave.nix | 11 | ||||
-rw-r--r-- | krebs/3modules/ci.nix | 175 | ||||
-rw-r--r-- | krebs/3modules/default.nix | 1 | ||||
-rw-r--r-- | krebs/3modules/krebs/default.nix | 10 | ||||
-rw-r--r-- | krebs/5pkgs/simple/buildbot-classic-slave/default.nix | 21 | ||||
-rw-r--r-- | krebs/5pkgs/simple/buildbot-classic/default.nix | 47 |
12 files changed, 279 insertions, 206 deletions
diff --git a/krebs/1systems/hotdog/config.nix b/krebs/1systems/hotdog/config.nix index 18c8a86cd..26f392da8 100644 --- a/krebs/1systems/hotdog/config.nix +++ b/krebs/1systems/hotdog/config.nix @@ -8,6 +8,8 @@ imports = [ <stockholm/krebs> <stockholm/krebs/2configs> + + <stockholm/krebs/2configs/shared-buildbot.nix> ]; krebs.build.host = config.krebs.hosts.hotdog; diff --git a/krebs/1systems/puyak/config.nix b/krebs/1systems/puyak/config.nix index 19ee2343d..e781f7469 100644 --- a/krebs/1systems/puyak/config.nix +++ b/krebs/1systems/puyak/config.nix @@ -7,7 +7,6 @@ <stockholm/krebs/2configs/secret-passwords.nix> <stockholm/krebs/2configs/hw/x220.nix> - <stockholm/krebs/2configs/repo-sync.nix> <stockholm/krebs/2configs/shared-buildbot.nix> <stockholm/krebs/2configs/stats/puyak-client.nix> ]; diff --git a/krebs/1systems/wolf/config.nix b/krebs/1systems/wolf/config.nix index 0deb01f0a..e883a176d 100644 --- a/krebs/1systems/wolf/config.nix +++ b/krebs/1systems/wolf/config.nix @@ -12,7 +12,6 @@ in <stockholm/krebs/2configs/save-diskspace.nix> <stockholm/krebs/2configs/graphite.nix> - <stockholm/krebs/2configs/repo-sync.nix> <stockholm/krebs/2configs/shared-buildbot.nix> <stockholm/krebs/2configs/shack/worlddomination.nix> diff --git a/krebs/2configs/repo-sync.nix b/krebs/2configs/repo-sync.nix index 157a30e69..b0b0b2f62 100644 --- a/krebs/2configs/repo-sync.nix +++ b/krebs/2configs/repo-sync.nix @@ -17,7 +17,7 @@ let verbose = false; channel = "#retiolum"; server = "ni.r"; - branches = [ "newest" ]; + branches = [ "master" ]; }; }); }; @@ -55,7 +55,7 @@ let }; latest = { url = "${mirror}${name}"; - ref = "heads/newest"; + ref = "heads/master"; }; }; krebs.git = defineRepo name true; diff --git a/krebs/2configs/shared-buildbot.nix b/krebs/2configs/shared-buildbot.nix index b534f0b62..7f243b506 100644 --- a/krebs/2configs/shared-buildbot.nix +++ b/krebs/2configs/shared-buildbot.nix @@ -1,183 +1,18 @@ { lib, config, pkgs, ... }: -# The buildbot config is self-contained and currently provides a way -# to test "krebs" configuration (infrastructure to be used by every krebsminister). +{ + imports = [ + <stockholm/krebs/2configs/repo-sync.nix> + ]; -# You can add your own test, test steps as required. Deploy the config on a -# krebs host like wolf and everything should be fine. - -# TODO for all users schedule a build for fast tests -let - hostname = config.networking.hostName; -in { - # due to the fact that we actually build stuff on the box via the daemon, - # /nix/store should be cleaned up automatically as well - services.nginx = { - enable = true; - virtualHosts.build = { - serverAliases = [ "build.${hostname}.r" ]; - locations."/".extraConfig = '' - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_pass http://127.0.0.1:${toString config.krebs.buildbot.master.web.port}; - ''; - }; - }; - - nix.gc.automatic = true; - nix.gc.dates = "05:23"; networking.firewall.allowedTCPPorts = [ 80 8010 9989 ]; - - krebs.buildbot.master = let - stockholm-mirror-url = "http://cgit.${hostname}.r/stockholm" ; - in { - slaves = { - testslave = "krebspass"; - }; - change_source.stockholm = '' - stockholm_repo = '${stockholm-mirror-url}' - cs.append(changes.GitPoller( - stockholm_repo, - workdir='stockholm-poller', branches=True, - project='stockholm', - pollinterval=60)) - ''; - scheduler = { - force-scheduler = '' - sched.append(schedulers.ForceScheduler( - name="force", - builderNames=[ - # "full-tests", - "fast-tests", - "build-local" - ])) - ''; - fast-tests-scheduler = '' - # test everything real quick - sched.append(schedulers.AnyBranchScheduler( - treeStableTimer=10, - name="fast-all-branches", - builderNames=["fast-tests"])) - ''; - test-cac-infest-master = '' - # files everyone depends on or are part of the share branch - def shared_files(change): - r =re.compile("^(krebs/.*|Makefile|default.nix|shell.nix)") - for file in change.files: - if r.match(file): - return True - return False - - sched.append(schedulers.SingleBranchScheduler( - change_filter=util.ChangeFilter(branch="master"), - fileIsImportant=shared_files, - treeStableTimer=60*60, # master was stable for the last hour - name="full-master", - builderNames=[ - # "full-tests", - "build-local" - ])) - ''; - }; - builder_pre = '' - # prepare grab_repo step for stockholm - grab_repo = steps.Git(repourl=stockholm_repo, mode='incremental') - - env = { - "LOGNAME": "krebs", - "NIX_REMOTE": "daemon", - "dummy_secrets": "true", - } - - # prepare nix-shell - # the dependencies which are used by the test script - deps = [ "gnumake", "jq", "nix", - "(import <stockholm>).pkgs.populate", - "(import <stockholm>).pkgs.test.infest-cac-centos7" ] - # TODO: --pure , prepare ENV in nix-shell command: - # SSL_CERT_FILE,LOGNAME,NIX_REMOTE - nixshell = ["nix-shell", - "-I", "stockholm=.", - "-I", "nixpkgs=/var/src/nixpkgs", - "-p" ] + deps + [ "--run" ] - - # prepare addShell function - def addShell(factory,**kwargs): - factory.addStep(steps.ShellCommand(**kwargs)) - ''; - builder = { - fast-tests = '' - f = util.BuildFactory() - f.addStep(grab_repo) - - for i in [ "test-minimal-deploy", "test-all-krebs-modules", "wolf", "test-centos7" ]: - addShell(f,name="build-{}".format(i),env=env, - command=nixshell + \ - ["mkdir -p /tmp/testbuild/$LOGNAME && touch /tmp/testbuild/$LOGNAME/.populate; \ - make \ - test \ - target=$LOGNAME@${config.krebs.build.host.name}/tmp/testbuild/$LOGNAME \ - method=eval \ - system={}".format(i)]) - - bu.append(util.BuilderConfig(name="fast-tests", - slavenames=slavenames, - factory=f)) - - ''; - # this build will try to build against local nixpkgs - # TODO change to do a 'local' populate and use the retrieved nixpkgs - build-local = '' - f = util.BuildFactory() - f.addStep(grab_repo) - - - bu.append(util.BuilderConfig(name="build-local", - slavenames=slavenames, - factory=f)) - ''; -# slow-tests = '' -# s = util.BuildFactory() -# s.addStep(grab_repo) -# -# # slave needs 2 files: -# # * cac.json -# # * retiolum -# s.addStep(steps.FileDownload(mastersrc="${config.krebs.buildbot.master.workDir}/cac.json", slavedest="cac.json")) -# s.addStep(steps.FileDownload(mastersrc="${config.krebs.buildbot.master.workDir}/retiolum-ci.rsa_key.priv", slavedest="retiolum.rsa_key.priv")) -# addShell(s, name="infest-cac-centos7",env=env, -# sigtermTime=60, # SIGTERM 1 minute before SIGKILL -# timeout=10800, # 3h -# command=nixshell + ["infest-cac-centos7"]) -# -# bu.append(util.BuilderConfig(name="full-tests", -# slavenames=slavenames, -# factory=s)) -# ''; - }; - enable = true; - web = { - enable = true; - }; - irc = { - enable = true; - nick = "${hostname}bot"; - server = "ni.r"; - channels = [ "retiolum" ]; - allowForce = true; - }; - extraConfig = '' - c['buildbotURL'] = "http://build.${hostname}.r/" - ''; - }; - - krebs.buildbot.slave = { - enable = true; - masterhost = "localhost"; - username = "testslave"; - password = "krebspass"; - packages = with pkgs; [ gnumake jq nix populate ]; - # all nix commands will need a working nixpkgs installation - extraEnviron = { - NIX_PATH="nixpkgs=/var/src/nixpkgs:nixos-config=./krebs/1systems/${hostname}/config.nix:stockholm=./"; }; + krebs.ci.enable = true; + krebs.ci.users.krebs ={ + all = true; + hosts = [ + "test-arch" + "test-centos6" + "test-centos7" + "test-all-krebs-modules" + ]; }; } diff --git a/krebs/3modules/buildbot/master.nix b/krebs/3modules/buildbot/master.nix index 6c7af6da5..a7624c8f2 100644 --- a/krebs/3modules/buildbot/master.nix +++ b/krebs/3modules/buildbot/master.nix @@ -2,15 +2,6 @@ with import <stockholm/lib>; let - - # https://github.com/NixOS/nixpkgs/issues/14026 - nixpkgs-fix = import (pkgs.fetchgit { - url = https://github.com/nixos/nixpkgs; - rev = "e026b5c243ea39810826e68362718f5d703fb5d0"; - sha256 = "11lqd480bi6xbi7xbh4krrxmbp6a6iafv1d0q3sj461al0x0has8"; - }) {}; - - buildbot = nixpkgs-fix.buildbot; buildbot-master-config = pkgs.writeText "buildbot-master.cfg" '' # -*- python -*- from buildbot.plugins import * @@ -357,7 +348,7 @@ let set -efux if [ ! -e ${workdir} ];then mkdir -p ${workdir} - ${buildbot}/bin/buildbot create-master -r -l 10 -f ${workdir} + ${pkgs.buildbot-classic}/bin/buildbot create-master -r -l 10 -f ${workdir} fi # always override the master.cfg cp ${buildbot-master-config} ${workdir}/master.cfg @@ -366,18 +357,18 @@ let ${ concatMapStringsSep "\n" (f: "cp ${secretsdir}/${f} ${workdir}/${f}" ) cfg.secrets } # sanity - ${buildbot}/bin/buildbot checkconfig ${workdir} + ${pkgs.buildbot-classic}/bin/buildbot checkconfig ${workdir} # TODO: maybe upgrade? not sure about this # normally we should write buildbot.tac by our own - # ${buildbot}/bin/buildbot upgrade-master ${workdir} + # ${pkgs.buildbot-classic}/bin/buildbot upgrade-master ${workdir} chmod 700 -R ${workdir} chown buildbotMaster:buildbotMaster -R ${workdir} ''; - ExecStart = "${buildbot}/bin/buildbot start ${workdir}"; - ExecStop = "${buildbot}/bin/buildbot stop ${workdir}"; - ExecReload = "${buildbot}/bin/buildbot reconfig ${workdir}"; + ExecStart = "${pkgs.buildbot-classic}/bin/buildbot start ${workdir}"; + ExecStop = "${pkgs.buildbot-classic}/bin/buildbot stop ${workdir}"; + ExecReload = "${pkgs.buildbot-classic}/bin/buildbot reconfig ${workdir}"; PrivateTmp = "true"; User = "buildbotMaster"; Restart = "always"; diff --git a/krebs/3modules/buildbot/slave.nix b/krebs/3modules/buildbot/slave.nix index 932923ae5..544f9c4e0 100644 --- a/krebs/3modules/buildbot/slave.nix +++ b/krebs/3modules/buildbot/slave.nix @@ -2,12 +2,6 @@ with import <stockholm/lib>; let - nixpkgs-fix = import (pkgs.fetchgit { - url = https://github.com/nixos/nixpkgs; - rev = "e026b5c243ea39810826e68362718f5d703fb5d0"; - sha256 = "11lqd480bi6xbi7xbh4krrxmbp6a6iafv1d0q3sj461al0x0has8"; - }) {}; - buildbot-slave-init = pkgs.writeText "buildbot-slave.tac" '' import os @@ -158,7 +152,6 @@ let workdir = shell.escape cfg.workDir; contact = shell.escape cfg.contact; description = shell.escape cfg.description; - buildbot = nixpkgs-fix.buildbot-slave; # TODO:make this in { PermissionsStartOnly = true; @@ -175,8 +168,8 @@ let chown buildbotSlave:buildbotSlave -R ${workdir} chmod 700 -R ${workdir} ''; - ExecStart = "${buildbot}/bin/buildslave start ${workdir}"; - ExecStop = "${buildbot}/bin/buildslave stop ${workdir}"; + ExecStart = "${pkgs.buildbot-classic-slave}/bin/buildslave start ${workdir}"; + ExecStop = "${pkgs.buildbot-classic-slave}/bin/buildslave stop ${workdir}"; PrivateTmp = "true"; User = "buildbotSlave"; Restart = "always"; diff --git a/krebs/3modules/ci.nix b/krebs/3modules/ci.nix new file mode 100644 index 000000000..542a9252f --- /dev/null +++ b/krebs/3modules/ci.nix @@ -0,0 +1,175 @@ +{ config, pkgs, ... }: +with import <stockholm/lib>; +let + cfg = config.krebs.ci; + + hostname = config.networking.hostName; +in +{ + options.krebs.ci = { + enable = mkEnableOption "krebs continous integration"; + users = mkOption { + type = with types; attrsOf (submodule { + options = { + all = mkOption { + type = bool; + default = true; + }; + hosts = mkOption { + type = listOf str; + default = []; + }; + }; + }); + example = { + lass.all = true; + krebs = { + all = true; + hosts = [ + "test-all-krebs-modules" + "test-arch" + ]; + }; + }; + default = {}; + }; + }; + + config = mkIf cfg.enable { + services.nginx = { + enable = true; + virtualHosts.build = { + serverAliases = [ "build.${hostname}.r" ]; + locations."/".extraConfig = '' + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://127.0.0.1:${toString config.krebs.buildbot.master.web.port}; + ''; + }; + }; + + nix.gc.automatic = true; + nix.gc.dates = "05:23"; + + krebs.buildbot.master = { + slaves = { + testslave = "lasspass"; + }; + change_source.stockholm = '' + stockholm_repo = 'http://cgit.${hostname}.r/stockholm' + cs.append( + changes.GitPoller( + stockholm_repo, + workdir='stockholm-poller', branches=True, + project='stockholm', + pollinterval=10 + ) + ) + ''; + scheduler = { + build-scheduler = '' + # build all hosts + sched.append( + schedulers.SingleBranchScheduler( + change_filter=util.ChangeFilter(branch_re=".*"), + treeStableTimer=10, + name="build-all-branches", + builderNames=[ + "build-hosts" + ] + ) + ) + ''; + force-scheduler = '' + sched.append( + schedulers.ForceScheduler( + name="force", + builderNames=[ + "build-hosts" + ] + ) + ) + ''; + }; + builder_pre = '' + # prepare grab_repo step for stockholm + grab_repo = steps.Git( + repourl=stockholm_repo, + mode='full' + ) + + # prepare addShell function + def addShell(factory,**kwargs): + factory.addStep(steps.ShellCommand(**kwargs)) + ''; + builder = { + build-hosts = '' + f = util.BuildFactory() + f.addStep(grab_repo) + + def build_host(user, host): + addShell(f, + name="{}".format(host), + env={ + "NIX_PATH": "secrets=/var/src/stockholm/null:/var/src", + "NIX_REMOTE": "daemon", + "dummy_secrets": "true", + }, + command=[ + "nix-shell", "--run", + "test --user={} --system={} --target=$LOGNAME@${config.krebs.build.host.name}$HOME/{}".format(user, host, user) + ] + ) + + ${let + user-hosts = mapAttrs (user: a: let + managed-hosts = attrNames (filterAttrs (_: h: (h.owner.name == user) && h.managed) config.krebs.hosts); + defined-hosts = a.hosts; + in + defined-hosts ++ (optionals a.all managed-hosts) + ) cfg.users; + + in + concatStringsSep "\n" ( + (mapAttrsToList (user: hosts: + concatMapStringsSep "\n" (host: + "build_host(\"${user}\", \"${host}\")" + ) hosts + ) user-hosts) + ) + } + + bu.append( + util.BuilderConfig( + name="build-hosts", + slavenames=slavenames, + factory=f + ) + ) + + ''; + }; + enable = true; + web.enable = true; + irc = { + enable = true; + nick = "build|${hostname}"; + server = "ni.r"; + channels = [ "retiolum" "noise" ]; + allowForce = true; + }; + extraConfig = '' + c['buildbotURL'] = "http://build.${hostname}.r/" + ''; + }; + + krebs.buildbot.slave = { + enable = true; + masterhost = "localhost"; + username = "testslave"; + password = "lasspass"; + packages = with pkgs; [ gnumake jq nix populate ]; + }; + + }; +} diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index 6123b6dd9..b0ad2baf5 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -12,6 +12,7 @@ let ./buildbot/master.nix ./buildbot/slave.nix ./build.nix + ./ci.nix ./current.nix ./exim.nix ./exim-retiolum.nix diff --git a/krebs/3modules/krebs/default.nix b/krebs/3modules/krebs/default.nix index 07543489a..27fbb7088 100644 --- a/krebs/3modules/krebs/default.nix +++ b/krebs/3modules/krebs/default.nix @@ -32,12 +32,15 @@ in { hosts = { hotdog = { owner = config.krebs.users.krebs; + managed = true; nets = { retiolum = { ip4.addr = "10.243.77.3"; ip6.addr = "42:0:0:0:0:0:77:3"; aliases = [ "hotdog.r" + "build.hotdog.r" + "cgit.hotdog.r" ]; tinc.pubkey = '' -----BEGIN RSA PUBLIC KEY----- @@ -56,6 +59,7 @@ in { }; puyak = { owner = config.krebs.users.krebs; + managed = true; nets = { retiolum = { ip4.addr = "10.243.77.2"; @@ -82,6 +86,7 @@ in { }; wolf = { owner = config.krebs.users.krebs; + managed = true; nets = { shack = { ip4.addr = "10.42.2.150" ; @@ -120,6 +125,11 @@ in { krebs = { pubkey = "lol"; # TODO krebs.users.krebs.pubkey should be unnecessary }; + hotdog-repo-sync = { + name = "hotdog-repo-sync"; + mail = "spam@krebsco.de"; + pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILzTvaR3QqOD3oEEGHQzg/sRnNbKJnZYcV9htDvXmu53"; + }; puyak-repo-sync = { name = "puyak-repo-sync"; mail = "spam@krebsco.de"; diff --git a/krebs/5pkgs/simple/buildbot-classic-slave/default.nix b/krebs/5pkgs/simple/buildbot-classic-slave/default.nix new file mode 100644 index 000000000..c316889e4 --- /dev/null +++ b/krebs/5pkgs/simple/buildbot-classic-slave/default.nix @@ -0,0 +1,21 @@ +{ coreutils, fetchgit, fetchFromGitHub, buildbot-classic, python2Packages, ... }: + +python2Packages.buildPythonApplication { + name = "buildbot-classic-slave-0.8.12"; + namePrefix = ""; + + src = buildbot-classic.src; + postUnpack = "sourceRoot=\${sourceRoot}/slave"; + + patchPhase = '' + substituteInPlace buildslave/scripts/logwatcher.py --replace /usr/bin/tail ${coreutils}/bin/tail + ''; + + propagatedBuildInputs = [ python2Packages.twisted ]; + doCheck = false; + + postInstall = '' + mkdir -p "$out/share/man/man1" + cp docs/buildslave.1 "$out/share/man/man1" + ''; +} diff --git a/krebs/5pkgs/simple/buildbot-classic/default.nix b/krebs/5pkgs/simple/buildbot-classic/default.nix new file mode 100644 index 000000000..a3d924c4a --- /dev/null +++ b/krebs/5pkgs/simple/buildbot-classic/default.nix @@ -0,0 +1,47 @@ +{ fetchgit, fetchFromGitHub, python2Packages, ... }: +let + # https://github.com/NixOS/nixpkgs/issues/14026 + nixpkgs-fix = import (fetchgit { + url = https://github.com/nixos/nixpkgs; + rev = "e026b5c243ea39810826e68362718f5d703fb5d0"; + sha256 = "11lqd480bi6xbi7xbh4krrxmbp6a6iafv1d0q3sj461al0x0has8"; + }) {}; + +in nixpkgs-fix.buildPythonApplication { + name = "buildbot-classic-0.8.12"; + namePrefix = ""; + patches = []; + + src = fetchFromGitHub { + owner = "krebscode"; + repo = "buildbot-classic"; + rev = "5b4f5f6f1"; + sha256 = "1j3xn1gjzvsf90jvfmyln71fzlhjx642ivrqf47zfxpkacljja93"; + }; + postUnpack = "sourceRoot=\${sourceRoot}/master"; + + patchPhase = + # The code insists on /usr/bin/tail, /usr/bin/make, etc. + '' echo "patching erroneous absolute path references..." + for i in $(find -name \*.py) + do + sed -i "$i" \ + -e "s|/usr/bin/python|$(type -P python)|g ; s|/usr/bin/||g" + done + + sed -i 's/==/>=/' setup.py + ''; + + propagatedBuildInputs = [ + python2Packages.jinja2 + python2Packages.twisted + nixpkgs-fix.pythonPackages.dateutil_1_5 + nixpkgs-fix.pythonPackages.sqlalchemy_migrate_0_7 + ]; + doCheck = false; + postInstall = '' + mkdir -p "$out/share/man/man1" + cp docs/buildbot.1 "$out/share/man/man1" + ''; +} + |