aboutsummaryrefslogtreecommitdiff
path: root/modules/private/buildbot
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-12-01 15:14:07 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-12-01 15:14:07 +0100
commit0012da0ff3d45df9f68412b90be4f7c24d46a777 (patch)
treea4fd1cb0e17d39610a629dcd256857309268abdc /modules/private/buildbot
parent573e17101354432a4167c21d832bb2873d6ad220 (diff)
downloadNix-0012da0ff3d45df9f68412b90be4f7c24d46a777.tar.gz
Nix-0012da0ff3d45df9f68412b90be4f7c24d46a777.tar.zst
Nix-0012da0ff3d45df9f68412b90be4f7c24d46a777.zip
Add cours to buildbot
Diffstat (limited to 'modules/private/buildbot')
-rw-r--r--modules/private/buildbot/default.nix4
-rw-r--r--modules/private/buildbot/projects/immaeEu/__init__.py78
2 files changed, 68 insertions, 14 deletions
diff --git a/modules/private/buildbot/default.nix b/modules/private/buildbot/default.nix
index 8a09139..273ad70 100644
--- a/modules/private/buildbot/default.nix
+++ b/modules/private/buildbot/default.nix
@@ -182,7 +182,9 @@ in
182 )} 182 )}
183 ''; 183 '';
184 environment = let 184 environment = let
185 project_env = lib.attrsets.mapAttrs' (k: v: lib.attrsets.nameValuePair "BUILDBOT_${k}" v) project.environment; 185 project_env = with lib.attrsets;
186 mapAttrs' (k: v: nameValuePair "BUILDBOT_${k}" v) project.environment //
187 mapAttrs' (k: v: nameValuePair "BUILDBOT_PATH_${k}" (v pkgs)) (attrByPath ["builderPaths"] {} project);
186 buildbot_config = pkgs.python3Packages.buildPythonPackage (rec { 188 buildbot_config = pkgs.python3Packages.buildPythonPackage (rec {
187 name = "buildbot_config-${project.name}"; 189 name = "buildbot_config-${project.name}";
188 src = ./projects + "/${project.name}"; 190 src = ./projects + "/${project.name}";
diff --git a/modules/private/buildbot/projects/immaeEu/__init__.py b/modules/private/buildbot/projects/immaeEu/__init__.py
index 437af72..f29eb14 100644
--- a/modules/private/buildbot/projects/immaeEu/__init__.py
+++ b/modules/private/buildbot/projects/immaeEu/__init__.py
@@ -11,14 +11,20 @@ class E():
11 BUILDBOT_URL = "https://git.immae.eu/buildbot/{}/".format(PROJECT) 11 BUILDBOT_URL = "https://git.immae.eu/buildbot/{}/".format(PROJECT)
12 SOCKET = "unix:/run/buildbot/{}.sock".format(PROJECT) 12 SOCKET = "unix:/run/buildbot/{}.sock".format(PROJECT)
13 PB_SOCKET = "unix:address=/run/buildbot/{}_pb.sock".format(PROJECT) 13 PB_SOCKET = "unix:address=/run/buildbot/{}_pb.sock".format(PROJECT)
14 RELEASE_PATH = "/var/lib/buildbot/outputs/immaeEu"
15 SSH_KEY_PATH = "/var/lib/buildbot/buildbot_key" 14 SSH_KEY_PATH = "/var/lib/buildbot/buildbot_key"
16 SSH_HOST_KEY = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIFbhFTl2A2RJn5L51yxJM4XfCS2ZaiSX/jo9jFSdghF" 15 SSH_HOST_KEY = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIFbhFTl2A2RJn5L51yxJM4XfCS2ZaiSX/jo9jFSdghF"
17 XMPP_RECIPIENTS = os.environ["BUILDBOT_XMPP_RECIPIENTS"].split(" ") 16 XMPP_RECIPIENTS = os.environ["BUILDBOT_XMPP_RECIPIENTS"].split(" ")
18 17
19 IMMAE_EU_GIT_URL = "gitolite@git.immae.eu:perso/Immae/Sites/Blog" 18 IMMAE_EU_GIT_URL = "gitolite@git.immae.eu:perso/Immae/Sites/Blog"
19 COURS_GIT_URL = "gitolite@git.immae.eu:perso/Immae/Sites/Cours"
20 NORMALESUP_GIT_URL = "gitolite@git.immae.eu:perso/Immae/Projets/Sites/Normalesup" 20 NORMALESUP_GIT_URL = "gitolite@git.immae.eu:perso/Immae/Projets/Sites/Normalesup"
21 21
22 COURS_RELEASE_PATH = "/var/lib/buildbot/outputs/cours"
23 COURS_TARBALL_PATH = "/var/lib/ftp/release.immae.eu/cours"
24 COURS_TARBALL_URL = "https://release.immae.eu/cours"
25 IMMAE_EU_RELEASE_PATH = "/var/lib/buildbot/outputs/immaeEu"
26 NORMALESUP_RELEASE_PATH = "/var/lib/buildbot/outputs/recherche"
27
22 # master.cfg 28 # master.cfg
23 SECRETS_FILE = os.getcwd() + "/secrets" 29 SECRETS_FILE = os.getcwd() + "/secrets"
24 LDAP_URL = "ldaps://ldap.immae.eu:636" 30 LDAP_URL = "ldaps://ldap.immae.eu:636"
@@ -54,55 +60,101 @@ def configure(c):
54 60
55 c['schedulers'].append(hook_scheduler("ImmaeEu", timer=1)) 61 c['schedulers'].append(hook_scheduler("ImmaeEu", timer=1))
56 c['schedulers'].append(hook_scheduler("Normalesup", timer=1)) 62 c['schedulers'].append(hook_scheduler("Normalesup", timer=1))
57 c['schedulers'].append(force_scheduler("force_immae_eu", ["ImmaeEu_build", "Normalesup_build"])) 63 c['schedulers'].append(hook_scheduler("Cours", timer=1))
64 c['schedulers'].append(force_scheduler("force_immae_eu", ["ImmaeEu_build", "Normalesup_build", "Cours_build"]))
58 65
59 c['builders'].append(immae_eu_factory()) 66 c['builders'].append(immae_eu_factory())
60 c['builders'].append(normalesup_factory()) 67 c['builders'].append(normalesup_factory())
68 c['builders'].append(cours_factory())
61 69
62 c['services'].append(SlackStatusPush( 70 c['services'].append(SlackStatusPush(
63 name="slack_status_immae_eu_project", 71 name="slack_status_immae_eu_project",
64 builders=["ImmaeEu_build", "Normalesup_build"], 72 builders=["ImmaeEu_build", "Normalesup_build", "Cours_build"],
65 serverUrl=open(E.SECRETS_FILE + "/slack_webhook", "r").read().rstrip())) 73 serverUrl=open(E.SECRETS_FILE + "/slack_webhook", "r").read().rstrip()))
66 c['services'].append(XMPPStatusPush( 74 c['services'].append(XMPPStatusPush(
67 name="xmpp_status_immae_eu_project", 75 name="xmpp_status_immae_eu_project",
68 builders=["ImmaeEu_build", "Normalesup_build"], 76 builders=["ImmaeEu_build", "Normalesup_build", "Cours_build"],
69 recipients=E.XMPP_RECIPIENTS, 77 recipients=E.XMPP_RECIPIENTS,
70 password=open(E.SECRETS_FILE + "/notify_xmpp_password", "r").read().rstrip())) 78 password=open(E.SECRETS_FILE + "/notify_xmpp_password", "r").read().rstrip()))
71 79
72def immae_eu_factory(): 80def immae_eu_factory():
81 path_env = {
82 "PATH": os.environ["BUILDBOT_PATH_ImmaeEu"] + ":${PATH}"
83 }
73 factory = util.BuildFactory() 84 factory = util.BuildFactory()
74 factory.addStep(steps.Git(logEnviron=False, repourl=E.IMMAE_EU_GIT_URL, 85 factory.addStep(steps.Git(logEnviron=False, repourl=E.IMMAE_EU_GIT_URL,
75 submodules=True, sshPrivateKey=open(E.SSH_KEY_PATH).read().rstrip(), 86 submodules=True, sshPrivateKey=open(E.SSH_KEY_PATH).read().rstrip(),
76 sshHostKey=E.SSH_HOST_KEY, mode="full", method="copy")) 87 sshHostKey=E.SSH_HOST_KEY, mode="full", method="copy"))
77 factory.addStep(steps.ShellCommand(name="build website", 88 factory.addStep(steps.ShellCommand(name="build website",
78 logEnviron=False, haltOnFailure=True, workdir="source", 89 logEnviron=False, haltOnFailure=True, workdir="source",
79 command=["make", "html"])) 90 env=path_env, command=["make", "html"]))
80 factory.addStep(steps.MasterShellCommand(command="rm -rf {}".format(E.RELEASE_PATH))) 91 factory.addStep(steps.MasterShellCommand(command="rm -rf {}".format(E.IMMAE_EU_RELEASE_PATH)))
81 factory.addStep(steps.DirectoryUpload(workersrc="../source/output", 92 factory.addStep(steps.DirectoryUpload(workersrc="../source/output",
82 masterdest=E.RELEASE_PATH, 93 masterdest=E.IMMAE_EU_RELEASE_PATH,
83 url="https://www.immae.eu")) 94 url="https://www.immae.eu"))
84 factory.addStep(steps.MasterShellCommand(command="chmod -R a+rX {}".format(E.RELEASE_PATH))) 95 factory.addStep(steps.MasterShellCommand(command="chmod -R a+rX {}".format(E.IMMAE_EU_RELEASE_PATH)))
85 96
86 return util.BuilderConfig(name="ImmaeEu_build", workernames=["generic-worker-immae-eu"], factory=factory) 97 return util.BuilderConfig(name="ImmaeEu_build", workernames=["generic-worker-immae-eu"], factory=factory)
87 98
99def cours_factory():
100 path_env = {
101 "PATH": os.environ["BUILDBOT_PATH_Cours"] + ":${PATH}"
102 }
103 factory = util.BuildFactory()
104 factory.addStep(steps.Git(logEnviron=False, repourl=E.COURS_GIT_URL,
105 submodules=True, sshPrivateKey=open(E.SSH_KEY_PATH).read().rstrip(),
106 sshHostKey=E.SSH_HOST_KEY, mode="full", method="copy"))
107 factory.addStep(steps.ShellCommand(name="build website",
108 logEnviron=False, haltOnFailure=True, workdir="source",
109 command=["make", "build"], env=path_env))
110 factory.addStep(steps.MasterShellCommand(command="rm -rf {}".format(E.COURS_RELEASE_PATH)))
111 factory.addStep(steps.DirectoryUpload(workersrc="../source/build",
112 masterdest=E.COURS_RELEASE_PATH,
113 url="https://www.immae.eu/cours"))
114 factory.addStep(steps.MasterShellCommand(command="chmod -R a+rX {}".format(E.COURS_RELEASE_PATH)))
115
116 factory.addStep(steps.ShellCommand(name="build pdfs",
117 logEnviron=False, haltOnFailure=True, workdir="source",
118 command=["make", "pdfs"], env=path_env))
119
120 package = util.Interpolate("cours_%(kw:clean_branch)s.tar.gz", clean_branch=clean_branch)
121 release_file = "{0}/cours_%(kw:clean_branch)s.tar.gz"
122 package_dest = util.Interpolate(release_file.format(E.COURS_TARBALL_PATH), clean_branch=clean_branch)
123 package_url = util.Interpolate(release_file.format(E.COURS_TARBALL_URL), clean_branch=clean_branch)
124 factory.addStep(steps.ShellCommand(name="build pdf tarball",
125 logEnviron=False, haltOnFailure=True, workdir="source",
126 command=["tar", "-cvf", package, "-C", "pdfs", "mp", "mpsi"], env=path_env))
127 factory.addStep(steps.FileUpload(name="upload package", workersrc=package,
128 workdir="source", masterdest=package_dest,
129 url=package_url, mode=0o644))
130
131 return util.BuilderConfig(name="Cours_build", workernames=["generic-worker-immae-eu"], factory=factory)
132
88def normalesup_factory(): 133def normalesup_factory():
134 path_env = {
135 "PATH": os.environ["BUILDBOT_PATH_Normalesup"] + ":${PATH}"
136 }
89 factory = util.BuildFactory() 137 factory = util.BuildFactory()
90 factory.addStep(steps.Git(logEnviron=False, repourl=E.NORMALESUP_GIT_URL, 138 factory.addStep(steps.Git(logEnviron=False, repourl=E.NORMALESUP_GIT_URL,
91 submodules=True, sshPrivateKey=open(E.SSH_KEY_PATH).read().rstrip(), 139 submodules=True, sshPrivateKey=open(E.SSH_KEY_PATH).read().rstrip(),
92 sshHostKey=E.SSH_HOST_KEY, mode="full", method="copy")) 140 sshHostKey=E.SSH_HOST_KEY, mode="full", method="copy"))
93 factory.addStep(steps.ShellCommand(name="build website", 141 factory.addStep(steps.ShellCommand(name="build website",
94 logEnviron=False, haltOnFailure=True, workdir="source", 142 logEnviron=False, haltOnFailure=True, workdir="source",
95 command=["make", "build"])) 143 command=["make", "build"], env=path_env))
96 factory.addStep(steps.ShellCommand(name="give read access to all files", 144 factory.addStep(steps.ShellCommand(name="give read access to all files",
97 logEnviron=False, haltOnFailure=True, workdir="source", 145 logEnviron=False, haltOnFailure=True, workdir="source",
98 command="chmod -R a+rX build")) 146 command="chmod -R a+rX build", env=path_env))
99 factory.addStep(steps.ShellCommand(name="synchronize with phare", 147 factory.addStep(steps.ShellCommand(name="synchronize with phare",
100 logEnviron=False, haltOnFailure=True, workdir="source", 148 logEnviron=False, haltOnFailure=True, workdir="source",
101 command=[ 149 env=path_env, command=[
102 "rsync", "-av", "--delete", 150 "rsync", "-av", "--delete",
103 "-e", "ssh -i {} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o CheckHostIP=no".format(E.SSH_KEY_PATH), 151 "-e", "ssh -i {} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o CheckHostIP=no".format(E.SSH_KEY_PATH),
104 "build/", 152 "build/",
105 "bouya@phare.normalesup.org:" 153 os.environ["BUILDBOT_NORMALESUP_HOST"]
106 ])) 154 ]))
155 factory.addStep(steps.MasterShellCommand(command="rm -rf {}".format(E.NORMALESUP_RELEASE_PATH)))
156 factory.addStep(steps.DirectoryUpload(workersrc="../source/build", masterdest=E.NORMALESUP_RELEASE_PATH,
157 url="https://www.immae.eu/recherche"))
158 factory.addStep(steps.MasterShellCommand(command="chmod -R a+rX {}".format(E.NORMALESUP_RELEASE_PATH)))
107 159
108 return util.BuilderConfig(name="Normalesup_build", workernames=["generic-worker-immae-eu"], factory=factory) 160 return util.BuilderConfig(name="Normalesup_build", workernames=["generic-worker-immae-eu"], factory=factory)