Import of the watch repository from Pebble

This commit is contained in:
Matthieu Jeanson 2024-12-12 16:43:03 -08:00 committed by Katharine Berry
commit 3b92768480
10334 changed files with 2564465 additions and 0 deletions

View file

@ -0,0 +1 @@
{"__symbol_cache_version__":11,"fb880a119e72c5d947d16a216246686c":{"have":{"class":{"PebbleArcanistConfiguration":920}},"need":{"function":{"idx":1373,"id":1472,"pht":3316,"phutil_passthru":3404,"head":4161},"class":{"ArcanistConfiguration":956,"PhutilClassMapQuery":1479,"ArcanistUsageException":5251,"PhutilEditDistanceMatrix":6064,"ArcanistAliasWorkflow":2800},"class\/interface":{"ArcanistWorkflow":1766,"ArcanistConfigurationManager":2194,"PhutilConsole":2251,"PhutilEditDistanceMatrix":6868}},"xmap":{"PebbleArcanistConfiguration":["ArcanistConfiguration"]}}}

View file

@ -0,0 +1,17 @@
<?php
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
phutil_register_library('pebble-arc-config', __FILE__);

View file

@ -0,0 +1,32 @@
<?php
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* This file is automatically generated. Use 'arc liberate' to rebuild it.
*
* @generated
* @phutil-library-version 2
*/
phutil_register_library_map(array(
'__library_version__' => 2,
'class' => array(
'PebbleArcanistConfiguration' => 'pebble/PebbleArcanistConfiguration.php',
),
'function' => array(),
'xmap' => array(
'PebbleArcanistConfiguration' => 'ArcanistConfiguration',
),
));

View file

@ -0,0 +1,73 @@
<?php
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Runtime workflow configuration. In Arcanist, commands you type like
* "arc diff" or "arc lint" are called "workflows". This class allows you to add
* new workflows (and extend existing workflows) by subclassing it and then
* pointing to your subclass in your project configuration.
*
* When specified as the **arcanist_configuration** class in your project's
* ##.arcconfig##, your subclass will be instantiated (instead of this class)
* and be able to handle all the method calls. In particular, you can:
*
* - create, replace, or disable workflows by overriding buildWorkflow()
* and buildAllWorkflows();
* - add additional steps before or after workflows run by overriding
* willRunWorkflow() or didRunWorkflow() or didAbortWorkflow(); and
* - add new flags to existing workflows by overriding
* getCustomArgumentsForCommand().
*
* @concrete-extensible
*/
class PebbleArcanistConfiguration extends ArcanistConfiguration {
const TREESTATUS_URL = "https://treestatus.marlinspike.hq.getpebble.com/api/ci/state/TT-MC/master";
const FAIL_WHALE = "
▄██████████████▄▐█▄▄▄▄█▌
██████▌▄▌▄▐▐▌███▌▀▀██▀▀
████▄█▌▄▌▄▐▐▌▀███▄▄█▌
▄▄▄▄▄██████████████▀
";
/*
* Implement the willRunWorkflow hook in order to check whether or not
* master is green before allowing a diff to be landed
*/
public function willRunWorkflow($command, ArcanistWorkflow $workflow) {
if ($workflow->getWorkflowName() == "land") {
$build_status_str = file_get_contents(self::TREESTATUS_URL);
$build_status = json_decode($build_status_str);
$console = PhutilConsole::getConsole();
if ($build_status->is_open) {
$console->writeOut(
"**<bg:green> %s </bg>** %s\n",
pht('Master OK!'),
pht('Merging is allowed'));
return;
} else {
$console->writeOut(
"%s\n**<bg:red> %s </bg>** %s\n",
pht(self::FAIL_WHALE),
pht('Master Borked :('),
pht('Don\'t land unless your diff fixes it!'));
if (!$console->confirm(pht('Land revision anyways?'))) {
throw new ArcanistUserAbortException();
}
}
}
}
}