Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #14 from chromeos/degit-globs
Browse files Browse the repository at this point in the history
Add CI testing with GitHub Actions
  • Loading branch information
Snugug committed Jan 14, 2020
2 parents 07014ca + 01319fe commit e67fbae
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 171 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/nodejs.yml
@@ -0,0 +1,85 @@
name: Node CI

on: [push]

jobs:
build-test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Switch Node Version
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Determine Lockfile
id: lockfile
run: |
if [[ -f "package-lock.json" || -f "npm-shrinkwrap.json" ]]; then
echo "::set-output name=exists::true"
else
echo "::set-output name=exists::false"
fi
- name: Install - Lockfile
if: steps.lockfile.outputs.exists == 'true'
run: |
npm ci
- name: Install - No Lockfile
if: steps.lockfile.outputs.exists == 'false'
run: |
npm install
- name: Build and Test
run: |
npm run build --if-present
npm test
env:
CI: true
- name: Upload built state
uses: actions/upload-artifact@v1
with:
name: site
path: public

lighthouse:
needs: build-test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Download compiled site
uses: actions/download-artifact@v1
with:
name: site
path: public
- name: Lighthouse Audit
uses: treosh/lighthouse-ci-action@v2
with:
configPath: lighthouse.config.json
# Uncomment to deploy to GitHub Pages after including a GitHub token in project's secrets
# deploy:
# needs: build-test
# runs-on: ubuntu-latest
# if: success() && github.ref == 'refs/heads/master'
# steps:
# - name: Checkout
# uses: actions/checkout@v1
# - name: Switch Node Version
# uses: actions/setup-node@v1
# with:
# node-version: ${{ matrix.node-version }}
# - name: Install
# run: |
# npm ci
# - name: Download compiled site
# uses: actions/download-artifact@v1
# with:
# name: site
# path: public
# - run: touch public/.nojekyll
# - name: Deploy to GitHub Pages
# run: npm run deploy
# env:
# GH_TOKEN: ${{ secrets.GH_TOKEN }}
1 change: 1 addition & 0 deletions .nvmrc
@@ -0,0 +1 @@
v12
2 changes: 1 addition & 1 deletion degit.json
@@ -1,6 +1,6 @@
[
{
"action": "remove",
"files": [".github", "CODE_OF_CONDUCT.md", ".npmrc"]
"files": [".github/ISSUE_TEMPLATE", ".github/CONTRIBUTING.md", ".github/pull_request_template.md", "CODE_OF_CONDUCT.md", ".npmrc"]
}
]
43 changes: 43 additions & 0 deletions lighthouse.config.json
@@ -0,0 +1,43 @@
{
"ci": {
"collect": {
"numberOfRuns": 3,
"url": ["/en", "/fr"],
"staticDistDir": "./public"
},
"assert": {
"assertions": {
"categories:performance": [
"error",
{
"minScore": 0.9
}
],
"categories:accessibility": [
"error",
{
"minScore": 0.9
}
],
"categories:best-practices": [
"error",
{
"minScore": 0.9
}
],
"categories:seo": [
"error",
{
"minScore": 0.85
}
],
"categories:pwa": [
"error",
{
"minScore": 0.9
}
]
}
}
}
}
6 changes: 1 addition & 5 deletions package.json
Expand Up @@ -15,8 +15,6 @@
"postbuild": "better-npm-run postbuild",
"pretest": "run-s test:lint",
"test": "nyc ava",
"test:lighthouse": "ava tests/lighthouse.js",
"posttest": "run-s build test:lighthouse",
"server": "gulp dev",
"dev": "better-npm-run dev",
"compile": "better-npm-run compile",
Expand Down Expand Up @@ -93,7 +91,6 @@
"devDependencies": {
"ava": "^2.4.0",
"better-npm-run": "^0.1.1",
"chrome-launcher": "^0.11.2",
"del-cli": "^2.0.0",
"eslint": "^6.5.1",
"eslint-config-google": "^0.14.0",
Expand All @@ -106,7 +103,6 @@
"fs-extra": "^8.1.0",
"gulp": "^4.0.2",
"husky": "^3.0.7",
"lighthouse": "^5.4.0",
"npm-run-all": "^4.1.5",
"nyc": "^14.1.1",
"prettier": "^1.18.2",
Expand All @@ -119,7 +115,7 @@
"iso-639-1": "^2.1.0",
"service-worker-i18n-redirect": "^1.0.0",
"service-worker-includes": "^1.0.0",
"static-site-scaffold": "^3.0.0",
"static-site-scaffold": "^3.0.1",
"workbox-cacheable-response": "^5.0.0-rc.1",
"workbox-expiration": "^5.0.0-rc.1",
"workbox-precaching": "^5.0.0-rc.1",
Expand Down
12 changes: 9 additions & 3 deletions templates/_layouts/_wrapper.html
Expand Up @@ -6,7 +6,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />

<title>{% if title %}{{title}} | {% endif %}Static Site Scaffold</title>
<meta name="Description" content="{{ metadesc }}" />
<meta name="theme-color" content="#2196f3"/>
<link rel="apple-touch-icon" href="/images/icons/icon-192x192.png">

{% for lang in site.languages %} {%if lang !== locale.code %}
<link rel="alternate" hreflang="{{lang}}" href="{{page.url | localeURL(lang)}}" />
Expand All @@ -15,15 +18,18 @@
<link rel="manifest" href="/manifest.json" />
<link rel="stylesheet" href="/css/style.css" />
<script type="module" defer src="/js/main.js"></script>
<title>{{ title }}</title>
</head>
<body>
{% from 'nav.html' import nav %} {{ nav(locale.code) }}
<select name="lang" id="lang">
<select name="lang" id="lang" aria-label="Select preferred language">
{% for lang in site.languages %}
<option value="{{lang}}" {% if lang === locale.code %}selected{% endif %}>{{lang | langName}}</option>
{% endfor %}
</select>
{{ content | safe }}
<main>
{{ content | safe }}
</main>
</body>
</html>


30 changes: 0 additions & 30 deletions tests/helpers/chrome.js

This file was deleted.

80 changes: 0 additions & 80 deletions tests/helpers/lighthouse.js

This file was deleted.

51 changes: 0 additions & 51 deletions tests/lighthouse.js

This file was deleted.

2 changes: 1 addition & 1 deletion tests/log.js
Expand Up @@ -15,7 +15,7 @@
*/
import test from 'ava';
import sinon from 'sinon';
import { log } from '../src/js/log';
import { log } from '../src/js/lib/log';

test('Logs non-tables', t => {
const mock = sinon.mock(console);
Expand Down

0 comments on commit e67fbae

Please sign in to comment.