Remove facts tracker (#15111)
* Removed Travis references * Remove used facts tracker
Kayla Ngan committed
Mar 15, 2019 at 15:25 UTC
ff4fb6d368c2197871d071b6de8ffd2beb1467b5
4 files changed
-201
.circleci/config.yml
-1
@@ -7,7 +7,6 @@ jobs:
7
8
environment:
9
TZ: /usr/share/zoneinfo/America/Los_Angeles
10
- TRAVIS_REPO_SLUG: facebook/react
10
11
parallelism: 4
12
scripts/circleci/test_entry_point.sh
-1
@@ -15,7 +15,6 @@ if [ $((0 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then
15
COMMANDS_TO_RUN+=('./scripts/circleci/check_license.sh')
16
COMMANDS_TO_RUN+=('./scripts/circleci/check_modules.sh')
17
COMMANDS_TO_RUN+=('./scripts/circleci/test_print_warnings.sh')
18
- COMMANDS_TO_RUN+=('./scripts/circleci/track_stats.sh')
18
fi
19
20
if [ $((1 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then
scripts/circleci/track_stats.sh
deleted
-8
@@ -1,8 +0,0 @@
1
-#!/bin/bash
2
-
3
-set -e
4
-
5
-ALL_FILES=$(find packages -name '*.js' | grep -v umd/ | grep -v __tests__ | grep -v __mocks__)
6
-COUNT_ALL_FILES=$(echo "$ALL_FILES" | wc -l)
7
-COUNT_WITH_FLOW=$(grep '@flow' $ALL_FILES | perl -pe 's/:.+//' | wc -l)
8
-node scripts/facts-tracker/index.js "flow-files" "$COUNT_WITH_FLOW/$COUNT_ALL_FILES"
scripts/facts-tracker/index.js
deleted
-191
@@ -1,191 +0,0 @@
1
-#!/usr/bin/env node
2
-
3
-/**
4
- * Copyright (c) Facebook, Inc. and its affiliates.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
9
-
10
-'use strict';
11
-
12
-const fs = require('fs');
13
-const path = require('path');
14
-const execFileSync = require('child_process').execFileSync;
15
-
16
-let cwd = null;
17
-function exec(command, args) {
18
- console.error('>', [command].concat(args));
19
- const options = {};
20
- if (cwd) {
21
- options.cwd = cwd;
22
- }
23
- return execFileSync(command, args, options).toString();
24
-}
25
-
26
-const isCI = !!process.env.TRAVIS_REPO_SLUG;
27
-
28
-if (isCI) {
29
- const branch = process.env.TRAVIS_BRANCH || process.env.CIRCLE_BRANCH;
30
- const isPullRequest =
31
- (!!process.env.TRAVIS_PULL_REQUEST &&
32
- process.env.TRAVIS_PULL_REQUEST !== 'false') ||
33
- !!process.env.CI_PULL_REQUEST;
34
-
35
- if (branch !== 'master') {
36
- console.error('facts-tracker: Branch is not master, exiting...');
37
- process.exit(0);
38
- }
39
-
40
- if (isPullRequest) {
41
- console.error('facts-tracker: This is a pull request, exiting...');
42
- process.exit(0);
43
- }
44
-
45
- if (!process.env.GITHUB_USER) {
46
- console.error(
47
- 'In order to use facts-tracker, you need to configure a ' +
48
- 'few environment variables in order to be able to commit to the ' +
49
- 'repository. Follow those steps to get you setup:\n' +
50
- '\n' +
51
- 'Go to https://github.com/settings/tokens/new\n' +
52
- ' - Fill "Token description" with "facts-tracker for ' +
53
- process.env.TRAVIS_REPO_SLUG +
54
- '"\n' +
55
- ' - Check "public_repo"\n' +
56
- ' - Press "Generate Token"\n' +
57
- '\n' +
58
- 'In a different tab, go to https://travis-ci.org/' +
59
- process.env.TRAVIS_REPO_SLUG +
60
- '/settings\n' +
61
- ' - Make sure "Build only if .travis.yml is present" is ON\n' +
62
- ' - Fill "Name" with "GITHUB_USER" and "Value" with the name of the ' +
63
- 'account you generated the token with. Press "Add"\n' +
64
- '\n' +
65
- 'Once this is done, commit anything to the repository to restart ' +
66
- 'Travis and it should work :)'
67
- );
68
- process.exit(1);
69
- }
70
-
71
- exec('git', [
72
- 'config',
73
- '--global',
74
- 'user.name',
75
- process.env.GITHUB_USER_NAME || 'facts-tracker',
76
- ]);
77
- exec('git', [
78
- 'config',
79
- '--global',
80
- 'user.email',
81
- process.env.GITHUB_USER_EMAIL || 'facts-tracker@no-reply.github.com',
82
- ]);
83
-}
84
-
85
-if (process.argv.length <= 2) {
86
- console.error('Usage: facts-tracker <name1> <value1> <name2> <value2>...');
87
- process.exit(1);
88
-}
89
-
90
-function getRepoSlug() {
91
- if (isCI) {
92
- return process.env.TRAVIS_REPO_SLUG;
93
- }
94
-
95
- const remotes = exec('git', ['remote', '-v']).split('\n');
96
- for (let i = 0; i < remotes.length; ++i) {
97
- const match = remotes[i].match(/^origin\t[^:]+:([^\.]+).+\(fetch\)/);
98
- if (match) {
99
- return match[1];
100
- }
101
- }
102
-
103
- console.error('Cannot find repository slug, sorry.');
104
- process.exit(1);
105
-}
106
-
107
-const repoSlug = getRepoSlug();
108
-const currentCommitHash = exec('git', ['rev-parse', 'HEAD']).trim();
109
-const currentTimestamp = new Date()
110
- .toISOString()
111
- .replace('T', ' ')
112
- .replace(/\..+/, '');
113
-
114
-function checkoutFactsFolder() {
115
- const factsFolder = '../' + repoSlug.split('/')[1] + '-facts';
116
- if (!fs.existsSync(factsFolder)) {
117
- let repoURL;
118
- if (isCI) {
119
- repoURL =
120
- 'https://' +
121
- process.env.GITHUB_USER +
122
- '@github.com/' +
123
- repoSlug +
124
- '.git';
125
- } else {
126
- repoURL = 'git@github.com:' + repoSlug + '.git';
127
- }
128
-
129
- exec('git', [
130
- 'clone',
131
- '--branch',
132
- 'facts',
133
- '--depth=5',
134
- repoURL,
135
- factsFolder,
136
- ]);
137
- }
138
-
139
- cwd = path.resolve(factsFolder);
140
- exec('git', ['fetch']);
141
- if (exec('git', ['status', '--porcelain'])) {
142
- console.error('facts-tracker: `git status` is not clean, aborting.');
143
- process.exit(1);
144
- }
145
- exec('git', ['rebase', 'origin/facts']);
146
-}
147
-checkoutFactsFolder();
148
-
149
-for (let i = 2; i < process.argv.length; i += 2) {
150
- const name = process.argv[i].trim();
151
- const value = process.argv[i + 1];
152
- if (value.indexOf('\n') !== -1) {
153
- console.error(
154
- 'facts-tracker: skipping',
155
- name,
156
- 'as the value contains new lines:',
157
- value
158
- );
159
- continue;
160
- }
161
-
162
- const filename = name + '.txt';
163
- let lastLine;
164
- try {
165
- lastLine = exec('tail', ['-n', '1', filename]);
166
- } catch (e) {
167
- // ignore error
168
- }
169
- const lastValue =
170
- lastLine && lastLine.replace(/^[^\t]+\t[^\t]+\t/, '').slice(0, -1); // commit hash \t timestamp \t // trailing \n
171
-
172
- if (value !== lastValue) {
173
- fs.appendFileSync(
174
- path.resolve(cwd, filename),
175
- currentCommitHash + '\t' + currentTimestamp + '\t' + value + '\n'
176
- );
177
- }
178
-
179
- console.log(name);
180
- console.log(lastValue);
181
- console.log(value);
182
-}
183
-
184
-if (exec('git', ['status', '--porcelain'])) {
185
- exec('git', ['add', '--all']);
186
- exec('git', ['commit', '-m', 'Adding facts for ' + currentCommitHash]);
187
- exec('git', ['push', 'origin', 'facts']);
188
-} else {
189
- console.error('facts-tracker: nothing to update');
190
-}
191
-cwd = null;