diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c6e526b2c0..b1d8737419 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -115,16 +115,15 @@ jobs: env: DENOBOT_PAT: ${{ secrets.DENOBOT_PAT }} run: | - # Note gh-pages branch is cloned into //gh-pages/ by - # tools/benchmark.py, hence the following copy is ok: + git clone --depth 1 -b gh-pages https://${DENOBOT_PAT}@github.com/denoland/deno.git gh-pages + python ./tools/build_benchmark_jsons.py cp -r website/* gh-pages/ cd gh-pages - git remote add origin2 https://${DENOBOT_PAT}@github.com/denoland/deno.git git config user.email "propelml@gmail.com" git config user.name "denobot" git add . git commit --message "Update benchmarks" - git push origin2 gh-pages + git push origin gh-pages - name: Worker info if: matrix.kind == 'bench' diff --git a/tools/benchmark.py b/tools/benchmark.py index 7d812daf3e..85e126b880 100755 --- a/tools/benchmark.py +++ b/tools/benchmark.py @@ -10,7 +10,6 @@ import os import sys import json import time -import shutil import tempfile import subprocess from util import build_path, executable_suffix, root_path, run, run_output @@ -30,10 +29,6 @@ exec_time_benchmarks = [ ("workers_round_robin", ["tests/workers_round_robin_bench.ts"]), ] -gh_pages_data_file = "gh-pages/data.json" -all_data_file = "website/data.json" # Includes all benchmark data. -recent_data_file = "website/recent.json" # Includes recent 20 benchmark data. - def read_json(filename): with open(filename) as json_file: @@ -45,19 +40,6 @@ def write_json(filename, data): json.dump(data, outfile) -def import_data_from_gh_pages(): - if os.path.exists(all_data_file): - return - try: - run([ - "git", "clone", "--depth", "1", "-b", "gh-pages", - "https://github.com/denoland/deno.git", "gh-pages" - ]) - shutil.copy(gh_pages_data_file, all_data_file) - except ValueError: - write_json(all_data_file, []) # writes empty json data - - def get_binary_sizes(build_dir): sizes = {} mtimes = {} @@ -246,7 +228,6 @@ def main(argv): deno_exe = os.path.join(build_dir, "deno") os.chdir(root_path) - import_data_from_gh_pages() new_data = { "created_at": time.strftime("%Y-%m-%dT%H:%M:%SZ"), @@ -275,11 +256,7 @@ def main(argv): print json.dumps(new_data, indent=2) print "===== " - all_data = read_json(all_data_file) - all_data.append(new_data) - - write_json(all_data_file, all_data) - write_json(recent_data_file, all_data[-20:]) + write_json(os.path.join(build_dir, "bench.json"), new_data) if __name__ == '__main__': diff --git a/tools/build_benchmark_jsons.py b/tools/build_benchmark_jsons.py new file mode 100755 index 0000000000..1d7a03401c --- /dev/null +++ b/tools/build_benchmark_jsons.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +from util import build_path +from benchmark import read_json, write_json +import os + +current_data_file = os.path.join(build_path(), "bench.json") +gh_pages_data_file = "gh-pages/data.json" +all_data_file = "website/data.json" # Includes all benchmark data. +recent_data_file = "website/recent.json" # Includes recent 20 benchmark data. + +assert os.path.exists(current_data_file) +assert os.path.exists(gh_pages_data_file) + +new_data = read_json(current_data_file) +all_data = read_json(gh_pages_data_file) +all_data.append(new_data) + +write_json(all_data_file, all_data) +write_json(recent_data_file, all_data[-20:])