Run GitHub Action tests against local HTTP server (#3638)

This commit is contained in:
Peter Hedenskog 2022-04-26 06:11:19 +02:00 committed by GitHub
parent 8206cfd1ce
commit 4e323784fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 122 additions and 100 deletions

View File

@ -4,3 +4,4 @@ assets/*
sitespeed-result/*
lib/plugins/yslow/scripts/*
lib/plugins/html/assets/js/*
test/data/*

View File

@ -16,15 +16,19 @@ jobs:
docker buildx install
docker buildx build --load --platform linux/amd64 -t sitespeedio/sitespeed.io .
docker buildx build --load --platform linux/amd64 -t sitespeedio/sitespeed.io:slim --file Dockerfile-slim .
- name: Install local HTTP server
run: npm install serve -g
- name: Start local HTTP server
run: (serve test/data/html/ -l 3001&)
- name: Run test on default container for Chrome
run: docker run --rm sitespeedio/sitespeed.io https://www.sitespeed.io -n 1 -b chrome
run: docker run --rm --network=host sitespeedio/sitespeed.io http://127.0.0.1:3001 -n 1 -b chrome
- name: Run test on default container for Firefox
run: docker run --rm sitespeedio/sitespeed.io https://www.sitespeed.io -n 1 -b firefox
run: docker run --rm --network=host sitespeedio/sitespeed.io http://127.0.0.1:3001 -n 1 -b firefox
- name: Run test on default container for Edge
run: docker run --rm sitespeedio/sitespeed.io https://www.sitespeed.io -n 1 -b edge
run: docker run --rm --network=host sitespeedio/sitespeed.io http://127.0.0.1:3001 -n 1 -b edge
- name: Run test on slim container
run: docker run --rm sitespeedio/sitespeed.io:slim https://www.sitespeed.io -n 1 --browsertime.firefox.preference "devtools.netmonitor.persistlog:true"
run: docker run --rm --network=host sitespeedio/sitespeed.io:slim http://127.0.0.1:3001 -n 1 --browsertime.firefox.preference "devtools.netmonitor.persistlog:true"
- name: Test WebPageReplay with Chrome
run: docker run --cap-add=NET_ADMIN --rm -e REPLAY=true -e LATENCY=100 sitespeedio/sitespeed.io https://www.sitespeed.io -n 3 -b chrome
- name: Test WebPageReplay with Firefox
run: docker run --cap-add=NET_ADMIN --rm -e REPLAY=true -e LATENCY=100 sitespeedio/sitespeed.io https://www.sitespeed.io -n 3 -b firefox --browsertime.firefox.acceptInsecureCerts true
run: docker run --cap-add=NET_ADMIN --rm --network=host -e REPLAY=true -e LATENCY=100 sitespeedio/sitespeed.io https://www.sitespeed.io -n 3 -b firefox --browsertime.firefox.acceptInsecureCerts true

View File

@ -34,25 +34,29 @@ jobs:
run: |
google-chrome --version
firefox --version
- name: Install local HTTP server
run: npm install serve -g
- name: Start local HTTP server
run: (serve test/data/html/ -l 3001&)
- name: Test old budget
run: bin/sitespeed.js -b firefox -n 2 --budget.configPath test/oldBudget.json --summary --xvfb https://www.sitespeed.io/
run: bin/sitespeed.js -b firefox -n 2 --budget.configPath test/oldBudget.json --summary --xvfb http://127.0.0.1:3001/simple/
- name: Test new budget file
run: bin/sitespeed.js --useHash -n 1 --budget.configPath test/budget.json --xvfb https://www.sitespeed.io/#heybaberia
run: bin/sitespeed.js --useHash -n 1 --budget.configPath test/budget.json --xvfb http://127.0.0.1:3001/simple/#heybaberia
- name: Use AXE
run: bin/sitespeed.js --useAlias start --mobile -n 1 --utc --axe.enable --xvfb https://www.sitespeed.io/
run: bin/sitespeed.js --useAlias start --mobile -n 1 --utc --axe.enable --xvfb http://127.0.0.1:3001/simple/
- name: Use Fireefox with --mobile
run: bin/sitespeed.js -b firefox --metrics.list --mobile -n 1 https://www.sitespeed.io/ --sustainable.enable --xvfb
run: bin/sitespeed.js -b firefox --metrics.list --mobile -n 1 http://127.0.0.1:3001/simple/ --sustainable.enable --xvfb
- name: Test --multi
run: bin/sitespeed.js --multi -b chrome -n 1 test/prepostscripts/preSample.js https://www.sitespeed.io/documentation/ test/prepostscripts/postSample.js --xvfb
run: bin/sitespeed.js --multi -b chrome -n 1 test/prepostscripts/preSample.js http://127.0.0.1:3001/simple/ test/prepostscripts/postSample.js --xvfb
- name: Test --multi and --tcpdump
run: bin/sitespeed.js --multi -n 1 https://www.sitespeed.io/ https://www.sitespeed.io/documentation/ --tcpdump --xvfb
run: bin/sitespeed.js --multi -n 1 http://127.0.0.1:3001/simple/ http://127.0.0.1:3001/dimple/ --tcpdump --xvfb
- name: Test --multi with one file
run: bin/sitespeed.js --multi -n 3 test/prepostscripts/multi.js --xvfb
- name: Test setting HTML output pageSummaries
run: bin/sitespeed.js https://www.sitespeed.io/ https://www.google.com -v -n 1 --html.pageSummaryMetrics transferSize.css --html.pageSummaryMetrics requests.httpErrors --html.pageSummaryMetrics score.performance --xvfb
run: bin/sitespeed.js http://127.0.0.1:3001/simple/ http://127.0.0.1:3001/dimple/ -v -n 1 --html.pageSummaryMetrics transferSize.css --html.pageSummaryMetrics requests.httpErrors --html.pageSummaryMetrics score.performance --xvfb
- name: Test setting HTML output summary boxes
run: bin/sitespeed.js https://www.sitespeed.io/ -v -n 1 --html.summaryBoxes score.performance --html.summaryBoxes timings.firstPaint --xvfb
run: bin/sitespeed.js http://127.0.0.1:3001/simple/ -v -n 1 --html.summaryBoxes score.performance --html.summaryBoxes timings.firstPaint --xvfb
- name: Run test with Graphite
run: bin/sitespeed.js https://www.sitespeed.io/ -n 1 --graphite.host 127.0.0.1 --xvfb
run: bin/sitespeed.js http://127.0.0.1:3001/simple/ -n 1 --graphite.host 127.0.0.1 --xvfb
- name: Run test without a CLI
run: xvfb-run node test/runWithoutCli.js

View File

@ -19,5 +19,9 @@ jobs:
run: |
sudo safaridriver --enable
npm ci
- name: Install local HTTP server
run: npm install serve -g
- name: Start local HTTP server
run: (serve test/data/html/ -l 3001&)
- name: Run test
run: bin/sitespeed.js -b safari https://www.sitespeed.io/
run: bin/sitespeed.js -b safari http://127.0.0.1:3001/

121
npm-shrinkwrap.json generated
View File

@ -2239,6 +2239,22 @@
"node": ">=10"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"node_modules/combined-stream": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
@ -3207,24 +3223,6 @@
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/eslint/node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/eslint/node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"node_modules/eslint/node_modules/debug": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
@ -3278,15 +3276,6 @@
"node": ">=0.10.0"
}
},
"node_modules/eslint/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/eslint/node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@ -4162,6 +4151,15 @@
"node": ">=0.10.0"
}
},
"node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/has-symbols": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz",
@ -8310,22 +8308,6 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/wrap-ansi/node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/wrap-ansi/node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"node_modules/wrap-ansi/node_modules/strip-ansi": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",
@ -10190,6 +10172,19 @@
"convert-to-spaces": "^1.0.1"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"combined-stream": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
@ -10918,21 +10913,6 @@
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"debug": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
@ -10968,12 +10948,6 @@
}
}
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@ -11697,6 +11671,12 @@
"ansi-regex": "^2.0.0"
}
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true
},
"has-symbols": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz",
@ -14946,19 +14926,6 @@
"color-convert": "^2.0.1"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"strip-ansi": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",

View File

@ -41,7 +41,8 @@
"files": [
"test/**/*",
"!test/prepostscripts",
"!test/runWithoutCli.js"
"!test/runWithoutCli.js",
"!test/data"
]
},
"scripts": {

View File

@ -0,0 +1,3 @@
body{
color: #B24926;
}

View File

@ -0,0 +1,15 @@
<!doctype html>
<html>
<head>
<title>This is a test site</title>
<link rel="stylesheet" href="/css/main.css">
</head>
<body>
<h1>Hello!</h1>
<p>This is a paragraph, we load one CSS, one JavaScript and one image.<p>
<p><a href="/simple/">Simple</a></p>
<p><a href="/search/">Search</a></p>
<img src="/img/pirate.png">
<script type="text/javascript" src="/js/jquery-2.1.4.min.js"></script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

4
test/data/html/js/jquery-2.1.4.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,9 @@
<html>
<head>
<title>Search</title>
</head>
<body>
<h1>Super search</h1>
<input type="text" id="search-input" placeholder="Search ..." class="input-field">
</body>
</html>

View File

@ -0,0 +1,10 @@
<html>
<head>
<title>This is a super simple test page</title>
</head>
<body>
<h1>Welcome to the super simple and fast test page</h1>
<p>It will be hard to create a faster page than this page.</p>
<p><a href="/dimple/">Dimple</a></p>
</body>
</html>

View File

@ -1,5 +1,5 @@
module.exports = async function (context, commands) {
await commands.measure.start('https://www.sitespeed.io');
await commands.measure.start('https://www.sitespeed.io/examples/');
return commands.measure.start('https://www.sitespeed.io/documentation/');
await commands.measure.start('http://127.0.0.1:3001/simple/');
await commands.measure.start('http://127.0.0.1:3001/dimple/');
return commands.measure.start('http://127.0.0.1:3001/search/');
};

View File

@ -1,5 +1,5 @@
module.exports = async function (context, commands) {
context.log.info('In pretask!!!');
await commands.navigate('https://www.sitespeed.io/');
await commands.navigate('http://127.0.0.1:3001/simple/');
context.taskData.loadedSitespeed = true;
};

View File

@ -1,5 +1,5 @@
const sitespeed = require('../lib/sitespeed');
const urls = ['https://www.sitespeed.io/'];
const urls = ['http://127.0.0.1:3001/simple/'];
async function run() {
try {