feat: archive zoo_backup for home sync
This commit is contained in:
@@ -0,0 +1,183 @@
|
||||
---
|
||||
name: mvn-test
|
||||
description: Run Maven tests in PAISY worktrees. Resolves module paths (including svmodules nesting), builds dependencies, parses results, and stores outcomes in BigMind. Use when asked to run tests, execute test classes, or verify a module build.
|
||||
---
|
||||
|
||||
# Maven Test & Build Runner
|
||||
|
||||
## When to use
|
||||
|
||||
- Running all tests for a PAISY module
|
||||
- Running a specific test class or method
|
||||
- Building a fat JAR for SSH deployment
|
||||
- Verifying a build after code changes in a worktree
|
||||
- Troubleshooting Maven dependency/version issues
|
||||
|
||||
## When NOT to use
|
||||
|
||||
- SSH integration tests on PAISY instances → use `ssh-integration-test` or `vmhalling-eau-test` skill
|
||||
- Creating new test files → use Code mode directly
|
||||
- Running non-Maven tests (npm, etc.)
|
||||
|
||||
## Required Inputs
|
||||
|
||||
| Input | Source | Example |
|
||||
|-------|--------|---------|
|
||||
| `TICKET_KEY` | Jira issue key | `ESIDEPAISY-12366` |
|
||||
| `MODULE` | PAISY module name | `svmeldungen_persistence`, `eau`, `eubp` |
|
||||
| `TEST_CLASS` | Fully qualified test class (optional) | `manager.db.dsak.ArbeitgeberkontoManagerTest` |
|
||||
|
||||
## Module Path Resolution
|
||||
|
||||
| Module name | Maven `-pl` path |
|
||||
|------------|-----------------|
|
||||
| eau | `java/modules/cs-modules/eau` |
|
||||
| eubp | `java/modules/cs-modules/eubp` |
|
||||
| svmeldungen | `java/modules/cs-modules/svmodules/svmeldungen` |
|
||||
| svmeldungen_persistence | `java/modules/cs-modules/svmodules/svmeldungen_persistence` |
|
||||
| dabpv | `java/modules/cs-modules/dabpv` |
|
||||
| rvbea | `java/modules/cs-modules/rvbea` |
|
||||
| svbea | `java/modules/cs-modules/svbea` |
|
||||
| babea | `java/modules/cs-modules/babea` |
|
||||
| dsvv | `java/modules/cs-modules/dsvv` |
|
||||
| dsbd | `java/modules/cs-modules/dsbd` |
|
||||
| estatistik | `java/modules/cs-modules/estatistik` |
|
||||
| persistence | `java/persistence` |
|
||||
| sv-common | `java/modules/sv-common` |
|
||||
|
||||
If the module is not in this table, search for it:
|
||||
```bash
|
||||
find java/modules -name "pom.xml" -path "*/<MODULE>/*" | head -3
|
||||
```
|
||||
|
||||
## Workflow
|
||||
|
||||
### 1. Determine worktree path
|
||||
|
||||
```bash
|
||||
WORKTREE="/Users/pplate/git/paisy-<TICKET_KEY>"
|
||||
# Verify it exists
|
||||
ls "$WORKTREE/java/pom.xml"
|
||||
```
|
||||
|
||||
If no worktree exists, fall back to the main repo: `/Users/pplate/git/paisy`
|
||||
|
||||
### 2. Resolve module path
|
||||
|
||||
Look up `MODULE` in the path resolution table above. Store as `MODULE_PATH`.
|
||||
|
||||
### 3. Run tests
|
||||
|
||||
**All module tests:**
|
||||
```bash
|
||||
cd <WORKTREE> && mvn test -pl <MODULE_PATH> -am -f java/pom.xml
|
||||
```
|
||||
|
||||
**Specific test class:**
|
||||
```bash
|
||||
cd <WORKTREE> && mvn test -pl <MODULE_PATH> -am -Dtest="<TEST_CLASS>" -Dsurefire.failIfNoSpecifiedTests=false -f java/pom.xml
|
||||
```
|
||||
|
||||
**Specific test method:**
|
||||
```bash
|
||||
cd <WORKTREE> && mvn test -pl <MODULE_PATH> -am -Dtest="<TEST_CLASS>#<methodName>" -Dsurefire.failIfNoSpecifiedTests=false -f java/pom.xml
|
||||
```
|
||||
|
||||
### 4. Parse results
|
||||
|
||||
Look for these patterns in the output:
|
||||
|
||||
| Pattern | Meaning |
|
||||
|---------|---------|
|
||||
| `Tests run: N, Failures: F, Errors: E, Skipped: S` | Surefire summary |
|
||||
| `BUILD SUCCESS` | All tests passed |
|
||||
| `BUILD FAILURE` | At least one test failed or compilation error |
|
||||
| `There are test failures` | Link to surefire reports |
|
||||
|
||||
If tests fail, read the surefire report:
|
||||
```bash
|
||||
find <WORKTREE>/<MODULE_PATH>/target/surefire-reports -name "*.txt" -exec grep -l "FAILURE\|ERROR" {} \;
|
||||
```
|
||||
|
||||
### 5. Store results in BigMind
|
||||
|
||||
```python
|
||||
memory_store_fact(
|
||||
category="codebase",
|
||||
fact=f"{TICKET_KEY}: mvn test {MODULE} — {tests_run} run, {failures} failures, {errors} errors. {'BUILD SUCCESS' or 'BUILD FAILURE'}"
|
||||
)
|
||||
```
|
||||
|
||||
## Building Fat JARs (for SSH deployment)
|
||||
|
||||
### Package a module with all dependencies:
|
||||
```bash
|
||||
cd <WORKTREE> && mvn package -pl :EAU -am -DskipTests -f java/pom.xml -Drevision=100.0.0-TEST -o -q
|
||||
```
|
||||
|
||||
### Locate the built JAR:
|
||||
```bash
|
||||
find <MODULE_PATH>/target -name "*-jar-with-dependencies.jar" | head -1
|
||||
```
|
||||
|
||||
### Module artifact IDs (for `-pl :NAME`):
|
||||
|
||||
| Module | Artifact ID | Fat JAR name |
|
||||
|--------|-------------|-------------|
|
||||
| eau | `EAU` | `EAU-*-jar-with-dependencies.jar` |
|
||||
| eubp | `EUBP` | `EUBP-*-jar-with-dependencies.jar` |
|
||||
| svmeldungen | `SVMeldungen` | `SVMeldungen-*-jar-with-dependencies.jar` |
|
||||
| dabpv | `dabpv-module` | `dabpv-module-*-jar-with-dependencies.jar` |
|
||||
| persistence | `persistence` | (no fat JAR) |
|
||||
|
||||
Use `:ARTIFACT_ID` with `-pl` for single-module builds (faster than path-based).
|
||||
|
||||
## Critical: Version Timestamp Issue
|
||||
|
||||
PAISY uses `${revision}` which resolves to a **timestamp-based SNAPSHOT** (e.g., `100-DEV-SNAPSHOT-20260505-0755`). This changes **every minute**.
|
||||
|
||||
**Problem:** If you `mvn install` at 07:55 and then `mvn test` at 07:56, the version changed and artifacts can't be found.
|
||||
|
||||
**Solutions:**
|
||||
|
||||
1. **Always use `-am` (also-make)** — builds from source, no cached artifacts needed
|
||||
2. **Pin the version:** `-Drevision=100.0.0-TEST` — stable across commands
|
||||
3. **Use `-o` (offline)** — prevents remote lookups that fail on VPN/cert issues
|
||||
4. **Never use `-pl` without `-am`** for test runs — dependencies won't resolve
|
||||
|
||||
### Recommended command patterns:
|
||||
|
||||
```bash
|
||||
# Compile check (fast)
|
||||
mvn compile -pl :EAU -am -f java/pom.xml -o -q
|
||||
|
||||
# Run specific test (reliable)
|
||||
mvn test -pl :EAU -am -f java/pom.xml \
|
||||
-Dtest="main.CenterAzvuFixTest" \
|
||||
-Dsurefire.failIfNoSpecifiedTests=false \
|
||||
-Dmaven.test.skip=false -DskipTests=false \
|
||||
-Drevision=100.0.0-TEST -o
|
||||
|
||||
# Build fat JAR for deployment
|
||||
mvn package -pl :EAU -am -DskipTests -f java/pom.xml \
|
||||
-Drevision=100.0.0-TEST -o -q
|
||||
```
|
||||
|
||||
### Why `-Dmaven.test.skip=false -DskipTests=false`?
|
||||
|
||||
Some modules have `<skipTests>true</skipTests>` in their POM or parent POM. These flags override that to force test execution.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
| Problem | Solution |
|
||||
|---------|----------|
|
||||
| `Could not find artifact` | Add `-am` flag to build dependencies first |
|
||||
| `No tests were executed` | Check test class path — use package-relative path, not fully qualified with `src/test/java/` |
|
||||
| `Compilation failure` in dependency | Run `mvn compile -pl <MODULE_PATH> -am -f java/pom.xml` first to isolate |
|
||||
| OOM during tests | Add `-Xmx1g` via `MAVEN_OPTS`: `MAVEN_OPTS="-Xmx1g" mvn test ...` |
|
||||
| Test hangs | Add `-Dsurefire.timeout=120` to kill stuck tests after 120s |
|
||||
| `Tests are skipped` | Add `-Dmaven.test.skip=false -DskipTests=false` |
|
||||
| Version mismatch (timestamp) | Pin with `-Drevision=100.0.0-TEST` |
|
||||
| Certificate/SSL error on artifact download | Add `-o` (offline) — use local sources with `-am` |
|
||||
| `No tests matching pattern` in dependency modules | Add `-Dsurefire.failIfNoSpecifiedTests=false` |
|
||||
| Wrong module selected by `-pl` | Use artifact ID (`:EAU`) not path — check with `grep '<artifactId>' <MODULE_PATH>/pom.xml` |
|
||||
Reference in New Issue
Block a user