From 294f7f172ec5a3c35064ee87e4ef66a5a60b6e5a Mon Sep 17 00:00:00 2001 From: Keyong Han Date: Wed, 5 Aug 2020 16:05:55 -0700 Subject: [PATCH] use generic name --- ci/dev/README.md | 7 +- ci/dev/dev_test.sh | 19 ----- ..._prod_builders.json => prod_builders.json} | 0 ...ne_try_builders.json => try_builders.json} | 0 ci/dev/validate_json.dart | 76 ------------------- 5 files changed, 1 insertion(+), 101 deletions(-) delete mode 100644 ci/dev/dev_test.sh rename ci/dev/{engine_prod_builders.json => prod_builders.json} (100%) rename ci/dev/{engine_try_builders.json => try_builders.json} (100%) delete mode 100644 ci/dev/validate_json.dart diff --git a/ci/dev/README.md b/ci/dev/README.md index 8c0f473f376e3..fe2a07712bd60 100644 --- a/ci/dev/README.md +++ b/ci/dev/README.md @@ -2,7 +2,7 @@ This directory contains resources that the Flutter team uses during the development of engine. ## Luci builder file -`engine_try_builders.json` and `engine_prod_builders.json` contains the +`try_builders.json` and `prod_builders.json` contains the supported luci try/prod builders for engine. It follows format: ```json { @@ -21,8 +21,3 @@ supported luci try/prod builders for engine. It follows format: This file will be mainly used in [`flutter/cocoon`](https://github.com/flutter/cocoon) to trigger/update engine luci tasks. -If any new changes, please validate json contents by running -``` -dart validate_json.dart engine_try_builders.json -dart validate_json.dart engine_prod_builders.json -``` diff --git a/ci/dev/dev_test.sh b/ci/dev/dev_test.sh deleted file mode 100644 index 43d4880bce736..0000000000000 --- a/ci/dev/dev_test.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# Copyright 2020 The Flutter Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Runner for dart tests. It expects a single parameter with the full -# path to the start folder where tests will be run. - -set -e - -dir=$(dirname $0) - -pushd $dir > /dev/null -dart validate_json.dart engine_try_builders.json -dart validate_json.dart engine_prod_builders.json - -popd > /dev/null - - diff --git a/ci/dev/engine_prod_builders.json b/ci/dev/prod_builders.json similarity index 100% rename from ci/dev/engine_prod_builders.json rename to ci/dev/prod_builders.json diff --git a/ci/dev/engine_try_builders.json b/ci/dev/try_builders.json similarity index 100% rename from ci/dev/engine_try_builders.json rename to ci/dev/try_builders.json diff --git a/ci/dev/validate_json.dart b/ci/dev/validate_json.dart deleted file mode 100644 index 957813cf4d3eb..0000000000000 --- a/ci/dev/validate_json.dart +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2020 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:convert'; -import 'dart:io'; -import 'dart:io' show File; -import 'dart:io' as io_internals show exit; - -final bool hasColor = stdout.supportsAnsiEscapes; -final String bold = hasColor ? '\x1B[1m' : ''; // used for shard titles -final String red = hasColor ? '\x1B[31m' : ''; // used for errors -final String reset = hasColor ? '\x1B[0m' : ''; -final String reverse = hasColor ? '\x1B[7m' : ''; // used for clocks - -/// Validates if the input builders JSON file has valid contents. -/// -/// Examples: -/// dart validate_json.dart /path/to/json/file -Future main(List args) async { - final String jsonString = await File(args[0]).readAsString(); - Map decodedJson; - final List messages = []; - try { - decodedJson = json.decode(jsonString) as Map; - final List builders = decodedJson['builders'] as List; - if (builders == null) { - messages.add('${bold}Json format is violated: no "builders" exists. Please follow: $reset'); - messages.add(''' - { - "builders":[ - { - "name":"xxx", - "repo":"engine" - }, { - "name":"xxx", - "repo":"engine" - } - ] - }'''); - exitWithError(messages); - } - } on ExitException catch (error) { - error.apply(); - } - print('$clock ${bold}Analysis successful for ${args[0]}.$reset'); -} - -class ExitException implements Exception { - ExitException(this.exitCode); - - final int exitCode; - - void apply() { - io_internals.exit(exitCode); - } -} - -void exitWithError(List messages) { - final String redLine = '$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset'; - print(redLine); - messages.forEach(print); - print(redLine); - exit(1); -} - -String get clock { - final DateTime now = DateTime.now(); - return '$reverse▌' - '${now.hour.toString().padLeft(2, "0")}:' - '${now.minute.toString().padLeft(2, "0")}:' - '${now.second.toString().padLeft(2, "0")}' - '▐$reset'; -} - -