Skip to content

Commit

Permalink
misc(ci): build report and deploy to now.sh on every commit (#8194)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish authored and connorjclark committed Apr 13, 2019
1 parent c727c19 commit 41065f1
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .build-for-now.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

##
# @license Copyright 2019 Google Inc. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
##

set -x

# Manually install this one report dependency. Avoid installing all deps (for speed)
rm package.json
yarn add details-element-polyfill@2.2.0

# Create dist if it's not already there
mkdir -p dist

# Generate the report and place as dist/index.html
node lighthouse-core/scripts/build-report-for-autodeployment.js
22 changes: 22 additions & 0 deletions lighthouse-core/scripts/build-report-for-autodeployment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env node

/**
* @license Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';

/* eslint-disable no-console */
const fs = require('fs');
const path = require('path');

const ReportGenerator = require('../../lighthouse-core/report/report-generator.js');
const lhr = require('../../lighthouse-core/test/results/sample_v2.json');

console.log('🕒 Generating report for sample_v2.json...');
// @ts-ignore
const html = ReportGenerator.generateReport(lhr, 'html');
const filename = path.join(__dirname, '../../dist/index.html');
fs.writeFileSync(filename, html, {encoding: 'utf-8'});
console.log('✅', filename, 'written.');
12 changes: 12 additions & 0 deletions now.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 2,
"builds": [
{
"src": ".build-for-now.sh",
"use": "@now/static-build"
}
],
"github": {
"silent": true
}
}

0 comments on commit 41065f1

Please sign in to comment.