Merge ~cjwatson/launchpad:allow-empty-ci-output-files into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: ebb824f81420bc5e88a78fe6665ae2f34cfd9eec
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:allow-empty-ci-output-files
Merge into: launchpad:master
Diff against target: 40 lines (+18/-0)
2 files modified
lib/lp/code/model/revisionstatus.py (+1/-0)
lib/lp/code/model/tests/test_revisionstatus.py (+17/-0)
Reviewer Review Type Date Requested Status
Guruprasad Approve
Review via email: mp+444577@code.launchpad.net

Commit message

Allow CI build artifacts to be zero-length

Description of the change

It isn't necessarily unreasonable for artifacts produced by CI builds to be zero-length: for example, https://git.launchpad.net/ubuntu-cdimage declares an output file resulting from from `./run-tests >output`, and the `./run-tests` command there produces no output if the tests succeed. Allow this rather than OOPSing.

To post a comment you must log in.
Revision history for this message
Guruprasad (lgp171188) wrote :

LGTM 👍

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/code/model/revisionstatus.py b/lib/lp/code/model/revisionstatus.py
2index dbc910a..c079a87 100644
3--- a/lib/lp/code/model/revisionstatus.py
4+++ b/lib/lp/code/model/revisionstatus.py
5@@ -141,6 +141,7 @@ class RevisionStatusReport(StormBase):
6 file=file,
7 contentType="application/octet-stream",
8 restricted=self.git_repository.private,
9+ allow_zero_length=True,
10 )
11 getUtility(IRevisionStatusArtifactSet).new(lfa, self, artifact_type)
12
13diff --git a/lib/lp/code/model/tests/test_revisionstatus.py b/lib/lp/code/model/tests/test_revisionstatus.py
14index 1ab7618..9ff6cc9 100644
15--- a/lib/lp/code/model/tests/test_revisionstatus.py
16+++ b/lib/lp/code/model/tests/test_revisionstatus.py
17@@ -356,6 +356,23 @@ class TestRevisionStatusReportWebservice(TestCaseWithFactory):
18 sha1(content.encode()).hexdigest(),
19 )
20
21+ def test_attach_empty_file(self):
22+ report = self.factory.makeRevisionStatusReport(
23+ title="build:0",
24+ ci_build=self.factory.makeCIBuild(),
25+ )
26+
27+ with person_logged_in(report.creator):
28+ report.attach("empty", b"")
29+
30+ artifacts = list(
31+ getUtility(IRevisionStatusArtifactSet).findByReport(report)
32+ )
33+ self.assertEqual(
34+ artifacts[0].library_file.content.sha1,
35+ hashlib.sha1(b"").hexdigest(),
36+ )
37+
38 def test_update(self):
39 test_properties = {
40 "launchpad.source-name": "go-module",

Subscribers

People subscribed via source and target branches

to status/vote changes: