Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
blog
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
blog
Commits
d676d0a8
Commit
d676d0a8
authored
7 years ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
Added Lighthouse and Sitespeed.io tests (Fabric tasks).
parent
a9c3cc1a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+5
-0
5 additions, 0 deletions
README.md
fabfile.py
+34
-3
34 additions, 3 deletions
fabfile.py
with
39 additions
and
3 deletions
README.md
+
5
−
0
View file @
d676d0a8
...
@@ -6,6 +6,9 @@
...
@@ -6,6 +6,9 @@
-
Python 3.6
-
Python 3.6
-
[
Pipenv
](
https://pipenv.org
)
-
[
Pipenv
](
https://pipenv.org
)
-
[
Docker
](
https://www.docker.com/
)
(
Only
needed for running the lighthouse and
sitespeed tests)
-
[
direnv
](
http://direnv.net/
)
(
Just
for ease of use)
## Usage
## Usage
...
@@ -17,10 +20,12 @@ Available commands:
...
@@ -17,10 +20,12 @@ Available commands:
build Build local version of site
build Build local version of site
clean Remove generated files
clean Remove generated files
dev Auto-regenerate files and serve at http://localhost:8080/
dev Auto-regenerate files and serve at http://localhost:8080/
lighthouse Run Chrome's Lighthouse report against the local dev server
preview Build production version of site
preview Build production version of site
publish Publish to production via rsync
publish Publish to production via rsync
regenerate Automatically regenerate site upon file modification
regenerate Automatically regenerate site upon file modification
serve Serve site at http://localhost:8080/
serve Serve site at http://localhost:8080/
sitespeed Run sitespeed test against the local dev server
```
```
...
...
This diff is collapsed.
Click to expand it.
fabfile.py
+
34
−
3
View file @
d676d0a8
from
fabric.api
import
lcd
,
env
,
local
,
hosts
from
fabric.api
import
lcd
,
env
,
local
,
hosts
,
warn_only
import
fabric.contrib.project
as
project
import
fabric.contrib.project
as
project
import
multiprocessing
import
multiprocessing
import
os
env
.
use_ssh_config
=
True
# Local path configuration (can be absolute or relative to fabfile)
# Local path configuration (can be absolute or relative to fabfile)
env
.
deploy_path
=
'
output
'
env
.
deploy_path
=
'
output
'
DEPLOY_PATH
=
env
.
deploy_path
DEPLOY_PATH
=
env
.
deploy_path
...
@@ -10,10 +12,12 @@ DEPLOY_PATH = env.deploy_path
...
@@ -10,10 +12,12 @@ DEPLOY_PATH = env.deploy_path
production
=
'
www.shore.co.il
'
production
=
'
www.shore.co.il
'
dest_path
=
'
/var/www/htdocs/www.shore.co.il/blog/
'
dest_path
=
'
/var/www/htdocs/www.shore.co.il/blog/
'
UID
=
os
.
getuid
()
def
clean
():
def
clean
():
"""
Remove generated files
"""
"""
Remove generated files
"""
local
(
f
'
rm -r __pycache__/
{
DEPLOY_PATH
}
/*
'
)
local
(
f
'
rm -r
f
__pycache__/
{
DEPLOY_PATH
}
/*
sitespeed-result/ lighthouse-result/
'
)
def
build
():
def
build
():
...
@@ -34,9 +38,11 @@ def serve():
...
@@ -34,9 +38,11 @@ def serve():
def
dev
():
def
dev
():
"""
Auto-regenerate files and serve at http://localhost:8080/
"""
"""
Auto-regenerate files and serve at http://localhost:8080/
"""
server_process
=
multiprocessing
.
Process
(
target
=
serve
)
server_process
=
multiprocessing
.
Process
(
target
=
serve
,
daemon
=
True
)
server_process
.
start
()
server_process
.
start
()
regenerate
()
regenerate
()
server_process
.
terminate
()
server_process
.
join
(
timeout
=
3
)
def
preview
():
def
preview
():
...
@@ -55,3 +61,28 @@ def publish():
...
@@ -55,3 +61,28 @@ def publish():
delete
=
True
,
delete
=
True
,
extra_opts
=
'
-c
'
,
extra_opts
=
'
-c
'
,
)
)
def
sitespeed
():
"""
Run sitespeed test against the local dev server
"""
build
()
with
warn_only
():
local
(
'
docker run --rm --privileged --net=host gliderlabs/hostlocal
'
)
server_process
=
multiprocessing
.
Process
(
target
=
serve
,
daemon
=
True
)
server_process
.
start
()
local
(
f
'
docker run --rm --shm-size=1g -u
{
UID
}
-v
"
$PWD:/sitespeed.io
"
sitespeedio/sitespeed.io http://169.254.255.254:8080/
'
)
server_process
.
terminate
()
server_process
.
join
(
timeout
=
3
)
def
lighthouse
():
"""
Run Chrome
'
s Lighthouse report against the local dev server
"""
build
()
with
warn_only
():
local
(
'
docker run --rm --privileged --net=host gliderlabs/hostlocal
'
)
server_process
=
multiprocessing
.
Process
(
target
=
serve
,
daemon
=
True
)
server_process
.
start
()
local
(
'
mkdir -p lighthouse-result
'
)
local
(
'
docker run --rm -u {UID} -v
"
$PWD/lighthouse-result:/home/chrome/reports
"
--cap-add=SYS_ADMIN --user=1000 justinribeiro/lighthouse lighthouse --chrome-flags=
"
--headless --no-sandbox --disable-gpu
"
http://169.254.255.254:8080/
'
)
server_process
.
terminate
()
server_process
.
join
(
timeout
=
3
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment