Skip to content

Commit

Permalink
Merge pull request #249 from motemen/author
Browse files Browse the repository at this point in the history
integration test on master
  • Loading branch information
Songmu committed Dec 30, 2019
2 parents 48b328d + c747cbb commit 063bd95
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/integration.yaml
@@ -0,0 +1,21 @@
name: integration
on:
push:
branches:
- master
jobs:
test:
runs-on: macOS-latest
steps:
- name: setup go
uses: actions/setup-go@v1
with:
go-version: 1.x
- name: checkout
uses: actions/checkout@v1
- name: install
run: |
GOBIN=$HOME/bin make install
brew install mercurial fossil bazaar
- name: test
run: PATH=$HOME/bin:$PATH ./misc/author/integration_test.sh
72 changes: 72 additions & 0 deletions misc/author/bench.pl
@@ -0,0 +1,72 @@
#!/usr/bin/env perl
use 5.014;
use warnings;
use utf8;
use autodie;
use Time::HiRes qw/gettimeofday tv_interval/;

# you need `ghg` command to work it. ref. https://github.com/Songmu/ghg
my $workdir = '.tmp';
my $trial = 30;
my @vers = reverse qw/
v0.17.4
v0.17.3
v0.14.2
v0.14.1
v0.12.8
v0.12.6
v0.9.0
v0.8.0
/;

$ENV{GHG_HOME} = $workdir;
sub logf {
my $msg = sprintf(shift, @_);
$msg .= "\n" if $msg !~ /\n\z/ms;
print STDERR $msg;
}

for my $ver (@vers) {
my $bin = "$workdir/bin/ghq-$ver";
next if -f $bin;

logf 'installing ghq %s', $ver;
my $cmd = "ghg get -u motemen/ghq\@$ver";
`$cmd > /dev/null 2>&1`;
rename "$workdir/bin/ghq", $bin;
}

my $VCS_GIT = '-vcs=git';
logf 'starting benchmark';
chomp(my $repos = `$workdir/bin/ghq-v0.14.2 list | wc -l`);
logf '%d repositories on local', $repos;
my %results;
for my $i (1..$trial) {
logf 'trial: %d', $i;
for my $ver (@vers) {
my $bin = "$workdir/bin/ghq-$ver";
for my $opt ('', $VCS_GIT) {
if ($opt eq $VCS_GIT) {
if ($ver !~ /^v0\.1/ || $ver lt 'v0.11.1') {
next;
}
}
my $t = [gettimeofday];
`$bin list $opt > /dev/null`;
my $elapsed = tv_interval $t;
if ($? > 0) {
die 'error occurred on version: '. $ver;
}
$results{$ver . $opt} += $elapsed;
}
}
}

for my $ver (@vers) {
my $val = $results{$ver};
printf "%s: %0.5f\n", $ver, ($val/$trial);
my $ver_with_git = $ver . $VCS_GIT;
if (my $val = $results{$ver_with_git}) {
printf "%s: %0.5f\n", $ver_with_git, ($val/$trial);
}
}
28 changes: 28 additions & 0 deletions misc/author/integration_test.sh
@@ -0,0 +1,28 @@
#!/bin/sh

cleanup() {
code=$?
rm -rf $tmpdir
exit $code
}
trap cleanup EXIT

tmpdir=$(mktemp -d)

set -ex

export GHQ_ROOT=$tmpdir

ghq get motemen/ghq
ghq get www.mercurial-scm.org/repo/hello
ghq get https://launchpad.net/terminator
ghq get --vcs fossil https://www.sqlite.org/src
ghq get --shallow --vcs=git-svn https://svn.apache.org/repos/asf/httpd/httpd
ghq get https://svn.apache.org/repos/asf/subversion

test -d $tmpdir/github.com/motemen/ghq/.git
test -d $tmpdir/www.mercurial-scm.org/repo/hello/.hg
test -d $tmpdir/launchpad.net/terminator/.bzr
test -f $tmpdir/www.sqlite.org/src/.fslckout
test -d $tmpdir/svn.apache.org/repos/asf/httpd/httpd/.git/svn
test -d $tmpdir/svn.apache.org/repos/asf/subversion/.svn

0 comments on commit 063bd95

Please sign in to comment.