Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
update_spreadsheet Namespace Reference

Functions

 authenticate ()
 
 get_next_run_id (sheet)
 
 add_new_fuzzing_entry (sheet, run, tests, success, rerun, skipped, timeout, divergences)
 
 get_run_statistic_summary (run)
 
 main ()
 

Variables

list SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
 
str SPREADSHEET_ID = '1nDoK-dCuEmf6yo55a303UClRd7AwjbzPkRr37ijWcC8'
 
str RANGE_NAME = 'Sheet1!A3:H'
 
str VERIFY_CURRENT_ROW_FORMULA = '=B:B-C:C-D:D-E:E-F:F'
 

Detailed Description

Tool to automatically update the DartFuzzStats spreadsheet

Requires a one-time authentication step with a @google account.

Function Documentation

◆ add_new_fuzzing_entry()

update_spreadsheet.add_new_fuzzing_entry (   sheet,
  run,
  tests,
  success,
  rerun,
  skipped,
  timeout,
  divergences 
)

Definition at line 65 of file update_spreadsheet.py.

66 divergences):
67
68 entry = [run, tests, success, skipped, timeout, divergences, rerun]
69 print(
70 'Adding entry for run %d. Tests: %d Successes: %d Skipped: %d Timeouts: %d, Divergences: %d Re-runs: %d'
71 % tuple(entry))
72
73 values = {'values': [entry + [VERIFY_CURRENT_ROW_FORMULA]]}
74 sheet.values().append(
75 spreadsheetId=SPREADSHEET_ID,
76 range=RANGE_NAME,
77 body=values,
78 valueInputOption='USER_ENTERED').execute()
79
80
81# Scrapes the fuzzing shards for fuzzing run statistics.
82#
83# Returns a list of statistics in the following order:
84#
85# - # of tests
86# - # of successes
87# - # of re-runs
88# - # of skipped runs
89# - # of timeouts
90# - # of divergences
91#
void print(void *str)
Definition bridge.cpp:126
static void append(char **dst, size_t *count, const char *src, size_t n)
Definition editor.cpp:211

◆ authenticate()

update_spreadsheet.authenticate ( )

Definition at line 31 of file update_spreadsheet.py.

31def authenticate():
32 dir_path = os.path.dirname(os.path.realpath(__file__))
33 creds = None
34 # The file token.pickle stores the user's access and refresh tokens, and is
35 # created automatically when the authorization flow completes for the first
36 # time.
37 pickle_path = os.path.join(dir_path, 'token.pickle')
38 if os.path.exists(pickle_path):
39 with open(pickle_path, 'rb') as token:
40 creds = pickle.load(token)
41 # If there are no (valid) credentials available, let the user log in.
42 if not creds or not creds.valid:
43 if creds and creds.expired and creds.refresh_token:
44 creds.refresh(Request())
45 else:
46 flow = InstalledAppFlow.from_client_secrets_file(
47 os.path.join(dir_path, 'credentials.json'), SCOPES)
48 creds = flow.run_local_server(port=0)
49 # Save the credentials for the next run
50 with open(pickle_path, 'wb') as token:
51 pickle.dump(creds, token)
52 return build('sheets', 'v4', credentials=creds)
53
54
55# Returns the next run ID based on the last run ID found in the fuzzing
56# spreadsheet.
Definition build.py:1

◆ get_next_run_id()

update_spreadsheet.get_next_run_id (   sheet)

Definition at line 57 of file update_spreadsheet.py.

57def get_next_run_id(sheet):
58 result = sheet.values().get(
59 spreadsheetId=SPREADSHEET_ID, range=RANGE_NAME).execute()
60 values = result.get('values', [])
61 return int(values[-1][0]) + 1
62
63
64# Inserts a new entry into the fuzzing spreadsheet.
Type::kYUV Type::kRGBA() int(0.7 *637)

◆ get_run_statistic_summary()

update_spreadsheet.get_run_statistic_summary (   run)

Definition at line 92 of file update_spreadsheet.py.

92def get_run_statistic_summary(run):
93 dir_path = os.path.dirname(os.path.realpath(__file__))
94 output = subprocess.check_output([
95 'python3',
96 os.path.join(dir_path, 'collect_data.py'), '--output-csv', '--type=sum',
97 'https://ci.chromium.org/p/dart/builders/ci.sandbox/fuzz-linux/%d' % run
98 ])
99 return list(map(int, output.decode('UTF-8').rstrip().split(',')))
100
101

◆ main()

update_spreadsheet.main ( )

Definition at line 102 of file update_spreadsheet.py.

102def main():
103 service = authenticate()
104 # Call the Sheets API
105 sheet = service.spreadsheets()
106 while True:
107 try:
108 next_id = get_next_run_id(sheet)
109 summary = get_run_statistic_summary(next_id)
110 add_new_fuzzing_entry(sheet, next_id, *summary)
111 except:
112 # get_run_statistic_summary exits with non-zero exit code if we're out
113 # of runs to check.
114 print('No more runs to process. Exiting.')
115 break
116
117
Definition main.py:1

Variable Documentation

◆ RANGE_NAME

str update_spreadsheet.RANGE_NAME = 'Sheet1!A3:H'

Definition at line 26 of file update_spreadsheet.py.

◆ SCOPES

list update_spreadsheet.SCOPES = ['https://www.googleapis.com/auth/spreadsheets']

Definition at line 22 of file update_spreadsheet.py.

◆ SPREADSHEET_ID

str update_spreadsheet.SPREADSHEET_ID = '1nDoK-dCuEmf6yo55a303UClRd7AwjbzPkRr37ijWcC8'

Definition at line 25 of file update_spreadsheet.py.

◆ VERIFY_CURRENT_ROW_FORMULA

str update_spreadsheet.VERIFY_CURRENT_ROW_FORMULA = '=B:B-C:C-D:D-E:E-F:F'

Definition at line 28 of file update_spreadsheet.py.