mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-19 14:05:04 +00:00
Version prop fix + test (#3764)
# Description of Changes Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --- ## 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.
This commit is contained in:
parent
cdd1ab704f
commit
64766a129c
15
build.gradle
15
build.gradle
@ -171,18 +171,9 @@ subprojects {
|
|||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure all packaging tasks depend on writeVersion from root project
|
tasks.named("processResources") {
|
||||||
tasks.withType(org.springframework.boot.gradle.tasks.bundling.BootJar) {
|
dependsOn(rootProject.tasks.writeVersion)
|
||||||
dependsOn(rootProject.tasks.writeVersion)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(Jar) {
|
|
||||||
dependsOn(rootProject.tasks.writeVersion)
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(org.gradle.api.tasks.bundling.Zip) {
|
|
||||||
dependsOn(rootProject.tasks.writeVersion)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
@ -169,6 +169,50 @@ compare_file_lists() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Get the expected version from Gradle once
|
||||||
|
get_expected_version() {
|
||||||
|
./gradlew printVersion --quiet | tail -1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to verify the application version
|
||||||
|
verify_app_version() {
|
||||||
|
local service_name=$1
|
||||||
|
local base_url=$2
|
||||||
|
|
||||||
|
echo "Checking version for $service_name (expecting $EXPECTED_VERSION)..."
|
||||||
|
|
||||||
|
# Try to access the homepage and extract the version
|
||||||
|
local response
|
||||||
|
response=$(curl -s "$base_url")
|
||||||
|
|
||||||
|
# Extract version from pixel tracking tag
|
||||||
|
local actual_version
|
||||||
|
actual_version=$(echo "$response" | grep -o 'appVersion=[0-9.]*' | head -1 | sed 's/appVersion=//')
|
||||||
|
|
||||||
|
# If we couldn't find the version in the pixel tag, try other approaches
|
||||||
|
if [ -z "$actual_version" ]; then
|
||||||
|
# Check for "App Version:" format
|
||||||
|
if echo "$response" | grep -q "App Version:"; then
|
||||||
|
actual_version=$(echo "$response" | grep -o "App Version: [0-9.]*" | sed 's/App Version: //')
|
||||||
|
else
|
||||||
|
echo "❌ Version verification failed: Could not find version information"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the extracted version matches expected version
|
||||||
|
if [ "$actual_version" = "$EXPECTED_VERSION" ]; then
|
||||||
|
echo "✅ Version verification passed: $actual_version"
|
||||||
|
return 0
|
||||||
|
elif [ "$actual_version" = "0.0.0" ]; then
|
||||||
|
echo "❌ Version verification failed: Found placeholder version 0.0.0"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
echo "❌ Version verification failed: Found $actual_version, expected $EXPECTED_VERSION"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function to test a Docker Compose configuration
|
# Function to test a Docker Compose configuration
|
||||||
test_compose() {
|
test_compose() {
|
||||||
local compose_file=$1
|
local compose_file=$1
|
||||||
@ -206,21 +250,28 @@ run_tests() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Main testing routine
|
# Main testing routine
|
||||||
main() {
|
main() {
|
||||||
SECONDS=0
|
SECONDS=0
|
||||||
|
|
||||||
cd "$PROJECT_ROOT"
|
cd "$PROJECT_ROOT"
|
||||||
|
|
||||||
export DOCKER_CLI_EXPERIMENTAL=enabled
|
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||||
export COMPOSE_DOCKER_CLI_BUILD=0
|
export COMPOSE_DOCKER_CLI_BUILD=0
|
||||||
export DISABLE_ADDITIONAL_FEATURES=true
|
export DISABLE_ADDITIONAL_FEATURES=true
|
||||||
|
|
||||||
# Run the gradlew build command and check if it fails
|
# Run the gradlew build command and check if it fails
|
||||||
if ! ./gradlew clean build; then
|
if ! ./gradlew clean build; then
|
||||||
echo "Gradle build failed with security disabled, exiting script."
|
echo "Gradle build failed with security disabled, exiting script."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Get expected version after the build to ensure version.properties is created
|
||||||
|
echo "Getting expected version from Gradle..."
|
||||||
|
EXPECTED_VERSION=$(get_expected_version)
|
||||||
|
echo "Expected version: $EXPECTED_VERSION"
|
||||||
|
|
||||||
# Building Docker images
|
# 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 -f ./Dockerfile .
|
||||||
docker build --build-arg VERSION_TAG=alpha -t docker.stirlingpdf.com/stirlingtools/stirling-pdf:latest-ultra-lite -f ./Dockerfile.ultra-lite .
|
docker build --build-arg VERSION_TAG=alpha -t docker.stirlingpdf.com/stirlingtools/stirling-pdf:latest-ultra-lite -f ./Dockerfile.ultra-lite .
|
||||||
@ -237,6 +288,16 @@ main() {
|
|||||||
echo "Webpage accessibility lite tests failed"
|
echo "Webpage accessibility lite tests failed"
|
||||||
fi
|
fi
|
||||||
cd "$PROJECT_ROOT"
|
cd "$PROJECT_ROOT"
|
||||||
|
|
||||||
|
echo "Testing version verification..."
|
||||||
|
if verify_app_version "Stirling-PDF-Ultra-Lite" "http://localhost:8080"; then
|
||||||
|
passed_tests+=("Stirling-PDF-Ultra-Lite-Version-Check")
|
||||||
|
echo "Version verification passed for Stirling-PDF-Ultra-Lite"
|
||||||
|
else
|
||||||
|
failed_tests+=("Stirling-PDF-Ultra-Lite-Version-Check")
|
||||||
|
echo "Version verification failed for Stirling-PDF-Ultra-Lite"
|
||||||
|
fi
|
||||||
|
|
||||||
docker-compose -f "./exampleYmlFiles/docker-compose-latest-ultra-lite.yml" down
|
docker-compose -f "./exampleYmlFiles/docker-compose-latest-ultra-lite.yml" down
|
||||||
|
|
||||||
# run_tests "Stirling-PDF" "./exampleYmlFiles/docker-compose-latest.yml"
|
# run_tests "Stirling-PDF" "./exampleYmlFiles/docker-compose-latest.yml"
|
||||||
@ -249,6 +310,11 @@ main() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Get expected version after the security-enabled build
|
||||||
|
echo "Getting expected version from Gradle (security enabled)..."
|
||||||
|
EXPECTED_VERSION=$(get_expected_version)
|
||||||
|
echo "Expected version with security enabled: $EXPECTED_VERSION"
|
||||||
|
|
||||||
# Building Docker images with security enabled
|
# 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 -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-ultra-lite -f ./Dockerfile.ultra-lite .
|
||||||
@ -274,6 +340,15 @@ main() {
|
|||||||
fi
|
fi
|
||||||
cd "$PROJECT_ROOT"
|
cd "$PROJECT_ROOT"
|
||||||
|
|
||||||
|
echo "Testing version verification..."
|
||||||
|
if verify_app_version "Stirling-PDF-Security-Fat" "http://localhost:8080"; then
|
||||||
|
passed_tests+=("Stirling-PDF-Security-Fat-Version-Check")
|
||||||
|
echo "Version verification passed for Stirling-PDF-Security-Fat"
|
||||||
|
else
|
||||||
|
failed_tests+=("Stirling-PDF-Security-Fat-Version-Check")
|
||||||
|
echo "Version verification failed for Stirling-PDF-Security-Fat"
|
||||||
|
fi
|
||||||
|
|
||||||
docker-compose -f "./exampleYmlFiles/docker-compose-latest-fat-security.yml" down
|
docker-compose -f "./exampleYmlFiles/docker-compose-latest-fat-security.yml" down
|
||||||
|
|
||||||
run_tests "Stirling-PDF-Security-Fat-with-login" "./exampleYmlFiles/test_cicd.yml"
|
run_tests "Stirling-PDF-Security-Fat-with-login" "./exampleYmlFiles/test_cicd.yml"
|
||||||
@ -342,6 +417,15 @@ main() {
|
|||||||
echo "Disabled Endpoints tests failed"
|
echo "Disabled Endpoints tests failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Testing version verification..."
|
||||||
|
if verify_app_version "Stirling-PDF-Fat-Disable-Endpoints" "http://localhost:8080"; then
|
||||||
|
passed_tests+=("Stirling-PDF-Fat-Disable-Endpoints-Version-Check")
|
||||||
|
echo "Version verification passed for Stirling-PDF-Fat-Disable-Endpoints"
|
||||||
|
else
|
||||||
|
failed_tests+=("Stirling-PDF-Fat-Disable-Endpoints-Version-Check")
|
||||||
|
echo "Version verification failed for Stirling-PDF-Fat-Disable-Endpoints"
|
||||||
|
fi
|
||||||
|
|
||||||
docker-compose -f "./exampleYmlFiles/docker-compose-latest-fat-endpoints-disabled.yml" down
|
docker-compose -f "./exampleYmlFiles/docker-compose-latest-fat-endpoints-disabled.yml" down
|
||||||
|
|
||||||
# Report results
|
# Report results
|
||||||
|
Loading…
x
Reference in New Issue
Block a user