Developer-Dashboard
view release on metacpan or search on metacpan
integration/blank-env/run-integration.pl view on Meta::CPAN
use strict;
use warnings;
use File::Basename qw(dirname);
use File::Copy qw(copy);
use File::Path qw(make_path remove_tree);
use File::Spec;
use IO::Select;
use IPC::Open3 qw(open3);
use JSON::XS qw(decode_json);
use Symbol qw(gensym);
use Time::HiRes qw(sleep time);
our $BROWSER_BINARY;
# main()
# Executes the full blank-environment integration flow against a host-built tarball.
# Input: none.
# Output: process exit status via die on failure or zero on success.
sub main {
my $tarball = $ENV{DASHBOARD_TARBALL_IN_CONTAINER} || '/artifacts/Developer-Dashboard.tar.gz';
my $dist_dir = '/tmp/developer-dashboard-dist';
my $home = '/tmp/developer-dashboard-integration-home';
my $cookie = '/tmp/developer-dashboard-cookies.txt';
my $compose = '/tmp/developer-dashboard-compose-project';
my $project = '/tmp/fake-project';
my $runtime_root = File::Spec->catdir( $project, '.developer-dashboard' );
my $cli_root = File::Spec->catdir( $runtime_root, 'cli' );
my $update_root = File::Spec->catdir( $cli_root, 'update.d' );
my $bookmarks = File::Spec->catdir( $runtime_root, 'dashboards' );
my $configs = File::Spec->catdir( $runtime_root, 'config' );
my $profile = '/tmp/developer-dashboard-browser-profile';
my $project_cd = 'cd ' . _shell_quote($project) . ' && ';
_assert( -f $tarball, 'host-built tarball is mounted into the container' );
_reset_dir($dist_dir);
_reset_dir($home);
_reset_dir($compose);
_reset_dir($project);
_reset_dir($profile);
local $ENV{HOME} = $home;
local $ENV{PERL_MM_USE_DEFAULT} = 1;
local $ENV{NONINTERACTIVE_TESTING} = 1;
local $ENV{PERL_CANARY_STABILITY_NOPROMPT} = 1;
_run_shell( 'extract host-built tarball', "tar -xzf " . _shell_quote($tarball) . ' -C ' . _shell_quote($dist_dir) );
my $source_root = _single_subdir($dist_dir);
_assert( defined $source_root && -d $source_root, 'extracted tarball produced one source root' );
my $expected_version = _distribution_version($source_root);
_assert( defined $expected_version && $expected_version ne '', 'extracted tarball exposes a distribution version' );
my $install_tarball = _versioned_install_tarball_path($expected_version);
_copy_file( $tarball, $install_tarball );
_write_text(
File::Spec->catfile( $compose, 'compose.yaml' ),
<<'YAML'
services:
hello:
image: busybox:latest
command: ["echo", "hello"]
YAML
);
_write_text(
File::Spec->catfile( $configs, 'config.json' ),
<<'JSON'
{
"collectors": [
{
"name": "fake.config.collector",
"command": "printf 'fake config collector output\n'",
"cwd": "home",
"interval": 30
},
{
"name": "broken.collector",
"code": "this is broken perl code",
"cwd": "home",
"interval": 1,
"indicator": {
"name": "broken.indicator",
"label": "Broken",
"icon": "B"
}
},
{
"name": "healthy.collector",
"command": "printf 'healthy config collector output\n'",
"cwd": "home",
"interval": 1,
"indicator": {
"name": "healthy.indicator",
"label": "Healthy",
"icon": "H"
}
}
]
}
JSON
);
_write_text(
File::Spec->catfile( $bookmarks, 'project-home' ),
<<'BOOKMARK'
TITLE: Project Home
:--------------------------------------------------------------------------------:
BOOKMARK: project-home
:--------------------------------------------------------------------------------:
STASH: {}
:--------------------------------------------------------------------------------:
HTML: <div id="project-marker">Fake Project Home</div>
BOOKMARK
);
_write_text(
File::Spec->catfile( $bookmarks, 'legacy-ajax' ),
<<'BOOKMARK'
TITLE: Legacy Ajax
:--------------------------------------------------------------------------------:
BOOKMARK: legacy-ajax
( run in 2.078 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )