From 4581dc8d24472944c6013ff541890193b006fbd0 Mon Sep 17 00:00:00 2001 From: Andre Wiggins <459878+andrewiggins@users.noreply.github.com> Date: Wed, 20 Jan 2021 10:40:56 -0800 Subject: [PATCH] Separate benchmarks into their own workflow (#2944) * Separate benchmarks into their own workflow This change enables us to only run benchmarks on PRs that change files relevant to the benchmarks --- .github/workflows/benchmarks.yml | 302 +++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 242 ------------------------- 2 files changed, 302 insertions(+), 242 deletions(-) create mode 100644 .github/workflows/benchmarks.yml diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml new file mode 100644 index 0000000000..ee1cb17bd3 --- /dev/null +++ b/.github/workflows/benchmarks.yml @@ -0,0 +1,302 @@ +name: Benchmarks + +on: + workflow_dispatch: + pull_request: + branches: + - '**' + paths: + - 'src/**.js' + push: + branches: + - master + - restructure + paths: + - 'src/**.js' + +jobs: + prepare: + name: Prepare benchmarks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - name: Cache node modules + uses: actions/cache@v1 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + # This uses the same name as the build-action so we can share the caches. + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - run: npm ci + - name: Package + # Use --ignore-scripts here to avoid re-building again before pack + run: | + npm pack --ignore-scripts + mv preact-*.tgz preact.tgz + tar -xzf preact.tgz + - name: Upload build output + uses: actions/upload-artifact@v2 + with: + name: build-output + path: package/ + - uses: andrewiggins/download-base-artifact@v1 + with: + artifact: npm-package + workflow: ci.yml + required: false + - name: Upload base preact package + uses: actions/upload-artifact@v2 + with: + name: build-output + path: preact.tgz + - name: Initialize Tachometer Results Report + uses: andrewiggins/tachometer-reporter-action@v2 + with: + initialize: true + + bench_text_update: + name: Bench text_update + runs-on: ubuntu-latest + needs: prepare + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - uses: actions/download-artifact@v2 + with: + name: build-output + - name: install & build + run: | + cd benches + npm ci + - name: bench + run: | + export CHROMEDRIVER_FILEPATH=$(which chromedriver) + cd benches + npm run bench text_update.html + - name: Upload results + uses: actions/upload-artifact@v2 + with: + name: results + path: benches/results/text_update.json + - uses: andrewiggins/tachometer-reporter-action@v2 + with: + path: benches/results/text_update.json + report-id: text_update + base-bench-name: preact-master + pr-bench-name: preact-local + + bench_many_updates: + name: Bench many_updates + runs-on: ubuntu-latest + needs: prepare + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - uses: actions/download-artifact@v2 + with: + name: build-output + - name: install & build + run: | + cd benches + npm ci + - name: bench + run: | + export CHROMEDRIVER_FILEPATH=$(which chromedriver) + cd benches + npm run bench many_updates.html + - name: Upload results + uses: actions/upload-artifact@v2 + with: + name: results + path: benches/results/many_updates.json + - uses: andrewiggins/tachometer-reporter-action@v2 + with: + path: benches/results/many_updates.json + report-id: many_updates + base-bench-name: preact-master + pr-bench-name: preact-local + + bench_02_replace1k: + name: Bench 02_replace1k + runs-on: ubuntu-latest + needs: prepare + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - uses: actions/download-artifact@v2 + with: + name: build-output + - name: install & build + run: | + cd benches + npm ci + - name: bench + run: | + export CHROMEDRIVER_FILEPATH=$(which chromedriver) + cd benches + npm run bench 02_replace1k.html + - name: Upload results + uses: actions/upload-artifact@v2 + with: + name: results + path: benches/results/02_replace1k.json + - uses: andrewiggins/tachometer-reporter-action@v2 + with: + path: benches/results/02_replace1k.json + report-id: 02_replace1k + base-bench-name: preact-master + pr-bench-name: preact-local + summarize: 'duration, usedJSHeapSize' + + bench_03_update10th1k_x16: + name: Bench 03_update10th1k_x16 + runs-on: ubuntu-latest + needs: prepare + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - uses: actions/download-artifact@v2 + with: + name: build-output + - name: install & build + run: | + cd benches + npm ci + - name: bench + run: | + export CHROMEDRIVER_FILEPATH=$(which chromedriver) + cd benches + npm run bench 03_update10th1k_x16.html + - name: Upload results + uses: actions/upload-artifact@v2 + with: + name: results + path: benches/results/03_update10th1k_x16.json + - uses: andrewiggins/tachometer-reporter-action@v2 + with: + path: benches/results/03_update10th1k_x16.json + report-id: 03_update10th1k_x16 + base-bench-name: preact-master + pr-bench-name: preact-local + + bench_07_create10k: + name: Bench 07_create10k + runs-on: ubuntu-latest + needs: prepare + timeout-minutes: 20 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - uses: actions/download-artifact@v2 + with: + name: build-output + - name: install & build + run: | + cd benches + npm ci + - name: bench + run: | + export CHROMEDRIVER_FILEPATH=$(which chromedriver) + cd benches + npm run bench 07_create10k.html + - name: Upload results + uses: actions/upload-artifact@v2 + with: + name: results + path: benches/results/07_create10k.json + - uses: andrewiggins/tachometer-reporter-action@v2 + with: + path: benches/results/07_create10k.json + report-id: 07_create10k + base-bench-name: preact-master + pr-bench-name: preact-local + + bench_hydrate1k: + name: Bench hydrate1k + runs-on: ubuntu-latest + needs: prepare + timeout-minutes: 20 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - uses: actions/download-artifact@v2 + with: + name: build-output + - name: install & build + run: | + cd benches + npm ci + - name: bench + run: | + export CHROMEDRIVER_FILEPATH=$(which chromedriver) + cd benches + npm run bench hydrate1k.html + - name: Upload results + uses: actions/upload-artifact@v2 + with: + name: results + path: benches/results/hydrate1k.json + - uses: andrewiggins/tachometer-reporter-action@v2 + with: + path: benches/results/hydrate1k.json + report-id: hydrate1k + base-bench-name: preact-master + pr-bench-name: preact-local + + bench_filter_list: + name: Bench filter_list + runs-on: ubuntu-latest + needs: prepare + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - uses: actions/download-artifact@v2 + with: + name: build-output + - name: install & build + run: | + cd benches + npm ci + - name: bench + run: | + export CHROMEDRIVER_FILEPATH=$(which chromedriver) + cd benches + npm run bench filter_list.html + - name: Upload results + uses: actions/upload-artifact@v2 + with: + name: results + path: benches/results/filter_list.json + - uses: andrewiggins/tachometer-reporter-action@v2 + with: + path: benches/results/filter_list.json + report-id: filter_list + base-bench-name: preact-master + pr-bench-name: preact-local diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63d29f2b57..80dcd86f7f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,250 +50,8 @@ jobs: run: | npm pack --ignore-scripts mv preact-*.tgz preact.tgz - tar -xzf preact.tgz - - name: Upload build output - uses: actions/upload-artifact@v2 - with: - name: build-output - path: package/ - name: Upload npm package uses: actions/upload-artifact@v2 with: name: npm-package path: preact.tgz - - name: Initialize Tachometer Results Report - uses: andrewiggins/tachometer-reporter-action@v2 - with: - initialize: true - - bench_text_update: - name: Bench text_update - runs-on: ubuntu-latest - needs: build_test - timeout-minutes: 10 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - uses: actions/download-artifact@v2 - with: - name: build-output - - uses: andrewiggins/download-base-artifact@v1 - with: - artifact: npm-package - required: false - - name: install & build - run: | - cd benches - npm ci - - name: bench - run: | - export CHROMEDRIVER_FILEPATH=$(which chromedriver) - cd benches - npm run bench text_update.html - - uses: andrewiggins/tachometer-reporter-action@v2 - with: - path: benches/results/text_update.json - report-id: text_update - base-bench-name: preact-master - pr-bench-name: preact-local - - bench_many_updates: - name: Bench many_updates - runs-on: ubuntu-latest - needs: build_test - timeout-minutes: 10 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - uses: actions/download-artifact@v2 - with: - name: build-output - - uses: andrewiggins/download-base-artifact@v1 - with: - artifact: npm-package - required: false - - name: install & build - run: | - cd benches - npm ci - - name: bench - run: | - export CHROMEDRIVER_FILEPATH=$(which chromedriver) - cd benches - npm run bench many_updates.html - - uses: andrewiggins/tachometer-reporter-action@v2 - with: - path: benches/results/many_updates.json - report-id: many_updates - base-bench-name: preact-master - pr-bench-name: preact-local - - bench_02_replace1k: - name: Bench 02_replace1k - runs-on: ubuntu-latest - needs: build_test - timeout-minutes: 10 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - uses: actions/download-artifact@v2 - with: - name: build-output - - uses: andrewiggins/download-base-artifact@v1 - with: - artifact: npm-package - required: false - - name: install & build - run: | - cd benches - npm ci - - name: bench - run: | - export CHROMEDRIVER_FILEPATH=$(which chromedriver) - cd benches - npm run bench 02_replace1k.html - - uses: andrewiggins/tachometer-reporter-action@v2 - with: - path: benches/results/02_replace1k.json - report-id: 02_replace1k - base-bench-name: preact-master - pr-bench-name: preact-local - summarize: 'duration, usedJSHeapSize' - - bench_03_update10th1k_x16: - name: Bench 03_update10th1k_x16 - runs-on: ubuntu-latest - needs: build_test - timeout-minutes: 10 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - uses: actions/download-artifact@v2 - with: - name: build-output - - uses: andrewiggins/download-base-artifact@v1 - with: - artifact: npm-package - required: false - - name: install & build - run: | - cd benches - npm ci - - name: bench - run: | - export CHROMEDRIVER_FILEPATH=$(which chromedriver) - cd benches - npm run bench 03_update10th1k_x16.html - - uses: andrewiggins/tachometer-reporter-action@v2 - with: - path: benches/results/03_update10th1k_x16.json - report-id: 03_update10th1k_x16 - base-bench-name: preact-master - pr-bench-name: preact-local - - bench_07_create10k: - name: Bench 07_create10k - runs-on: ubuntu-latest - needs: build_test - timeout-minutes: 20 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - uses: actions/download-artifact@v2 - with: - name: build-output - - uses: andrewiggins/download-base-artifact@v1 - with: - artifact: npm-package - required: false - - name: install & build - run: | - cd benches - npm ci - - name: bench - run: | - export CHROMEDRIVER_FILEPATH=$(which chromedriver) - cd benches - npm run bench 07_create10k.html - - uses: andrewiggins/tachometer-reporter-action@v2 - with: - path: benches/results/07_create10k.json - report-id: 07_create10k - base-bench-name: preact-master - pr-bench-name: preact-local - - bench_hydrate1k: - name: Bench hydrate1k - runs-on: ubuntu-latest - needs: build_test - timeout-minutes: 20 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - uses: actions/download-artifact@v2 - with: - name: build-output - - uses: andrewiggins/download-base-artifact@v1 - with: - artifact: npm-package - required: false - - name: install & build - run: | - cd benches - npm ci - - name: bench - run: | - export CHROMEDRIVER_FILEPATH=$(which chromedriver) - cd benches - npm run bench hydrate1k.html - - uses: andrewiggins/tachometer-reporter-action@v2 - with: - path: benches/results/hydrate1k.json - report-id: hydrate1k - base-bench-name: preact-master - pr-bench-name: preact-local - - bench_filter_list: - name: Bench filter_list - runs-on: ubuntu-latest - needs: build_test - timeout-minutes: 10 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - uses: actions/download-artifact@v2 - with: - name: build-output - - uses: andrewiggins/download-base-artifact@v1 - with: - artifact: npm-package - required: false - - name: install & build - run: | - cd benches - npm ci - - name: bench - run: | - export CHROMEDRIVER_FILEPATH=$(which chromedriver) - cd benches - npm run bench filter_list.html - - uses: andrewiggins/tachometer-reporter-action@v2 - with: - path: benches/results/filter_list.json - report-id: filter_list - base-bench-name: preact-master - pr-bench-name: preact-local