Merge ~cjwatson/launchpad-buildd:ci-chown-build-tree into launchpad-buildd:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: f3a4b80e219400ef22f7013f7917188092e8ef21
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad-buildd:ci-chown-build-tree
Merge into: launchpad-buildd:master
Diff against target: 64 lines (+13/-0)
3 files modified
debian/changelog (+8/-0)
lpbuildd/target/run_ci.py (+1/-0)
lpbuildd/target/tests/test_run_ci.py (+4/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+436371@code.launchpad.net

Commit message

In CI jobs, chown the VCS tree to buildd:buildd after fetching it

Description of the change

Otherwise lpcraft running as the buildd user can't read its .git directory. For example, this broke Launchpad's own CI jobs.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

I've going to self-approve this - it's a regression in launchpad-buildd 227 that affected Launchpad's own CI jobs, and I have a simple end-to-end test case for it on dogfood that I'll be able to run easily (https://code.dogfood.paddev.net/~cjwatson/+git/git-test).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index bb87638..e48d607 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,11 @@
6+launchpad-buildd (228) UNRELEASED; urgency=medium
7+
8+ * In CI jobs, chown the VCS tree to buildd:buildd after fetching it, since
9+ otherwise lpcraft running as the buildd user can't read its .git
10+ directory.
11+
12+ -- Colin Watson <cjwatson@ubuntu.com> Thu, 26 Jan 2023 11:30:11 +0000
13+
14 launchpad-buildd (227) focal; urgency=medium
15
16 * Tolerate receiving "builder_constraints": None.
17diff --git a/lpbuildd/target/run_ci.py b/lpbuildd/target/run_ci.py
18index 62757e2..c0e8703 100644
19--- a/lpbuildd/target/run_ci.py
20+++ b/lpbuildd/target/run_ci.py
21@@ -95,6 +95,7 @@ class RunCIPrepare(BuilderProxyOperationMixin, VCSOperationMixin,
22 env = self.build_proxy_environment(proxy_url=self.args.proxy_url)
23 self.vcs_fetch("tree", cwd="/build", env=env)
24 self.vcs_update_status(self.buildd_path)
25+ self.backend.run(["chown", "-R", "buildd:buildd", "/build/tree"])
26
27 def run(self):
28 try:
29diff --git a/lpbuildd/target/tests/test_run_ci.py b/lpbuildd/target/tests/test_run_ci.py
30index 3eac5fc..08c4d95 100644
31--- a/lpbuildd/target/tests/test_run_ci.py
32+++ b/lpbuildd/target/tests/test_run_ci.py
33@@ -233,6 +233,7 @@ class TestRunCIPrepare(TestCase):
34 RanBuildCommand(
35 ["git", "rev-parse", "HEAD^{}"],
36 cwd="/build/tree", get_output=True, universal_newlines=True),
37+ RanCommand(["chown", "-R", "buildd:buildd", "/build/tree"]),
38 ]))
39 status_path = os.path.join(run_ci_prepare.backend.build_path, "status")
40 with open(status_path) as status:
41@@ -259,6 +260,7 @@ class TestRunCIPrepare(TestCase):
42 RanBuildCommand(
43 ["git", "rev-parse", "next^{}"],
44 cwd="/build/tree", get_output=True, universal_newlines=True),
45+ RanCommand(["chown", "-R", "buildd:buildd", "/build/tree"]),
46 ]))
47 status_path = os.path.join(run_ci_prepare.backend.build_path, "status")
48 with open(status_path) as status:
49@@ -285,6 +287,7 @@ class TestRunCIPrepare(TestCase):
50 RanBuildCommand(
51 ["git", "rev-parse", "refs/tags/1.0^{}"],
52 cwd="/build/tree", get_output=True, universal_newlines=True),
53+ RanCommand(["chown", "-R", "buildd:buildd", "/build/tree"]),
54 ]))
55 status_path = os.path.join(run_ci_prepare.backend.build_path, "status")
56 with open(status_path) as status:
57@@ -318,6 +321,7 @@ class TestRunCIPrepare(TestCase):
58 RanBuildCommand(
59 ["git", "rev-parse", "HEAD^{}"],
60 cwd="/build/tree", get_output=True, universal_newlines=True),
61+ RanCommand(["chown", "-R", "buildd:buildd", "/build/tree"]),
62 ]))
63 status_path = os.path.join(run_ci_prepare.backend.build_path, "status")
64 with open(status_path) as status:

Subscribers

People subscribed via source and target branches