mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-1765: Merge changes migrating JS unit tests to frontend-maven-plugin and headless Firefox.
This commit is contained in:
13
Dockerfile
13
Dockerfile
@@ -30,9 +30,14 @@ ARG TOMCAT_JRE=jdk8
|
|||||||
# Use official maven image for the build
|
# Use official maven image for the build
|
||||||
FROM maven:3-jdk-8 AS builder
|
FROM maven:3-jdk-8 AS builder
|
||||||
|
|
||||||
# Use args to build radius auth extension such as
|
# Install firefox browser for sake of JavaScript unit tests
|
||||||
# `--build-arg BUILD_PROFILE=lgpl-extensions`
|
RUN apt-get update && apt-get install -y firefox-esr
|
||||||
ARG BUILD_PROFILE
|
|
||||||
|
# Arbitrary arguments that can be passed to the maven build. By default, an
|
||||||
|
# argument will be provided to explicitly unskip any skipped tests. To, for
|
||||||
|
# example, allow the building of the RADIUS auth extension, pass a build profile
|
||||||
|
# as well: `--build-arg MAVEN_ARGUMENTS="-P lgpl-extensions -DskipTests=false"`.
|
||||||
|
ARG MAVEN_ARGUMENTS="-DskipTests=false"
|
||||||
|
|
||||||
# Build environment variables
|
# Build environment variables
|
||||||
ENV \
|
ENV \
|
||||||
@@ -45,7 +50,7 @@ COPY guacamole-docker/bin/ /opt/guacamole/bin/
|
|||||||
COPY . "$BUILD_DIR"
|
COPY . "$BUILD_DIR"
|
||||||
|
|
||||||
# Run the build itself
|
# Run the build itself
|
||||||
RUN /opt/guacamole/bin/build-guacamole.sh "$BUILD_DIR" /opt/guacamole "$BUILD_PROFILE"
|
RUN /opt/guacamole/bin/build-guacamole.sh "$BUILD_DIR" /opt/guacamole
|
||||||
|
|
||||||
# For the runtime image, we start with the official Tomcat distribution
|
# For the runtime image, we start with the official Tomcat distribution
|
||||||
FROM tomcat:${TOMCAT_VERSION}-${TOMCAT_JRE}
|
FROM tomcat:${TOMCAT_VERSION}-${TOMCAT_JRE}
|
||||||
|
2
guacamole-common-js/.gitignore
vendored
2
guacamole-common-js/.gitignore
vendored
@@ -1,2 +1,4 @@
|
|||||||
|
node/
|
||||||
|
node_modules/
|
||||||
target/
|
target/
|
||||||
*~
|
*~
|
||||||
|
54
guacamole-common-js/karma-ci.conf.js
Normal file
54
guacamole-common-js/karma-ci.conf.js
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A karma configuration intended for use in builds or CI. Runs all discovered
|
||||||
|
* unit tests under a headless firefox browser and immediately exits.
|
||||||
|
*/
|
||||||
|
module.exports = function(config) {
|
||||||
|
config.set({
|
||||||
|
|
||||||
|
// Discover and run jasmine tests
|
||||||
|
frameworks: ['jasmine'],
|
||||||
|
|
||||||
|
// Pattern matching all javascript source and tests
|
||||||
|
files: [
|
||||||
|
'src/**/*.js'
|
||||||
|
],
|
||||||
|
|
||||||
|
// Run the tests once and exit
|
||||||
|
singleRun: true,
|
||||||
|
|
||||||
|
// Disable automatic test running on changed files
|
||||||
|
autoWatch: false,
|
||||||
|
|
||||||
|
// Use a headless firefox browser to run the tests
|
||||||
|
browsers: ['FirefoxHeadless'],
|
||||||
|
customLaunchers: {
|
||||||
|
'FirefoxHeadless': {
|
||||||
|
base: 'Firefox',
|
||||||
|
flags: [
|
||||||
|
'--headless'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
2778
guacamole-common-js/package-lock.json
generated
Normal file
2778
guacamole-common-js/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
8
guacamole-common-js/package.json
Normal file
8
guacamole-common-js/package.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"description": "Dependencies to be installed by maven for running JS tests",
|
||||||
|
"devDependencies": {
|
||||||
|
"karma": "^6.4.1",
|
||||||
|
"karma-firefox-launcher": "^2.1.2",
|
||||||
|
"karma-jasmine": "^5.1.0"
|
||||||
|
}
|
||||||
|
}
|
@@ -37,6 +37,23 @@
|
|||||||
<relativePath>../</relativePath>
|
<relativePath>../</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The location where temporary files should be stored for communicating
|
||||||
|
between karma and firefox. The default location, /tmp, does not work
|
||||||
|
if firefox is installed via snap.
|
||||||
|
-->
|
||||||
|
<firefox.temp.dir>${project.build.directory}/tmp</firefox.temp.dir>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Skip tests unless requested otherwise with -DskipTests=false.
|
||||||
|
Skipped by default because these tests require firefox to be installed.
|
||||||
|
-->
|
||||||
|
<skipTests>true</skipTests>
|
||||||
|
|
||||||
|
</properties>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
The base JavaScript API of the Guacamole project, providing JavaScript
|
The base JavaScript API of the Guacamole project, providing JavaScript
|
||||||
support for the Guacamole stack, including a full client
|
support for the Guacamole stack, including a full client
|
||||||
@@ -114,27 +131,92 @@
|
|||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<!-- Unit test using Jasmin and PhantomJS -->
|
<!-- Skip tests if configured to do so -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.github.searls</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>jasmine-maven-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.2</version>
|
<version>3.0.0</version>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>${skipTests}</skipTests>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Ensure the firefox temp directory exists -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
<id>createFirefoxTempdir</id>
|
||||||
|
<phase>test</phase>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<mkdir dir="${firefox.temp.dir}"/>
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>test</goal>
|
<goal>run</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Unit test using Jasmin and Firefox -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.github.eirslett</groupId>
|
||||||
|
<artifactId>frontend-maven-plugin</artifactId>
|
||||||
|
<version>1.12.1</version>
|
||||||
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<phantomjs>
|
|
||||||
<version>2.1.1</version>
|
<!-- The version of node to use for running tests -->
|
||||||
</phantomjs>
|
<nodeVersion>v16.19.1</nodeVersion>
|
||||||
<sourceIncludes>
|
|
||||||
<sourceInclude>**/*.min.js</sourceInclude>
|
<!-- Install dependencies with "npm ci" for repeatability -->
|
||||||
</sourceIncludes>
|
<arguments>ci</arguments>
|
||||||
<jsSrcDir>${project.build.directory}/${project.build.finalName}</jsSrcDir>
|
|
||||||
|
<!-- The location of the karma config file -->
|
||||||
|
<karmaConfPath>karma-ci.conf.js</karmaConfPath>
|
||||||
|
|
||||||
|
<!-- Tell karma to use the custom temp directory -->
|
||||||
|
<environmentVariables>
|
||||||
|
<TMPDIR>${firefox.temp.dir}</TMPDIR>
|
||||||
|
</environmentVariables>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
||||||
|
<executions>
|
||||||
|
|
||||||
|
<!-- Install node.js and NPM before running tests -->
|
||||||
|
<execution>
|
||||||
|
<id>install node and npm</id>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>install-node-and-npm</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
|
||||||
|
<!-- Install test dependencies -->
|
||||||
|
<execution>
|
||||||
|
<id>npm install</id>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>npm</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
|
||||||
|
<!-- Run all tests non-interactively -->
|
||||||
|
<execution>
|
||||||
|
<id>run tests</id>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>karma</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
|
||||||
|
</executions>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
|
@@ -38,15 +38,9 @@
|
|||||||
## subdirectories within this directory, and files will thus be grouped by
|
## subdirectories within this directory, and files will thus be grouped by
|
||||||
## extension type.
|
## extension type.
|
||||||
##
|
##
|
||||||
## @param BUILD_PROFILE
|
|
||||||
## The build profile that will be passed to Maven build process. Defaults
|
|
||||||
## to empty string. Can be set to "lgpl-extensions" to e.g. include
|
|
||||||
## RADIUS authentication extension.
|
|
||||||
##
|
|
||||||
|
|
||||||
BUILD_DIR="$1"
|
BUILD_DIR="$1"
|
||||||
DESTINATION="$2"
|
DESTINATION="$2"
|
||||||
BUILD_PROFILE="$3"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Create destination, if it does not yet exist
|
# Create destination, if it does not yet exist
|
||||||
@@ -60,16 +54,11 @@ mkdir -p "$DESTINATION"
|
|||||||
|
|
||||||
cd "$BUILD_DIR"
|
cd "$BUILD_DIR"
|
||||||
|
|
||||||
# Required for build leveraging PhantomJS for unit testing (without this, the
|
#
|
||||||
# build fails with "libssl_conf.so: cannot open shared object file: No such
|
# Run the maven build, applying any arbitrary provided maven arguments.
|
||||||
# file or directory")
|
#
|
||||||
export OPENSSL_CONF=/etc/ssl
|
|
||||||
|
|
||||||
if [ -z "$BUILD_PROFILE" ]; then
|
mvn $MAVEN_ARGUMENTS package
|
||||||
mvn package
|
|
||||||
else
|
|
||||||
mvn -P "$BUILD_PROFILE" package
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copy guacamole.war to destination
|
# Copy guacamole.war to destination
|
||||||
|
Reference in New Issue
Block a user