From 982c3af463cd5ef8a4b5409a470917332b89a891 Mon Sep 17 00:00:00 2001 From: Shruti Mantri Date: Thu, 22 Aug 2024 14:27:37 +0530 Subject: [PATCH 1/2] feat(docs): add full examples for github tasks --- .../io/kestra/plugin/github/code/Search.java | 34 +++++--- .../kestra/plugin/github/commits/Search.java | 34 +++++--- .../kestra/plugin/github/issues/Comment.java | 18 +++-- .../kestra/plugin/github/issues/Create.java | 81 +++++++++++-------- .../kestra/plugin/github/issues/Search.java | 29 ++++--- .../io/kestra/plugin/github/pulls/Create.java | 26 +++--- .../io/kestra/plugin/github/pulls/Search.java | 30 ++++--- .../plugin/github/repositories/Search.java | 70 ++++++++++------ .../kestra/plugin/github/topics/Search.java | 32 +++++--- .../io/kestra/plugin/github/users/Search.java | 32 +++++--- 10 files changed, 252 insertions(+), 134 deletions(-) diff --git a/src/main/java/io/kestra/plugin/github/code/Search.java b/src/main/java/io/kestra/plugin/github/code/Search.java index 0311ee0..dbb6a5b 100644 --- a/src/main/java/io/kestra/plugin/github/code/Search.java +++ b/src/main/java/io/kestra/plugin/github/code/Search.java @@ -36,22 +36,34 @@ @Plugin( examples = { @Example( + title = "Search for code in a repository.", + full = true, code = """ - id: search - type: io.kestra.plugin.github.code.Search - oauthToken: your_github_token - query: "addClass in:file language:js repo:jquery/jquery" + id: github_code_search_flow + namespace: company.team + + tasks: + - id: search_code + type: io.kestra.plugin.github.code.Search + oauthToken: your_github_token + query: "addClass in:file language:js repo:jquery/jquery" """ ), @Example( + title = "Search for code in a repository.", + full = true, code = """ - id: search - type: io.kestra.plugin.github.code.Search - oauthToken: your_github_token - query: addClass - in: file - language: js - repository: jquery/jquery + id: github_code_search_flow + namespace: company.team + + tasks: + - id: search_code + type: io.kestra.plugin.github.code.Search + oauthToken: your_github_token + query: addClass + in: file + language: js + repository: jquery/jquery """ ) } diff --git a/src/main/java/io/kestra/plugin/github/commits/Search.java b/src/main/java/io/kestra/plugin/github/commits/Search.java index 01875fd..e4a1d6d 100644 --- a/src/main/java/io/kestra/plugin/github/commits/Search.java +++ b/src/main/java/io/kestra/plugin/github/commits/Search.java @@ -32,26 +32,38 @@ @Getter @NoArgsConstructor @Schema( - title = "Search for GitHub commits", - description = "Requires authentication" + title = "Search for GitHub commits.", + description = "Requires authentication." ) @Plugin( examples = { @Example( + title = "Search for commits in a repository.", + full = true, code = """ - id: commits - type: io.kestra.plugin.github.commits.Search - oauthToken: your_github_token - query: "Initial repo:kestra-io/plugin-github language:java" + id: github_commit_search_flow + namespace: company.team + + tasks: + - id: search_commit + type: io.kestra.plugin.github.commits.Search + oauthToken: your_github_token + query: "Initial repo:kestra-io/plugin-github language:java" """ ), @Example( + title = "Search for commits in a repository.", + full = true, code = """ - id: commits - type: io.kestra.plugin.github.commits.Search - oauthToken: your_github_token - query: Initial - repository: kestra-io/plugin-github + id: github_commit_search_flow + namespace: company.team + + tasks: + - id: search_commit + type: io.kestra.plugin.github.commits.Search + oauthToken: your_github_token + query: Initial + repository: kestra-io/plugin-github """ ) } diff --git a/src/main/java/io/kestra/plugin/github/issues/Comment.java b/src/main/java/io/kestra/plugin/github/issues/Comment.java index c136bb9..7176d83 100644 --- a/src/main/java/io/kestra/plugin/github/issues/Comment.java +++ b/src/main/java/io/kestra/plugin/github/issues/Comment.java @@ -27,13 +27,19 @@ @Plugin( examples = { @Example( + title = "Put a comment on an issue in a repository.", + full = true, code = """ - id: comment - type: io.kestra.plugin.github.issues.Comment - oauthToken: your_github_token - repository: kestra-io/kestra - issueNumber: 1347 - body: "{{ execution.id }} has failed on {{ taskrun.startDate }}. See the link below for more details" + id: github_comment_on_issue_flow + namespace: company.team + + tasks: + - id: comment_on_issue + type: io.kestra.plugin.github.issues.Comment + oauthToken: your_github_token + repository: kestra-io/kestra + issueNumber: 1347 + body: "{{ execution.id }} has failed on {{ taskrun.startDate }}. See the link below for more details" """ ) } diff --git a/src/main/java/io/kestra/plugin/github/issues/Create.java b/src/main/java/io/kestra/plugin/github/issues/Create.java index 0f6808e..dac2224 100644 --- a/src/main/java/io/kestra/plugin/github/issues/Create.java +++ b/src/main/java/io/kestra/plugin/github/issues/Create.java @@ -28,49 +28,62 @@ @Plugin( examples = { @Example( - title = "Create an issue in a repository", + title = "Create an issue in a repository using JWT token.", + full = true, code = """ - id: create - type: io.kestra.plugin.github.issues.Create - jwtToken: your_github_jwt_token - repository: kestra-io/kestra - title: Workflow failed - body: "{{ execution.id }} has failed on {{ taskrun.startDate }}. See the link below for more details" - labels: - - bug - - workflow + id: github_issue_create_flow + namespace: company.team + + tasks: + - id: create_issue + type: io.kestra.plugin.github.issues.Create + jwtToken: your_github_jwt_token + repository: kestra-io/kestra + title: Workflow failed + body: "{{ execution.id }} has failed on {{ taskrun.startDate }}. See the link below for more details" + labels: + - bug + - workflow """ ), @Example( - title = "Create an issue in a repository", + title = "Create an issue in a repository using OAuth token.", code = """ - id: create - type: io.kestra.plugin.github.issues.Create - login: your_github_login - oauthToken: your_github_token - repository: kestra-io/kestra - title: Workflow failed - body: "{{ execution.id }} has failed on {{ taskrun.startDate }}. See the link below for more details" - labels: - - bug - - workflow + id: github_issue_create_flow + namespace: company.team + + tasks: + - id: create_issue + type: io.kestra.plugin.github.issues.Create + login: your_github_login + oauthToken: your_github_token + repository: kestra-io/kestra + title: Workflow failed + body: "{{ execution.id }} has failed on {{ taskrun.startDate }}. See the link below for more details" + labels: + - bug + - workflow """ ), @Example( - title = "Create an issue in a repository", + title = "Create an issue in a repository with assignees.", code = """ - id: create - type: io.kestra.plugin.github.issues.Create - oauthToken: your_github_token - repository: kestra-io/kestra - title: Workflow failed - body: "{{ execution.id }} has failed on {{ taskrun.startDate }}. See the link below for more details" - labels: - - bug - - workflow - assignees: - - MyDeveloperUserName - - MyDesignerUserName + id: github_issue_create_flow + namespace: company.team + + tasks: + - id: create_issue + type: io.kestra.plugin.github.issues.Create + oauthToken: your_github_token + repository: kestra-io/kestra + title: Workflow failed + body: "{{ execution.id }} has failed on {{ taskrun.startDate }}. See the link below for more details" + labels: + - bug + - workflow + assignees: + - MyDeveloperUserName + - MyDesignerUserName """ ) } diff --git a/src/main/java/io/kestra/plugin/github/issues/Search.java b/src/main/java/io/kestra/plugin/github/issues/Search.java index c944c4c..1344f9f 100644 --- a/src/main/java/io/kestra/plugin/github/issues/Search.java +++ b/src/main/java/io/kestra/plugin/github/issues/Search.java @@ -23,20 +23,31 @@ @Plugin( examples = { @Example( + title = "Search for issues in a repository.", + full = true, code = """ - id: search - type: io.kestra.plugin.github.issues.Search - oauthToken: your_github_token - query: "repo:kestra-io/plugin-github is:open" + id: github_issue_search_flow + namespace: company.team + + tasks: + - id: search_issues + type: io.kestra.plugin.github.issues.Search + oauthToken: your_github_token + query: "repo:kestra-io/plugin-github is:open" """ ), @Example( + title = "Search for open issues in a repository.", code = """ - id: search - type: io.kestra.plugin.github.issues.Search - oauthToken: your_github_token - repository: kestra-io/plugin-github - open: TRUE + id: github_issue_search_flow + namespace: company.team + + tasks: + - id: search_open_issues + type: io.kestra.plugin.github.issues.Search + oauthToken: your_github_token + repository: kestra-io/plugin-github + open: TRUE """ ) } diff --git a/src/main/java/io/kestra/plugin/github/pulls/Create.java b/src/main/java/io/kestra/plugin/github/pulls/Create.java index 478e7a7..2a51b4a 100644 --- a/src/main/java/io/kestra/plugin/github/pulls/Create.java +++ b/src/main/java/io/kestra/plugin/github/pulls/Create.java @@ -21,21 +21,27 @@ @Getter @NoArgsConstructor @Schema( - title = "Create a pull request", - description = "If no authentication is provided, anonymous authentication will be used" + title = "Create a pull request.", + description = "If no authentication is provided, anonymous authentication will be used." ) @Plugin( examples = { @Example( + title = "Create a pull request in a repository.", + full = true, code = """ - id: create - type: io.kestra.plugin.github.pulls.Create - oauthToken: your_github_token - repository: kestra-io/kestra - sourceBranch: develop - targetBranch: main - title: Workflow failed - body: "{{ execution.id }} has failed on {{ taskrun.startDate }}. See the link below for more details" + id: github_pulls_create_flow + namespace: company.team + + tasks: + - id: create_pull_request + type: io.kestra.plugin.github.pulls.Create + oauthToken: your_github_token + repository: kestra-io/kestra + sourceBranch: develop + targetBranch: main + title: Workflow failed + body: "{{ execution.id }} has failed on {{ taskrun.startDate }}. See the link below for more details" """ ) } diff --git a/src/main/java/io/kestra/plugin/github/pulls/Search.java b/src/main/java/io/kestra/plugin/github/pulls/Search.java index 540e17e..ef309ac 100644 --- a/src/main/java/io/kestra/plugin/github/pulls/Search.java +++ b/src/main/java/io/kestra/plugin/github/pulls/Search.java @@ -24,20 +24,32 @@ @Plugin( examples = { @Example( + title = "Search for pull requests in a repository.", + full = true, code = """ - id: search - type: io.kestra.plugin.github.pulls.Search - oauthToken: your_github_token - query: "repo:kestra-io/plugin-github is:open" + id: github_pulls_search_flow + namespace: company.team + + tasks: + - id: search_pull_requests + type: io.kestra.plugin.github.pulls.Search + oauthToken: your_github_token + query: "repo:kestra-io/plugin-github is:open" """ ), @Example( + title = "Search for open pull requests in a repository.", + full = true, code = """ - id: search - type: io.kestra.plugin.github.pulls.Search - oauthToken: your_github_token - repository: kestra-io/plugin-github - open: TRUE + id: github_pulls_search_flow + namespace: company.team + + tasks: + - id: search_open_pull_requests + type: io.kestra.plugin.github.pulls.Search + oauthToken: your_github_token + repository: kestra-io/plugin-github + open: TRUE """ ) } diff --git a/src/main/java/io/kestra/plugin/github/repositories/Search.java b/src/main/java/io/kestra/plugin/github/repositories/Search.java index d6be607..45ddc25 100644 --- a/src/main/java/io/kestra/plugin/github/repositories/Search.java +++ b/src/main/java/io/kestra/plugin/github/repositories/Search.java @@ -17,47 +17,69 @@ @Getter @NoArgsConstructor @Schema( - title = "Search for GitHub repositories", - description = "If no authentication is provided, anonymous authentication will be used. Anonymous authentication can't retrieve full information" + title = "Search for GitHub repositories.", + description = "If no authentication is provided, anonymous authentication will be used. Anonymous authentication can't retrieve full information." ) @Plugin( examples = { @Example( + title = "Search for Github repositories using query.", + full = true, code = """ - id: repos - type: io.kestra.plugin.github.repositories.Search - oauthToken: your_github_token - query: "repo:kestra-io/plugin-github" + id: github_repo_search_flow + namespace: company.team + + tasks: + - id: search_repositories + type: io.kestra.plugin.github.repositories.Search + oauthToken: your_github_token + query: "repo:kestra-io/plugin-github" """ ), @Example( + title = "Search for Github repositories using repository.", + full = true, code = """ - id: repos - type: io.kestra.plugin.github.repositories.Search - oauthToken: your_github_token - repository: kestra-io/plugin-github + id: github_repo_search_flow + namespace: company.team + + tasks: + - id: search_repositories + type: io.kestra.plugin.github.repositories.Search + oauthToken: your_github_token + repository: kestra-io/plugin-github """ ), @Example( + title = "Search for Github repositories and order the results.", + full = true, code = """ - id: repos - type: io.kestra.plugin.github.repositories.Search - oauthToken: your_github_token - query: "user:kestra-io language:java is:public" - sort: STARS - order: DESC + id: github_repo_search_flow + namespace: company.team + tasks: + - id: search_repositories + type: io.kestra.plugin.github.repositories.Search + oauthToken: your_github_token + query: "user:kestra-io language:java is:public" + sort: STARS + order: DESC """ ), @Example( + title = "Search for Github repositories with filters like language and visibility, and order the results.", + full = true, code = """ - id: repos - type: io.kestra.plugin.github.repositories.Search - oauthToken: your_github_token - user: kestra-io - language: java - visibility: PUBLIC - sort: STARS - order: DESC + id: github_repo_search_flow + namespace: company.team + tasks: + - id: search_repositories + type: io.kestra.plugin.github.repositories.Search + oauthToken: your_github_token + user: kestra-io + language: java + visibility: PUBLIC + sort: STARS + order: DESC """ ) } diff --git a/src/main/java/io/kestra/plugin/github/topics/Search.java b/src/main/java/io/kestra/plugin/github/topics/Search.java index 25a2106..20ab3f4 100644 --- a/src/main/java/io/kestra/plugin/github/topics/Search.java +++ b/src/main/java/io/kestra/plugin/github/topics/Search.java @@ -33,21 +33,33 @@ @Plugin( examples = { @Example( + title = "Search for topics.", + full = true, code = """ - id: search - type: io.kestra.plugin.github.topics.Search - oauthToken: your_github_token - query: "micronaut framework is:not-curated repositories:>100" + id: github_topic_search_flow + namespace: company.team + + tasks: + - id: search_topics + type: io.kestra.plugin.github.topics.Search + oauthToken: your_github_token + query: "micronaut framework is:not-curated repositories:>100" """ ), @Example( + title = "Search for topics with conditions.", + full = true, code = """ - id: search - type: io.kestra.plugin.github.topics.Search - oauthToken: your_github_token - query: "micronaut framework" - is: NOT_CURATED - repositories: >100 + id: github_topic_search_flow + namespace: company.team + + tasks: + - id: search_topics + type: io.kestra.plugin.github.topics.Search + oauthToken: your_github_token + query: "micronaut framework" + is: NOT_CURATED + repositories: >100 """ ) } diff --git a/src/main/java/io/kestra/plugin/github/users/Search.java b/src/main/java/io/kestra/plugin/github/users/Search.java index 0e97c0a..bbe8c07 100644 --- a/src/main/java/io/kestra/plugin/github/users/Search.java +++ b/src/main/java/io/kestra/plugin/github/users/Search.java @@ -23,21 +23,33 @@ @Plugin( examples = { @Example( + title = "Search for users.", + full = true, code = """ - id: users - type: io.kestra.plugin.github.users.Search - oauthToken: your_github_token - query: "kestra-io in:login language:java" + id: github_user_search_flow + namespace: company.team + + tasks: + - id: search_users + type: io.kestra.plugin.github.users.Search + oauthToken: your_github_token + query: "kestra-io in:login language:java" """ ), @Example( + title = "Search for users with conditions.", + full = true, code = """ - id: users - type: io.kestra.plugin.github.users.Search - oauthToken: your_github_token - query: kestra-io - in: login - language: java + id: github_user_search_flow + namespace: company.team + + tasks: + - id: search_users + type: io.kestra.plugin.github.users.Search + oauthToken: your_github_token + query: kestra-io + in: login + language: java """ ) } From afbc56f29a94a329c1743c1d32200986222307f5 Mon Sep 17 00:00:00 2001 From: Shruti Mantri Date: Thu, 22 Aug 2024 18:02:33 +0530 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Will Russell --- src/main/java/io/kestra/plugin/github/repositories/Search.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/kestra/plugin/github/repositories/Search.java b/src/main/java/io/kestra/plugin/github/repositories/Search.java index 45ddc25..6946437 100644 --- a/src/main/java/io/kestra/plugin/github/repositories/Search.java +++ b/src/main/java/io/kestra/plugin/github/repositories/Search.java @@ -56,6 +56,7 @@ code = """ id: github_repo_search_flow namespace: company.team + tasks: - id: search_repositories type: io.kestra.plugin.github.repositories.Search @@ -71,6 +72,7 @@ code = """ id: github_repo_search_flow namespace: company.team + tasks: - id: search_repositories type: io.kestra.plugin.github.repositories.Search