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
diff --git a/lib/lp/code/model/revisionstatus.py b/lib/lp/code/model/revisionstatus.py
index dbc910a..c079a87 100644
--- a/lib/lp/code/model/revisionstatus.py
+++ b/lib/lp/code/model/revisionstatus.py
@@ -141,6 +141,7 @@ class RevisionStatusReport(StormBase):
141 file=file,141 file=file,
142 contentType="application/octet-stream",142 contentType="application/octet-stream",
143 restricted=self.git_repository.private,143 restricted=self.git_repository.private,
144 allow_zero_length=True,
144 )145 )
145 getUtility(IRevisionStatusArtifactSet).new(lfa, self, artifact_type)146 getUtility(IRevisionStatusArtifactSet).new(lfa, self, artifact_type)
146147
diff --git a/lib/lp/code/model/tests/test_revisionstatus.py b/lib/lp/code/model/tests/test_revisionstatus.py
index 1ab7618..9ff6cc9 100644
--- a/lib/lp/code/model/tests/test_revisionstatus.py
+++ b/lib/lp/code/model/tests/test_revisionstatus.py
@@ -356,6 +356,23 @@ class TestRevisionStatusReportWebservice(TestCaseWithFactory):
356 sha1(content.encode()).hexdigest(),356 sha1(content.encode()).hexdigest(),
357 )357 )
358358
359 def test_attach_empty_file(self):
360 report = self.factory.makeRevisionStatusReport(
361 title="build:0",
362 ci_build=self.factory.makeCIBuild(),
363 )
364
365 with person_logged_in(report.creator):
366 report.attach("empty", b"")
367
368 artifacts = list(
369 getUtility(IRevisionStatusArtifactSet).findByReport(report)
370 )
371 self.assertEqual(
372 artifacts[0].library_file.content.sha1,
373 hashlib.sha1(b"").hexdigest(),
374 )
375
359 def test_update(self):376 def test_update(self):
360 test_properties = {377 test_properties = {
361 "launchpad.source-name": "go-module",378 "launchpad.source-name": "go-module",

Subscribers

People subscribed via source and target branches

to status/vote changes: