From 1a4b51fefb68a5209989d71777724b336add0b51 Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Thu, 17 Feb 2022 00:06:26 +0100 Subject: [PATCH] Use the latest build status when checking docs.rs When documentation for a crate is rebuilt the `builds.json` can return multiple results, ordered latest first, so we must take the first element of the array rather than the last. --- services/docsrs/docsrs.service.js | 2 +- services/docsrs/docsrs.tester.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/services/docsrs/docsrs.service.js b/services/docsrs/docsrs.service.js index ca88f67e49259..f5c12f3ff8542 100644 --- a/services/docsrs/docsrs.service.js +++ b/services/docsrs/docsrs.service.js @@ -54,7 +54,7 @@ export default class DocsRs extends BaseJsonService { async handle({ crate, version = 'latest' }) { const { build_status: buildStatus } = ( await this.fetch({ crate, version }) - ).pop() + ).shift() return this.constructor.render({ version, buildStatus }) } } diff --git a/services/docsrs/docsrs.tester.js b/services/docsrs/docsrs.tester.js index 4006183adbc0c..eb62b35717751 100644 --- a/services/docsrs/docsrs.tester.js +++ b/services/docsrs/docsrs.tester.js @@ -10,6 +10,10 @@ t.create('Failing docs') .get('/tensorflow/0.16.1.json') .expectBadge({ label: 'docs@0.16.1', message: 'failing' }) +t.create('Multiple builds, latest passing') + .get('/bevy_tweening/0.3.1.json') + .expectBadge({ label: 'docs@0.3.1', message: 'passing' }) + t.create('Getting latest version works') .get('/rand/latest.json') .expectBadge({