Diff
Modified: trunk/Websites/perf.webkit.org/ChangeLog (275328 => 275329)
--- trunk/Websites/perf.webkit.org/ChangeLog 2021-04-01 00:47:35 UTC (rev 275328)
+++ trunk/Websites/perf.webkit.org/ChangeLog 2021-04-01 00:50:11 UTC (rev 275329)
@@ -1,3 +1,32 @@
+2021-03-31 Zhifei Fang <zhifei_f...@apple.com>
+
+ Add commit revision label support
+ https://bugs.webkit.org/show_bug.cgi?id=222897
+
+ Reviewed by Ryosuke Niwa.
+
+ Add new column revision label.
+ Make all commit api also can work with revision label.
+ Change the commit label display with commit revision label.
+
+ * browser-tests/commit-log-viewer-tests.js: Fix a failed test case, while requesting the remote api,
+ we should wait for those promises resolved and then wait for commponent to render.
+ * init-database.sql: Add new column revision_identifier.
+ * migrate-database.sql: Add new column revision_identifier.
+ * public/include/commit-log-fetcher.php: Make api that works with revision should work with revision label.
+ * public/include/commit-updater.php: Ditto.
+ * public/include/report-processor.php: Make the processor can also insert revision label.
+ * public/v3/models/commit-log.js:
+ (CommitLog.prototype.updateSingleton):
+ (CommitLog.prototype.revisionIdentifier):
+ (CommitLog.prototype.label): Make the label include revision label and revision.
+ (CommitLog.prototype.diff): Make the diff label include revision label and revision.
+ * server-tests/api-commits-tests.js:
+ * server-tests/api-report-commits-tests.js:
+ * server-tests/api-report-tests.js:
+ (reportWithRevisionIdentifierCommit):
+ * unit-tests/commit-log-tests.js:
+
2021-03-22 Dewei Zhu <dewei_...@apple.com>
[perf dashboard] Remove v1 and v2 code.
Modified: trunk/Websites/perf.webkit.org/browser-tests/commit-log-viewer-tests.js (275328 => 275329)
--- trunk/Websites/perf.webkit.org/browser-tests/commit-log-viewer-tests.js 2021-04-01 00:47:35 UTC (rev 275328)
+++ trunk/Websites/perf.webkit.org/browser-tests/commit-log-viewer-tests.js 2021-04-01 00:50:11 UTC (rev 275329)
@@ -55,6 +55,19 @@
"message": "another message",
};
+ const webkitCommit210950WithRevisionIdentifier = {
+ "id": "185338",
+ "revision": "210950",
+ "revisionIdentifier": "184278@main",
+ "repository": 1,
+ "previousCommit": null,
+ "ownsCommits": false,
+ "time": +new Date("2017-01-20T03:49:37.887Z"),
+ "authorName": "Commit Queue",
+ "authorEmail": "commit-qu...@webkit.org",
+ "message": "another message",
+ };
+
it('should initially be empty with no spinner', () => {
const context = new BrowsingContext();
return importCommitLogViewer(context).then((CommitLogViewer) => {
@@ -129,9 +142,9 @@
"status": "OK",
"commits": [webkitCommit210948],
});
-
+ await requests[0].promise;
+ await requests[1].promise;
await waitForComponentsToRender(context);
-
expect(viewer.content('spinner-container').offsetHeight).to.be(0);
expect(viewer.content('commits-list').matches(':empty')).to.be(false);
expect(viewer.content('commits-list').textContent).to.contain('r210949');
@@ -144,4 +157,47 @@
});
});
+ it('should show revision label', async () => {
+ const context = new BrowsingContext();
+ const CommitLogViewer = await importCommitLogViewer(context);
+ const Repository = context.symbols.Repository;
+ const requests = context.symbols.RemoteAPI.requests;
+ const viewer = new CommitLogViewer;
+ const webkit = new Repository(1, {name: 'WebKit'});
+ context.document.body.appendChild(viewer.element());
+
+ viewer.enqueueToRender();
+ await waitForComponentsToRender(context);
+
+ viewer.view(webkit, '210948', '210950');
+ await waitForComponentsToRender(context);
+ expect(viewer.content('spinner-container').offsetHeight).to.not.be(0);
+ expect(viewer.content('commits-list').matches(':empty')).to.be(true);
+ expect(viewer.content('repository-name').matches(':empty')).to.be(false);
+ expect(viewer.content('repository-name').textContent).to.contain('WebKit');
+ expect(requests.length).to.be(2);
+ expect(requests[0].url).to.be('/api/commits/1/?precedingRevision=210948&lastRevision=210950');
+ expect(requests[1].url).to.be('/api/commits/1/210948');
+ requests[0].resolve({
+ "status": "OK",
+ "commits": [webkitCommit210949, webkitCommit210950WithRevisionIdentifier],
+ });
+
+ requests[1].resolve({
+ "status": "OK",
+ "commits": [webkitCommit210948],
+ });
+
+ await requests[0].promise;
+ await requests[1].promise;
+ await waitForComponentsToRender(context);
+ expect(viewer.content('spinner-container').offsetHeight).to.be(0);
+ expect(viewer.content('commits-list').matches(':empty')).to.be(false);
+ expect(viewer.content('commits-list').textContent).to.contain('184278@main (r210950)');
+ expect(viewer.content('commits-list').textContent).to.contain('Commit Queue');
+ expect(viewer.content('repository-name').matches(':empty')).to.be(false);
+ expect(viewer.content('repository-name').textContent).to.contain('WebKit');
+ expect(viewer.content('commits-list').querySelector('a')).to.be(null);
+ });
+
});
Modified: trunk/Websites/perf.webkit.org/init-database.sql (275328 => 275329)
--- trunk/Websites/perf.webkit.org/init-database.sql 2021-04-01 00:47:35 UTC (rev 275328)
+++ trunk/Websites/perf.webkit.org/init-database.sql 2021-04-01 00:50:11 UTC (rev 275329)
@@ -102,6 +102,7 @@
commit_id serial PRIMARY KEY,
commit_repository integer NOT NULL REFERENCES repositories ON DELETE CASCADE,
commit_revision varchar(64) NOT NULL,
+ commit_revision_identifier varchar(64) DEFAULT NULL,
commit_previous_commit integer REFERENCES commits ON DELETE CASCADE,
commit_time timestamp,
commit_order integer,
@@ -109,7 +110,8 @@
commit_message text,
commit_reported boolean NOT NULL DEFAULT FALSE,
commit_testability varchar(128) DEFAULT NULL,
- CONSTRAINT commit_in_repository_must_be_unique UNIQUE(commit_repository, commit_revision));
+ CONSTRAINT commit_in_repository_must_be_unique UNIQUE(commit_repository, commit_revision),
+ CONSTRAINT commit_string_identifier_in_repository_must_be_unique UNIQUE(commit_repository, commit_revision_identifier));
CREATE INDEX commit_time_index ON commits(commit_time);
CREATE INDEX commit_order_index ON commits(commit_order);
Modified: trunk/Websites/perf.webkit.org/migrate-database.sql (275328 => 275329)
--- trunk/Websites/perf.webkit.org/migrate-database.sql 2021-04-01 00:47:35 UTC (rev 275328)
+++ trunk/Websites/perf.webkit.org/migrate-database.sql 2021-04-01 00:50:11 UTC (rev 275329)
@@ -2,6 +2,10 @@
BEGIN
ALTER TABLE build_requests ADD COLUMN IF NOT EXISTS request_status_description varchar(1024) DEFAULT NULL;
+ALTER TABLE platforms ADD COLUMN IF NOT EXISTS platform_group integer REFERENCES platform_groups DEFAULT NULL;
+ALTER TABLE commits ADD COLUMN IF NOT EXISTS commit_revision_identifier varchar(64) DEFAULT NULL;
+ALTER TABLE commits DROP CONSTRAINT commit_string_identifier_in_repository_must_be_unique;
+ALTER TABLE commits ADD CONSTRAINT commit_string_identifier_in_repository_must_be_unique UNIQUE(commit_repository, commit_revision_identifier);
CREATE TABLE IF NOT EXISTS platform_groups (
platformgroup_id serial PRIMARY KEY,
Modified: trunk/Websites/perf.webkit.org/public/include/commit-log-fetcher.php (275328 => 275329)
--- trunk/Websites/perf.webkit.org/public/include/commit-log-fetcher.php 2021-04-01 00:47:35 UTC (rev 275328)
+++ trunk/Websites/perf.webkit.org/public/include/commit-log-fetcher.php 2021-04-01 00:50:11 UTC (rev 275329)
@@ -8,7 +8,9 @@
static function find_commit_id_by_revision($db, $repository_id, $revision)
{
- $commit_rows = $db->query_and_fetch_all('SELECT commit_id FROM commits WHERE commit_repository = $1 AND commit_revision = $2', array($repository_id, $revision));
+ $column_name = CommitLogFetcher::is_commit_revision_identifier($revision) ? 'commit_revision_identifier' : 'commit_revision';
+
+ $commit_rows = $db->query_and_fetch_all("SELECT commit_id FROM commits WHERE commit_repository = $1 AND $column_name = $2", array($repository_id, $revision));
if ($commit_rows)
return $commit_rows[0]['commit_id'];
@@ -15,7 +17,7 @@
if (!ctype_alnum($revision))
return NULL;
- $commit_rows = $db->query_and_fetch_all('SELECT commit_id FROM commits WHERE commit_repository = $1 AND commit_revision LIKE $2 LIMIT 2', array($repository_id, Database::escape_for_like($revision) . '%'));
+ $commit_rows = $db->query_and_fetch_all("SELECT commit_id FROM commits WHERE commit_repository = $1 AND $column_name LIKE $2 LIMIT 2", array($repository_id, Database::escape_for_like($revision) . '%'));
if (!$commit_rows)
return NULL;
if (count($commit_rows) > 1)
@@ -55,6 +57,7 @@
{
$statements = 'SELECT commit_id as "id",
commit_revision as "revision",
+ commit_revision_identifier as "revisionIdentifier",
commit_previous_commit as "previousCommit",
commit_time as "time",
committer_name as "authorName",
@@ -192,8 +195,14 @@
return $this->format_single_commit($commit);
}
+ private static function is_commit_revision_identifier($commit_revision_or_revision_identifier)
+ {
+ return preg_match('/^\d+@[\w\.\-]*$/', $commit_revision_or_revision_identifier);
+ }
+
private function commit_for_revision($repository_id, $revision) {
- $commit_info = array('repository' => $repository_id, 'revision' => $revision);
+ $commit_info = array('repository' => $repository_id);
+ $commit_info[$this->is_commit_revision_identifier($revision) ? 'revision_identifier' : 'revision'] = $revision;
$row = $this->db->select_last_row('commits', 'commit', $commit_info);
if (!$row)
exit_with_error('UnknownCommit', $commit_info);
@@ -201,7 +210,8 @@
}
private function commit_for_revision_prefix($repository_id, $revision_prefix) {
- $rows = $this->db->query_and_fetch_all('SELECT * FROM commits WHERE commit_repository = $1 AND commit_revision LIKE $2 ORDER BY commit_revision LIMIT 2', array($repository_id, Database::escape_for_like($revision_prefix) . '%'));
+ $column_name = $this->is_commit_revision_identifier($revision_prefix) ? 'revision_identifier' : 'revision';
+ $rows = $this->db->query_and_fetch_all("SELECT * FROM commits WHERE commit_repository = $1 AND commit_$column_name LIKE $2 ORDER BY commit_$column_name LIMIT 2", array($repository_id, Database::escape_for_like($revision_prefix) . '%'));
if (count($rows) == 0)
exit_with_error('UnknownCommit', array('repository' => $repository_id, 'revision' => $revision_prefix));
if (count($rows) == 2) {
@@ -224,6 +234,7 @@
return array(
'id' => $commit_row['commit_id'],
'revision' => $commit_row['commit_revision'],
+ 'revisionIdentifier' => $commit_row['commit_revision_identifier'],
'repository' => $commit_row['commit_repository'],
'previousCommit' => $commit_row['commit_previous_commit'],
'time' => Database::to_js_time($commit_row['commit_time']),
Modified: trunk/Websites/perf.webkit.org/public/include/commit-updater.php (275328 => 275329)
--- trunk/Websites/perf.webkit.org/public/include/commit-updater.php 2021-04-01 00:47:35 UTC (rev 275328)
+++ trunk/Websites/perf.webkit.org/public/include/commit-updater.php 2021-04-01 00:50:11 UTC (rev 275329)
@@ -30,7 +30,6 @@
private function update_commit(&$update, $owner_commit_id, $owner_repository_id, $should_insert)
{
$commit_data = &$this->resolve_fields_from_database($update, $owner_repository_id, $should_insert);
-
$commit_select_query = array('repository' => $commit_data['repository'], 'revision' => $commit_data['revision']);
if ($should_insert) {
$commit_id = $this->db->update_or_insert_row('commits', 'commit', $commit_select_query, $commit_data);
@@ -74,6 +73,7 @@
private function &construct_update_list(&$commit_info_list, $should_insert)
{
$update_list = array();
+ $commit_revision_identifiers = array();
foreach ($commit_info_list as &$commit_info) {
self::validate_commits($commit_info);
@@ -81,6 +81,11 @@
$has_update = count($commit_data) > 1;
$update = array('commit' => &$commit_data, 'repository' => &$commit_info['repository']);
+ if (array_key_exists('revisionIdentifier', $commit_info)) {
+ if (array_key_exists($commit_info['revisionIdentifier'], $commit_revision_identifiers))
+ $this->exit_with_error('DuplicatedRevisionIdentifier', array('commit' => $commit_info));
+ $commit_revision_identifiers[$commit_info['revisionIdentifier']] = true;
+ }
if (array_key_exists('previousCommit', $commit_info)) {
$has_update = true;
$update['previous_commit'] = &$commit_info['previousCommit'];
@@ -104,6 +109,7 @@
$owned_commit_update_list = array();
foreach($commit_info['ownedCommits'] as $owned_repository_name => &$owned_commit_info) {
+ self::validate_commits($owned_commit_info, true);
$owned_commit = &self::construct_commit_data($owned_commit_info, $owned_repository_name, $should_insert);
$owned_commit_update = array('commit' => &$owned_commit, 'repository' => $owned_repository_name);
@@ -143,6 +149,9 @@
$commit_data['time'] = $commit_info['time'];
}
+ if (array_key_exists('revisionIdentifier', $commit_info))
+ $commit_data['revision_identifier'] = $commit_info['revisionIdentifier'];
+
if ($should_insert)
$commit_data['reported'] = true;
@@ -149,9 +158,9 @@
return $commit_data;
}
- private static function validate_commits(&$commit_info)
+ private static function validate_commits(&$commit_info, $is_own_commit = false)
{
- if (!array_key_exists('repository', $commit_info))
+ if (!array_key_exists('repository', $commit_info) && !$is_own_commit)
exit_with_error('MissingRepositoryName', array('commit' => $commit_info));
if (!array_key_exists('revision', $commit_info))
exit_with_error('MissingRevision', array('commit' => $commit_info));
@@ -160,6 +169,8 @@
exit_with_error('InvalidAuthorFormat', array('commit' => $commit_info));
if (array_key_exists('previousCommit', $commit_info))
require_format('Revision', $commit_info['previousCommit'], '/^[A-Za-z0-9 \.]+$/');
+ if (array_key_exists('revisionIdentifier', $commit_info))
+ require_format('RevisionIdentifier', $commit_info['revisionIdentifier'], '/^\d+@[\w\.\-]+$/');
}
private function resolve_repository($repository_name, $owner_repository_id, $should_insert)
Modified: trunk/Websites/perf.webkit.org/public/include/report-processor.php (275328 => 275329)
--- trunk/Websites/perf.webkit.org/public/include/report-processor.php 2021-04-01 00:47:35 UTC (rev 275328)
+++ trunk/Websites/perf.webkit.org/public/include/report-processor.php 2021-04-01 00:50:11 UTC (rev 275329)
@@ -162,14 +162,16 @@
$this->rollback_with_error('FailedToUpdateBuildRequest', array('buildRequest' => $build_request_id, 'build' => $build_id));
}
-
foreach ($revisions as $repository_name => $revision_data) {
$repository_id = $this->db->select_or_insert_row('repositories', 'repository', array('name' => $repository_name, 'owner' => NULL));
if (!$repository_id)
$this->rollback_with_error('FailedToInsertRepository', array('name' => $repository_name));
- $commit_data = array('repository' => $repository_id, 'revision' => $revision_data['revision'], 'time' => array_get($revision_data, 'timestamp'));
-
+ $commit_data = array(
+ 'repository' => $repository_id,
+ 'revision' => $revision_data['revision'],
+ 'time' => array_get($revision_data, 'timestamp'),
+ 'revision_identifier' => array_get($revision_data, 'revisionIdentifier', null));
$mismatching_commit = $this->db->query_and_fetch_all('SELECT * FROM build_commits, commits
WHERE build_commit = commit_id AND commit_build = $1 AND commit_repository = $2 AND commit_revision != $3 LIMIT 1',
array($build_id, $repository_id, $revision_data['revision']));
Modified: trunk/Websites/perf.webkit.org/public/v3/models/commit-log.js (275328 => 275329)
--- trunk/Websites/perf.webkit.org/public/v3/models/commit-log.js 2021-04-01 00:47:35 UTC (rev 275328)
+++ trunk/Websites/perf.webkit.org/public/v3/models/commit-log.js 2021-04-01 00:50:11 UTC (rev 275329)
@@ -20,6 +20,7 @@
console.assert(+this._rawData['time'] == +rawData['time']);
console.assert(this._rawData['revision'] == rawData['revision']);
+ console.assert(this._rawData['revisionIdentifier'] == rawData['revisionIdentifier']);
if (rawData.authorName)
this._rawData.authorName = rawData.authorName;
@@ -39,6 +40,7 @@
testability() { return this._rawData['testability']; }
author() { return this._rawData['authorName']; }
revision() { return this._rawData['revision']; }
+ revisionIdentifier() { return this._rawData['revisionIdentifier']; }
message() { return this._rawData['message']; }
url() { return this._repository.urlForRevision(this._rawData['revision']); }
ownsCommits() { return this._rawData['ownsCommits']; }
@@ -48,15 +50,33 @@
hasCommitOrder() { return this._rawData['order'] != null; }
setOwnerCommits(ownerCommit) { this._ownerCommit = ownerCommit; }
- label()
+ label() { return CommitLog._formatttedRevision(this.revision(), this.revisionIdentifier()); }
+
+ static _repositoryType(revision)
{
- const revision = this.revision();
- if (parseInt(revision) == revision) // e.g. r12345
- return 'r' + revision;
- if (revision.length == 40) // e.g. git hash
- return revision.substring(0, 12);
- return revision;
+ if (parseInt(revision) == revision)
+ return 'svn';
+ if (revision.length == 40)
+ return 'git';
+ return null;
}
+
+ static _formatttedRevision(revision, revisionIdentifier = null)
+ {
+ const formattedRevision = (() => {
+ switch (this._repositoryType(revision)) {
+ case 'svn':
+ return 'r' + revision; // e.g. r12345
+ case 'git':
+ return revision.substring(0, 12);
+ }
+ return revision;
+ })();
+ if (revisionIdentifier)
+ return `${revisionIdentifier} (${formattedRevision})`;
+ return formattedRevision;
+ }
+
title() { return this._repository.name() + ' at ' + this.label(); }
diff(previousCommit)
@@ -68,17 +88,24 @@
if (!previousCommit)
return {repository: repository, label: this.label(), url: this.url()};
- const to = this.revision();
- const from = previousCommit.revision();
- let label = null;
- if (parseInt(from) == from)// e.g. r12345.
- label = `r${from}-r${this.revision()}`;
- else if (to.length == 40) // e.g. git hash
- label = `${from.substring(0, 12)}..${to.substring(0, 12)}`;
- else
- label = `${from} - ${to}`;
+ const toRevision = this.revision();
+ const fromRevision = previousCommit.revision();
+ const identifierPattern = /(?<number>\d+)@(?<branch>[\w\.\-]+)/;
+ const repositoryType = CommitLog._repositoryType(toRevision);
+
+ const label = ((fromMatch, toMatch) => {
+ const separator = repositoryType == 'git' ? '..' : (repositoryType == 'svn' ? '-' : ' - ');
+ const revisionRange = `${CommitLog._formatttedRevision(fromRevision)}${separator}${CommitLog._formatttedRevision(toRevision)}`;
+ if (fromMatch && toMatch) {
+ console.assert(fromMatch.groups.branch == toMatch.groups.branch);
+ return `${fromMatch.groups.number}-${toMatch.groups.number}@${fromMatch.groups.branch} (${revisionRange})`;
+ }
+ if (fromMatch || toMatch)
+ return `${previousCommit.label()} - ${this.label()}`;
+ return revisionRange;
+ })(identifierPattern.exec(previousCommit.revisionIdentifier()), identifierPattern.exec(this.revisionIdentifier()));
- return {repository: repository, label: label, url: repository.urlForRevisionRange(from, to)};
+ return {repository, label, url: repository.urlForRevisionRange(fromRevision, toRevision)};
}
static fetchLatestCommitForPlatform(repository, platform)
Modified: trunk/Websites/perf.webkit.org/server-tests/api-commits-tests.js (275328 => 275329)
--- trunk/Websites/perf.webkit.org/server-tests/api-commits-tests.js 2021-04-01 00:47:35 UTC (rev 275328)
+++ trunk/Websites/perf.webkit.org/server-tests/api-commits-tests.js 2021-04-01 00:50:11 UTC (rev 275329)
@@ -17,6 +17,7 @@
{
"repository": "WebKit",
"revision": "210948",
+ "revisionIdentifier": "184276@main",
"time": "2017-01-20T02:52:34.577Z",
"author": {"name": "Zalan Bujtas", "account": "za...@apple.com"},
"message": "a message",
@@ -24,6 +25,7 @@
{
"repository": "WebKit",
"revision": "210949",
+ "revisionIdentifier": "184277@main",
"time": "2017-01-20T03:23:50.645Z",
"author": {"name": "Chris Dumez", "account": "cdu...@apple.com"},
"message": "some message",
@@ -32,12 +34,53 @@
"repository": "WebKit",
"previousCommit": "210949",
"revision": "210950",
+ "revisionIdentifier": "184278@main",
"time": "2017-01-20T03:49:37.887Z",
"author": {"name": "Commit Queue", "account": "commit-qu...@webkit.org"},
"message": "another message",
+ },
+ ]
+ };
+
+ const subcersionCommitsWithFakeRevisionIdentifier = {
+ "workerName": "someWorker",
+ "workerPassword": "somePassword",
+ "commits": [
+ {
+ "repository": "WebKit",
+ "revision": "210948",
+ "revisionIdentifier": "184276@main",
+ "time": "2017-01-20T02:52:34.577Z",
+ "author": {"name": "Zalan Bujtas", "account": "za...@apple.com"},
+ "message": "a message",
+ },
+ {
+ "repository": "WebKit",
+ "revision": "210949",
+ "revisionIdentifier": "184277@main",
+ "time": "2017-01-20T03:23:50.645Z",
+ "author": {"name": "Chris Dumez", "account": "cdu...@apple.com"},
+ "message": "some message",
+ },
+ {
+ "repository": "WebKit",
+ "previousCommit": "210949",
+ "revision": "210950",
+ "revisionIdentifier": "184278@main",
+ "time": "2017-01-20T03:49:37.887Z",
+ "author": {"name": "Commit Queue", "account": "commit-qu...@webkit.org"},
+ "message": "another message",
+ },
+ {
+ "repository": "WebKit",
+ "revision": "210951",
+ "revisionIdentifier": "184278@something",
+ "time": "2017-01-20T03:49:40.887Z",
+ "author": {"name": "Commit Queue", "account": "commit-qu...@webkit.org"},
+ "message": "another message",
}
]
- }
+ };
const commitsOnePrefixOfTheOther = {
"workerName": "someWorker",
@@ -46,6 +89,7 @@
{
"repository": "WebKit",
"revision": "21094",
+ "revisionIdentifier": "184272@main",
"time": "2017-01-20T02:52:34.577Z",
"author": {"name": "Zalan Bujtas", "account": "za...@apple.com"},
"message": "a message",
@@ -53,6 +97,7 @@
{
"repository": "WebKit",
"revision": "210949",
+ "revisionIdentifier": "184277@main",
"time": "2017-01-20T03:23:50.645Z",
"author": {"name": "Chris Dumez", "account": "cdu...@apple.com"},
"message": "some message",
@@ -524,6 +569,41 @@
});
});
+ it("should return commit with commit revision label", async () => {
+ await addWorkerForReport(subversionCommits);
+ const response = await TestServer.remoteAPI().postJSON('/api/report-commits/', subversionCommits);
+ assert.strictEqual(response['status'], 'OK');
+ const result = await TestServer.remoteAPI().getJSON(`/api/commits/WebKit/${subversionCommits.commits[0].revisionIdentifier}`);
+ assert.strictEqual(result['status'], 'OK');
+ assert.strictEqual(result.commits.length, 1);
+ assertCommitIsSameAsOneSubmitted(result.commits[0], subversionCommits.commits[0]);
+ });
+
+ it("should return 'AmbiguousRevisionPrefix' when more than one commits are found for a revision label prefix", async () => {
+ const remote = TestServer.remoteAPI();
+ await addWorkerForReport(subcersionCommitsWithFakeRevisionIdentifier);
+ await remote.postJSONWithStatus('/api/report-commits/', subcersionCommitsWithFakeRevisionIdentifier);
+ const result = await remote.getJSON('/api/commits/WebKit/184278@?prefix-match=true');
+ assert.strictEqual(result['status'], 'AmbiguousRevisionPrefix');
+ });
+
+ it("should not return 'AmbiguousRevisionPrefix' when there is a commit revision label extract matches specified revision prefix", async () => {
+ const remote = TestServer.remoteAPI();
+ await addWorkerForReport(subcersionCommitsWithFakeRevisionIdentifier);
+ await remote.postJSONWithStatus('/api/report-commits/', subcersionCommitsWithFakeRevisionIdentifier);
+ const result = await remote.getJSON('/api/commits/WebKit/184278@main?prefix-match=true');
+ assert.strictEqual(result['status'], 'OK');
+ assert.deepStrictEqual(result['commits'].length, 1);
+ assertCommitIsSameAsOneSubmitted(result['commits'][0], subcersionCommitsWithFakeRevisionIdentifier['commits'][2]);
+ });
+
+ it("should return 'UnknownCommit' when no commit is found for a revision label prefix", async () => {
+ const remote = TestServer.remoteAPI();
+ await addWorkerForReport(subcersionCommitsWithFakeRevisionIdentifier);
+ await remote.postJSONWithStatus('/api/report-commits/', subcersionCommitsWithFakeRevisionIdentifier);
+ const result = await remote.getJSON('/api/commits/WebKit/184278@x?prefix-match=true');
+ assert.strictEqual(result['status'], 'UnknownCommit');
+ });
});
describe('/api/commits/<repository>/owned-commits?owner-revision=<commit>', () => {
@@ -727,6 +807,33 @@
});
});
+ it("should return reported commits in the specified revision label range", async () => {
+ const db = TestServer.database();
+ await db.insert('repositories', {'id': 1, 'name': 'WebKit'});
+ await db.insert('commits', {'repository': 1, 'revision': '210948', 'revision_identifier': '184276@main', 'time': '2017-01-20T02:52:34.577Z', 'reported': true});
+ await db.insert('commits', {'repository': 1, 'revision': '210949', 'revision_identifier': '184277@main', 'time': '2017-01-20T03:23:50.645Z', 'reported': true});
+ await db.insert('commits', {'repository': 1, 'revision': '210950', 'revision_identifier': '184278@main', 'time': '2017-01-20T03:49:37.887Z', 'reported': true});
+ const result = await TestServer.remoteAPI().getJSON('/api/commits/WebKit/?precedingRevision=184276@main&lastRevision=184278@main');
+ assert.strictEqual(result['status'], 'OK');
+ assert.deepStrictEqual(result['commits'].length, 2);
+ assertCommitIsSameAsOneSubmitted(result['commits'][0], {
+ previousCommit: null,
+ revision: '210949',
+ revisionIdentifier: '184289@main',
+ time: '2017-01-20T03:23:50.645Z',
+ author: {name: null, account: null},
+ message: null,
+ });
+ assertCommitIsSameAsOneSubmitted(result['commits'][1], {
+ previousCommit: null,
+ revision: '210950',
+ revisionIdentifier: '184290@main',
+ time: '2017-01-20T03:49:37.887Z',
+ author: {name: null, account: null},
+ message: null,
+ });
+ });
+
it("should not include a revision not within the specified range", () => {
const db = TestServer.database();
const remote = TestServer.remoteAPI();
@@ -750,6 +857,23 @@
});
});
+ it("should not include a revision not within the specified commit revision label range", async () => {
+ const db = TestServer.database();
+ const remote = TestServer.remoteAPI();
+ await db.insert('repositories', {'id': 1, 'name': 'WebKit'}),
+ await db.insert('commits', {'repository': 1, 'revision': '210947', 'revision_identifier': '184275@main', 'time': '2017-01-20T02:38:45.485Z', 'reported': false});
+ await db.insert('commits', {'repository': 1, 'revision': '210948', 'revision_identifier': '184276@main', 'time': '2017-01-20T02:52:34.577Z', 'reported': false});
+ await db.insert('commits', {'repository': 1, 'revision': '210949', 'revision_identifier': '184277@main', 'time': '2017-01-20T03:23:50.645Z', 'reported': false});
+ await db.insert('commits', {'repository': 1, 'revision': '210950', 'revision_identifier': '184278@main', 'time': '2017-01-20T03:49:37.887Z', 'reported': false});
+ await addWorkerForReport(subversionCommits);
+ await remote.postJSONWithStatus('/api/report-commits/', subversionCommits);
+ const result = await remote.getJSON('/api/commits/WebKit/?precedingRevision=184275@main&lastRevision=184277@main');
+ assert.strictEqual(result['status'], 'OK');
+ assert.deepStrictEqual(result['commits'].length, 2);
+ assertCommitIsSameAsOneSubmitted(result['commits'][0], subversionCommits['commits'][0]);
+ assertCommitIsSameAsOneSubmitted(result['commits'][1], subversionCommits['commits'][1]);
+ });
+
});
});
Modified: trunk/Websites/perf.webkit.org/server-tests/api-report-commits-tests.js (275328 => 275329)
--- trunk/Websites/perf.webkit.org/server-tests/api-report-commits-tests.js 2021-04-01 00:47:35 UTC (rev 275328)
+++ trunk/Websites/perf.webkit.org/server-tests/api-report-commits-tests.js 2021-04-01 00:50:11 UTC (rev 275329)
@@ -26,6 +26,20 @@
}
],
};
+ const subversionCommitWithRevisionIdentifier = {
+ "workerName": "someWorker",
+ "workerPassword": "somePassword",
+ "commits": [
+ {
+ "repository": "WebKit",
+ "revision": "141977",
+ "revisionIdentifier": "127231@main",
+ "time": "2013-02-06T08:55:20.9Z",
+ "author": {"name": "Commit Queue", "account": "commit-qu...@webkit.org"},
+ "message": "some message",
+ }
+ ],
+ };
const subversionInvalidCommit = {
"workerName": "someWorker",
"workerPassword": "somePassword",
@@ -76,6 +90,44 @@
]
}
+ const duplicatedCommitRevisionIdentifierCommits = {
+ "workerName": "someWorker",
+ "workerPassword": "somePassword",
+ "commits": [
+ {
+ "repository": "WebKit",
+ "revision": "210948",
+ "revisionIdentifier": "184276@main",
+ "time": "2017-01-20T02:52:34.577Z",
+ "author": {"name": "Zalan Bujtas", "account": "za...@apple.com"},
+ "message": "a message",
+ },
+ {
+ "repository": "WebKit",
+ "revision": "210949",
+ "revisionIdentifier": "184276@main",
+ "time": "2017-01-20T03:23:50.645Z",
+ "author": {"name": "Chris Dumez", "account": "cdu...@apple.com"},
+ "message": "some message",
+ },
+ ]
+ }
+
+ const invalidCommitRevisionIdentifierCommits = {
+ "workerName": "someWorker",
+ "workerPassword": "somePassword",
+ "commits": [
+ {
+ "repository": "WebKit",
+ "revision": "210948",
+ "revisionIdentifier": "184276",
+ "time": "2017-01-20T02:52:34.577Z",
+ "author": {"name": "Zalan Bujtas", "account": "za...@apple.com"},
+ "message": "a message",
+ },
+ ]
+ }
+
it("should reject error when worker name is missing", () => {
return TestServer.remoteAPI().postJSON('/api/report-commits/', {}).then((response) => {
assert.strictEqual(response['status'], 'MissingWorkerName');
@@ -145,6 +197,22 @@
});
});
+ it("should reject an invalid revision label", async () => {
+ await addWorkerForReport(subversionCommit);
+ const response = await TestServer.remoteAPI().postJSON('/api/report-commits/', invalidCommitRevisionIdentifierCommits);
+ assert.strictEqual(response['status'], 'InvalidRevisionIdentifier');
+ const rows = await TestServer.database().selectAll('commits');
+ assert.strictEqual(rows.length, 0);
+ });
+
+ it("should reject with duplicated commit revision labels", async () => {
+ await addWorkerForReport(subversionCommit);
+ const response = await TestServer.remoteAPI().postJSON('/api/report-commits/', duplicatedCommitRevisionIdentifierCommits);
+ assert.strictEqual(response['status'], 'DuplicatedRevisionIdentifier');
+ const rows = await TestServer.database().selectAll('commits');
+ assert.strictEqual(rows.length, 0);
+ });
+
it("should store two commits from a valid worker", () => {
return addWorkerForReport(subversionTwoCommits).then(() => {
return TestServer.remoteAPI().postJSON('/api/report-commits/', subversionTwoCommits);
@@ -215,6 +283,25 @@
});
});
+ it("should update an existing commit with commit label if there is one", async () => {
+ const db = TestServer.database();
+ const reportedData = subversionCommitWithRevisionIdentifier.commits[0];
+ await addWorkerForReport(subversionCommitWithRevisionIdentifier);
+ await db.insert('repositories', {'id': 1, 'name': 'WebKit'}),
+ await db.insert('commits', {'repository': 1, 'revision': reportedData['revision'], 'time': reportedData['time']})
+ const response = await TestServer.remoteAPI().postJSON('/api/report-commits/', subversionCommitWithRevisionIdentifier);
+ assert.strictEqual(response['status'], 'OK');
+ const commits = await db.selectAll('commits');
+ const committers = await db.selectAll('committers');
+ assert.strictEqual(commits.length, 1);
+ assert.strictEqual(committers.length, 1);
+ assert.strictEqual(commits[0]['message'], reportedData['message']);
+ assert.strictEqual(commits[0]['revision_identifier'], reportedData['revisionIdentifier']);
+ assert.strictEqual(commits[0]['committer'], committers[0]['id']);
+ assert.strictEqual(committers[0]['name'], reportedData['author']['name']);
+ assert.strictEqual(committers[0]['account'], reportedData['author']['account']);
+ });
+
it("should not update an unrelated commit", () => {
const db = TestServer.database();
const firstData = subversionTwoCommits.commits[0];
@@ -590,6 +677,111 @@
assert.strictEqual(response['status'], 'OwnedCommitShouldNotContainTimestamp');
});
});
+
+ const invalidOwnedCommitUseRevisionIdentifierAsRevison = {
+ "workerName": "someWorker",
+ "workerPassword": "somePassword",
+ "commits": [
+ {
+ "repository": "OSX",
+ "revision": "Sierra16D32",
+ "order": 1,
+ "ownedCommits": {
+ "WebKit": {
+ "revision": "127232@main",
+ "author": {"name": "Commit Queue", "account": "commit-qu...@webkit.org"},
+ "message": "WebKit Commit",
+ }
+ }
+ }
+ ]
+ };
+
+ it("should reject inserting one commit with owned commits that use revision label as revision", async () => {
+ await addWorkerForReport(invalidOwnedCommitUseRevisionIdentifierAsRevison);
+ const response = await TestServer.remoteAPI().postJSON('/api/report-commits/', invalidOwnedCommitUseRevisionIdentifierAsRevison);
+ assert.strictEqual(response['status'], 'InvalidRevision');
+ });
+
+ const invalidRevisionIdentifierOwnedCommit = {
+ "workerName": "someWorker",
+ "workerPassword": "somePassword",
+ "commits": [
+ {
+ "repository": "OSX",
+ "revision": "Sierra16D32",
+ "order": 1,
+ "ownedCommits": {
+ "WebKit": {
+ "revision": "141978",
+ "revisionIdentifier": "127232",
+ "author": {"name": "Commit Queue", "account": "commit-qu...@webkit.org"},
+ "message": "WebKit Commit",
+ }
+ }
+ }
+ ]
+ };
+
+ it("should reject inserting one commit with owned commits that have invalid revision label", async () => {
+ await addWorkerForReport(invalidRevisionIdentifierOwnedCommit);
+ const response = await TestServer.remoteAPI().postJSON('/api/report-commits/', invalidRevisionIdentifierOwnedCommit);
+ assert.strictEqual(response['status'], 'InvalidRevisionIdentifier');
+ });
+
+ const invalidAuthorOwnedCommit = {
+ "workerName": "someWorker",
+ "workerPassword": "somePassword",
+ "commits": [
+ {
+ "repository": "OSX",
+ "revision": "Sierra16D32",
+ "order": 1,
+ "ownedCommits": {
+ "WebKit": {
+ "revision": "141978",
+ "revisionIdentifier": "127232@main",
+ "author": null,
+ "message": "WebKit Commit",
+ }
+ }
+ }
+ ]
+ };
+ it("should reject inserting one commit with owned commits that have invalid author", async () => {
+ await addWorkerForReport(invalidAuthorOwnedCommit);
+ const response = await TestServer.remoteAPI().postJSON('/api/report-commits/', invalidAuthorOwnedCommit);
+ assert.strictEqual(response['status'], 'InvalidAuthorFormat');
+ });
+
+ const ownedCommitWithRevisionIdentifier = {
+ "workerName": "someWorker",
+ "workerPassword": "somePassword",
+ "commits": [
+ {
+ "repository": "OSX",
+ "revision": "Sierra16D32",
+ "order": 1,
+ "ownedCommits": {
+ "WebKit": {
+ "revision": "141978",
+ "revisionIdentifier": "127232@main",
+ "author": {"name": "Commit Queue", "account": "commit-qu...@webkit.org"},
+ "message": "WebKit Commit",
+ }
+ }
+ }
+ ]
+ };
+
+ it("should insert one commit with commit revision label", async () => {
+ await addWorkerForReport(ownedCommitWithRevisionIdentifier);
+ const response = await TestServer.remoteAPI().postJSON('/api/report-commits/', ownedCommitWithRevisionIdentifier);
+ assert.strictEqual(response['status'], 'OK');
+ const db = TestServer.database();
+ const commit = await db.selectRows('commits', {'revision': '141978'});
+ assert.strictEqual(commit[0].revision_identifier, ownedCommitWithRevisionIdentifier.commits[0].ownedCommits['WebKit'].revisionIdentifier);
+ });
});
describe("/api/report-commits/ with insert=false", function () {
Modified: trunk/Websites/perf.webkit.org/server-tests/api-report-tests.js (275328 => 275329)
--- trunk/Websites/perf.webkit.org/server-tests/api-report-tests.js 2021-04-01 00:47:35 UTC (rev 275328)
+++ trunk/Websites/perf.webkit.org/server-tests/api-report-tests.js 2021-04-01 00:50:11 UTC (rev 275329)
@@ -77,6 +77,29 @@
};
}
+ function reportWithRevisionIdentifierCommit()
+ {
+ return {
+ "buildTag": "123",
+ "buildTime": "2013-02-28T10:12:03.388304",
+ "builderName": "someBuilder",
+ "workerName": "someWorker",
+ "builderPassword": "somePassword",
+ "platform": "Mountain Lion",
+ "tests": {},
+ "revisions": {
+ "macOS": {
+ "revision": "10.8.2 12C60"
+ },
+ "WebKit": {
+ "revision": "141977",
+ "revisionIdentifier": "127231@main",
+ "timestamp": "2013-02-06T08:55:20.9Z"
+ }
+ }
+ };
+ }
+
function emptyWorkerReport()
{
return {
@@ -351,6 +374,37 @@
});
});
+ it("should add revision label", async () => {
+ await addBuilderForReport(reportWithRevisionIdentifierCommit());
+ await TestServer.remoteAPI().postJSON('/api/report/', [reportWithRevisionIdentifierCommit()]);
+ const db = TestServer.database();
+ const repositories = await db.selectAll('repositories');
+ const commits = await db.selectAll('commits');
+ const buildCommitsRelations = await db.selectAll('build_commits', 'build_commit');
+ assert.strictEqual(repositories.length, 2);
+ assert.deepStrictEqual(repositories.map((row) => row['name']).sort(), ['WebKit', 'macOS']);
+
+ assert.strictEqual(commits.length, 2);
+ assert.strictEqual(buildCommitsRelations.length, 2);
+ assert.strictEqual(buildCommitsRelations[0]['build_commit'], commits[0]['id']);
+ assert.strictEqual(buildCommitsRelations[1]['build_commit'], commits[1]['id']);
+ assert.strictEqual(buildCommitsRelations[0]['commit_build'], buildCommitsRelations[1]['commit_build']);
+
+ let repositoryIdToName = {};
+ for (const repository of repositories)
+ repositoryIdToName[repository['id']] = repository['name'];
+
+ let repositoryNameToRevisionRow = {};
+ for (const commit of commits)
+ repositoryNameToRevisionRow[repositoryIdToName[commit['repository']]] = commit;
+
+ assert.strictEqual(repositoryNameToRevisionRow['macOS']['revision'], '10.8.2 12C60');
+ assert.strictEqual(repositoryNameToRevisionRow['WebKit']['revision'], '141977');
+ assert.strictEqual(repositoryNameToRevisionRow['WebKit']['revision_identifier'], '127231@main');
+ assert.strictEqual(repositoryNameToRevisionRow['WebKit']['time'].toString(),
+ new Date('2013-02-06 08:55:20.9').toString());
+ });
+
it("should not create a duplicate build for the same build number if build times are close", () => {
const firstReport = emptyReport();
firstReport['buildTime'] = '2013-02-28T10:12:04';
Modified: trunk/Websites/perf.webkit.org/unit-tests/commit-log-tests.js (275328 => 275329)
--- trunk/Websites/perf.webkit.org/unit-tests/commit-log-tests.js 2021-04-01 00:47:35 UTC (rev 275328)
+++ trunk/Websites/perf.webkit.org/unit-tests/commit-log-tests.js 2021-04-01 00:50:11 UTC (rev 275329)
@@ -17,6 +17,17 @@
});
}
+function webkitCommitWithRevisionIdentifier()
+{
+ return new CommitLog(1, {
+ id: 1,
+ repository: MockModels.webkit,
+ revision: '200805',
+ revisionIdentifier: '184276@main',
+ time: +(new Date('2016-05-13T00:55:57.841344Z')),
+ });
+}
+
function oldWebKitCommit()
{
return new CommitLog(2, {
@@ -27,6 +38,17 @@
});
}
+function oldWebKitCommitWithRevisionIdentifier()
+{
+ return new CommitLog(2, {
+ id: 2,
+ repository: MockModels.webkit,
+ revision: '200574',
+ revisionIdentifier: '175605@main',
+ time: +(new Date('2016-05-09T14:59:23.553767Z')),
+ });
+}
+
function gitWebKitCommit()
{
return new CommitLog(3, {
@@ -37,6 +59,17 @@
});
}
+function gitWebKitCommitWithRevisionIdentifier()
+{
+ return new CommitLog(3, {
+ id: 3,
+ repository: MockModels.webkit,
+ revision: '6f8b0dbbda95a440503b88db1dd03dad3a7b07fb',
+ revisionIdentifier: '184276@main',
+ time: +(new Date('2016-05-13T00:55:57.841344Z')),
+ });
+}
+
function oldGitWebKitCommit()
{
return new CommitLog(4, {
@@ -47,6 +80,17 @@
});
}
+function oldGitWebKitCommitWithRevisionIdentifier()
+{
+ return new CommitLog(4, {
+ id: 4,
+ repository: MockModels.webkit,
+ revision: 'ffda14e6db0746d10d0f050907e4a7325851e502',
+ revisionIdentifier: '175605@main',
+ time: +(new Date('2016-05-09T14:59:23.553767Z')),
+ });
+}
+
function osxCommit()
{
return new CommitLog(5, {
@@ -147,10 +191,18 @@
assert.equal(webkitCommit().label(), 'r200805');
});
- it('should truncate a Git hash at 8th character', function () {
+ it('should display revision label followed by svn refixed with "r"', () => {
+ assert.strictEqual(webkitCommitWithRevisionIdentifier().label(), '184276@main (r200805)')
+ });
+
+ it('should truncate a Git hash at 12th character', function () {
assert.equal(gitWebKitCommit().label(), '6f8b0dbbda95');
});
+ it('should display revision label followed by git hash truncated', () => {
+ assert.strictEqual(gitWebKitCommitWithRevisionIdentifier().label(), '184276@main (6f8b0dbbda95)')
+ });
+
it('should not modify OS X version', function () {
assert.equal(osxCommit().label(), '10.11.4 15E65');
});
@@ -161,10 +213,18 @@
assert.equal(webkitCommit().title(), 'WebKit at r200805');
});
- it('should truncate a Git hash at 8th character', function () {
+ it('should include revision label', () => {
+ assert.strictEqual(webkitCommitWithRevisionIdentifier().title(), 'WebKit at 184276@main (r200805)');
+ });
+
+ it('should truncate a Git hash at 12th character', function () {
assert.equal(gitWebKitCommit().title(), 'WebKit at 6f8b0dbbda95');
});
+ it('should display revision label followed by git hash truncated', () => {
+ assert.strictEqual(gitWebKitCommitWithRevisionIdentifier().title(), 'WebKit at 184276@main (6f8b0dbbda95)');
+ });
+
it('should not modify OS X version', function () {
assert.equal(osxCommit().title(), 'OS X at 10.11.4 15E65');
});
@@ -223,6 +283,31 @@
repository: MockModels.osx
});
});
+
+ it('should display revision label followed with revison and connect with "-", if both have revision label', () => {
+ assert.deepStrictEqual(webkitCommitWithRevisionIdentifier().diff(oldWebKitCommitWithRevisionIdentifier()), {
+ label: '175605-184276@main (r200574-r200805)',
+ url: '',
+ repository: MockModels.webkit
+ })
+ });
+
+ it('should display revision label followed with revison and connect with "-", if both have revision label', () => {
+ assert.deepStrictEqual(gitWebKitCommitWithRevisionIdentifier().diff(oldGitWebKitCommitWithRevisionIdentifier()), {
+ label: '175605-184276@main (ffda14e6db07..6f8b0dbbda95)',
+ url: '',
+ repository: MockModels.webkit
+ })
+ });
+
+ it('should contain revision label, if one of the commits doesn`t have the revision label', () => {
+ assert.deepStrictEqual(webkitCommitWithRevisionIdentifier().diff(oldWebKitCommit()), {
+ label: 'r200574 - 184276@main (r200805)',
+ url: '',
+ repository: MockModels.webkit
+ });
+ });
+
});
describe('hasOrdering', () => {