Skip to content

Commit 9cb4335

Browse files
bicknellraomarksjustinfagnani
authored
Run tests and benchmarks on GitHub actions. (#1203)
* Benchmarks moved out of https://github.com/PolymerLabs/tachometer * Fix npmignore * Remove misc benchmarks we aren't using for now * Change package name for lit-html sub-package * Remove private tag * Temporarily add an extra lit-html directory layer. We need this to make tachometer happy. Tachometer should be more flexible though, and then we can flatten this back out. * Move npmignore * Fork lit-html shack for lit-element version * Add .clang-format and reformat * Remove bench code for now * Add list-item element * Fix package.json * Rename shack grid to list for consistency * Clone lit-element shack for polymer version * Add lit-element package-lock * Polymer shack working, but uses lit * Polymer ShackCart element * Rename Polymer list-item to shack-item * Rename lit-element list-item to shack-item * Add lit-element shack-cart * Add Polymer shack-app element * Remove lit-html as polymer shack dependency * Add lit-element shack-app * refactor lit-html app into app/cart/item modules * If we're doing a micro benchmark, wait 100ms before rendering. This reduces variance quite a bit. * only nobench for lit-html for now * Add js-framework-benchmark benchmarks for lit-html * Remove now unneccessary implementation directory layer * Prepare to release lit-html-benchmarks 0.2.0 * Bump tachometer version * Add shack.json and README for comparing the 3 shack implementation * Convert JSON to module, add callback mode to lit-element and polymer shack * Include customElement.define cost in LitElement and Polymer benchmarks. * Add full package.json for lit-element-benchmarks * Bump dependencies * Remove unneeded file * Rename bench command to tach and document in README. * Bump tachometer version and recommend npx tachometer * Bump lit-html-benchmarks version * Bump deps, auto install sub-package deps, some cleanup. (#9) * Add modified GitHub actions workflows for tests and benchmarks from lit/lit. * Add full set of WCT test browsers originally listed in `.travis.yml`. * Break WCT line into multiple lines. * Stop running tests on browsers that time out after finishing all tests. Firefox is already being tested at stable by the non-Sauce workflow. * Update tachometer and chromedriver. * Fix benchmark labels. * Checkout benchmarks repo separately. * Install tachometer manually. * Remove `working-directory` keyword from reporter action. * Install latest tachometer version. * Fix working directory. * Install chromedriver at 91 (current GitHub actions Chrome version). * Update LitElement to v2. * Uninstall `lit-element-benchmarks`, `tachometer`, and `chromedriver`. * Remove everything except `/lit-element/`. * `/lit-element/` -> `/benchmarks/` * Update benchmarks `package.json`. * Update benchmarks workflow and config to run within the new benchmarks directory. * Run `npm ci` in benchmarks package and cache if possible. * Use the local repo for checking out `master` also. * Update version number in cache action key. Co-authored-by: Alexander Marks <aomarks@google.com> Co-authored-by: Justin Fagnani <justinfagnani@google.com>
1 parent 2b39872 commit 9cb4335

18 files changed

+7523
-2693
lines changed

.github/workflows/benchmarks.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Benchmarks
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
benchmarks:
7+
name: benchmarks
8+
9+
# We can't currently run benchmarks on PRs from forked repos, because the
10+
# tachometer action reports results by posting a comment, and we can't post
11+
# comments without a github token.
12+
if: github.event.pull_request == null || github.event.pull_request.head.repo.full_name == github.repository
13+
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/setup-node@v2
17+
with:
18+
node-version: 14
19+
20+
- uses: actions/checkout@v2
21+
22+
# By default, the actions/checkout@v2 only retrieves the one commit
23+
# associated with the pull request. The benchmarks test against the
24+
# `master` branch also, so we explicitly retrieve it here.
25+
- name: Fetch additional refs
26+
run: git fetch --no-tags --depth=1 origin master
27+
28+
- name: Restore benchmarks/node_modules
29+
id: cache
30+
uses: actions/cache@v2
31+
with:
32+
path: benchmarks/node_modules
33+
# Bump the number after `lit-element-2.x-benchmarks-node-modules` to
34+
# force a cache update. Note there are cache actions in other jobs in
35+
# this file that should all keep keys in sync.
36+
key: lit-element-2.x-benchmarks-node-modules-0-${{ runner.os }}-${{ hashFiles('benchmarks/package-lock.json') }}
37+
38+
- name: NPM install
39+
if: steps.cache.outputs.cache-hit != 'true'
40+
working-directory: ./benchmarks
41+
run: npm ci
42+
43+
- name: Benchmark
44+
working-directory: ./benchmarks
45+
run: npx tach --config tachometer.json --json-file results.json
46+
47+
- name: Report
48+
uses: andrewiggins/tachometer-reporter-action@v2
49+
with:
50+
path: ./benchmarks/results.json
51+
pr-bench-name: this-change
52+
base-bench-name: master

.github/workflows/tests.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- uses: actions/setup-node@v2
13+
with:
14+
node-version: 14
15+
16+
- run: npm ci
17+
18+
- run: >-
19+
npm run format && git diff --exit-code || (echo -e '\n\033[31mERROR:\033[0m
20+
Project is not formatted. Please run "npm run format".' && false)
21+
tests-local:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v2
26+
27+
- uses: actions/setup-node@v2
28+
with:
29+
node-version: 14
30+
31+
- name: Restore node_modules
32+
id: cache
33+
uses: actions/cache@v2
34+
with:
35+
path: node_modules
36+
# Bump the number after `lit-element-2.x-node-modules` to force a
37+
# cache update. Note there are cache actions in other jobs in this
38+
# file that should all keep keys in sync.
39+
key: lit-element-2.x-node-modules-0-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
40+
41+
- name: NPM install
42+
if: steps.cache.outputs.cache-hit != 'true'
43+
run: npm ci
44+
45+
- name: Install XVFB
46+
run: sudo apt-get install xvfb
47+
48+
- name: Build
49+
run: npm run build
50+
51+
- name: Test
52+
run: xvfb-run npx wct --npm
53+
54+
tests-sauce:
55+
# We can't run Sauce tests on PRs from forked repos, since they don't have
56+
# access to secrets.
57+
if: github.event.pull_request == null || github.event.pull_request.head.repo.full_name == github.repository
58+
59+
runs-on: ubuntu-latest
60+
61+
steps:
62+
- uses: actions/checkout@v2
63+
64+
- uses: actions/setup-node@v2
65+
with:
66+
node-version: 14
67+
68+
- name: Restore node_modules
69+
id: cache
70+
uses: actions/cache@v2
71+
with:
72+
path: node_modules
73+
# Bump the number after `lit-element-2.x-node-modules` to force a
74+
# cache update. Note there are cache actions in other jobs in this
75+
# file that should all keep keys in sync.
76+
key: lit-element-2.x-node-modules-0-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
77+
78+
- name: NPM install
79+
if: steps.cache.outputs.cache-hit != 'true'
80+
run: npm ci
81+
82+
- name: Build
83+
run: npm run build
84+
85+
- name: Test
86+
env:
87+
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
88+
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
89+
# This list of browsers originally included 'os x 10.12/safari@10' and
90+
# 'Linux/firefox', but these browsers both time out after running all
91+
# tests. This doesn't happen locally, so I'm not sure what's different
92+
# in GitHub actions that would break this.
93+
run: >
94+
npx wct --npm
95+
-s 'windows 10/microsoftedge@15'
96+
-s 'windows 10/microsoftedge@17'
97+
-s 'windows 8.1/internet explorer@11'
98+
-s 'os x 10.11/safari@9'
99+
-s 'macos 10.13/safari@11'
100+
-s 'Linux/chrome@41'

.travis.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
LitElement is simple base class for creating fast, lightweight web components with [lit-html](https://lit-html.polymer-project.org/).
44

5-
[![Build Status](https://travis-ci.org/lit/lit-element.svg?branch=master)](https://travis-ci.org/lit/lit-element)
5+
[![Build Status](https://github.com/lit/lit-element/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/lit/lit-element/actions/workflows/tests.yml?query=branch%3Amaster)
66
[![Published on npm](https://img.shields.io/npm/v/lit-element.svg)](https://www.npmjs.com/package/lit-element)
77
[![Join our Slack](https://img.shields.io/badge/slack-join%20chat-4a154b.svg)](https://lit.dev/slack-invite/)
88
[![Mentioned in Awesome lit-html](https://awesome.re/mentioned-badge.svg)](https://github.com/web-padawan/awesome-lit)

benchmarks/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules

0 commit comments

Comments
 (0)