This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
The following commit(s) were added to refs/heads/main by this push:
new 2c4debd6c Fix #3291: GitHub pull request, comment and tag sources make
no GitHub API requests per message (#3293)
2c4debd6c is described below
commit 2c4debd6cb9a396568ac6080cfb05756bae6a6f5
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Nov 20 21:06:27 2026 +0100
Fix #3291: GitHub pull request, comment and tag sources make no GitHub API
requests per message (#3293)
The three sources wrote the GitHub library object with marshal: json, and
Jackson called every getter, many of which read more from the GitHub API
(pull request details, commits, users and their followers, ...). Each
message made extra requests, and a failing one lost the message.
They now write the object from its fields with the writer of the GitHub
library, which asks GitHub for nothing, and keep the fields the
description lists with jq. The body is a String of JSON text in the field
names of the GitHub API.
The GitHub API stand-in of the Citrus tests lists every request and can
give a different first answer, so new Citrus tests show a new pull
request, comment and tag and check that the source made only its polls.
Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../camel-kamelets-catalog-sbom.json | 20 +++-
.../github-pullrequest-comment-source.kamelet.yaml | 26 ++++-
kamelets/github-pullrequest-source.kamelet.yaml | 28 ++++-
kamelets/github-tag-source.kamelet.yaml | 28 ++++-
.../main/resources/META-INF/kamelets-index.json | 6 +-
.../github-pullrequest-comment-source.kamelet.yaml | 26 ++++-
.../github-pullrequest-source.kamelet.yaml | 28 ++++-
.../kamelets/github-tag-source.kamelet.yaml | 28 ++++-
.../src/test/java/GitHubApiStub.java | 29 ++++-
.../github/api/repos/citrus/comment-demo.json | 23 ++++
.../comment-demo/issues/7/comments.first.json | 1 +
.../citrus/comment-demo/issues/7/comments.json | 23 ++++
.../api/repos/citrus/comment-demo/pulls.json | 114 +++++++++++++++++++
.../resources/github/api/repos/citrus/pr-demo.json | 23 ++++
.../api/repos/citrus/pr-demo/pulls.first.json | 1 +
.../github/api/repos/citrus/pr-demo/pulls.json | 124 +++++++++++++++++++++
.../github/api/repos/citrus/tag-demo.json | 23 ++++
.../api/repos/citrus/tag-demo/tags.first.json | 1 +
.../github/api/repos/citrus/tag-demo/tags.json | 12 ++
...pullrequest-comment-source-route.citrus.it.yaml | 88 +++++++++++++++
.../github-pullrequest-comment-source-route.yaml | 39 +++++++
.../github-pullrequest-source-route.citrus.it.yaml | 95 ++++++++++++++++
.../github/github-pullrequest-source-route.yaml | 42 +++++++
.../github/github-tag-source-route.citrus.it.yaml | 81 ++++++++++++++
.../resources/github/github-tag-source-route.yaml | 35 ++++++
.../src/test/resources/github/onlyPolls.groovy | 32 ++++++
26 files changed, 939 insertions(+), 37 deletions(-)
diff --git a/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
b/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
index 44920aeb0..9e09b8e3b 100644
--- a/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
+++ b/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
@@ -1804,6 +1804,17 @@
"name" : "camel.apache.org/versioned-by",
"value" : "runtime"
} ]
+ }, {
+ "bom-ref" : "pkg:maven/org.apache.camel/[email protected]",
+ "type" : "library",
+ "group" : "org.apache.camel",
+ "name" : "camel-jq",
+ "version" : "4.24.0-SNAPSHOT",
+ "purl" : "pkg:maven/org.apache.camel/[email protected]",
+ "properties" : [ {
+ "name" : "camel.apache.org/versioned-by",
+ "value" : "runtime"
+ } ]
}, {
"bom-ref" : "pkg:maven/org.apache.camel/[email protected]",
"type" : "library",
@@ -2541,13 +2552,13 @@
"dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
}, {
"ref" : "kamelet:github-pullrequest-comment-source",
- "dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
+ "dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
}, {
"ref" : "kamelet:github-pullrequest-source",
- "dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
+ "dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
}, {
"ref" : "kamelet:github-tag-source",
- "dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
+ "dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
}, {
"ref" : "kamelet:google-bigquery-sink",
"dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
@@ -3142,6 +3153,9 @@
}, {
"ref" : "pkg:maven/org.apache.camel/[email protected]",
"dependsOn" : [ ]
+ }, {
+ "ref" : "pkg:maven/org.apache.camel/[email protected]",
+ "dependsOn" : [ ]
}, {
"ref" : "pkg:maven/org.apache.camel/[email protected]",
"dependsOn" : [ ]
diff --git a/kamelets/github-pullrequest-comment-source.kamelet.yaml
b/kamelets/github-pullrequest-comment-source.kamelet.yaml
index d904e4779..5df36b86a 100644
--- a/kamelets/github-pullrequest-comment-source.kamelet.yaml
+++ b/kamelets/github-pullrequest-comment-source.kamelet.yaml
@@ -35,7 +35,7 @@ spec:
Use it to react to the discussion on pull requests, for example to
answer a command written in a comment, such as `/retest`, or to forward the
comments to a chat channel. To receive the pull requests themselves, use
`github-pullrequest-source`.
- Output: the body is the comment as JSON text. The
`CamelGitHubPullRequest` header gives the number of the pull request it was
written on.
+ Output: the body is the comment as JSON text, an object with the fields
of the GitHub API that say what it is: `id`, `body` (the text of the comment),
`html_url` (its web address), `user.login` (its author), `author_association`
(the role of the author in the repository, such as `OWNER` or `CONTRIBUTOR`),
`created_at` and `updated_at`. The `CamelGitHubPullRequest` header gives the
number of the pull request it was written on.
Good to know: only the comments written after the start are sent, and
only on pull requests that are still open. These are the comments of the
conversation of a pull request, not the review comments on lines of code. It
works with github.com, not with GitHub Enterprise Server. Once a minute by
default (`delay`), it asks GitHub for the open pull requests and for the
comments of each of them, and every request counts against the API rate limit
of the token.
required:
@@ -77,14 +77,32 @@ spec:
out:
mediaType: application/json
dependencies:
- - "camel:jackson3"
- "camel:github2"
+ - "camel:jq"
- "camel:kamelet"
template:
+ beans:
+ # writes the object from its fields, as the GitHub library reads it:
unlike its getters, this asks GitHub
+ # for nothing more
+ - name: gitHubJson
+ type: "#class:org.kohsuke.github.GitHub"
+ factoryMethod: getMappingObjectWriter
from:
uri:
"github2://pullRequestComment?oauthToken=RAW({{oauthToken}})&repoName={{repoName}}&repoOwner={{repoOwner}}&delay={{delay}}"
steps:
- - marshal:
- json: {}
+ - bean:
+ ref: "{{gitHubJson}}"
+ method: writeValueAsString
+ # keep the fields the description lists
+ - transform:
+ expression:
+ jq:
+ resultType: java.lang.String
+ expression: "{id: .id, body: .body, html_url: .html_url, user:
{login: .user.login}, author_association: .author_association, created_at:
.created_at, updated_at: .updated_at}"
+ - setHeader:
+ name: Content-Type
+ expression:
+ constant:
+ expression: application/json
- to:
uri: kamelet:sink
diff --git a/kamelets/github-pullrequest-source.kamelet.yaml
b/kamelets/github-pullrequest-source.kamelet.yaml
index e30bc0382..67dce21f2 100644
--- a/kamelets/github-pullrequest-source.kamelet.yaml
+++ b/kamelets/github-pullrequest-source.kamelet.yaml
@@ -35,9 +35,9 @@ spec:
Use it to react when someone proposes a change, for example to announce
the pull request in a chat channel, open a review ticket or start a check. To
receive the comments on pull requests, use `github-pullrequest-comment-source`.
- Output: the body is the pull request as JSON text. The
`CamelGitHubPullRequest` header gives its number, and
`CamelGitHubPullRequestHeadCommitSha` the SHA of its latest commit.
+ Output: the body is the pull request as JSON text, an object with the
fields of the GitHub API that say what it is: `number`, `title`, `body` (its
description), `state`, `draft`, `html_url` (its web address), `user.login` (its
author), `head` and `base` (the branch it comes from and the branch it goes to,
each with `ref`, `sha` and `label`), `labels` (each with its `name`),
`created_at` and `updated_at`. The `CamelGitHubPullRequest` header gives its
number, and `CamelGitHubPullRequ [...]
- Good to know: only the pull requests opened after the start are sent,
once each; updates, merges and closes are not. It works with github.com, not
with GitHub Enterprise Server. It asks GitHub for new pull requests once a
minute by default (`delay`), and every request counts against the API rate
limit of the token.
+ Good to know: only the pull requests opened after the start are sent,
once each; updates, merges and closes are not. The body holds only what GitHub
gives in its list of pull requests, so no more requests are made per pull
request; the size of the change, such as its additions or commits, and whether
it can be merged are not in it. It works with github.com, not with GitHub
Enterprise Server. It asks GitHub for new pull requests once a minute by
default (`delay`), and every request [...]
required:
- repoName
- repoOwner
@@ -81,14 +81,32 @@ spec:
out:
mediaType: application/json
dependencies:
- - "camel:jackson3"
- "camel:github2"
+ - "camel:jq"
- "camel:kamelet"
template:
+ beans:
+ # writes the object from its fields, as the GitHub library reads it:
unlike its getters, this asks GitHub
+ # for nothing more
+ - name: gitHubJson
+ type: "#class:org.kohsuke.github.GitHub"
+ factoryMethod: getMappingObjectWriter
from:
uri:
"github2://pullRequest?oauthToken=RAW({{oauthToken}})&repoName={{repoName}}&repoOwner={{repoOwner}}&delay={{delay}}"
steps:
- - marshal:
- json: {}
+ - bean:
+ ref: "{{gitHubJson}}"
+ method: writeValueAsString
+ # keep the fields the description lists
+ - transform:
+ expression:
+ jq:
+ resultType: java.lang.String
+ expression: "{number: .number, title: .title, body: .body,
state: .state, draft: .draft, html_url: .html_url, user: {login: .user.login},
head: {ref: .head.ref, sha: .head.sha, label: .head.label}, base: {ref:
.base.ref, sha: .base.sha, label: .base.label}, labels: [.labels[]? | {name:
.name}], created_at: .created_at, updated_at: .updated_at}"
+ - setHeader:
+ name: Content-Type
+ expression:
+ constant:
+ expression: application/json
- to:
uri: kamelet:sink
diff --git a/kamelets/github-tag-source.kamelet.yaml
b/kamelets/github-tag-source.kamelet.yaml
index 5e7cad280..a548d5070 100644
--- a/kamelets/github-tag-source.kamelet.yaml
+++ b/kamelets/github-tag-source.kamelet.yaml
@@ -35,9 +35,9 @@ spec:
Use it to react to a new version, for example to announce a release,
update a changelog or start a deployment. To receive every commit instead, use
`github-commit-source`.
- Output: the body is the tag as JSON text.
+ Output: the body is the tag as JSON text, an object with its `name`,
such as `v1.0.0`, and `commit.sha`, the SHA of the commit it points to.
- Good to know: only the tags created after the start are sent; the tags
that exist when it starts are skipped. It works with github.com, not with
GitHub Enterprise Server. It asks GitHub for the tags once a minute by default
(`delay`), and every request counts against the API rate limit of the token.
+ Good to know: only the tags created after the start are sent; the tags
that exist when it starts are skipped. GitHub lists a tag without its date or
the message of an annotated tag, so they are not in the body. It works with
github.com, not with GitHub Enterprise Server. It asks GitHub for the tags once
a minute by default (`delay`), and every request counts against the API rate
limit of the token.
required:
- repoName
- repoOwner
@@ -70,14 +70,32 @@ spec:
out:
mediaType: application/json
dependencies:
- - "camel:jackson3"
- "camel:github2"
+ - "camel:jq"
- "camel:kamelet"
template:
+ beans:
+ # writes the object from its fields, as the GitHub library reads it:
unlike its getters, this asks GitHub
+ # for nothing more
+ - name: gitHubJson
+ type: "#class:org.kohsuke.github.GitHub"
+ factoryMethod: getMappingObjectWriter
from:
uri:
"github2://tag?oauthToken=RAW({{oauthToken}})&repoName={{repoName}}&repoOwner={{repoOwner}}&delay={{delay}}"
steps:
- - marshal:
- json: {}
+ - bean:
+ ref: "{{gitHubJson}}"
+ method: writeValueAsString
+ # keep the fields the description lists
+ - transform:
+ expression:
+ jq:
+ resultType: java.lang.String
+ expression: "{name: .name, commit: {sha: .commit.sha}}"
+ - setHeader:
+ name: Content-Type
+ expression:
+ constant:
+ expression: application/json
- to:
uri: kamelet:sink
diff --git
a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
index b9a01f81f..88de20164 100644
--- a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
+++ b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
@@ -845,7 +845,7 @@
"supportLevel" : "Stable",
"title" : "GitHub Pull Request Comments Source",
"summary" : "Receives each new comment written on the open pull requests
of a GitHub repository, one message per comment, by asking the GitHub API for
new comments.",
- "description" : "Receives each new comment written on the open pull
requests of a GitHub repository, one message per comment, by asking the GitHub
API for new comments.\n\nUse it to react to the discussion on pull requests,
for example to answer a command written in a comment, such as `/retest`, or to
forward the comments to a chat channel. To receive the pull requests
themselves, use `github-pullrequest-source`.\n\nOutput: the body is the comment
as JSON text. The `CamelGitHubPullRe [...]
+ "description" : "Receives each new comment written on the open pull
requests of a GitHub repository, one message per comment, by asking the GitHub
API for new comments.\n\nUse it to react to the discussion on pull requests,
for example to answer a command written in a comment, such as `/retest`, or to
forward the comments to a chat channel. To receive the pull requests
themselves, use `github-pullrequest-source`.\n\nOutput: the body is the comment
as JSON text, an object with the fie [...]
"group" : "GitHub",
"namespace" : "Cloud",
"provider" : "Apache Software Foundation"
@@ -855,7 +855,7 @@
"supportLevel" : "Stable",
"title" : "GitHub Pull Request Source",
"summary" : "Receives each new pull request opened in a GitHub repository,
one message per pull request, by asking the GitHub API for new open pull
requests.",
- "description" : "Receives each new pull request opened in a GitHub
repository, one message per pull request, by asking the GitHub API for new open
pull requests.\n\nUse it to react when someone proposes a change, for example
to announce the pull request in a chat channel, open a review ticket or start a
check. To receive the comments on pull requests, use
`github-pullrequest-comment-source`.\n\nOutput: the body is the pull request as
JSON text. The `CamelGitHubPullRequest` header giv [...]
+ "description" : "Receives each new pull request opened in a GitHub
repository, one message per pull request, by asking the GitHub API for new open
pull requests.\n\nUse it to react when someone proposes a change, for example
to announce the pull request in a chat channel, open a review ticket or start a
check. To receive the comments on pull requests, use
`github-pullrequest-comment-source`.\n\nOutput: the body is the pull request as
JSON text, an object with the fields of the GitHub [...]
"group" : "GitHub",
"namespace" : "Cloud",
"provider" : "Apache Software Foundation"
@@ -865,7 +865,7 @@
"supportLevel" : "Stable",
"title" : "GitHub Tag Source",
"summary" : "Receives each new tag created in a GitHub repository, one
message per tag, by asking the GitHub API for the tags of the repository.",
- "description" : "Receives each new tag created in a GitHub repository, one
message per tag, by asking the GitHub API for the tags of the
repository.\n\nUse it to react to a new version, for example to announce a
release, update a changelog or start a deployment. To receive every commit
instead, use `github-commit-source`.\n\nOutput: the body is the tag as JSON
text.\n\nGood to know: only the tags created after the start are sent; the tags
that exist when it starts are skipped. It wor [...]
+ "description" : "Receives each new tag created in a GitHub repository, one
message per tag, by asking the GitHub API for the tags of the
repository.\n\nUse it to react to a new version, for example to announce a
release, update a changelog or start a deployment. To receive every commit
instead, use `github-commit-source`.\n\nOutput: the body is the tag as JSON
text, an object with its `name`, such as `v1.0.0`, and `commit.sha`, the SHA of
the commit it points to.\n\nGood to know: onl [...]
"group" : "GitHub",
"namespace" : "Cloud",
"provider" : "Apache Software Foundation"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/github-pullrequest-comment-source.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/github-pullrequest-comment-source.kamelet.yaml
index d904e4779..5df36b86a 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/github-pullrequest-comment-source.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/github-pullrequest-comment-source.kamelet.yaml
@@ -35,7 +35,7 @@ spec:
Use it to react to the discussion on pull requests, for example to
answer a command written in a comment, such as `/retest`, or to forward the
comments to a chat channel. To receive the pull requests themselves, use
`github-pullrequest-source`.
- Output: the body is the comment as JSON text. The
`CamelGitHubPullRequest` header gives the number of the pull request it was
written on.
+ Output: the body is the comment as JSON text, an object with the fields
of the GitHub API that say what it is: `id`, `body` (the text of the comment),
`html_url` (its web address), `user.login` (its author), `author_association`
(the role of the author in the repository, such as `OWNER` or `CONTRIBUTOR`),
`created_at` and `updated_at`. The `CamelGitHubPullRequest` header gives the
number of the pull request it was written on.
Good to know: only the comments written after the start are sent, and
only on pull requests that are still open. These are the comments of the
conversation of a pull request, not the review comments on lines of code. It
works with github.com, not with GitHub Enterprise Server. Once a minute by
default (`delay`), it asks GitHub for the open pull requests and for the
comments of each of them, and every request counts against the API rate limit
of the token.
required:
@@ -77,14 +77,32 @@ spec:
out:
mediaType: application/json
dependencies:
- - "camel:jackson3"
- "camel:github2"
+ - "camel:jq"
- "camel:kamelet"
template:
+ beans:
+ # writes the object from its fields, as the GitHub library reads it:
unlike its getters, this asks GitHub
+ # for nothing more
+ - name: gitHubJson
+ type: "#class:org.kohsuke.github.GitHub"
+ factoryMethod: getMappingObjectWriter
from:
uri:
"github2://pullRequestComment?oauthToken=RAW({{oauthToken}})&repoName={{repoName}}&repoOwner={{repoOwner}}&delay={{delay}}"
steps:
- - marshal:
- json: {}
+ - bean:
+ ref: "{{gitHubJson}}"
+ method: writeValueAsString
+ # keep the fields the description lists
+ - transform:
+ expression:
+ jq:
+ resultType: java.lang.String
+ expression: "{id: .id, body: .body, html_url: .html_url, user:
{login: .user.login}, author_association: .author_association, created_at:
.created_at, updated_at: .updated_at}"
+ - setHeader:
+ name: Content-Type
+ expression:
+ constant:
+ expression: application/json
- to:
uri: kamelet:sink
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/github-pullrequest-source.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/github-pullrequest-source.kamelet.yaml
index e30bc0382..67dce21f2 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/github-pullrequest-source.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/github-pullrequest-source.kamelet.yaml
@@ -35,9 +35,9 @@ spec:
Use it to react when someone proposes a change, for example to announce
the pull request in a chat channel, open a review ticket or start a check. To
receive the comments on pull requests, use `github-pullrequest-comment-source`.
- Output: the body is the pull request as JSON text. The
`CamelGitHubPullRequest` header gives its number, and
`CamelGitHubPullRequestHeadCommitSha` the SHA of its latest commit.
+ Output: the body is the pull request as JSON text, an object with the
fields of the GitHub API that say what it is: `number`, `title`, `body` (its
description), `state`, `draft`, `html_url` (its web address), `user.login` (its
author), `head` and `base` (the branch it comes from and the branch it goes to,
each with `ref`, `sha` and `label`), `labels` (each with its `name`),
`created_at` and `updated_at`. The `CamelGitHubPullRequest` header gives its
number, and `CamelGitHubPullRequ [...]
- Good to know: only the pull requests opened after the start are sent,
once each; updates, merges and closes are not. It works with github.com, not
with GitHub Enterprise Server. It asks GitHub for new pull requests once a
minute by default (`delay`), and every request counts against the API rate
limit of the token.
+ Good to know: only the pull requests opened after the start are sent,
once each; updates, merges and closes are not. The body holds only what GitHub
gives in its list of pull requests, so no more requests are made per pull
request; the size of the change, such as its additions or commits, and whether
it can be merged are not in it. It works with github.com, not with GitHub
Enterprise Server. It asks GitHub for new pull requests once a minute by
default (`delay`), and every request [...]
required:
- repoName
- repoOwner
@@ -81,14 +81,32 @@ spec:
out:
mediaType: application/json
dependencies:
- - "camel:jackson3"
- "camel:github2"
+ - "camel:jq"
- "camel:kamelet"
template:
+ beans:
+ # writes the object from its fields, as the GitHub library reads it:
unlike its getters, this asks GitHub
+ # for nothing more
+ - name: gitHubJson
+ type: "#class:org.kohsuke.github.GitHub"
+ factoryMethod: getMappingObjectWriter
from:
uri:
"github2://pullRequest?oauthToken=RAW({{oauthToken}})&repoName={{repoName}}&repoOwner={{repoOwner}}&delay={{delay}}"
steps:
- - marshal:
- json: {}
+ - bean:
+ ref: "{{gitHubJson}}"
+ method: writeValueAsString
+ # keep the fields the description lists
+ - transform:
+ expression:
+ jq:
+ resultType: java.lang.String
+ expression: "{number: .number, title: .title, body: .body,
state: .state, draft: .draft, html_url: .html_url, user: {login: .user.login},
head: {ref: .head.ref, sha: .head.sha, label: .head.label}, base: {ref:
.base.ref, sha: .base.sha, label: .base.label}, labels: [.labels[]? | {name:
.name}], created_at: .created_at, updated_at: .updated_at}"
+ - setHeader:
+ name: Content-Type
+ expression:
+ constant:
+ expression: application/json
- to:
uri: kamelet:sink
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/github-tag-source.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/github-tag-source.kamelet.yaml
index 5e7cad280..a548d5070 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/github-tag-source.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/github-tag-source.kamelet.yaml
@@ -35,9 +35,9 @@ spec:
Use it to react to a new version, for example to announce a release,
update a changelog or start a deployment. To receive every commit instead, use
`github-commit-source`.
- Output: the body is the tag as JSON text.
+ Output: the body is the tag as JSON text, an object with its `name`,
such as `v1.0.0`, and `commit.sha`, the SHA of the commit it points to.
- Good to know: only the tags created after the start are sent; the tags
that exist when it starts are skipped. It works with github.com, not with
GitHub Enterprise Server. It asks GitHub for the tags once a minute by default
(`delay`), and every request counts against the API rate limit of the token.
+ Good to know: only the tags created after the start are sent; the tags
that exist when it starts are skipped. GitHub lists a tag without its date or
the message of an annotated tag, so they are not in the body. It works with
github.com, not with GitHub Enterprise Server. It asks GitHub for the tags once
a minute by default (`delay`), and every request counts against the API rate
limit of the token.
required:
- repoName
- repoOwner
@@ -70,14 +70,32 @@ spec:
out:
mediaType: application/json
dependencies:
- - "camel:jackson3"
- "camel:github2"
+ - "camel:jq"
- "camel:kamelet"
template:
+ beans:
+ # writes the object from its fields, as the GitHub library reads it:
unlike its getters, this asks GitHub
+ # for nothing more
+ - name: gitHubJson
+ type: "#class:org.kohsuke.github.GitHub"
+ factoryMethod: getMappingObjectWriter
from:
uri:
"github2://tag?oauthToken=RAW({{oauthToken}})&repoName={{repoName}}&repoOwner={{repoOwner}}&delay={{delay}}"
steps:
- - marshal:
- json: {}
+ - bean:
+ ref: "{{gitHubJson}}"
+ method: writeValueAsString
+ # keep the fields the description lists
+ - transform:
+ expression:
+ jq:
+ resultType: java.lang.String
+ expression: "{name: .name, commit: {sha: .commit.sha}}"
+ - setHeader:
+ name: Content-Type
+ expression:
+ constant:
+ expression: application/json
- to:
uri: kamelet:sink
diff --git a/tests/camel-kamelets-itest/src/test/java/GitHubApiStub.java
b/tests/camel-kamelets-itest/src/test/java/GitHubApiStub.java
index bea703083..d41f1fce1 100644
--- a/tests/camel-kamelets-itest/src/test/java/GitHubApiStub.java
+++ b/tests/camel-kamelets-itest/src/test/java/GitHubApiStub.java
@@ -19,6 +19,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import org.citrusframework.base.endpoint.adapter.StaticEndpointAdapter;
@@ -33,8 +35,11 @@ import org.springframework.http.HttpStatus;
* Stands in for the GitHub API in the tests of the GitHub sources: answers a
request with the canned JSON in the
* resource {@code github/api/<path>.json}, where the path is the path of the
request without its query, such as
* {@code repos/citrus/demo/commits}. The addresses of the GitHub API in the
answers, which the GitHub client
- * follows to read more of an object, are changed to the address of the
stand-in. Other requests get 404, as from
- * GitHub, and are listed in {@link #unknown()}.
+ * follows to read more of an object, are changed to the address of the
stand-in. When the resource
+ * {@code github/api/<path>.first.json} exists, it is the answer to the first
request for that path after
+ * {@link #reset()} instead, so a source that remembers what exists when it
starts can be shown something new
+ * afterwards. Other requests get 404, as from GitHub, and are listed in
{@link #unknown()}. Every request is
+ * listed in {@link #requests()}, so a test can check that a source asked for
nothing more than it should.
*/
public class GitHubApiStub extends StaticEndpointAdapter {
@@ -46,18 +51,28 @@ public class GitHubApiStub extends StaticEndpointAdapter {
private final List<String> unknown = new CopyOnWriteArrayList<>();
+ private final List<String> requests = new CopyOnWriteArrayList<>();
+
+ private final Set<String> answered = ConcurrentHashMap.newKeySet();
+
public GitHubApiStub(int port) {
this.apiUrl = "http://localhost:" + port;
}
public void reset() {
unknown.clear();
+ requests.clear();
+ answered.clear();
}
public List<String> unknown() {
return unknown;
}
+ public List<String> requests() {
+ return requests;
+ }
+
@Override
protected Message handleMessageInternal(Message request) {
String path =
String.valueOf(request.getHeader(HttpMessageHeaders.HTTP_REQUEST_URI));
@@ -66,8 +81,16 @@ public class GitHubApiStub extends StaticEndpointAdapter {
path = path.substring(0, query);
}
path = path.replaceAll("^/+|/+$", "");
+ LOG.info("GitHub API request {}", path);
+ requests.add(path);
- String json = load("github/api/" + path + ".json");
+ String json = null;
+ if (answered.add(path)) {
+ json = load("github/api/" + path + ".first.json");
+ }
+ if (json == null) {
+ json = load("github/api/" + path + ".json");
+ }
if (json != null) {
return new HttpMessage(json.replace(GITHUB_API, apiUrl))
.status(HttpStatus.OK).contentType("application/json;
charset=utf-8");
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/comment-demo.json
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/comment-demo.json
new file mode 100644
index 000000000..80dc60585
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/comment-demo.json
@@ -0,0 +1,23 @@
+{
+ "id": 12,
+ "node_id": "R_12",
+ "name": "comment-demo",
+ "full_name": "citrus/comment-demo",
+ "private": false,
+ "owner": {
+ "login": "citrus",
+ "id": 1,
+ "node_id": "U_1",
+ "avatar_url": "https://avatars.githubusercontent.com/u/1",
+ "url": "https://api.github.com/users/citrus",
+ "html_url": "https://github.com/citrus",
+ "type": "User",
+ "site_admin": false
+ },
+ "html_url": "https://github.com/citrus/comment-demo",
+ "url": "https://api.github.com/repos/citrus/comment-demo",
+ "default_branch": "main",
+ "created_at": "2026-01-01T10:00:00Z",
+ "updated_at": "2026-11-01T10:00:00Z",
+ "pushed_at": "2026-11-01T10:00:00Z"
+}
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/comment-demo/issues/7/comments.first.json
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/comment-demo/issues/7/comments.first.json
new file mode 100644
index 000000000..fe51488c7
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/comment-demo/issues/7/comments.first.json
@@ -0,0 +1 @@
+[]
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/comment-demo/issues/7/comments.json
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/comment-demo/issues/7/comments.json
new file mode 100644
index 000000000..34c24a7c9
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/comment-demo/issues/7/comments.json
@@ -0,0 +1,23 @@
+[
+ {
+ "url":
"https://api.github.com/repos/citrus/comment-demo/issues/comments/701",
+ "html_url":
"https://github.com/citrus/comment-demo/pull/7#issuecomment-701",
+ "issue_url": "https://api.github.com/repos/citrus/comment-demo/issues/7",
+ "id": 701,
+ "node_id": "IC_701",
+ "user": {
+ "login": "john",
+ "id": 3,
+ "node_id": "U_3",
+ "avatar_url": "https://avatars.githubusercontent.com/u/3",
+ "url": "https://api.github.com/users/john",
+ "html_url": "https://github.com/john",
+ "type": "User",
+ "site_admin": false
+ },
+ "created_at": "2026-11-04T10:00:00Z",
+ "updated_at": "2026-11-04T10:00:00Z",
+ "author_association": "OWNER",
+ "body": "/retest"
+ }
+]
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/comment-demo/pulls.json
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/comment-demo/pulls.json
new file mode 100644
index 000000000..7137f68f0
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/comment-demo/pulls.json
@@ -0,0 +1,114 @@
+[
+ {
+ "url": "https://api.github.com/repos/citrus/comment-demo/pulls/7",
+ "id": 107,
+ "node_id": "PR_7",
+ "html_url": "https://github.com/citrus/comment-demo/pull/7",
+ "diff_url": "https://github.com/citrus/comment-demo/pull/7.diff",
+ "patch_url": "https://github.com/citrus/comment-demo/pull/7.patch",
+ "issue_url": "https://api.github.com/repos/citrus/comment-demo/issues/7",
+ "number": 7,
+ "state": "open",
+ "locked": false,
+ "title": "Fix the login page",
+ "user": {
+ "login": "jane",
+ "id": 2,
+ "node_id": "U_2",
+ "avatar_url": "https://avatars.githubusercontent.com/u/2",
+ "url": "https://api.github.com/users/jane",
+ "html_url": "https://github.com/jane",
+ "type": "User",
+ "site_admin": false
+ },
+ "body": "The login page did not load.",
+ "created_at": "2026-11-03T10:00:00Z",
+ "updated_at": "2026-11-03T10:00:00Z",
+ "closed_at": null,
+ "merged_at": null,
+ "merge_commit_sha": null,
+ "assignees": [],
+ "requested_reviewers": [],
+ "requested_teams": [],
+ "labels": [],
+ "milestone": null,
+ "draft": false,
+ "head": {
+ "label": "jane:fix-login",
+ "ref": "fix-login",
+ "sha": "3333333333333333333333333333333333333333",
+ "user": {
+ "login": "jane",
+ "id": 2,
+ "node_id": "U_2",
+ "avatar_url": "https://avatars.githubusercontent.com/u/2",
+ "url": "https://api.github.com/users/jane",
+ "html_url": "https://github.com/jane",
+ "type": "User",
+ "site_admin": false
+ },
+ "repo": {
+ "id": 12,
+ "node_id": "R_12",
+ "name": "comment-demo",
+ "full_name": "citrus/comment-demo",
+ "private": false,
+ "owner": {
+ "login": "citrus",
+ "id": 1,
+ "node_id": "U_1",
+ "avatar_url": "https://avatars.githubusercontent.com/u/1",
+ "url": "https://api.github.com/users/citrus",
+ "html_url": "https://github.com/citrus",
+ "type": "User",
+ "site_admin": false
+ },
+ "html_url": "https://github.com/citrus/comment-demo",
+ "url": "https://api.github.com/repos/citrus/comment-demo",
+ "default_branch": "main",
+ "created_at": "2026-01-01T10:00:00Z",
+ "updated_at": "2026-11-01T10:00:00Z",
+ "pushed_at": "2026-11-01T10:00:00Z"
+ }
+ },
+ "base": {
+ "label": "citrus:main",
+ "ref": "main",
+ "sha": "1111111111111111111111111111111111111111",
+ "user": {
+ "login": "citrus",
+ "id": 1,
+ "node_id": "U_1",
+ "avatar_url": "https://avatars.githubusercontent.com/u/1",
+ "url": "https://api.github.com/users/citrus",
+ "html_url": "https://github.com/citrus",
+ "type": "User",
+ "site_admin": false
+ },
+ "repo": {
+ "id": 12,
+ "node_id": "R_12",
+ "name": "comment-demo",
+ "full_name": "citrus/comment-demo",
+ "private": false,
+ "owner": {
+ "login": "citrus",
+ "id": 1,
+ "node_id": "U_1",
+ "avatar_url": "https://avatars.githubusercontent.com/u/1",
+ "url": "https://api.github.com/users/citrus",
+ "html_url": "https://github.com/citrus",
+ "type": "User",
+ "site_admin": false
+ },
+ "html_url": "https://github.com/citrus/comment-demo",
+ "url": "https://api.github.com/repos/citrus/comment-demo",
+ "default_branch": "main",
+ "created_at": "2026-01-01T10:00:00Z",
+ "updated_at": "2026-11-01T10:00:00Z",
+ "pushed_at": "2026-11-01T10:00:00Z"
+ }
+ },
+ "author_association": "CONTRIBUTOR"
+ }
+]
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/pr-demo.json
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/pr-demo.json
new file mode 100644
index 000000000..e00b36718
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/pr-demo.json
@@ -0,0 +1,23 @@
+{
+ "id": 11,
+ "node_id": "R_11",
+ "name": "pr-demo",
+ "full_name": "citrus/pr-demo",
+ "private": false,
+ "owner": {
+ "login": "citrus",
+ "id": 1,
+ "node_id": "U_1",
+ "avatar_url": "https://avatars.githubusercontent.com/u/1",
+ "url": "https://api.github.com/users/citrus",
+ "html_url": "https://github.com/citrus",
+ "type": "User",
+ "site_admin": false
+ },
+ "html_url": "https://github.com/citrus/pr-demo",
+ "url": "https://api.github.com/repos/citrus/pr-demo",
+ "default_branch": "main",
+ "created_at": "2026-01-01T10:00:00Z",
+ "updated_at": "2026-11-01T10:00:00Z",
+ "pushed_at": "2026-11-01T10:00:00Z"
+}
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/pr-demo/pulls.first.json
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/pr-demo/pulls.first.json
new file mode 100644
index 000000000..fe51488c7
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/pr-demo/pulls.first.json
@@ -0,0 +1 @@
+[]
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/pr-demo/pulls.json
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/pr-demo/pulls.json
new file mode 100644
index 000000000..2ba331065
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/pr-demo/pulls.json
@@ -0,0 +1,124 @@
+[
+ {
+ "url": "https://api.github.com/repos/citrus/pr-demo/pulls/7",
+ "id": 107,
+ "node_id": "PR_7",
+ "html_url": "https://github.com/citrus/pr-demo/pull/7",
+ "diff_url": "https://github.com/citrus/pr-demo/pull/7.diff",
+ "patch_url": "https://github.com/citrus/pr-demo/pull/7.patch",
+ "issue_url": "https://api.github.com/repos/citrus/pr-demo/issues/7",
+ "number": 7,
+ "state": "open",
+ "locked": false,
+ "title": "Fix the login page",
+ "user": {
+ "login": "jane",
+ "id": 2,
+ "node_id": "U_2",
+ "avatar_url": "https://avatars.githubusercontent.com/u/2",
+ "url": "https://api.github.com/users/jane",
+ "html_url": "https://github.com/jane",
+ "type": "User",
+ "site_admin": false
+ },
+ "body": "The login page did not load.",
+ "created_at": "2026-11-03T10:00:00Z",
+ "updated_at": "2026-11-03T10:00:00Z",
+ "closed_at": null,
+ "merged_at": null,
+ "merge_commit_sha": null,
+ "assignees": [],
+ "requested_reviewers": [],
+ "requested_teams": [],
+ "labels": [
+ {
+ "id": 21,
+ "node_id": "LA_21",
+ "url": "https://api.github.com/repos/citrus/pr-demo/labels/bug",
+ "name": "bug",
+ "color": "d73a4a",
+ "default": true,
+ "description": "Something is not working"
+ }
+ ],
+ "milestone": null,
+ "draft": false,
+ "head": {
+ "label": "jane:fix-login",
+ "ref": "fix-login",
+ "sha": "3333333333333333333333333333333333333333",
+ "user": {
+ "login": "jane",
+ "id": 2,
+ "node_id": "U_2",
+ "avatar_url": "https://avatars.githubusercontent.com/u/2",
+ "url": "https://api.github.com/users/jane",
+ "html_url": "https://github.com/jane",
+ "type": "User",
+ "site_admin": false
+ },
+ "repo": {
+ "id": 11,
+ "node_id": "R_11",
+ "name": "pr-demo",
+ "full_name": "citrus/pr-demo",
+ "private": false,
+ "owner": {
+ "login": "citrus",
+ "id": 1,
+ "node_id": "U_1",
+ "avatar_url": "https://avatars.githubusercontent.com/u/1",
+ "url": "https://api.github.com/users/citrus",
+ "html_url": "https://github.com/citrus",
+ "type": "User",
+ "site_admin": false
+ },
+ "html_url": "https://github.com/citrus/pr-demo",
+ "url": "https://api.github.com/repos/citrus/pr-demo",
+ "default_branch": "main",
+ "created_at": "2026-01-01T10:00:00Z",
+ "updated_at": "2026-11-01T10:00:00Z",
+ "pushed_at": "2026-11-01T10:00:00Z"
+ }
+ },
+ "base": {
+ "label": "citrus:main",
+ "ref": "main",
+ "sha": "1111111111111111111111111111111111111111",
+ "user": {
+ "login": "citrus",
+ "id": 1,
+ "node_id": "U_1",
+ "avatar_url": "https://avatars.githubusercontent.com/u/1",
+ "url": "https://api.github.com/users/citrus",
+ "html_url": "https://github.com/citrus",
+ "type": "User",
+ "site_admin": false
+ },
+ "repo": {
+ "id": 11,
+ "node_id": "R_11",
+ "name": "pr-demo",
+ "full_name": "citrus/pr-demo",
+ "private": false,
+ "owner": {
+ "login": "citrus",
+ "id": 1,
+ "node_id": "U_1",
+ "avatar_url": "https://avatars.githubusercontent.com/u/1",
+ "url": "https://api.github.com/users/citrus",
+ "html_url": "https://github.com/citrus",
+ "type": "User",
+ "site_admin": false
+ },
+ "html_url": "https://github.com/citrus/pr-demo",
+ "url": "https://api.github.com/repos/citrus/pr-demo",
+ "default_branch": "main",
+ "created_at": "2026-01-01T10:00:00Z",
+ "updated_at": "2026-11-01T10:00:00Z",
+ "pushed_at": "2026-11-01T10:00:00Z"
+ }
+ },
+ "author_association": "CONTRIBUTOR"
+ }
+]
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/tag-demo.json
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/tag-demo.json
new file mode 100644
index 000000000..647f2e0f3
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/tag-demo.json
@@ -0,0 +1,23 @@
+{
+ "id": 13,
+ "node_id": "R_13",
+ "name": "tag-demo",
+ "full_name": "citrus/tag-demo",
+ "private": false,
+ "owner": {
+ "login": "citrus",
+ "id": 1,
+ "node_id": "U_1",
+ "avatar_url": "https://avatars.githubusercontent.com/u/1",
+ "url": "https://api.github.com/users/citrus",
+ "html_url": "https://github.com/citrus",
+ "type": "User",
+ "site_admin": false
+ },
+ "html_url": "https://github.com/citrus/tag-demo",
+ "url": "https://api.github.com/repos/citrus/tag-demo",
+ "default_branch": "main",
+ "created_at": "2026-01-01T10:00:00Z",
+ "updated_at": "2026-11-01T10:00:00Z",
+ "pushed_at": "2026-11-01T10:00:00Z"
+}
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/tag-demo/tags.first.json
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/tag-demo/tags.first.json
new file mode 100644
index 000000000..fe51488c7
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/tag-demo/tags.first.json
@@ -0,0 +1 @@
+[]
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/tag-demo/tags.json
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/tag-demo/tags.json
new file mode 100644
index 000000000..b914ad536
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/api/repos/citrus/tag-demo/tags.json
@@ -0,0 +1,12 @@
+[
+ {
+ "name": "v1.0.0",
+ "zipball_url":
"https://api.github.com/repos/citrus/tag-demo/zipball/refs/tags/v1.0.0",
+ "tarball_url":
"https://api.github.com/repos/citrus/tag-demo/tarball/refs/tags/v1.0.0",
+ "commit": {
+ "sha": "4444444444444444444444444444444444444444",
+ "url":
"https://api.github.com/repos/citrus/tag-demo/commits/4444444444444444444444444444444444444444"
+ },
+ "node_id": "REF_1"
+ }
+]
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/github-pullrequest-comment-source-route.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/github/github-pullrequest-comment-source-route.citrus.it.yaml
new file mode 100644
index 000000000..fc6b04fbd
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/github-pullrequest-comment-source-route.citrus.it.yaml
@@ -0,0 +1,88 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+name: github-pullrequest-comment-source-route-test
+description: 'github-pullrequest-comment-source sends a comment written after
the start as JSON text with the fields its description lists, with the number
of its pull request in a header, and asks the GitHub API for nothing more than
its polls'
+variables:
+ # the repository of the canned answers of this test, and the only requests
the source may make for it
+ - name: "github.api.repo"
+ value: "citrus/comment-demo"
+ - name: "github.api.expected"
+ value:
"user,repos/citrus/comment-demo,repos/citrus/comment-demo/pulls,repos/citrus/comment-demo/issues/7/comments"
+actions:
+ # The stand-in of the GitHub API answers with canned JSON for the repository
citrus/comment-demo: pull request #7 has no comment when the source starts,
then one
+ - groovy:
+ script:
+ file: "github/resetApi.groovy"
+
+ # Create Camel JBang integration
+ - camel:
+ cli:
+ run:
+ waitForRunningState: false
+ integration:
+ file: "github/github-pullrequest-comment-source-route.yaml"
+ systemProperties:
+ properties:
+ - name: "http.sink.url"
+ value: "http://localhost:${cloud.http.server.port}"
+ # the GitHub API is the stand-in of the test
+ - name: "camel.component.github2.apiUrl"
+ value: "http://localhost:${github.api.port}"
+
+ # The new comment
+ - http:
+ server: "cloudHttpServer"
+ receiveRequest:
+ POST:
+ path: "/result"
+ type: "json"
+ headers:
+ - name: "X-Body-Type"
+ value: 'java.lang.String'
+ - name: "X-Content-Type"
+ value: 'ct=application/json'
+ - name: "X-Pull-Request"
+ value: '7'
+ body:
+ data: |
+ {
+ "id": 701,
+ "body": "/retest",
+ "html_url":
"https://github.com/citrus/comment-demo/pull/7#issuecomment-701",
+ "user": { "login": "john" },
+ "author_association": "OWNER",
+ "created_at": "2026-11-04T10:00:00Z",
+ "updated_at": "2026-11-04T10:00:00Z"
+ }
+ - http:
+ server: "cloudHttpServer"
+ sendResponse:
+ response:
+ status: 200
+ reasonPhrase: "OK"
+ version: "HTTP/1.1"
+
+ # The source asked the GitHub API for nothing per message: no user, commit
or pull request details
+ - groovy:
+ script:
+ file: "github/onlyPolls.groovy"
+
+ # and only for what it has canned answers for
+ - groovy:
+ script:
+ file: "github/noUnknownRequests.groovy"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/github-pullrequest-comment-source-route.yaml
b/tests/camel-kamelets-itest/src/test/resources/github/github-pullrequest-comment-source-route.yaml
new file mode 100644
index 000000000..5db5bcec0
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/github-pullrequest-comment-source-route.yaml
@@ -0,0 +1,39 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+- route:
+ from:
+ uri: "kamelet:github-pullrequest-comment-source"
+ parameters:
+ oauthToken: 'not-a-real-token'
+ repoOwner: 'citrus'
+ repoName: 'comment-demo'
+ delay: 1000
+ steps:
+ # what the Kamelet gives: the Java type of the body and the
Content-Type
+ - setHeader:
+ name: X-Body-Type
+ simple: "${body.getClass().getName()}"
+ - setHeader:
+ name: X-Content-Type
+ simple: "ct=${header.Content-Type}"
+ # Camel headers are not sent over HTTP: copy them
+ - setHeader:
+ name: X-Pull-Request
+ simple: "${header.CamelGitHubPullRequest}"
+ - to:
+ uri: "{{http.sink.url}}/result"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/github-pullrequest-source-route.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/github/github-pullrequest-source-route.citrus.it.yaml
new file mode 100644
index 000000000..5f756ca86
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/github-pullrequest-source-route.citrus.it.yaml
@@ -0,0 +1,95 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+name: github-pullrequest-source-route-test
+description: 'github-pullrequest-source sends a pull request opened after the
start as JSON text with the fields its description lists, with its number and
head commit in headers, and asks the GitHub API for nothing more than its polls'
+variables:
+ # the repository of the canned answers of this test, and the only requests
the source may make for it
+ - name: "github.api.repo"
+ value: "citrus/pr-demo"
+ - name: "github.api.expected"
+ value: "user,repos/citrus/pr-demo,repos/citrus/pr-demo/pulls"
+actions:
+ # The stand-in of the GitHub API answers with canned JSON for the repository
citrus/pr-demo: no pull request when the source starts, then pull request #7
+ - groovy:
+ script:
+ file: "github/resetApi.groovy"
+
+ # Create Camel JBang integration
+ - camel:
+ cli:
+ run:
+ waitForRunningState: false
+ integration:
+ file: "github/github-pullrequest-source-route.yaml"
+ systemProperties:
+ properties:
+ - name: "http.sink.url"
+ value: "http://localhost:${cloud.http.server.port}"
+ # the GitHub API is the stand-in of the test
+ - name: "camel.component.github2.apiUrl"
+ value: "http://localhost:${github.api.port}"
+
+ # The new pull request
+ - http:
+ server: "cloudHttpServer"
+ receiveRequest:
+ POST:
+ path: "/result"
+ type: "json"
+ headers:
+ - name: "X-Body-Type"
+ value: 'java.lang.String'
+ - name: "X-Content-Type"
+ value: 'ct=application/json'
+ - name: "X-Pull-Request"
+ value: '7'
+ - name: "X-Head-Commit-Sha"
+ value: '3333333333333333333333333333333333333333'
+ body:
+ data: |
+ {
+ "number": 7,
+ "title": "Fix the login page",
+ "body": "The login page did not load.",
+ "state": "open",
+ "draft": false,
+ "html_url": "https://github.com/citrus/pr-demo/pull/7",
+ "user": { "login": "jane" },
+ "head": { "ref": "fix-login", "sha":
"3333333333333333333333333333333333333333", "label": "jane:fix-login" },
+ "base": { "ref": "main", "sha":
"1111111111111111111111111111111111111111", "label": "citrus:main" },
+ "labels": [ { "name": "bug" } ],
+ "created_at": "2026-11-03T10:00:00Z",
+ "updated_at": "2026-11-03T10:00:00Z"
+ }
+ - http:
+ server: "cloudHttpServer"
+ sendResponse:
+ response:
+ status: 200
+ reasonPhrase: "OK"
+ version: "HTTP/1.1"
+
+ # The source asked the GitHub API for nothing per message: no user, commit
or pull request details
+ - groovy:
+ script:
+ file: "github/onlyPolls.groovy"
+
+ # and only for what it has canned answers for
+ - groovy:
+ script:
+ file: "github/noUnknownRequests.groovy"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/github-pullrequest-source-route.yaml
b/tests/camel-kamelets-itest/src/test/resources/github/github-pullrequest-source-route.yaml
new file mode 100644
index 000000000..63eed6bf3
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/github-pullrequest-source-route.yaml
@@ -0,0 +1,42 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+- route:
+ from:
+ uri: "kamelet:github-pullrequest-source"
+ parameters:
+ oauthToken: 'not-a-real-token'
+ repoOwner: 'citrus'
+ repoName: 'pr-demo'
+ delay: 1000
+ steps:
+ # what the Kamelet gives: the Java type of the body and the
Content-Type
+ - setHeader:
+ name: X-Body-Type
+ simple: "${body.getClass().getName()}"
+ - setHeader:
+ name: X-Content-Type
+ simple: "ct=${header.Content-Type}"
+ # Camel headers are not sent over HTTP: copy them
+ - setHeader:
+ name: X-Pull-Request
+ simple: "${header.CamelGitHubPullRequest}"
+ - setHeader:
+ name: X-Head-Commit-Sha
+ simple: "${header.CamelGitHubPullRequestHeadCommitSha}"
+ - to:
+ uri: "{{http.sink.url}}/result"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/github-tag-source-route.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/github/github-tag-source-route.citrus.it.yaml
new file mode 100644
index 000000000..6b89e136d
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/github-tag-source-route.citrus.it.yaml
@@ -0,0 +1,81 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+name: github-tag-source-route-test
+description: 'github-tag-source sends a tag created after the start as JSON
text with its name and commit SHA, and asks the GitHub API for nothing more
than its polls'
+variables:
+ # the repository of the canned answers of this test, and the only requests
the source may make for it
+ - name: "github.api.repo"
+ value: "citrus/tag-demo"
+ - name: "github.api.expected"
+ value: "user,repos/citrus/tag-demo,repos/citrus/tag-demo/tags"
+actions:
+ # The stand-in of the GitHub API answers with canned JSON for the repository
citrus/tag-demo: no tag when the source starts, then v1.0.0
+ - groovy:
+ script:
+ file: "github/resetApi.groovy"
+
+ # Create Camel JBang integration
+ - camel:
+ cli:
+ run:
+ waitForRunningState: false
+ integration:
+ file: "github/github-tag-source-route.yaml"
+ systemProperties:
+ properties:
+ - name: "http.sink.url"
+ value: "http://localhost:${cloud.http.server.port}"
+ # the GitHub API is the stand-in of the test
+ - name: "camel.component.github2.apiUrl"
+ value: "http://localhost:${github.api.port}"
+
+ # The new tag
+ - http:
+ server: "cloudHttpServer"
+ receiveRequest:
+ POST:
+ path: "/result"
+ type: "json"
+ headers:
+ - name: "X-Body-Type"
+ value: 'java.lang.String'
+ - name: "X-Content-Type"
+ value: 'ct=application/json'
+ body:
+ data: |
+ {
+ "name": "v1.0.0",
+ "commit": { "sha": "4444444444444444444444444444444444444444" }
+ }
+ - http:
+ server: "cloudHttpServer"
+ sendResponse:
+ response:
+ status: 200
+ reasonPhrase: "OK"
+ version: "HTTP/1.1"
+
+ # The source asked the GitHub API for nothing per message: no user, commit
or pull request details
+ - groovy:
+ script:
+ file: "github/onlyPolls.groovy"
+
+ # and only for what it has canned answers for
+ - groovy:
+ script:
+ file: "github/noUnknownRequests.groovy"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/github-tag-source-route.yaml
b/tests/camel-kamelets-itest/src/test/resources/github/github-tag-source-route.yaml
new file mode 100644
index 000000000..0116316cd
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/github/github-tag-source-route.yaml
@@ -0,0 +1,35 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+- route:
+ from:
+ uri: "kamelet:github-tag-source"
+ parameters:
+ oauthToken: 'not-a-real-token'
+ repoOwner: 'citrus'
+ repoName: 'tag-demo'
+ delay: 1000
+ steps:
+ # what the Kamelet gives: the Java type of the body and the
Content-Type
+ - setHeader:
+ name: X-Body-Type
+ simple: "${body.getClass().getName()}"
+ - setHeader:
+ name: X-Content-Type
+ simple: "ct=${header.Content-Type}"
+ - to:
+ uri: "{{http.sink.url}}/result"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/github/onlyPolls.groovy
b/tests/camel-kamelets-itest/src/test/resources/github/onlyPolls.groovy
new file mode 100644
index 000000000..772821846
--- /dev/null
+++ b/tests/camel-kamelets-itest/src/test/resources/github/onlyPolls.groovy
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Checks that the source asked the stand-in of the GitHub API for nothing but
the paths in the variable
+// github.api.expected (separated by commas), that is, nothing more than its
polls: no request per message.
+// Only the requests of the repository of the test, the variable
github.api.repo, and those outside of a
+// repository, such as users/<login>, are counted; the other repositories
belong to the integrations of other
+// tests, which may still be stopping.
+
+def expected = context.getVariable('github.api.expected').split(',').collect {
it.trim() } as Set
+def repo = 'repos/' + context.getVariable('github.api.repo')
+def requests = context.getReferenceResolver().resolve('gitHubApi').requests()
+def counted = requests.findAll { it == repo || it.startsWith(repo + '/') ||
!it.startsWith('repos/') }
+def unexpected = counted.findAll { !expected.contains(it) }.unique()
+if (!unexpected.isEmpty()) {
+ throw new AssertionError('The source asked the GitHub API for ' +
unexpected + ' besides its polls ' + expected
+ + '; all its requests: ' + counted)
+}