|
| 1 | +# CI Architecture |
| 2 | + |
| 3 | +Overview of the GitHub Actions CI/CD ecosystem for Apache Camel. |
| 4 | + |
| 5 | +## Workflow Overview |
| 6 | + |
| 7 | +``` |
| 8 | +PR opened/updated |
| 9 | + │ |
| 10 | + ├──► pr-id.yml ──► pr-commenter.yml (welcome message) |
| 11 | + │ |
| 12 | + └──► pr-build-main.yml (Build and test) |
| 13 | + │ |
| 14 | + ├── regen.sh (full build, no tests) |
| 15 | + ├── incremental-build (test affected modules) |
| 16 | + │ ├── File-path analysis |
| 17 | + │ ├── POM dependency analysis |
| 18 | + │ └── Extra modules (/component-test) |
| 19 | + │ |
| 20 | + └──► pr-test-commenter.yml (post unified comment) |
| 21 | +
|
| 22 | +PR comment: /component-test kafka http |
| 23 | + │ |
| 24 | + └──► pr-manual-component-test.yml |
| 25 | + │ |
| 26 | + └── dispatches "Build and test" with extra_modules |
| 27 | +``` |
| 28 | + |
| 29 | +## Workflows |
| 30 | + |
| 31 | +### `pr-build-main.yml` — Build and test |
| 32 | +- **Trigger**: `pull_request` (main branch), `workflow_dispatch` |
| 33 | +- **Matrix**: JDK 17, 21, 25 (25 is experimental) |
| 34 | +- **Steps**: |
| 35 | + 1. Full build via `regen.sh` (`mvn install -DskipTests -Pregen`) |
| 36 | + 2. Check for uncommitted generated files |
| 37 | + 3. Run incremental tests (only affected modules) |
| 38 | + 4. Upload test comment as artifact |
| 39 | +- **Inputs** (workflow_dispatch): `pr_number`, `pr_ref`, `extra_modules`, |
| 40 | + `skip_full_build` |
| 41 | + |
| 42 | +### `pr-test-commenter.yml` — Post CI test comment |
| 43 | +- **Trigger**: `workflow_run` on "Build and test" completion |
| 44 | +- **Purpose**: Posts the unified test summary comment on the PR |
| 45 | +- **Why separate**: Uses `workflow_run` to run in base repo context, allowing |
| 46 | + comment posting on fork PRs (where `GITHUB_TOKEN` is read-only) |
| 47 | + |
| 48 | +### `pr-manual-component-test.yml` — /component-test handler |
| 49 | +- **Trigger**: `issue_comment` with `/component-test` prefix |
| 50 | +- **Who**: MEMBER, OWNER, or CONTRIBUTOR only |
| 51 | +- **What**: Resolves component names to module paths, dispatches the main |
| 52 | + "Build and test" workflow with `extra_modules` and `skip_full_build=true` |
| 53 | +- **Build**: Uses a quick targeted build (`-Dquickly`) of the requested |
| 54 | + modules and their dependencies instead of the full `regen.sh` build |
| 55 | + |
| 56 | +### `pr-id.yml` + `pr-commenter.yml` — Welcome message |
| 57 | +- **Trigger**: `pull_request` (all branches) |
| 58 | +- **Purpose**: Posts the one-time welcome message on new PRs |
| 59 | +- **Why two workflows**: `pr-id.yml` runs in PR context (uploads PR number), |
| 60 | + `pr-commenter.yml` runs via `workflow_run` with write permissions |
| 61 | + |
| 62 | +### `main-build.yml` — Main branch build |
| 63 | +- **Trigger**: `push` to main, camel-4.14.x, camel-4.18.x |
| 64 | +- **Steps**: Same as PR build but without comment posting |
| 65 | + |
| 66 | +### Other workflows |
| 67 | +- `pr-labeler.yml` — Auto-labels PRs based on changed files |
| 68 | +- `pr-doc-validation.yml` — Validates documentation changes |
| 69 | +- `pr-cleanup-branches.yml` — Cleans up merged PR branches |
| 70 | +- `alternative-os-build-main.yml` — Tests on non-Linux OSes |
| 71 | +- `check-container-versions.yml` — Checks test container version updates |
| 72 | +- `generate-sbom-main.yml` — Generates SBOM for releases |
| 73 | +- `security-scan.yml` — Security vulnerability scanning |
| 74 | + |
| 75 | +## Actions |
| 76 | + |
| 77 | +### `incremental-build` |
| 78 | +The core test runner. Determines which modules to test using: |
| 79 | +1. **File-path analysis**: Maps changed files to Maven modules |
| 80 | +2. **POM dependency analysis via [Scalpel](https://github.com/maveniverse/scalpel)**: |
| 81 | + For parent POM changes, uses Maven model comparison to detect changed |
| 82 | + properties, managed dependencies, managed plugins, and property indirection. |
| 83 | + Scalpel runs in `report` mode during `mvn validate` and outputs a JSON |
| 84 | + report listing affected modules. |
| 85 | +3. **Extra modules**: Additional modules passed via `/component-test` |
| 86 | + |
| 87 | +Results are merged, deduplicated, and tested. The script also: |
| 88 | +- Detects tests disabled in CI (`@DisabledIfSystemProperty(named = "ci.env.name")`) |
| 89 | +- Applies an exclusion list for generated/meta modules |
| 90 | +- Generates a unified PR comment with all test information |
| 91 | + |
| 92 | +### `install-mvnd` |
| 93 | +Installs the Maven Daemon (mvnd) for faster builds. |
| 94 | + |
| 95 | +### `install-packages` |
| 96 | +Installs system packages required for the build. |
| 97 | + |
| 98 | +## PR Labels |
| 99 | + |
| 100 | +| Label | Effect | |
| 101 | +|-------|--------| |
| 102 | +| `skip-tests` | Skip all tests | |
| 103 | +| `test-dependents` | Force testing dependent modules even if threshold exceeded | |
| 104 | + |
| 105 | +## CI Environment |
| 106 | + |
| 107 | +The CI sets `-Dci.env.name=github.com` via `MVND_OPTS` (in `install-mvnd`). |
| 108 | +Tests can use `@DisabledIfSystemProperty(named = "ci.env.name")` to skip |
| 109 | +flaky tests in CI. The test comment warns about these skipped tests. |
| 110 | + |
| 111 | +## Scalpel POM Change Detection |
| 112 | + |
| 113 | +[Scalpel](https://github.com/maveniverse/scalpel) is a Maven extension that |
| 114 | +detects which modules are affected by POM changes using Maven model comparison |
| 115 | +(not simple text grep). It handles: |
| 116 | + |
| 117 | +- **Changed properties**: Compares old/new `<properties>` values |
| 118 | +- **Managed dependencies**: Detects changes in `<dependencyManagement>` entries |
| 119 | +- **Managed plugins**: Detects changes in `<pluginManagement>` entries |
| 120 | +- **Property indirection**: If a managed dependency's version uses a changed |
| 121 | + property (e.g. `${spring.version}`), that dependency is marked as changed |
| 122 | +- **Child module scanning**: For parent POM changes, checks each child module's |
| 123 | + `pom.xml` for references to changed properties, managed deps, or managed plugins |
| 124 | + |
| 125 | +Scalpel is cloned from GitHub and built during CI. It runs as a Maven core |
| 126 | +extension during `mvn validate` in `report` mode, outputting a JSON report |
| 127 | +(`target/scalpel-report.json`) without modifying the reactor. |
| 128 | + |
| 129 | +## Multi-JDK Artifact Behavior |
| 130 | + |
| 131 | +All non-experimental JDK matrix entries (17, 21) upload the CI comment |
| 132 | +artifact with `overwrite: true`. This ensures a comment is posted even if |
| 133 | +one JDK build fails. Since the comment content is identical across JDKs |
| 134 | +(same modules are tested regardless of JDK version), last writer wins. |
| 135 | + |
| 136 | +## Comment Markers |
| 137 | + |
| 138 | +PR comments use HTML markers for upsert (create-or-update) behavior: |
| 139 | +- `<!-- ci-tested-modules -->` — Unified test summary comment |
0 commit comments