Bug 1597903 - When a build differs, check if the generated-files differ. r=froydnj
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 04 Dec 2019 22:27:35 +0000
changeset 505556 ae2503b461f3c46365f1caf18781a9515fa388d6
parent 505555 6435902a44ef5129171c243f303b5ae2b172665b
child 505557 ebc95c785899006c401fd36b5eae32b9b55eeae2
push id102339
push usermh@glandium.org
push dateWed, 04 Dec 2019 22:28:31 +0000
treeherderautoland@ae2503b461f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1597903, 1601150
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1597903 - When a build differs, check if the generated-files differ. r=froydnj With this change, the error for bug 1601150 becomes: TEST-UNEXPECTED-FAIL | i686-unknown-linux-gnu/release/build/cranelift-codegen-37dab135a3db8b7a/out/inst_builder.rs differs. See the generated-files.diff.html or generated-files.diff.txt artifact TEST-UNEXPECTED-FAIL | i686-unknown-linux-gnu/release/build/cranelift-codegen-37dab135a3db8b7a/out/opcodes.rs differs. See the generated-files.diff.html or generated-files.diff.txt artifact TEST-UNEXPECTED-FAIL | i686-unknown-linux-gnu/release/build/cranelift-codegen-e483dcad1bdf8c4a/out/inst_builder.rs differs. See the generated-files.diff.html or generated-files.diff.txt artifact TEST-UNEXPECTED-FAIL | i686-unknown-linux-gnu/release/build/cranelift-codegen-e483dcad1bdf8c4a/out/opcodes.rs differs. See the generated-files.diff.html or generated-files.diff.txt artifact Differential Revision: https://phabricator.services.mozilla.com/D55771
taskcluster/docker/diffoscope/get_and_diffoscope
taskcluster/taskgraph/transforms/diffoscope.py
--- a/taskcluster/docker/diffoscope/get_and_diffoscope
+++ b/taskcluster/docker/diffoscope/get_and_diffoscope
@@ -40,16 +40,53 @@ case "$ORIG_URL" in
 */target.apk)
 	OMNIJAR=assets/omni.ja
 	;;
 *)
 	OMNIJAR=omni.ja
 	;;
 esac
 
+report_error() {
+	# We "parse" the diff output, so we look at the lines that contain a "tee", like:
+	# ├── firefox
+	# │ ├── libxul.so
+	# │ │ ├── readelf --wide --notes {}
+	# We ignore lines like the last one, to only report file names. And we ignore
+	# lines for directories such as the first one, but still look at them to report
+	# full paths.
+	python3 <<-EOF
+		TEE = '├──'
+		paths = set()
+		path = []
+		with open("$1.txt") as fh:
+		    for l in fh:
+		        if TEE not in l:
+		            continue
+		        fields = l.split()
+		        # We rely on the number of │ to figure out at what level the file
+		        # name applies.
+		        if fields[-2:-1] == [TEE]:
+		            path[len(fields) - 2:] = [fields[-1]]
+		        else:
+		            # Align path length to match the number of │
+		            path.append(None)
+		        path_ = [p for p in path if p]
+		        full_path = '/'.join(path_)
+		        parent_path = '/'.join(path_[:1])
+		        if parent_path in paths:
+		            paths.remove(parent_path)
+		        if full_path:
+		            paths.add(full_path)
+
+		for p in sorted(paths):
+		    print('TEST-UNEXPECTED-FAIL | {} differs. See the $1.html or $1.txt artifact'.format(p))
+	EOF
+}
+
 # Builds are 99% of the time differing in some small ways, so it's not
 # really useful to report a failure (at least not until we actually
 # care about the builds being 100% identical).
 POST=true
 
 fail() {
 	exit 1
 }
@@ -82,46 +119,31 @@ if diffoscope \
 	--text diff.txt \
 	--progress \
 	$DIFFOSCOPE_ARGS \
 	a b
 then
 	# Ok
 	:
 else
-	# The builds differ, let's try to output a useful error.
+	# The builds differ, let's check the generated files.
+	if curl -L -f "${ORIG_URL%/*}/target.generated-files.tar.gz" > a.generated-files.tar.gz && \
+	   curl -L -f "${NEW_URL%/*}/target.generated-files.tar.gz" > b.generated-files.tar.gz
+	then
+		HAVE_GENERATED_FILES=1
+	else
+		HAVE_GENERATED_FILES=
+	fi
 
-	# We "parse" the diff output, so we look at the lines that contain a "tee", like:
-	# ├── firefox
-	# │ ├── libxul.so
-	# │ │ ├── readelf --wide --notes {}
-	# We ignore lines like the last one, to only report file names. And we ignore
-	# lines for directories such as the first one, but still look at them to report
-	# full paths.
-	python3 <<-EOF
-		TEE = '├──'
-		paths = set()
-		path = []
-		with open("diff.txt") as fh:
-		    for l in fh:
-		        if TEE not in l:
-		            continue
-		        fields = l.split()
-		        # We rely on the number of │ to figure out at what level the file
-		        # name applies.
-		        if fields[-2:-1] == [TEE]:
-		            path[len(fields) - 2:] = [fields[-1]]
-		        else:
-		            # Align path length to match the number of │
-		            path.append(None)
-		        path_ = [p for p in path if p]
-		        full_path = '/'.join(path_)
-		        parent_path = '/'.join(path_[:1])
-		        if parent_path in paths:
-		            paths.remove(parent_path)
-		        if full_path:
-		            paths.add(full_path)
+	if test -n "$HAVE_GENERATED_FILES" && diffoscope \
+		--html generated-files.diff.html \
+		--text generated-files.diff.txt \
+		--progress \
+		--output-empty \
+		a.generated-files.tar.gz b.generated-files.tar.gz
+	then
+		report_error diff
+	else
+		report_error generated-files.diff
+	fi
 
-		for p in sorted(paths):
-		    print('TEST-UNEXPECTED-FAIL | {} differs. See the diff.html or diff.txt artifact'.format(p))
-	EOF
 	$POST
 fi
--- a/taskcluster/taskgraph/transforms/diffoscope.py
+++ b/taskcluster/taskgraph/transforms/diffoscope.py
@@ -128,23 +128,24 @@ def fill_template(config, tasks):
                 'kind': 'other',
                 'tier': 2,
             },
             'worker-type': 'b-linux',
             'worker': {
                 'docker-image': {'in-tree': 'diffoscope'},
                 'artifacts': [{
                     'type': 'file',
-                    'path': '/builds/worker/diff.html',
-                    'name': 'public/diff.html',
-                }, {
-                    'type': 'file',
-                    'path': '/builds/worker/diff.txt',
-                    'name': 'public/diff.txt',
-                }],
+                    'path': '/builds/worker/{}'.format(f),
+                    'name': 'public/{}'.format(f),
+                } for f in (
+                    'diff.html',
+                    'diff.txt',
+                    'generated-files.diff.html',
+                    'generated-files.diff.txt',
+                )],
                 'env': {
                     'ORIG_URL': urls['original'],
                     'NEW_URL': urls['new'],
                     'DIFFOSCOPE_ARGS': ' '.join(
                         task[k] for k in ('args', 'extra-args') if k in task),
                     'PRE_DIFF': '; '.join(task.get('pre-diff-commands', [])),
                 },
                 'max-run-time': 1800,