Skip to content

Commit

Permalink
Add Selenium Hub & test on chrome, firefox, opera & phantomjs
Browse files Browse the repository at this point in the history
  • Loading branch information
ylavoie committed Dec 23, 2020
1 parent e011b68 commit 2bcc8e9
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 38 deletions.
98 changes: 76 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,24 @@ _defaults: &defaults
# Make sure that .profile is sourced to local::lib
shell: /bin/bash --login -eo pipefail


# Define aliases for simplification
aliases:
- &store_artifacts
store_artifacts:
path: /tmp/artifact/

job_filters: &job_filters
branches:
ignore:
- /1\.2\..*/
- /1\.3\..*/
- /1\.4\..*/
- /1\.5\..*/
- /1\.6\..*/

# Reuseable commands
commands:

prove:
steps:
- run:
Expand All @@ -24,12 +33,9 @@ commands:
then
export HARNESS_PERL_SWITCHES="$HARNESS_PERL_SWITCHES -MDevel::Cover=-ignore,^/|^utils/|^x?t/|\.lttc$,-blib,0"
fi
echo $PERL5OPT
echo $HARNESS_PERL_SWITCHES
echo $PWD
# Coverage explicitly without parallellism to prevent resource contention
# when Devel::Cover writes coverage database on process-exit
prove -j2 --recurse \
BROWSER=$BROWSER prove -j2 --recurse \
--pgtap-option dbname=lsmbinstalltest \
--pgtap-option username=postgres \
--pgtap-option psql=.circleci/psql-wrap \
Expand Down Expand Up @@ -59,6 +65,7 @@ commands:
cover -report text > /tmp/artifact/coverage.txt
fi
- *store_artifacts

prep_env:
parameters:
perl:
Expand All @@ -76,22 +83,22 @@ commands:
keys:
# Find a cache corresponding to this specific package-lock.json checksum
# when this file is changed, this key will fail
- v1-npm-deps-{{ checksum "~/package-lock.json" }}
- v1-npm-deps-{{ checksum "./package-lock.json" }}
# Find the most recently generated cache used from any branch
- v1-npm-deps-
- run:
name: Make Dojo
command: |
make dojo
- save_cache:
key: v1-npm-deps-{{ checksum "~/package-lock.json" }}
key: v1-npm-deps-{{ checksum "./package-lock.json" }}
paths:
- node_modules
# Freshen up CPAN
- restore_cache:
keys:
# Get latest cache for the current specs
- v2-cpm-<< parameters.perl >>-{{ .Branch }}-{{ checksum "~/project/cpanfile" }}
- v2-cpm-<< parameters.perl >>-{{ .Branch }}-{{ checksum "./cpanfile" }}
# Fall back to the latest for the current branch
- v2-cpm-<< parameters.perl >>-{{ .Branch }}-
# Fall back to the latest for master
Expand Down Expand Up @@ -119,9 +126,9 @@ commands:
Devel::Cover::Report::Coveralls
fi
- save_cache:
key: v2-cpm-<< parameters.perl >>-{{ .Branch }}-{{ checksum "~/project/cpanfile" }}
key: v2-cpm-<< parameters.perl >>-{{ .Branch }}-{{ checksum "./cpanfile" }}
paths:
- ~/perl5
- $HOME/perl5
- run:
name: Set up dirs and files
command: |
Expand All @@ -138,18 +145,29 @@ commands:
-e "s/# \(backup_email_from = \).*\$/\1lsmb-backups@example.com/g" \
-e "s/#dojo_built = 1/dojo_built = 0/" \
ledgersmb.conf
- run:
name: Set up host IP & BASE variables
command: |
echo "export LSMB_BASE_URL=http://$(hostname -I |awk '{print $1}'):5000" >> $BASH_ENV
echo "export PSGI_BASE_URL=http://$(hostname -I |awk '{print $1}'):5762" >> $BASH_ENV
source $BASH_ENV
start_plackup:
description: "Start plackup"
steps:
- run:
command: |
PERL5OPT="$PERL5OPT -MDevel::Cover=-ignore,^/|^utils/|^x?t/|\.lttc$,-blib,0" \
LSMB_BASE_URL=http://$(hostname -I |awk '{print $1}'):5000 \
PSGI_BASE_URL=http://$(hostname -I |awk '{print $1}'):5762 \
plackup -I$HOME/project/lib -I$HOME/project/old/lib \
-s Gazelle --port 5762 --workers=2 --max-reqs-per-child=50000 \
$HOME/project/bin/ledgersmb-server.psgi
echo "Plackup done!"
touch plackup-done
background: true

start_proxy:
description: "Start the proxy"
parameters:
Expand All @@ -168,23 +186,31 @@ executors:
parameters:
perl:
type: string
default: latest
postgres:
type: string
default: latest
browser:
type: string
default: chrome
coverage:
type: integer
default: 1
selenium:
type: string
default: selenium/standalone-chrome
docker:
- image: ledgersmb/ledgersmb_circleci-perl:<< parameters.perl >>
- image: ledgersmb/ledgersmb_circleci-postgres:<< parameters.postgres >>
environment:
POSTGRES_PASSWORD: test
- image: ledgersmb/ledgersmb_circleci-<< parameters.browser >>
- image: << parameters.selenium >>
environment:
SE_OPTS: "-port 4422 "
GRID_DEBUG: "true"
environment:
BROWSER: << parameters.browser >>
COVERAGE: << parameters.coverage >>
# DEVEL_COVER_OPTIONS:
RELEASE_TESTING: 1
PGHOST: localhost
PGUSER: postgres
Expand All @@ -197,13 +223,42 @@ executors:

# Define jobs
jobs:
test_nodojo:
test_webpack_chrome:
<<: *defaults
executor:
name: test
perl: '5.30'
postgres: '11'
browser: chrome
selenium: selenium/standalone-chrome:3.141.59
steps:
- prep_env:
perl: '5.30'
- start_plackup
- start_proxy
- prove
test_webpack_firefox:
<<: *defaults
executor:
name: test
perl: '5.30'
postgres: '11'
browser: firefox
selenium: selenium/standalone-firefox:3.141.59
steps:
- prep_env:
perl: '5.30'
- start_plackup
- start_proxy
- prove
test_webpack_phantomjs:
<<: *defaults
executor:
name: test
perl: '5.30'
postgres: '11'
browser: phantomjs
selenium: ylavoie/standalone-phantomjs:latest
steps:
- prep_env:
perl: '5.30'
Expand All @@ -216,12 +271,11 @@ jobs:
workflows:
workflow:
jobs:
- test_nodojo:
filters:
branches:
ignore:
- /1\.2\..*/
- /1\.3\..*/
- /1\.4\..*/
- /1\.5\..*/
- /1\.6\..*/
- test_webpack_chrome:
filters: *job_filters

- test_webpack_firefox:
filters: *job_filters

- test_webpack_phantomjs:
filters: *job_filters
54 changes: 42 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ name: CI
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: '*'
branches: ['*']
pull_request:
branches: '*'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand All @@ -24,8 +24,18 @@ jobs:
strategy:
fail-fast: false
matrix:
perl: [ "5.24", "5.28", "5.32" ]
include:
- perl: "5.32"
BROWSER: "chrome"
SELENIUM: "selenium/standalone-chrome:3.141.59"
- perl: "5.28"
BROWSER: "firefox"
SELENIUM: "selenium/standalone-firefox:3.141.59"
- perl: "5.24"
BROWSER: "phantomjs"
SELENIUM: "ylavoie/standalone-phantomjs:latest"
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: ledgersmb/ledgersmb-dev-postgres
Expand Down Expand Up @@ -58,15 +68,15 @@ jobs:
# Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0
node-version: 15.x

- name: Cache node modules
- name: Restore cached node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache cpan modules
- name: Restore cached cpan modules
uses: actions/cache@v2.1.3
with:
# A list of files, directories, and wildcard patterns to cache and restore
Expand All @@ -80,10 +90,21 @@ jobs:
uses: actions/checkout@v2.3.4

- name: Install apt packages
run: sudo apt-get update && sudo apt-get install -y texlive-latex-recommended texlive-xetex gettext nginx
run: sudo apt-get update &&
sudo apt-get install -qqy texlive-latex-recommended texlive-xetex gettext nginx
env:
DEBIAN_FRONTEND: noninteractive

- name: Cache cpan modules
uses: actions/cache@v2.1.3
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: $PERL5LIB
# An explicit key for restoring and saving the cache
key: ${{ runner.os }}-cpan-${{ hashFiles('**/cpanfile') }}
# An ordered list of keys to use for restoring the cache if no cache hit occurred for key
restore-keys: ${{ runner.os }}-cpan-

- name: install with cpm
run: |
cpanm --notest App::cpm
Expand All @@ -94,19 +115,28 @@ jobs:

- name: Other preparations
run: |
mkdir screens logs
mkdir -p screens logs
cp doc/conf/ledgersmb.conf.default ledgersmb.conf
- name: Starting 'starman'
run: starman --preload-app --pid starman.pid --workers 2 -Ilib -Iold/lib --port 5762 bin/ledgersmb-server.psgi &
# Use plackup to add reloading capability & debug
#run: plackup -Ilib -Iold/lib --port 5762 --server Starman --Reload lib,old,xt/lib,t,xt,/opt/hostedtoolcache/perl/${{ matrix.perl }}/x64/lib/site_perl/${{ matrix.perl }},/usr/share/perl,/usr/share/perl5 bin/ledgersmb-server.psgi &

- name: Starting 'nginx'
run: |
sed -e "s#{ROOT}#$PWD#" doc/conf/webserver/nginx-travis.conf >/tmp/nginx.conf
nginx -c /tmp/nginx.conf &
- name: Starting 'PhantomJS'
run: phantomjs --webdriver=4422 2>/dev/null >/dev/null &
- name: Starting ${{ matrix.BROWSER }}
run: |
echo "$(ip addr show docker0 | grep -Po 'inet \K[\d.]+') host.docker.internal" | sudo tee -a /etc/hosts
docker run -v /dev/shm:/dev/shm -p 4422:4444 -e GRID_DEBUG=true --add-host=host.docker.internal:$(ip addr show docker0 | grep -Po 'inet \K[\d.]+') ${{ matrix.SELENIUM }} &
# Uncomment to debug
#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# if: ${{ matrix.BROWSER }} == "chrome"

# Runs a single command using the runners shell
- name: Run Perl tests
Expand All @@ -118,6 +148,6 @@ jobs:
PGPASSWORD: test
LSMB_NEW_DB: lsmbinstalltest
LSMB_TEST_DB: 1
LSMB_BASE_URL: http://127.0.0.1:5000
PSGI_BASE_URL: http://127.0.0.1:5762
REMOTE_SERVER_ADDR: 127.0.0.1
LSMB_BASE_URL: http://host.docker.internal:5000
PSGI_BASE_URL: http://host.docker.internal:5762
BROWSER: ${{ matrix.BROWSER }}
12 changes: 12 additions & 0 deletions UI/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@
</a>
</div>
<div id="version_info">[% text("LedgerSMB [_1]", version) %]</div>
<script>
(function myFunction() {
var n = navigator,
dua = n.userAgent;
document.getElementById("version_info").innerHTML =
document.getElementById("version_info").innerHTML + ":" + (
dua.indexOf("Opera") >= 0 ? "Opera" :
dua.indexOf("Gecko") >= 0 ? "Firefox" :
parseFloat(dua.split("Chrome/")[1]) ? "Chrome" :
n);
})();
</script>
<table id="header_info" class="header_table">
<tr>
<td id="login_info_header" class="header_left">
Expand Down
4 changes: 2 additions & 2 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ on 'develop' => sub {
requires 'Test::Pod::Coverage';
requires 'Test2::V0';
requires 'Text::Diff';
requires 'Weasel', '0.21';
requires 'Weasel', '0.27';
requires 'Weasel::Driver::Selenium2', '0.11';
requires 'Weasel::Session', '0.11';
requires 'Weasel::Widgets::Dojo', '0.04';
requires 'Weasel::Widgets::Dojo', '0.07';

feature 'debug', "Debug pane" =>
sub {
Expand Down
17 changes: 16 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2bcc8e9

Please sign in to comment.