Skip to content

Commit

Permalink
lit-html-1.x: Run tests on GitHub actions (#1967)
Browse files Browse the repository at this point in the history
* Copy test workflow from main branch.

* Update test workflows to work with the lit-html-1.x branch.

* Run local tests in XVFB

* Update `actions/setup-node` and node version.

* Remove 'benchmarks.yml' reference in comments.

* Delete `.travis.yml` and `travis-bench.sh`.

* Initial attempt at porting the benchmarks to a GitHub action.

* Update tachometer.

* Copy benchmarks workflow from main branch.

* Update benchmark workflow to work with the lit-html-1.x branch.

* Fix node_modules key.

* Update to `actions/setup-node@v2`.

* Use `git+https` protocol to avoid SSH which doesn't seem to work.

* Move tachometer config to an external file.

* Fix benchmark names in report action.

* Update chromedriver.

* Update URLs and references in tachometer.json .

* Update ref in tachometer.json .

* Update badge in README.md .

* Remove `report-id` field from Tachometer reporter step.
  • Loading branch information
bicknellr committed Jun 24, 2021
1 parent 95a010a commit 208ca77
Show file tree
Hide file tree
Showing 8 changed files with 829 additions and 391 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Benchmarks

on: [pull_request]

jobs:
benchmarks:
name: benchmarks

# We can't currently run benchmarks on PRs from forked repos, because the
# tachometer action reports results by posting a comment, and we can't post
# comments without a github token.
if: github.event.pull_request == null || github.event.pull_request.head.repo.full_name == github.repository

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: 14

- name: Restore node_modules
id: cache
uses: actions/cache@v2
with:
path: node_modules
# Bump the number after `lit-1.x-node-modules` to force a cache
# update. Note there are multiple cache actions in `tests.yml` that
# should all keep keys in sync.
key: lit-1.x-node-modules-0-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: NPM install
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci

- name: Build
run: npm run build

- name: Benchmark
run: npx tach --config tachometer.json --json-file results.json

- name: Report
uses: andrewiggins/tachometer-reporter-action@v2
with:
path: results.json
pr-bench-name: this-change
base-bench-name: lit-html-1.x
90 changes: 90 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Tests

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: 14

- run: npm ci

- run: >-
npm run format && git diff --exit-code || (echo -e '\n\033[31mERROR:\033[0m
Project is not formatted. Please run "npm run format".' && false)
tests-local:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: 14

- name: Restore node_modules
id: cache
uses: actions/cache@v2
with:
path: node_modules
# Bump the number after `lit-1.x-node-modules` to force a cache
# update. Note there are cache actions in other jobs in this file that
# should all keep keys in sync.
key: lit-1.x-node-modules-0-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: NPM install
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci

- name: Install XVFB
run: sudo apt-get install xvfb

- name: Build
run: npm run build

- name: Test
run: xvfb-run npx wct --npm

tests-sauce:
# We can't run Sauce tests on PRs from forked repos, since they don't have
# access to secrets.
if: github.event.pull_request == null || github.event.pull_request.head.repo.full_name == github.repository

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: 14

- name: Restore node_modules
id: cache
uses: actions/cache@v2
with:
path: node_modules
# Bump the number after `lit-1.x-node-modules` to force a cache
# update. Note there are cache actions in other jobs in this file that
# should all keep keys in sync.
key: lit-1.x-node-modules-0-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: NPM install
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci

- name: Build
run: npm run build

- name: Test
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
run: npx wct -s 'windows 10/microsoftedge@17' -s 'windows 10/microsoftedge@15' -s 'macos 10.13/safari@11' -s 'macos 10.12/safari@10' -s 'windows 8.1/internet explorer@11' -s 'Linux/chrome@41' --npm
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# lit-html
Efficient, Expressive, Extensible HTML templates in JavaScript

[![Build Status](https://travis-ci.org/lit/lit.svg?branch=lit-html-1.4.x)](https://travis-ci.org/Polymer/lit-html)
[![Build Status](https://github.com/lit/lit/actions/workflows/tests.yml/badge.svg?branch=lit-html-1.x)](https://github.com/lit/lit/actions/workflows/tests.yml?query=branch%3Alit-html-1.x)
[![Published on npm](https://img.shields.io/npm/v/lit-html.svg)](https://www.npmjs.com/package/lit-html)
[![Join our Slack](https://img.shields.io/badge/slack-join%20chat-4a154b.svg)](https://lit.dev/slack-invite/)
[![Mentioned in Awesome Lit](https://awesome.re/mentioned-badge.svg)](https://github.com/web-padawan/awesome-lit)
Expand Down
Loading

0 comments on commit 208ca77

Please sign in to comment.