~shimon/forgeperf-ci

d1276042d923e895de2ce35f4f588357b41fc266 — Itoh Shimon 2 years ago 27935bd main
dump.
5 files changed, 86 insertions(+), 0 deletions(-)

M .gitignore
A LICENSE.txt
A README.md
A Vagrantfile
A start-forgeperf
M .gitignore => .gitignore +2 -0
@@ 0,0 1,2 @@
/.vagrant
/vagrant_data

A LICENSE.txt => LICENSE.txt +21 -0
@@ 0,0 1,21 @@
The MIT License (MIT)

Copyright (c) 2022 Itoh Shimon

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

A README.md => README.md +10 -0
@@ 0,0 1,10 @@
# forgeperf CI

## Build

```
vagrant up
vagrant ssh -c start-forgeperf
vagrant halt
vagrant destroy
```

A Vagrantfile => Vagrantfile +24 -0
@@ 0,0 1,24 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-20.04"

  config.vm.synced_folder "vagrant_data", "/vagrant_data", create: true

  config.vm.provider "virtualbox" do |vb|
    vb.cpus = 4
    vb.memory = "8192"
  end

  config.vm.provision "file",
                      source: "start-forgeperf",
                      destination: "/home/vagrant/bin/start-forgeperf"

  config.vm.provision "shell", inline: <<-SHELL
    set -eu
    apt-get update
    apt-get install -y chromium-browser golang xvfb x11-xserver-utils npm git
    npm install -g lighthouse@6.3.0
  SHELL
end

A start-forgeperf => start-forgeperf +29 -0
@@ 0,0 1,29 @@
#! /bin/bash

set -eux

cd ~

git clone --depth 1 https://git.sr.ht/~shimon/forgeperf
mkdir -p .config/configstore
echo '{"isErrorReportingEnabled": false}' > .config/configstore/lighthouse.json

cd ~/forgeperf

go build -o forgeperf main.go
export DISPLAY=:0
Xvfb :0 &
count=5
for i in $(seq $count); do
	if xset q > /dev/null; then
		echo "xvfb is alive."
		break
	fi
	if [ $i -eq $count ]; then
		echo "xvfb has timed out."
		exit 1
	fi
	sleep 1
done
./forgeperf
tar cvzf /vagrant_data/report.tar.gz report/*