Compare commits

...
Author SHA1 Message Date
james.maes 9b303f880f test: enforce Maven log-safety guard in CI (#12)
Run the reviewed output regression before publishing and capture both output streams. Refs QRun-IO/qqq#903.
2026-09-29 12:41:18 -05:00
james.maes df249441d7 fix: keep Maven settings out of orb logs (#12) 2026-09-26 12:13:46 -05:00
5 changed files with 65 additions and 3 deletions

No files matched your search

+3
View File
@@ -29,6 +29,9 @@ jobs:
- image: cimg/base:current
steps:
- checkout
- run:
name: Verify Maven settings stay out of build logs
command: bash tests/test_maven_settings_output.sh
# Run your orb's commands to validate them.
- qqq-orb/install_asciidoctor
-1
View File
@@ -25,5 +25,4 @@ set -e
##############################################
## Deploy signed artifacts to Maven Central ##
##############################################
cat /tmp/circleci/mvn-settings.xml
mvn -s /tmp/circleci/mvn-settings.xml -P release -B -DskipTests -Dgpg.keyname="$GPG_KEYNAME" -Dgpg.passphrase="$GPG_PASSPHRASE" deploy
-1
View File
@@ -47,4 +47,3 @@ http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.
EOF
echo "✅ Maven settings file created: /tmp/circleci/mvn-settings.xml"
cat /tmp/circleci/mvn-settings.xml
+7 -1
View File
@@ -16,6 +16,7 @@ set -e
###################
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TEST_SCRIPT="$SCRIPT_DIR/test_calculate_version.sh"
SETTINGS_TEST_SCRIPT="$SCRIPT_DIR/test_maven_settings_output.sh"
VERBOSE=false
CI_MODE=false
@@ -54,6 +55,10 @@ main() {
echo "❌ Test script not found: $TEST_SCRIPT"
exit 1
fi
if [[ ! -f "$SETTINGS_TEST_SCRIPT" ]]; then
echo "❌ Test script not found: $SETTINGS_TEST_SCRIPT"
exit 1
fi
###############
## Run tests ##
@@ -68,7 +73,7 @@ main() {
## CI mode: minimal output, focus on results ##
###############################################
echo "Running tests in CI mode..."
if "$TEST_SCRIPT" $test_args > /tmp/test_output.log 2>&1; then
if { "$TEST_SCRIPT" $test_args && bash "$SETTINGS_TEST_SCRIPT"; } > /tmp/test_output.log 2>&1; then
echo "✅ All tests passed!"
exit 0
else
@@ -82,6 +87,7 @@ main() {
## Interactive mode: full output ##
###################################
"$TEST_SCRIPT" $test_args
bash "$SETTINGS_TEST_SCRIPT"
fi
}
+55
View File
@@ -0,0 +1,55 @@
#!/bin/bash
set -euo pipefail
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source_dir="$(dirname "$script_dir")/src/scripts"
test_dir="$(mktemp -d)"
trap 'rm -rf "$test_dir"' EXIT
mkdir -p "$test_dir/bin"
# Keep the production scripts' fixed CircleCI path away from any shared /tmp file.
sed "s|/tmp/circleci|$test_dir/circleci|g" \
"$source_dir/setup_maven_settings.sh" > "$test_dir/setup.sh"
sed "s|/tmp/circleci|$test_dir/circleci|g" \
"$source_dir/mvn_jar_deploy.sh" > "$test_dir/deploy.sh"
bash "$test_dir/setup.sh" > "$test_dir/setup-output" 2>&1
settings="$test_dir/circleci/mvn-settings.xml"
test -f "$settings"
grep -Fq "\${env.CENTRAL_USERNAME}" "$settings"
grep -Fq "\${env.CENTRAL_PASSWORD}" "$settings"
if grep -Fq '<settings' "$test_dir/setup-output" ||
grep -Fq "\${env.CENTRAL_USERNAME}" "$test_dir/setup-output"; then
echo 'Setup printed Maven settings content' >&2
exit 1
fi
# A distinctive future secret must never be echoed by the deploy wrapper.
printf '\n<!-- settings-output-sentinel -->\n' >> "$settings"
cat > "$test_dir/bin/mvn" <<'EOF'
#!/bin/bash
printf '%s\n' "$@" > "$TEST_MVN_ARGS"
EOF
chmod +x "$test_dir/bin/mvn"
PATH="$test_dir/bin:$PATH" TEST_MVN_ARGS="$test_dir/mvn-args" \
GPG_KEYNAME=test-key GPG_PASSPHRASE=test-passphrase \
bash "$test_dir/deploy.sh" > "$test_dir/deploy-output" 2>&1
if grep -Fq 'settings-output-sentinel' "$test_dir/deploy-output"; then
echo 'Deploy printed Maven settings content' >&2
exit 1
fi
cat > "$test_dir/expected-args" <<EOF
-s
$settings
-P
release
-B
-DskipTests
-Dgpg.keyname=test-key
-Dgpg.passphrase=test-passphrase
deploy
EOF
diff -u "$test_dir/expected-args" "$test_dir/mvn-args"
echo 'Maven settings setup and deploy output are safe; deploy arguments preserved'