mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-02-21 00:17:05 +01:00
# Description of Changes This pull request includes several updates to the Docker configuration and Java application UI scaling. The changes enhance environment variable management, dependency installation, and UI responsiveness to different screen sizes. ### Docker Configuration Updates: * Added new environment variables `STIRLING_PDF_DESKTOP_UI`, `PYTHONPATH`, `UNO_PATH`, and `URE_BOOTSTRAP` to `Dockerfile` and `Dockerfile.fat` to improve the configuration and integration of the LibreOffice environment. [[1]](diffhunk://#diff-dd2c0eb6ea5cfc6c4bd4eac30934e2d5746747af48fef6da689e85b752f39557L38-R46) [[2]](diffhunk://#diff-571631582b988e88c52c86960cc083b0b8fa63cf88f056f26e9e684195221c27L40-R49) * Updated the `CMD` instruction in `Dockerfile` and `Dockerfile.fat` to run both the Java application and `unoserver` simultaneously. [[1]](diffhunk://#diff-dd2c0eb6ea5cfc6c4bd4eac30934e2d5746747af48fef6da689e85b752f39557L87-R96) [[2]](diffhunk://#diff-571631582b988e88c52c86960cc083b0b8fa63cf88f056f26e9e684195221c27L87-R100) * Modified the `RUN` instruction to include additional Python dependencies and setup a virtual environment. [[1]](diffhunk://#diff-dd2c0eb6ea5cfc6c4bd4eac30934e2d5746747af48fef6da689e85b752f39557L68-R81) [[2]](diffhunk://#diff-571631582b988e88c52c86960cc083b0b8fa63cf88f056f26e9e684195221c27R72-R86) ### Workflow Enhancements: * Added `STIRLING_PDF_DESKTOP_UI` environment variable to the GitHub Actions workflows (`PR-Demo-Comment.yml` and `push-docker.yml`) to ensure consistent environment settings. [[1]](diffhunk://#diff-145fe5c0ed8c24e4673c9ad39800dd171a2d0a2e8050497cff980fc7e3a3df0dR106) [[2]](diffhunk://#diff-76056236de05155107f6a660f1e3956059e37338011b8f0e72188afcb9b17b6fR41) ### Java Application UI Scaling: * Introduced `UIScaling` utility to dynamically adjust the size of UI components based on screen resolution in `DesktopBrowser` and `LoadingWindow` classes. [[1]](diffhunk://#diff-dff83b0fe53cba8ee80dc8cee96b9c2bfec612ec1f2c636ebdf22dedb36671e8L218-R219) [[2]](diffhunk://#diff-dff83b0fe53cba8ee80dc8cee96b9c2bfec612ec1f2c636ebdf22dedb36671e8L267-R270) [[3]](diffhunk://#diff-3e287daf297213b698b3c94d6e6ed4aae139d570ba6b115da459d72b5c36c42fL44-R64) [[4]](diffhunk://#diff-3e287daf297213b698b3c94d6e6ed4aae139d570ba6b115da459d72b5c36c42fL86-R102) * Improved the loading of icons by using the `UIScaling` utility for better visual quality. --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing) for more details. --------- Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com> Co-authored-by: a <a>
192 lines
6.1 KiB
Bash
192 lines
6.1 KiB
Bash
#!/bin/bash
|
|
|
|
# Find project root by locating build.gradle
|
|
find_root() {
|
|
local dir="$PWD"
|
|
while [[ "$dir" != "/" ]]; do
|
|
if [[ -f "$dir/build.gradle" ]]; then
|
|
echo "$dir"
|
|
return 0
|
|
fi
|
|
dir="$(dirname "$dir")"
|
|
done
|
|
echo "Error: build.gradle not found" >&2
|
|
exit 1
|
|
}
|
|
|
|
PROJECT_ROOT=$(find_root)
|
|
|
|
# Function to check the health of the service with a timeout of 80 seconds
|
|
check_health() {
|
|
local service_name=$1
|
|
local compose_file=$2
|
|
local end=$((SECONDS+60))
|
|
|
|
echo -n "Waiting for $service_name to become healthy..."
|
|
until [ "$(docker inspect --format='{{json .State.Health.Status}}' "$service_name")" == '"healthy"' ] || [ $SECONDS -ge $end ]; do
|
|
sleep 3
|
|
echo -n "."
|
|
if [ $SECONDS -ge $end ]; then
|
|
echo -e "\n$service_name health check timed out after 80 seconds."
|
|
echo "Printing logs for $service_name:"
|
|
docker logs "$service_name"
|
|
return 1
|
|
fi
|
|
done
|
|
echo -e "\n$service_name is healthy!"
|
|
echo "Printing logs for $service_name:"
|
|
docker logs "$service_name"
|
|
return 0
|
|
}
|
|
|
|
# Function to test a Docker Compose configuration
|
|
test_compose() {
|
|
local compose_file=$1
|
|
local service_name=$2
|
|
local status=0
|
|
|
|
echo "Testing $compose_file configuration..."
|
|
|
|
# Start up the Docker Compose service
|
|
docker-compose -f "$compose_file" up -d
|
|
|
|
# Wait for the service to become healthy
|
|
if check_health "$service_name" "$compose_file"; then
|
|
echo "$service_name test passed."
|
|
else
|
|
echo "$service_name test failed."
|
|
status=1
|
|
fi
|
|
|
|
return $status
|
|
}
|
|
|
|
# Keep track of which tests passed and failed
|
|
declare -a passed_tests
|
|
declare -a failed_tests
|
|
|
|
run_tests() {
|
|
local test_name=$1
|
|
local compose_file=$2
|
|
|
|
if test_compose "$compose_file" "$test_name"; then
|
|
passed_tests+=("$test_name")
|
|
else
|
|
failed_tests+=("$test_name")
|
|
fi
|
|
}
|
|
|
|
# Main testing routine
|
|
main() {
|
|
SECONDS=0
|
|
|
|
cd "$PROJECT_ROOT"
|
|
|
|
export DOCKER_ENABLE_SECURITY=false
|
|
# Run the gradlew build command and check if it fails
|
|
if ! ./gradlew clean build; then
|
|
echo "Gradle build failed with security disabled, exiting script."
|
|
exit 1
|
|
fi
|
|
|
|
# Building Docker images
|
|
# docker build --no-cache --pull --build-arg VERSION_TAG=alpha -t stirlingtools/stirling-pdf:latest -f ./Dockerfile .
|
|
docker build --no-cache --pull --build-arg VERSION_TAG=alpha -t stirlingtools/stirling-pdf:latest-ultra-lite -f ./Dockerfile.ultra-lite .
|
|
|
|
# Test each configuration
|
|
run_tests "Stirling-PDF-Ultra-Lite" "./exampleYmlFiles/docker-compose-latest-ultra-lite.yml"
|
|
|
|
echo "Testing webpage accessibility..."
|
|
cd "testing"
|
|
if ./test_webpages.sh -f webpage_urls.txt -b http://localhost:8080; then
|
|
passed_tests+=("Webpage-Accessibility-lite")
|
|
else
|
|
failed_tests+=("Webpage-Accessibility-lite")
|
|
echo "Webpage accessibility lite tests failed"
|
|
fi
|
|
cd "$PROJECT_ROOT"
|
|
docker-compose -f "./exampleYmlFiles/docker-compose-latest-ultra-lite.yml" down
|
|
|
|
# run_tests "Stirling-PDF" "./exampleYmlFiles/docker-compose-latest.yml"
|
|
# docker-compose -f "./exampleYmlFiles/docker-compose-latest.yml" down
|
|
|
|
export DOCKER_ENABLE_SECURITY=true
|
|
# Run the gradlew build command and check if it fails
|
|
if ! ./gradlew clean build; then
|
|
echo "Gradle build failed with security enabled, exiting script."
|
|
exit 1
|
|
fi
|
|
|
|
# Building Docker images with security enabled
|
|
# docker build --no-cache --pull --build-arg VERSION_TAG=alpha -t stirlingtools/stirling-pdf:latest -f ./Dockerfile .
|
|
# docker build --no-cache --pull --build-arg VERSION_TAG=alpha -t stirlingtools/stirling-pdf:latest-ultra-lite -f ./Dockerfile.ultra-lite .
|
|
docker build --no-cache --pull --build-arg VERSION_TAG=alpha -t stirlingtools/stirling-pdf:latest-fat -f ./Dockerfile.fat .
|
|
|
|
|
|
# Test each configuration with security
|
|
# run_tests "Stirling-PDF-Ultra-Lite-Security" "./exampleYmlFiles/docker-compose-latest-ultra-lite-security.yml"
|
|
# docker-compose -f "./exampleYmlFiles/docker-compose-latest-ultra-lite-security.yml" down
|
|
# run_tests "Stirling-PDF-Security" "./exampleYmlFiles/docker-compose-latest-security.yml"
|
|
# docker-compose -f "./exampleYmlFiles/docker-compose-latest-security.yml" down
|
|
|
|
|
|
run_tests "Stirling-PDF-Security-Fat" "./exampleYmlFiles/docker-compose-latest-fat-security.yml"
|
|
|
|
echo "Testing webpage accessibility..."
|
|
cd "testing"
|
|
if ./test_webpages.sh -f webpage_urls_full.txt -b http://localhost:8080; then
|
|
passed_tests+=("Webpage-Accessibility-full")
|
|
else
|
|
failed_tests+=("Webpage-Accessibility-full")
|
|
echo "Webpage accessibility full tests failed"
|
|
fi
|
|
cd "$PROJECT_ROOT"
|
|
|
|
docker-compose -f "./exampleYmlFiles/docker-compose-latest-fat-security.yml" down
|
|
|
|
run_tests "Stirling-PDF-Security-Fat-with-login" "./exampleYmlFiles/test_cicd.yml"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
cd "testing/cucumber"
|
|
if python -m behave; then
|
|
passed_tests+=("Stirling-PDF-Regression")
|
|
else
|
|
failed_tests+=("Stirling-PDF-Regression")
|
|
echo "Printing docker logs of failed regression"
|
|
docker logs "Stirling-PDF-Security-Fat-with-login"
|
|
echo "Printed docker logs of failed regression"
|
|
fi
|
|
cd "$PROJECT_ROOT"
|
|
fi
|
|
|
|
docker-compose -f "./exampleYmlFiles/test_cicd.yml" down
|
|
|
|
# Report results
|
|
echo "All tests completed in $SECONDS seconds."
|
|
|
|
|
|
if [ ${#passed_tests[@]} -ne 0 ]; then
|
|
echo "Passed tests:"
|
|
fi
|
|
for test in "${passed_tests[@]}"; do
|
|
echo -e "\e[32m$test\e[0m" # Green color for passed tests
|
|
done
|
|
|
|
if [ ${#failed_tests[@]} -ne 0 ]; then
|
|
echo "Failed tests:"
|
|
fi
|
|
for test in "${failed_tests[@]}"; do
|
|
echo -e "\e[31m$test\e[0m" # Red color for failed tests
|
|
done
|
|
|
|
# Check if there are any failed tests and exit with an error code if so
|
|
if [ ${#failed_tests[@]} -ne 0 ]; then
|
|
echo "Some tests failed."
|
|
exit 1
|
|
else
|
|
echo "All tests passed successfully."
|
|
exit 0
|
|
fi
|
|
}
|
|
|
|
main |