Compare commits

...
Author SHA1 Message Date
james.maesandCodex 6806de4892 fix: validate MCP pull requests once
Co-Authored-By: Codex <noreply@openai.com>
2026-10-20 19:43:46 -05:00
james.maes a9d51ebd47 Merge pull request #32 from QRun-IO/fix/integration-test-results
fix: preserve Maven reports and publication completion
2026-10-20 19:21:25 -05:00
james.maesandCodex 284c69aa3e fix: allow Central publication wait to finish
Co-Authored-By: Codex <noreply@openai.com>
2026-10-20 19:18:31 -05:00
james.maesandCodex fb30d9acc5 fix: retain integration and multi-module test reports
Co-Authored-By: Codex <noreply@openai.com>
2026-10-20 19:16:27 -05:00
james.maes 563f88bdad Merge pull request #30 from QRun-IO/fix/confirmed-central-publication
fix: require confirmed Central release publication
2026-10-20 18:46:32 -05:00
james.maesandCodex 4cb662f076 fix: require confirmed Central release publication
Co-Authored-By: Codex <noreply@openai.com>
2026-10-20 18:44:33 -05:00
james.maes a2cdd818f6 Merge pull request #28 from QRun-IO/fix/resolved-publication-poms
fix: resolve Maven publication POM coordinates centrally
2026-10-20 18:37:34 -05:00
james.maesandCodex 42e0be02c9 fix: enforce Maven publication gate in orb audit
Co-Authored-By: Codex <noreply@openai.com>
2026-10-20 18:35:53 -05:00
james.maesandCodex b71c9ca4d7 fix: resolve Maven publication POM coordinates centrally
Co-Authored-By: Codex <noreply@openai.com>
2026-10-20 07:50:31 -05:00
13 changed files with 221 additions and 35 deletions

No files matched your search

+14 -2
View File
@@ -22,6 +22,15 @@ main-filters: &main-filters
only: [main]
jobs:
maven-publication-contract:
resource_class: small
docker:
- image: cimg/openjdk:21.0
steps:
- checkout
- run:
name: Verify resolved multi-module publication POMs
command: python3 tests/test_maven_publication_poms.py
pipeline-contract-test:
resource_class: small
docker:
@@ -63,6 +72,7 @@ jobs:
bash tests/test_maven_ci_push.sh
bash tests/test_create_github_release.sh
bash tests/test_maven_ci_cache.sh
bash tests/test_maven_test_results.sh
bash tests/test_maven_ci_install.sh
bash tests/test_snapshot_refresh.sh
bash tests/test_maven_settings_output.sh
@@ -148,13 +158,15 @@ workflows:
filters: *filters
- pipeline-contract-test:
filters: *filters
- maven-publication-contract:
filters: *filters
# Auto-publish dev snapshot on develop
- publish-dev-snapshot:
context: orb-publishing
filters: *develop-filters
requires: [command-test, pipeline-contract-test]
requires: [command-test, pipeline-contract-test, maven-publication-contract]
# Auto-publish production release on main
- publish-production:
context: orb-publishing
filters: *main-filters
requires: [command-test, pipeline-contract-test]
requires: [command-test, pipeline-contract-test, maven-publication-contract]
+7
View File
@@ -81,6 +81,7 @@ test-pipelines: pack
bash tests/test_maven_ci_push.sh
bash tests/test_create_github_release.sh
bash tests/test_maven_ci_cache.sh
bash tests/test_maven_test_results.sh
bash tests/test_maven_ci_install.sh
bash tests/test_snapshot_refresh.sh
bash tests/test_maven_settings_output.sh
@@ -208,3 +209,9 @@ publish-release: check-clean check-branch lint clean dev test-all
echo "Pushing tag to remote..."; \
git push origin "$$version"; \
echo "✅ Production release $$version published successfully!"
.PHONY: test-publication-poms
# Explicit integration gate: requires Java/Maven and public plugin downloads into
# an isolated temporary repository. Never publishes or uses signing credentials.
test-publication-poms:
python3 tests/test_maven_publication_poms.py
+5 -3
View File
@@ -1,9 +1,8 @@
description: >
Publishes artifacts to Maven Central (Sonatype Central Portal)
- Restores Maven dependency cache
- Debugs Maven settings to verify configuration
- Configures Maven credentials without logging settings
- Sets up GPG signing for artifact verification
- Deploys signed artifacts to Maven Central using release profile
- Deploys signed artifacts and waits for confirmed Central release publication
- Saves Maven cache for future builds
steps:
@@ -15,6 +14,9 @@ steps:
command: <<include(scripts/mvn_jar_deploy_gpg_setup.sh)>>
- run:
name: Publish to Sonatype Central (releases and SNAPSHOTs)
# Central's native publication wait can be silent for its 30-minute limit.
# Let Maven return its real result before CircleCI's inactivity watchdog.
no_output_timeout: 35m
command: <<include(scripts/mvn_jar_deploy.sh)>>
- save_cache:
paths:
+9 -1
View File
@@ -25,4 +25,12 @@ set -e
##############################################
## Deploy signed artifacts to Maven Central ##
##############################################
mvn -s /tmp/circleci/mvn-settings.xml -P release -B -DskipTests -Dgpg.keyname="$GPG_KEYNAME" -Dgpg.passphrase="$GPG_PASSPHRASE" deploy
# Resolve CI-friendly coordinates without stripping parent/BOM configuration.
# Flatten must share this Maven process so deploy uses the resolved project POMs.
# Central 0.8.x: this completion flag overrides inherited literal waitUntil=uploaded.
# Do not report a release as successful until Central confirms publication.
mvn -s /tmp/circleci/mvn-settings.xml -P release -B -DskipTests \
-Dgpg.keyname="$GPG_KEYNAME" -Dgpg.passphrase="$GPG_PASSPHRASE" \
-DwaitForPublishCompletion=true \
-Dflatten.mode=resolveCiFriendliesOnly -DupdatePomFile=true \
org.codehaus.mojo:flatten-maven-plugin:1.7.3:flatten deploy
+8 -24
View File
@@ -1,26 +1,10 @@
#!/bin/bash
# Collect unit and integration JUnit reports without losing same-named module suites.
set -euo pipefail
############################################################################
## mvn_verify_save_test_results.sh
## Test Results Collection Script
##
## This script collects JUnit test results from Maven Surefire reports
## and saves them to the CircleCI test results directory for reporting.
## It finds all XML test result files and copies them to the standard location.
##
## Process:
## 1. Creates test results directory structure
## 2. Finds all Surefire XML report files
## 3. Copies test results to CircleCI test results directory
##
## Usage: Called by CircleCI orb command mvn_verify
## Output: Collects and saves JUnit test results for CircleCI reporting
############################################################################
set -e
#############################################################
## Create test results directory and collect JUnit reports ##
#############################################################
mkdir -p ~/test-results/junit/
find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/junit/ \;
mkdir -p "$HOME/test-results/junit"
while IFS= read -r -d '' report; do
destination="$HOME/test-results/junit/${report#./}"
mkdir -p "$(dirname "$destination")"
cp "$report" "$destination"
done < <(find . -type f \( -path '*/target/surefire-reports/TEST-*.xml' -o -path '*/target/failsafe-reports/TEST-*.xml' \) -print0)
+1 -1
View File
@@ -164,7 +164,7 @@
"on": {
"push": {
"branches": [
"**"
"main"
]
},
"pull_request": {
+1 -1
View File
@@ -177,7 +177,7 @@ class AuditTests(unittest.TestCase):
self.assertEqual('unknown', report['status'])
self.assertNotIn('missing_manifest', [f['code'] for f in report['findings']])
for path, old, new in [('.circleci/config.yml', 'orb-tools/pack', 'disabled-pack'),
('.circleci/test-deploy.yml', 'requires: [command-test, pipeline-contract-test]', 'requires: []'),
('.circleci/test-deploy.yml', 'requires: [command-test, pipeline-contract-test, maven-publication-contract]', 'requires: [command-test, pipeline-contract-test]'),
('.circleci/test-deploy.yml', 'circleci orb validate ', 'echo skipped ')]:
self.assertIn(old, files[path])
changed = dict(files, **{path: files[path].replace(old, new)})
+2 -1
View File
@@ -51,7 +51,8 @@ class SpecialistNativeTests(unittest.TestCase):
self.assertEqual(steps[3], original['jobs']['build-and-test']['steps'][3])
self.assertEqual(steps[4]['if'], 'always()')
caller = bridge.canonical('mcp-rag', SHA)
self.assertEqual(caller['on']['push'], {'branches': ['**']})
# Feature branches run once through the PR event, not also on push.
self.assertEqual(caller['on']['push'], {'branches': ['main']})
self.assertEqual(caller['on']['pull_request'], {'branches': ['main']})
self.assertEqual(caller['jobs']['validate']['secrets'], {
'QQQ_MCP_VOYAGE_API_KEY': '${{ secrets.QQQ_MCP_VOYAGE_API_KEY }}'})
+11
View File
@@ -63,6 +63,17 @@ class MavenCiContract(unittest.TestCase):
self.assertIn("-Dgpg.keyname=", deploy)
self.assertIn("-DskipTests", deploy)
def test_publication_wait_outlives_central_native_timeout(self):
steps = read("src/commands/mvn_jar_deploy.yml")["steps"]
publish = next(s["run"] for s in steps if "mvn_jar_deploy.sh" in str(s))
# Central 0.8.x waits silently up to 1800 seconds; the default Circle
# ten-minute inactivity limit killed an already-uploaded RC in production.
timeout = publish["no_output_timeout"]
self.assertTrue(timeout.endswith("m"))
self.assertGreater(int(timeout[:-1]), 30)
self.assertLessEqual(int(timeout[:-1]), 40)
self.assertNotIn("max_auto_reruns", publish)
if __name__ == "__main__":
unittest.main()
+107
View File
@@ -0,0 +1,107 @@
#!/usr/bin/env python3
"""Real Maven publication contract. Requires Java/Maven; no remote deploy or secrets.
Run explicitly with make test-publication-poms. Public plugins are downloaded to
an isolated temporary local repository; nothing is installed to the user's m2.
"""
import hashlib
from pathlib import Path
import shutil
import subprocess
import tempfile
import xml.etree.ElementTree as ET
ROOT = Path(__file__).resolve().parents[1]
GOAL = 'org.codehaus.mojo:flatten-maven-plugin:1.7.3:flatten'
FLAGS = ['-Dflatten.mode=resolveCiFriendliesOnly', '-DupdatePomFile=true']
NS = {'m': 'http://maven.apache.org/POM/4.0.0'}
def pom(body):
return '<project xmlns="http://maven.apache.org/POM/4.0.0"><modelVersion>4.0.0</modelVersion>' + body + '</project>'
def run_case(base, repository, lifecycle):
project = base / ('bound' if lifecycle else 'plain')
project.mkdir()
group = 'example.bound' if lifecycle else 'example.plain'
flatten = ("<plugin><groupId>org.codehaus.mojo</groupId><artifactId>flatten-maven-plugin</artifactId>"
"<version>1.7.3</version><configuration><updatePomFile>true</updatePomFile>"
"<flattenMode>resolveCiFriendliesOnly</flattenMode></configuration><executions>"
"<execution><id>flatten</id><phase>process-resources</phase><goals><goal>flatten</goal>"
"</goals></execution></executions></plugin>") if lifecycle else ''
(project / 'pom.xml').write_text(pom(f"""
<groupId>{group}</groupId><artifactId>parent</artifactId><version>${{revision}}</version><packaging>pom</packaging>
<name>Publication fixture</name><description>Inherited release metadata</description><url>https://example.invalid/fixture</url>
<licenses><license><name>Fixture license</name><url>https://example.invalid/license</url></license></licenses>
<properties><revision>1.2.3</revision><maven.compiler.release>17</maven.compiler.release></properties>
<modules><module>library</module><module>application</module></modules>
<dependencyManagement><dependencies><dependency><groupId>{group}</groupId><artifactId>library</artifactId>
<version>${{revision}}</version></dependency></dependencies></dependencyManagement>
<build><pluginManagement><plugins><plugin><groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId><version>3.13.0</version><configuration><release>17</release></configuration>
</plugin></plugins></pluginManagement><plugins>{flatten}</plugins></build>
"""), encoding='utf-8')
for artifact in ('library', 'application'):
child = project / artifact
child.mkdir()
dependencies = (f'<dependencies><dependency><groupId>{group}</groupId><artifactId>library</artifactId></dependency></dependencies>'
if artifact == 'application' else '')
(child / 'pom.xml').write_text(pom(f'<parent><groupId>{group}</groupId><artifactId>parent</artifactId>'
'<version>${revision}</version></parent>' + f'<artifactId>{artifact}</artifactId>' + dependencies), encoding='utf-8')
sources = {path: hashlib.sha256(path.read_bytes()).hexdigest() for path in project.rglob('pom.xml')}
settings = base / 'settings.xml'
settings.write_text('<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"/>', encoding='utf-8')
maven = shutil.which('mvn') or shutil.which('mvn.cmd')
if not maven:
raise RuntimeError('Maven is required for this explicit integration gate')
command = [maven, '-B', '-ntp', '-s', str(settings), '-gs', str(settings), '-Dmaven.repo.local=' + str(repository)]
def execute(directory, goals):
subprocess.run(command + goals, cwd=directory, check=True, timeout=600)
execute(project, FLAGS + [GOAL, 'install'])
for path, digest in sources.items():
assert hashlib.sha256(path.read_bytes()).hexdigest() == digest, 'Source POM was rewritten'
installed = repository / group.replace('.', '/')
for artifact in ('parent', 'library', 'application'):
tree = ET.parse(installed / artifact / '1.2.3' / (artifact + '-1.2.3.pom'))
for node in tree.findall('m:version', NS) + tree.findall('m:parent/m:version', NS):
assert node.text == '1.2.3', 'Unresolved deployed coordinate: ' + artifact
parent = ET.parse(installed / 'parent/1.2.3/parent-1.2.3.pom')
assert parent.findtext('m:licenses/m:license/m:name', namespaces=NS) == 'Fixture license'
assert parent.find('m:dependencyManagement', NS) is not None
assert parent.find('m:build/m:pluginManagement', NS) is not None, 'Parent build contract was stripped'
# Remove reactor availability: cold consumer can use only installed artifacts.
hidden = project.with_name(project.name + '-unavailable')
project.rename(hidden)
consumer = base / ('consumer-bound' if lifecycle else 'consumer-plain')
consumer.mkdir()
(consumer / 'pom.xml').write_text(pom(f'<parent><groupId>{group}</groupId><artifactId>parent</artifactId>'
'<version>1.2.3</version><relativePath/></parent><artifactId>cold-consumer</artifactId>'
f'<dependencies><dependency><groupId>{group}</groupId><artifactId>application</artifactId>'
'<version>1.2.3</version></dependency></dependencies>'), encoding='utf-8')
execute(consumer, ['validate', 'org.apache.maven.plugins:maven-help-plugin:3.5.1:effective-pom', '-Doutput=effective.xml',
'org.apache.maven.plugins:maven-dependency-plugin:3.7.1:build-classpath', '-Dmdep.outputFile=classpath.txt'])
effective = ET.parse(consumer / 'effective.xml')
assert effective.findtext('m:licenses/m:license/m:name', namespaces=NS) == 'Fixture license'
managed = effective.find('m:dependencyManagement/m:dependencies/m:dependency', NS)
assert managed.findtext('m:version', namespaces=NS) == '1.2.3'
plugins = effective.findall('m:build/m:pluginManagement/m:plugins/m:plugin', NS)
compiler = next(p for p in plugins if p.findtext('m:artifactId', namespaces=NS) == 'maven-compiler-plugin')
assert compiler.findtext('m:configuration/m:release', namespaces=NS) == '17'
classpath = (consumer / 'classpath.txt').read_text()
assert 'application-1.2.3.jar' in classpath and 'library-1.2.3.jar' in classpath
print('PASS real resolved publication + cold consumer: ' + ('lifecycle-bound' if lifecycle else 'no-existing-flatten'))
def main():
deployment = (ROOT / 'src/scripts/mvn_jar_deploy.sh').read_text()
for flag in FLAGS:
assert flag in deployment, 'Deployment missing tested flatten configuration'
assert GOAL + ' deploy' in deployment, 'Flatten and deploy must share a Maven process'
with tempfile.TemporaryDirectory(prefix='qqq-publication-') as directory:
base = Path(directory)
for lifecycle in (False, True):
run_case(base, base / 'repository', lifecycle)
if __name__ == '__main__': main()
+19
View File
@@ -49,7 +49,26 @@ release
-DskipTests
-Dgpg.keyname=test-key
-Dgpg.passphrase=test-passphrase
-DwaitForPublishCompletion=true
-Dflatten.mode=resolveCiFriendliesOnly
-DupdatePomFile=true
org.codehaus.mojo:flatten-maven-plugin:1.7.3:flatten
deploy
EOF
diff -u "$test_dir/expected-args" "$test_dir/mvn-args"
# A Central validation failure or publication timeout must fail this wrapper.
cat > "$test_dir/bin/mvn" <<'EOF'
#!/bin/bash
exit 42
EOF
set +e
PATH="$test_dir/bin:$PATH" GPG_KEYNAME=test-key GPG_PASSPHRASE=test-passphrase \
bash "$test_dir/deploy.sh" > "$test_dir/failure-output" 2>&1
status=$?
set -e
if [ "$status" -ne 42 ]; then
echo 'Deploy did not preserve Maven publication failure' >&2
exit 1
fi
echo 'Maven settings setup and deploy output are safe; deploy arguments preserved'
+35
View File
@@ -0,0 +1,35 @@
#!/bin/bash
# Exercise the actual collector with colliding suites, spaces and non-JUnit XML.
set -euo pipefail
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/../src/scripts" && pwd)
scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
export HOME="$scratch/home"
mkdir -p "$scratch/repo"
cd "$scratch/repo"
# A repository with no tests is valid.
bash "$script_dir/mvn_verify_save_test_results.sh"
[[ -d "$HOME/test-results/junit" ]]
[[ -z "$(find "$HOME/test-results/junit" -type f -print)" ]]
for module in 'module one' 'module two'; do
for runner in surefire failsafe; do
report="$module/target/$runner-reports/TEST-shared.xml"
mkdir -p "$(dirname "$report")"
printf '<testsuite name="%s %s"/>\n' "$module" "$runner" > "$report"
done
done
printf '<failsafe-summary/>\n' > 'module one/target/failsafe-reports/failsafe-summary.xml'
printf '<configuration/>\n' > 'module one/target/surefire-reports/configuration.xml'
mkdir -p unrelated
printf '<testsuite/>\n' > unrelated/TEST-ignore.xml
bash "$script_dir/mvn_verify_save_test_results.sh"
[[ "$(find "$HOME/test-results/junit" -type f | wc -l)" -eq 4 ]]
for module in 'module one' 'module two'; do
for runner in surefire failsafe; do
report="$module/target/$runner-reports/TEST-shared.xml"
cmp "$report" "$HOME/test-results/junit/$report"
done
done
printf 'PASS: unit/integration reports, module collisions, spaces, exclusions and no tests\n'
+2 -2
View File
@@ -138,7 +138,7 @@ def owner_gate_errors(snapshot):
if not gates.issubset(set(lint.get('orb-tools/continue', {}).get('requires', []))):
errors.append('continuation must depend on every lint/pack/review/shellcheck gate')
tests = invocations(deploy, 'test-deploy')
required = {'command-test', 'pipeline-contract-test'}
required = {'command-test', 'pipeline-contract-test', 'maven-publication-contract'}
for test in required:
definition = deploy.get('jobs', {}).get(test, {})
if test not in tests or not definition.get('steps') or not any(isinstance(step, dict) and 'run' in step for step in definition['steps']):
@@ -146,7 +146,7 @@ def owner_gate_errors(snapshot):
for name, branch in [('publish-dev-snapshot', 'develop'), ('publish-production', 'main')]:
invocation = tests.get(name, {})
if not required.issubset(set(invocation.get('requires', []))):
errors.append(name + ' must require both test gates')
errors.append(name + ' must require all test gates')
if invocation.get('filters', {}).get('branches', {}).get('only') != [branch]:
errors.append(name + ' branch filter')
commands = []