From 582ab4b239bf5f735814829e27e201c17549600e Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 13:19:16 +0300 Subject: [PATCH 01/49] add deps --- pom.xml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 05db501..0c67179 100644 --- a/pom.xml +++ b/pom.xml @@ -23,10 +23,20 @@ 21 + + com.jcabi + jcabi-http + 2.0.0 + + + org.glassfish + jakarta.json + 1.1.6 + com.github.ArtemGet entrys - 0.3.0 + 0.4.0 com.github.ArtemGet From fd7a74959e4e49a5271be3c7a42bb7f0389a17db Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 13:19:31 +0300 Subject: [PATCH 02/49] add config file --- src/main/resources/application.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/resources/application.yaml diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml new file mode 100644 index 0000000..2f6c044 --- /dev/null +++ b/src/main/resources/application.yaml @@ -0,0 +1,22 @@ +#Telegram bot settings +bot: + #Bot name. Provided by botfather. + name: ${BOT_NAME} + #Bot token. Provided by botfather. + #Example: 1234567890:AAxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + token: ${BOT_TOKEN} + #Users that could use bot. Array of userid in format id_1;id_2;id3. + #Example: -123;-234;-345 + admins: ${BOT_ADMINS} +#Source code management settings +provider: + #SCM auth token to make requests. Must have permission to read all project's repos(tags,pull-requests,commits etc), + #create tags and push commits to ci/cd repo. + #Example:glpat-xxxxxxxxxxxxxxxxxxxx + token: ${PROVIDER_TOKEN} + #SCM host, with protocol. Only http:// is supported for now. + #Example:http://gitlab.blabla123.dev.ts/ + host: ${PROVIDER_HOST} + #ID of project in which all repos is placed. Int value. + #Example: 123 + project: ${PROJECT_ID} \ No newline at end of file From 371ef814c025c9368dcaf8d6a173371ba9336ea6 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 13:19:52 +0300 Subject: [PATCH 03/49] add EFunc, remove ESplit --- .../artemget/tagrelease/entry/EFunc.java | 33 ++++++++ .../artemget/tagrelease/entry/ESplit.java | 84 ------------------- 2 files changed, 33 insertions(+), 84 deletions(-) create mode 100644 src/main/java/io/github/artemget/tagrelease/entry/EFunc.java delete mode 100644 src/main/java/io/github/artemget/tagrelease/entry/ESplit.java diff --git a/src/main/java/io/github/artemget/tagrelease/entry/EFunc.java b/src/main/java/io/github/artemget/tagrelease/entry/EFunc.java new file mode 100644 index 0000000..7117bf1 --- /dev/null +++ b/src/main/java/io/github/artemget/tagrelease/entry/EFunc.java @@ -0,0 +1,33 @@ +/* + * MIT License + * + * Copyright (c) 2024-2025. Artem Getmanskii + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.github.artemget.tagrelease.entry; + +import io.github.artemget.entrys.EntryException; +import org.cactoos.Func; + +public interface EFunc extends Func { + @Override + Y apply(X x) throws EntryException; +} diff --git a/src/main/java/io/github/artemget/tagrelease/entry/ESplit.java b/src/main/java/io/github/artemget/tagrelease/entry/ESplit.java deleted file mode 100644 index 2b343fb..0000000 --- a/src/main/java/io/github/artemget/tagrelease/entry/ESplit.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2024-2025. Artem Getmanskii - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package io.github.artemget.tagrelease.entry; - -import io.github.artemget.entrys.Entry; -import io.github.artemget.entrys.EntryException; -import java.util.Set; -import java.util.regex.PatternSyntaxException; - -/** - * Split entry. - * - * @since 0.1.0 - */ -public final class ESplit implements Entry> { - /** - * Origin string entry. - */ - private final Entry origin; - - /** - * Split delimiter. - */ - private final String delimiter; - - /** - * Creates split entry with default ; delimiter. - * - * @param origin Entry - */ - public ESplit(final Entry origin) { - this(origin, ";"); - } - - /** - * Main ctor. - * - * @param origin Entry - * @param delimiter For splitting - */ - public ESplit(final Entry origin, final String delimiter) { - this.origin = origin; - this.delimiter = delimiter; - } - - @Override - public Set value() throws EntryException { - final String value = this.origin.value(); - try { - return Set.of(value.split(this.delimiter)); - } catch (final PatternSyntaxException exception) { - throw new EntryException( - String.format( - "Wrong pattern delimiter: %s for entry value: %s", - this.delimiter, - value - ), - exception - ); - } - } -} From b1876480cafa3bdc61104c26abde12c643318944 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 13:20:44 +0300 Subject: [PATCH 04/49] rename exception --- .../io/github/artemget/tagrelease/domain/Service.java | 4 ++-- .../{TagException.java => DomainException.java} | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) rename src/main/java/io/github/artemget/tagrelease/exception/{TagException.java => DomainException.java} (84%) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/Service.java b/src/main/java/io/github/artemget/tagrelease/domain/Service.java index b1cf289..74a5512 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/Service.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/Service.java @@ -24,7 +24,7 @@ package io.github.artemget.tagrelease.domain; -import io.github.artemget.tagrelease.exception.TagException; +import io.github.artemget.tagrelease.exception.DomainException; import org.cactoos.Scalar; /** @@ -53,5 +53,5 @@ public interface Service { * @param rule To build tag * @return Service with a new tag */ - Service tagged(Scalar rule) throws TagException; + Service tagged(Scalar rule) throws DomainException; } diff --git a/src/main/java/io/github/artemget/tagrelease/exception/TagException.java b/src/main/java/io/github/artemget/tagrelease/exception/DomainException.java similarity index 84% rename from src/main/java/io/github/artemget/tagrelease/exception/TagException.java rename to src/main/java/io/github/artemget/tagrelease/exception/DomainException.java index 56d0123..0847524 100644 --- a/src/main/java/io/github/artemget/tagrelease/exception/TagException.java +++ b/src/main/java/io/github/artemget/tagrelease/exception/DomainException.java @@ -27,23 +27,23 @@ import java.io.Serial; /** - * Throws at build/get tag. + * Throws at domain logic error. * * @since 0.1.0 */ -public class TagException extends Exception { +public class DomainException extends Exception { @Serial private static final long serialVersionUID = 4172661814037122452L; - public TagException(final String message) { + public DomainException(final String message) { super(message); } - public TagException(final String message, final Throwable cause) { + public DomainException(final String message, final Throwable cause) { super(message, cause); } - public TagException(final Throwable cause) { + public DomainException(final Throwable cause) { super(cause); } } From be2339a5b37daea8310671f8c44e6cdccfe1649c Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 13:22:12 +0300 Subject: [PATCH 05/49] add Services All --- ...ServiceGitlabEager.java => ServiceEa.java} | 40 +++++- .../artemget/tagrelease/domain/Services.java | 7 +- .../tagrelease/domain/ServicesAll.java | 128 ++++++++++++++++++ 3 files changed, 166 insertions(+), 9 deletions(-) rename src/main/java/io/github/artemget/tagrelease/domain/{ServiceGitlabEager.java => ServiceEa.java} (60%) create mode 100644 src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServiceGitlabEager.java b/src/main/java/io/github/artemget/tagrelease/domain/ServiceEa.java similarity index 60% rename from src/main/java/io/github/artemget/tagrelease/domain/ServiceGitlabEager.java rename to src/main/java/io/github/artemget/tagrelease/domain/ServiceEa.java index 91410ab..63d2d3c 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/ServiceGitlabEager.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServiceEa.java @@ -24,7 +24,16 @@ package io.github.artemget.tagrelease.domain; -import io.github.artemget.tagrelease.exception.TagException; +import com.amihaiemil.eoyaml.Yaml; +import com.jcabi.http.Request; +import com.jcabi.http.response.RestResponse; +import io.github.artemget.entrys.Entry; +import io.github.artemget.entrys.EntryException; +import io.github.artemget.entrys.json.EJsonStr; +import io.github.artemget.tagrelease.exception.DomainException; +import java.io.IOException; +import java.io.StringReader; +import javax.json.Json; import org.cactoos.Scalar; /** @@ -33,7 +42,7 @@ * @since 0.1.0 */ @SuppressWarnings("PMD.AvoidFieldNameMatchingMethodName") -public final class ServiceGitlabEager implements Service { +public final class ServiceEa implements Service { /** * Application name. */ @@ -44,13 +53,32 @@ public final class ServiceGitlabEager implements Service { */ private final String tag; + //TODO: remove eager and req in ctor + public ServiceEa(final Entry name, final Entry tag) throws EntryException, IOException { + this( + name.value(), + Yaml.createYamlInput( + new EJsonStr( + Json.createReader( + new StringReader( + tag.value().fetch().as(RestResponse.class).body() + ) + ).readObject() + , "content" + ).value() + ).readYamlMapping() + .yamlMapping("image") + .string("tag") + ); + } + /** * Main ctor. * * @param name Of application * @param tag Of application */ - public ServiceGitlabEager(final String name, final String tag) { + public ServiceEa(final String name, final String tag) { this.name = name; this.tag = tag; } @@ -68,11 +96,11 @@ public String tag() { // @checkstyle IllegalCatchCheck (50 lines) @SuppressWarnings("PMD.AvoidCatchingGenericException") @Override - public Service tagged(final Scalar rule) throws TagException { + public Service tagged(final Scalar rule) throws DomainException { try { - return new ServiceGitlabEager(this.name, rule.value()); + return new ServiceEa(this.name, rule.value()); } catch (final Exception exception) { - throw new TagException( + throw new DomainException( String.format("Failed to create tag for service: %s", this.name), exception ); diff --git a/src/main/java/io/github/artemget/tagrelease/domain/Services.java b/src/main/java/io/github/artemget/tagrelease/domain/Services.java index 183a171..2e206e1 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/Services.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/Services.java @@ -24,6 +24,7 @@ package io.github.artemget.tagrelease.domain; +import io.github.artemget.tagrelease.exception.DomainException; import java.util.List; import java.util.stream.Collectors; import org.cactoos.Text; @@ -39,7 +40,7 @@ public interface Services { * * @return Services */ - List services(); + List services() throws DomainException; /** * Returns service from stand by it's name. @@ -47,7 +48,7 @@ public interface Services { * @param name Of service * @return Service */ - Service service(String name); + Service service(String name) throws DomainException; /** * Printed Services. @@ -71,7 +72,7 @@ public Printed(final Services services) { } @Override - public String asString() { + public String asString() throws DomainException{ return this.services.services().stream() .map( service -> diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java b/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java new file mode 100644 index 0000000..04cfa24 --- /dev/null +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java @@ -0,0 +1,128 @@ +/* + * MIT License + * + * Copyright (c) 2024-2025. Artem Getmanskii + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.github.artemget.tagrelease.domain; + +import com.jcabi.http.Request; +import com.jcabi.http.request.JdkRequest; +import com.jcabi.http.response.RestResponse; +import io.github.artemget.entrys.Entry; +import io.github.artemget.entrys.EntryException; +import io.github.artemget.entrys.json.EJsonStr; +import io.github.artemget.tagrelease.entry.EFunc; +import io.github.artemget.tagrelease.exception.DomainException; +import java.io.IOException; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.List; +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonValue; + +/** + * Fetch repositories(services) from gitlab project. + * + * @since 0.0.1 + */ +public final class ServicesAll implements Services { + private final EFunc named; + private final Entry all; + + public ServicesAll(final Entry host, final Entry project) { + this( + (service) -> ServicesAll.fetched( + new JdkRequest(host.value()).uri() + .path(String.format("api/v4/groups/%s/projects", project.value())) + .queryParam("search", service) + .back().method(Request.GET).header("Accept", "application/json") + ), + () -> ServicesAll.fetched( + new JdkRequest(host.value()).uri() + .path(String.format("api/v4/groups/%s/projects", project.value())) + .back().method(Request.GET).header("Accept", "application/json") + ) + ); + } + + public ServicesAll(final EFunc named, final Entry all) { + this.named = named; + this.all = all; + } + + private static JsonArray fetched(final Request request) throws EntryException { + try { + return Json.createReader( + new StringReader(request.fetch().as(RestResponse.class).body()) + ).readArray(); + } catch (final IOException exception) { + throw new EntryException( + "Failed to fetch from gitlab", + exception + ); + } + } + + @Override + public List services() throws DomainException { + final JsonArray response; + try { + response = this.all.value(); + } catch (final EntryException exception) { + throw new DomainException("Failed to fetch all services from gitlab", exception); + } + final List services = new ArrayList<>(); + for (final JsonValue service : response) { + services.add(this.parsed(service)); + } + return services; + } + + @Override + public Service service(String name) throws DomainException { + final JsonArray response; + try { + response = this.named.apply(name); + } catch (final EntryException exception) { + throw new DomainException( + String.format("Failed to fetch '%s' service from gitlab", name), + exception + ); + } + for (final JsonValue value : response) { + final Service service = this.parsed(value); + if (name.equals(service.name())) { + return service; + } + } + throw new DomainException(String.format("No service with name: %s", name)); + } + + private Service parsed(final JsonValue service) throws DomainException { + try { + return new ServiceEa(new EJsonStr(service.asJsonObject(), "name").value(), ""); + } catch (final EntryException exception) { + throw new DomainException("Failed to parse service from gitlab", exception); + } + } +} From 16c65bad3b33406adef484f120cb659ca8456aee Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 13:22:25 +0300 Subject: [PATCH 06/49] add Services All command --- .../command/CmdListAllServices.java | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/main/java/io/github/artemget/tagrelease/command/CmdListAllServices.java diff --git a/src/main/java/io/github/artemget/tagrelease/command/CmdListAllServices.java b/src/main/java/io/github/artemget/tagrelease/command/CmdListAllServices.java new file mode 100644 index 0000000..a770059 --- /dev/null +++ b/src/main/java/io/github/artemget/tagrelease/command/CmdListAllServices.java @@ -0,0 +1,86 @@ +/* + * MIT License + * + * Copyright (c) 2024-2025. Artem Getmanskii + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.github.artemget.tagrelease.command; + +import io.github.artemget.entrys.Entry; +import io.github.artemget.tagrelease.domain.Service; +import io.github.artemget.tagrelease.domain.Services; +import io.github.artemget.tagrelease.domain.ServicesAll; +import io.github.artemget.tagrelease.exception.DomainException; +import io.github.artemget.teleroute.command.Cmd; +import io.github.artemget.teleroute.command.CmdException; +import io.github.artemget.teleroute.send.Send; +import io.github.artemget.teleroute.telegrambots.send.SendMessageWrap; +import java.util.List; +import java.util.stream.Collectors; +import org.telegram.telegrambots.meta.api.methods.send.SendMessage; +import org.telegram.telegrambots.meta.api.objects.Update; +import org.telegram.telegrambots.meta.bots.AbsSender; + +/** + * Bot command. + * List all repositories in gitlab and send reply to user message. + * + * @since 0.0.1 + */ +public final class CmdListAllServices implements Cmd { + private final Services services; + + public CmdListAllServices(final Entry host, final Entry project) { + this(new ServicesAll(host, project)); + } + + public CmdListAllServices(final Services services) { + this.services = services; + } + + @Override + public Send execute(final Update update) throws CmdException { + List srvs; + try { + srvs = this.services.services(); + } catch (final DomainException exception) { + throw new CmdException( + String.format( + "Error list all services. From user:'%s', userId:'%s' in chat:'%s'", + update.getMessage().getFrom().getUserName(), + update.getMessage().getFrom().getId(), + update.getMessage().getChatId() + ), + exception + ); + } + final SendMessage message = new SendMessage( + update.getMessage().getChatId().toString(), + String.format( + "```\n%s```", + srvs.stream().map(Service::name).collect(Collectors.joining("\n")) + ) + ); + message.setReplyToMessageId(update.getMessage().getMessageId()); + message.enableMarkdownV2(true); + return new SendMessageWrap<>(message); + } +} From 3bcf58b4fd803a95fb9b5173f05944e4f6decf5d Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 13:23:00 +0300 Subject: [PATCH 07/49] fixed types --- .../io/github/artemget/tagrelease/match/MatchAdmin.java | 6 +++--- .../io/github/artemget/tagrelease/match/MatchChats.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/match/MatchAdmin.java b/src/main/java/io/github/artemget/tagrelease/match/MatchAdmin.java index 2eae29d..d05f98d 100644 --- a/src/main/java/io/github/artemget/tagrelease/match/MatchAdmin.java +++ b/src/main/java/io/github/artemget/tagrelease/match/MatchAdmin.java @@ -28,7 +28,7 @@ import io.github.artemget.entrys.EntryException; import io.github.artemget.entrys.EntryExceptionUnchecked; import io.github.artemget.teleroute.update.Wrap; -import java.util.Set; +import java.util.List; import java.util.function.Predicate; import org.telegram.telegrambots.meta.api.objects.Update; @@ -41,14 +41,14 @@ public final class MatchAdmin implements Predicate> { /** * Admin ids. */ - private final Entry> admins; + private final Entry> admins; /** * Main ctor. * * @param admins Of bot. */ - public MatchAdmin(final Entry> admins) { + public MatchAdmin(final Entry> admins) { this.admins = admins; } diff --git a/src/main/java/io/github/artemget/tagrelease/match/MatchChats.java b/src/main/java/io/github/artemget/tagrelease/match/MatchChats.java index 4684eb1..d167122 100644 --- a/src/main/java/io/github/artemget/tagrelease/match/MatchChats.java +++ b/src/main/java/io/github/artemget/tagrelease/match/MatchChats.java @@ -28,7 +28,7 @@ import io.github.artemget.entrys.EntryException; import io.github.artemget.entrys.EntryExceptionUnchecked; import io.github.artemget.teleroute.update.Wrap; -import java.util.Set; +import java.util.List; import java.util.function.Predicate; import org.telegram.telegrambots.meta.api.objects.Update; @@ -41,14 +41,14 @@ public final class MatchChats implements Predicate> { /** * Chat ids. */ - private final Entry> chats; + private final Entry> chats; /** * Main ctor. * * @param chats Where bot is used. */ - public MatchChats(final Entry> chats) { + public MatchChats(final Entry> chats) { this.chats = chats; } From 587488a43bc06153b9cb622eab2d8865eff225f1 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 13:36:02 +0300 Subject: [PATCH 08/49] add token --- .../tagrelease/command/CmdListAllServices.java | 8 ++++++-- .../artemget/tagrelease/domain/ServicesAll.java | 14 +++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/command/CmdListAllServices.java b/src/main/java/io/github/artemget/tagrelease/command/CmdListAllServices.java index a770059..abbec12 100644 --- a/src/main/java/io/github/artemget/tagrelease/command/CmdListAllServices.java +++ b/src/main/java/io/github/artemget/tagrelease/command/CmdListAllServices.java @@ -48,8 +48,12 @@ public final class CmdListAllServices implements Cmd { private final Services services; - public CmdListAllServices(final Entry host, final Entry project) { - this(new ServicesAll(host, project)); + public CmdListAllServices( + final Entry host, + final Entry project, + final Entry token + ) { + this(new ServicesAll(host, project, token)); } public CmdListAllServices(final Services services) { diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java b/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java index 04cfa24..d48b0d5 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java @@ -49,18 +49,26 @@ public final class ServicesAll implements Services { private final EFunc named; private final Entry all; - public ServicesAll(final Entry host, final Entry project) { + public ServicesAll( + final Entry host, + final Entry project, + final Entry token + ) { this( (service) -> ServicesAll.fetched( new JdkRequest(host.value()).uri() .path(String.format("api/v4/groups/%s/projects", project.value())) .queryParam("search", service) - .back().method(Request.GET).header("Accept", "application/json") + .back().method(Request.GET) + .header("Accept", "application/json") + .header("PRIVATE-TOKEN:", token.value()) ), () -> ServicesAll.fetched( new JdkRequest(host.value()).uri() .path(String.format("api/v4/groups/%s/projects", project.value())) - .back().method(Request.GET).header("Accept", "application/json") + .back().method(Request.GET) + .header("Accept", "application/json") + .header("PRIVATE-TOKEN:", token.value()) ) ); } From 02a61dbf114368f3218cbefd65ac88f161b12282 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 13:37:11 +0300 Subject: [PATCH 09/49] add route to list all services, replace env to yaml config --- .../artemget/tagrelease/Entrypoint.java | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java index b3ac843..2b4f6ad 100644 --- a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java +++ b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java @@ -25,19 +25,14 @@ package io.github.artemget.tagrelease; import io.github.artemget.entrys.EntryException; -import io.github.artemget.entrys.system.EEnv; +import io.github.artemget.entrys.file.EVal; +import io.github.artemget.entrys.operation.ESplit; import io.github.artemget.tagrelease.bot.Bot; import io.github.artemget.tagrelease.bot.BotReg; -import io.github.artemget.tagrelease.command.CmdListStand; -import io.github.artemget.tagrelease.command.CmdListStands; -import io.github.artemget.tagrelease.domain.StandsGitlab; -import io.github.artemget.tagrelease.entry.ESplit; +import io.github.artemget.tagrelease.command.CmdListAllServices; import io.github.artemget.tagrelease.match.MatchAdmin; -import io.github.artemget.tagrelease.match.MatchChats; -import io.github.artemget.teleroute.match.MatchAll; import io.github.artemget.teleroute.match.MatchRegex; import io.github.artemget.teleroute.route.RouteDfs; -import io.github.artemget.teleroute.route.RouteEnd; import io.github.artemget.teleroute.route.RouteFork; import org.telegram.telegrambots.meta.exceptions.TelegramApiException; @@ -59,30 +54,35 @@ public class Entrypoint { public static void main(final String[] args) throws EntryException, TelegramApiException { new BotReg( new Bot( - new EEnv("BOT_NAME"), - new EEnv("BOT_TOKEN"), + new EVal("bot.name"), + new EVal("bot.token"), new RouteFork<>( - new MatchAll<>( - new MatchChats(new ESplit(new EEnv("BOT_CHATS"))), - new MatchAdmin(new ESplit(new EEnv("BOT_ADMINS"))) - ), + new MatchAdmin(new ESplit(new EVal("admins"))), new RouteDfs<>( new RouteFork<>( - new MatchRegex<>("Покажи сервисы"), - new CmdListStands(new StandsGitlab()) - ), - new RouteFork<>( - new MatchRegex<>("Покажи сервис"), - new CmdListStand(new StandsGitlab()) - ), - new RouteFork<>( - new MatchRegex<>("Собери тэги по стенду"), - new RouteEnd<>(), - new RouteFork<>( - new MatchRegex<>("Собери тэг"), - new RouteEnd<>() + new MatchRegex<>("([Пп]покажи сервисы|\\+).*"), + new CmdListAllServices( + new EVal("provider.host"), + new EVal("provider.project"), + new EVal("provider.token") ) ) +// new RouteFork<>( +// new MatchRegex<>("Покажи стенды"), +// new CmdListStands(new StandsGitlab()) +// ), +// new RouteFork<>( +// new MatchRegex<>("Покажи стенд"), +// new CmdListStand(new StandsGitlab()) +// ), +// new RouteFork<>( +// new MatchRegex<>("Собери тэги по стенду"), +// new RouteEnd<>(), +// new RouteFork<>( +// new MatchRegex<>("Собери тэг"), +// new RouteEnd<>() +// ) +// ) ) ) ) From af2b4c08c0e0aed10494d45f11218669ad94c195 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 14:15:53 +0300 Subject: [PATCH 10/49] add entry fetch --- .../tagrelease/domain/ServicesAll.java | 26 ++------- .../artemget/tagrelease/entry/EFetchArr.java | 56 +++++++++++++++++++ 2 files changed, 61 insertions(+), 21 deletions(-) create mode 100644 src/main/java/io/github/artemget/tagrelease/entry/EFetchArr.java diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java b/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java index d48b0d5..98772e5 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java @@ -26,17 +26,14 @@ import com.jcabi.http.Request; import com.jcabi.http.request.JdkRequest; -import com.jcabi.http.response.RestResponse; import io.github.artemget.entrys.Entry; import io.github.artemget.entrys.EntryException; import io.github.artemget.entrys.json.EJsonStr; +import io.github.artemget.tagrelease.entry.EFetchArr; import io.github.artemget.tagrelease.entry.EFunc; import io.github.artemget.tagrelease.exception.DomainException; -import java.io.IOException; -import java.io.StringReader; import java.util.ArrayList; import java.util.List; -import javax.json.Json; import javax.json.JsonArray; import javax.json.JsonValue; @@ -55,21 +52,21 @@ public ServicesAll( final Entry token ) { this( - (service) -> ServicesAll.fetched( + (service) -> new EFetchArr( new JdkRequest(host.value()).uri() .path(String.format("api/v4/groups/%s/projects", project.value())) .queryParam("search", service) .back().method(Request.GET) .header("Accept", "application/json") .header("PRIVATE-TOKEN:", token.value()) - ), - () -> ServicesAll.fetched( + ).value(), + () -> new EFetchArr( new JdkRequest(host.value()).uri() .path(String.format("api/v4/groups/%s/projects", project.value())) .back().method(Request.GET) .header("Accept", "application/json") .header("PRIVATE-TOKEN:", token.value()) - ) + ).value() ); } @@ -78,19 +75,6 @@ public ServicesAll(final EFunc named, final Entry this.all = all; } - private static JsonArray fetched(final Request request) throws EntryException { - try { - return Json.createReader( - new StringReader(request.fetch().as(RestResponse.class).body()) - ).readArray(); - } catch (final IOException exception) { - throw new EntryException( - "Failed to fetch from gitlab", - exception - ); - } - } - @Override public List services() throws DomainException { final JsonArray response; diff --git a/src/main/java/io/github/artemget/tagrelease/entry/EFetchArr.java b/src/main/java/io/github/artemget/tagrelease/entry/EFetchArr.java new file mode 100644 index 0000000..37c7ee3 --- /dev/null +++ b/src/main/java/io/github/artemget/tagrelease/entry/EFetchArr.java @@ -0,0 +1,56 @@ +/* + * MIT License + * + * Copyright (c) 2024-2025. Artem Getmanskii + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.github.artemget.tagrelease.entry; + +import com.jcabi.http.Request; +import com.jcabi.http.response.RestResponse; +import io.github.artemget.entrys.Entry; +import io.github.artemget.entrys.EntryException; +import java.io.IOException; +import java.io.StringReader; +import javax.json.Json; +import javax.json.JsonArray; + +public class EFetchArr implements Entry { + private final Request request; + + public EFetchArr(final Request request) { + this.request = request; + } + + @Override + public JsonArray value() throws EntryException { + try { + return Json.createReader( + new StringReader(request.fetch().as(RestResponse.class).body()) + ).readArray(); + } catch (final IOException exception) { + throw new EntryException( + String.format("Failed to fetch json array from resource:%s", this.request.uri()), + exception + ); + } + } +} From b1e60ab1b98b930dbbc9b5f6dd17ba084d6b5a0d Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 15:10:33 +0300 Subject: [PATCH 11/49] add fetch json obj/arr --- .../artemget/tagrelease/entry/EFetchArr.java | 24 +++++------- .../EFetchJson.java} | 38 ++++++++++++------- .../EFetchObj.java} | 34 ++++++++++------- 3 files changed, 56 insertions(+), 40 deletions(-) rename src/main/java/io/github/artemget/tagrelease/{domain/StandsGitlab.java => entry/EFetchJson.java} (55%) rename src/main/java/io/github/artemget/tagrelease/{domain/ServicesGitlab.java => entry/EFetchObj.java} (59%) diff --git a/src/main/java/io/github/artemget/tagrelease/entry/EFetchArr.java b/src/main/java/io/github/artemget/tagrelease/entry/EFetchArr.java index 37c7ee3..d8c4d17 100644 --- a/src/main/java/io/github/artemget/tagrelease/entry/EFetchArr.java +++ b/src/main/java/io/github/artemget/tagrelease/entry/EFetchArr.java @@ -25,32 +25,28 @@ package io.github.artemget.tagrelease.entry; import com.jcabi.http.Request; -import com.jcabi.http.response.RestResponse; import io.github.artemget.entrys.Entry; import io.github.artemget.entrys.EntryException; -import java.io.IOException; -import java.io.StringReader; -import javax.json.Json; import javax.json.JsonArray; +import javax.json.JsonStructure; public class EFetchArr implements Entry { - private final Request request; + private final Entry origin; public EFetchArr(final Request request) { - this.request = request; + this(new EFetchJson(request)); + } + + public EFetchArr(final Entry origin) { + this.origin = origin; } @Override public JsonArray value() throws EntryException { try { - return Json.createReader( - new StringReader(request.fetch().as(RestResponse.class).body()) - ).readArray(); - } catch (final IOException exception) { - throw new EntryException( - String.format("Failed to fetch json array from resource:%s", this.request.uri()), - exception - ); + return this.origin.value().asJsonArray(); + } catch (final ClassCastException exception) { + throw new EntryException("Failed to map json structure to JsonArray", exception); } } } diff --git a/src/main/java/io/github/artemget/tagrelease/domain/StandsGitlab.java b/src/main/java/io/github/artemget/tagrelease/entry/EFetchJson.java similarity index 55% rename from src/main/java/io/github/artemget/tagrelease/domain/StandsGitlab.java rename to src/main/java/io/github/artemget/tagrelease/entry/EFetchJson.java index e5fd2ec..5524956 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/StandsGitlab.java +++ b/src/main/java/io/github/artemget/tagrelease/entry/EFetchJson.java @@ -22,23 +22,35 @@ * SOFTWARE. */ -package io.github.artemget.tagrelease.domain; +package io.github.artemget.tagrelease.entry; -import java.util.List; +import com.jcabi.http.Request; +import com.jcabi.http.response.RestResponse; +import io.github.artemget.entrys.Entry; +import io.github.artemget.entrys.EntryException; +import java.io.IOException; +import java.io.StringReader; +import javax.json.Json; +import javax.json.JsonStructure; -/** - * Servers. - * - * @since 0.1.0 - */ -public final class StandsGitlab implements Stands { - @Override - public List stands() { - throw new UnsupportedOperationException(); +public class EFetchJson implements Entry { + private final Request request; + + public EFetchJson(final Request request) { + this.request = request; } @Override - public Stand stand(final String name) { - throw new UnsupportedOperationException(); + public JsonStructure value() throws EntryException { + try { + return Json.createReader( + new StringReader(request.fetch().as(RestResponse.class).body()) + ).read(); + } catch (final IOException exception) { + throw new EntryException( + String.format("Failed to fetch json array from resource:%s", this.request.uri()), + exception + ); + } } } diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServicesGitlab.java b/src/main/java/io/github/artemget/tagrelease/entry/EFetchObj.java similarity index 59% rename from src/main/java/io/github/artemget/tagrelease/domain/ServicesGitlab.java rename to src/main/java/io/github/artemget/tagrelease/entry/EFetchObj.java index 7ab47fb..6effbf5 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/ServicesGitlab.java +++ b/src/main/java/io/github/artemget/tagrelease/entry/EFetchObj.java @@ -22,23 +22,31 @@ * SOFTWARE. */ -package io.github.artemget.tagrelease.domain; +package io.github.artemget.tagrelease.entry; -import java.util.List; +import com.jcabi.http.Request; +import io.github.artemget.entrys.Entry; +import io.github.artemget.entrys.EntryException; +import javax.json.JsonObject; +import javax.json.JsonStructure; -/** - * Applications from gitlab. - * - * @since 0.1.0 - */ -public final class ServicesGitlab implements Services { - @Override - public List services() { - throw new UnsupportedOperationException(); +public class EFetchObj implements Entry { + private final Entry origin; + + public EFetchObj(final Request request) { + this(new EFetchJson(request)); + } + + public EFetchObj(final Entry origin) { + this.origin = origin; } @Override - public Service service(final String name) { - throw new UnsupportedOperationException(); + public JsonObject value() throws EntryException { + try { + return this.origin.value().asJsonObject(); + } catch (final ClassCastException exception) { + throw new EntryException("Failed to map json structure to JsonObject", exception); + } } } From 21fe1deb5eb70c4630c62eefe62109873d4ff00d Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 15:10:48 +0300 Subject: [PATCH 12/49] add release repo id to config --- src/main/resources/application.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 2f6c044..5d3ba01 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -19,4 +19,7 @@ provider: host: ${PROVIDER_HOST} #ID of project in which all repos is placed. Int value. #Example: 123 - project: ${PROJECT_ID} \ No newline at end of file + project: ${PROJECT_ID} + #ID of repo where all stands are placed. + #Example: 123 + release: ${RELEASE_ID} From aba0034fa11e71c838256101824785e00c25503a Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 15:12:08 +0300 Subject: [PATCH 13/49] implement stand in gitlab --- .../artemget/tagrelease/domain/Stand.java | 5 ++-- .../domain/{StandGitlab.java => StandGl.java} | 29 +++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) rename src/main/java/io/github/artemget/tagrelease/domain/{StandGitlab.java => StandGl.java} (61%) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/Stand.java b/src/main/java/io/github/artemget/tagrelease/domain/Stand.java index 66b445d..352b0db 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/Stand.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/Stand.java @@ -24,6 +24,7 @@ package io.github.artemget.tagrelease.domain; +import io.github.artemget.tagrelease.exception.DomainException; import org.cactoos.Text; /** @@ -44,7 +45,7 @@ public interface Stand { * * @return Services */ - Services services(); + Services services() throws DomainException; /** * Printed server. @@ -71,7 +72,7 @@ public Printed(final Stand stand) { } @Override - public String asString() { + public String asString() throws DomainException { return String.format( """ Стенд: %s diff --git a/src/main/java/io/github/artemget/tagrelease/domain/StandGitlab.java b/src/main/java/io/github/artemget/tagrelease/domain/StandGl.java similarity index 61% rename from src/main/java/io/github/artemget/tagrelease/domain/StandGitlab.java rename to src/main/java/io/github/artemget/tagrelease/domain/StandGl.java index f8135c4..f2ca38d 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/StandGitlab.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/StandGl.java @@ -24,19 +24,38 @@ package io.github.artemget.tagrelease.domain; +import io.github.artemget.entrys.Entry; +import io.github.artemget.entrys.EntryException; +import io.github.artemget.tagrelease.exception.DomainException; + /** - * Server at gitlab. + * Stand for customer. * * @since 0.1.0 */ -public final class StandGitlab implements Stand { +public final class StandGl implements Stand { + private final String name; + private final Entry services; + + public StandGl(final String name, final Entry services) { + this.name = name; + this.services = services; + } + @Override public String name() { - throw new UnsupportedOperationException(); + return this.name; } @Override - public Services services() { - throw new UnsupportedOperationException(); + public Services services() throws DomainException { + try { + return this.services.value(); + } catch (final EntryException exception) { + throw new DomainException( + String.format("Failed to fetch services from stand:'%s'", this.name), + exception + ); + } } } From ca486709446e368bd021b827eef1c0aa94236fbb Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 15:12:43 +0300 Subject: [PATCH 14/49] implement stands in gitlab --- .../artemget/tagrelease/domain/Stands.java | 7 +- .../artemget/tagrelease/domain/StandsGl.java | 134 ++++++++++++++++++ 2 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java diff --git a/src/main/java/io/github/artemget/tagrelease/domain/Stands.java b/src/main/java/io/github/artemget/tagrelease/domain/Stands.java index 78120af..628a115 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/Stands.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/Stands.java @@ -24,6 +24,7 @@ package io.github.artemget.tagrelease.domain; +import io.github.artemget.tagrelease.exception.DomainException; import java.util.List; import java.util.stream.Collectors; import org.cactoos.Text; @@ -39,7 +40,7 @@ public interface Stands { * * @return Servers */ - List stands(); + List stands() throws DomainException; /** * Returns server by it's name. @@ -47,7 +48,7 @@ public interface Stands { * @param name Name * @return Server */ - Stand stand(String name); + Stand stand(String name) throws DomainException; /** * Printed servers. @@ -69,7 +70,7 @@ public Printed(final Stands stands) { } @Override - public String asString() { + public String asString() throws DomainException { return this.stands.stands().stream() .map(st -> new Stand.Printed(st).toString()) .collect(Collectors.joining()); diff --git a/src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java b/src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java new file mode 100644 index 0000000..d6ce305 --- /dev/null +++ b/src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java @@ -0,0 +1,134 @@ +/* + * MIT License + * + * Copyright (c) 2024-2025. Artem Getmanskii + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.github.artemget.tagrelease.domain; + +import com.jcabi.http.Request; +import com.jcabi.http.request.JdkRequest; +import io.github.artemget.entrys.Entry; +import io.github.artemget.entrys.EntryException; +import io.github.artemget.entrys.json.EJsonStr; +import io.github.artemget.tagrelease.entry.EFetchArr; +import io.github.artemget.tagrelease.entry.EFetchObj; +import io.github.artemget.tagrelease.entry.EFunc; +import io.github.artemget.tagrelease.exception.DomainException; +import java.util.ArrayList; +import java.util.List; +import javax.json.JsonArray; +import javax.json.JsonObject; +import javax.json.JsonValue; + +/** + * Servers. + * + * @since 0.1.0 + */ +public final class StandsGl implements Stands { + /** + * Gitlab request. List repository branches. + * GET /projects/:id/repository/branches + */ + private final Entry stands; + + /** + * Gitlab request. List repository branch by name. + * GET /projects/:id/repository/branches + */ + private final EFunc stand; + + private final EFunc services; + + + public StandsGl( + final Entry url, + final Entry project, + final Entry repo, + final Entry token + ) { + this( + () -> new EFetchArr( + new JdkRequest(url.value()).uri() + .path(String.format("api/v4/projects/:%s/repository/branches", repo.value())) + .back().method(Request.GET) + .header("Accept", "application/json") + .header("PRIVATE-TOKEN:", token.value()) + ).value(), + (name) -> new EFetchObj( + new JdkRequest(url.value()).uri() + .path( + String.format( + "api/v4/projects/%s/repository/branches/%s", repo.value(), name + ) + ).back() + .method(Request.GET) + .header("Accept", "application/json") + .header("PRIVATE-TOKEN:", token.value()) + ).value(), + (branch) -> new ServicesGl(url, project, () -> branch, token) + ); + } + + public StandsGl( + final Entry stands, + final EFunc stand, + final EFunc services + ) { + this.stands = stands; + this.stand = stand; + this.services = services; + } + + @Override + public List stands() throws DomainException { + final JsonArray response; + try { + response = this.stands.value(); + } catch (EntryException exception) { + throw new DomainException("Failed to fetch all services from gitlab", exception); + } + final List stands = new ArrayList<>(); + for (final JsonValue branch : response) { + stands.add(this.enriched(branch.asJsonObject())); + } + return stands; + } + + @Override + public Stand stand(final String name) throws DomainException { + try { + return this.enriched(this.stand.apply(name)); + } catch (final EntryException exception) { + throw new DomainException("Failed to fetch all services from gitlab", exception); + } + } + + private Stand enriched(final JsonObject service) throws DomainException { + try { + final String branch = new EJsonStr(service, "name").value(); + return new StandGl(branch, () -> this.services.apply(branch)); + } catch (final EntryException exception) { + throw new DomainException("Failed to parse service from gitlab", exception); + } + } +} From 9225bf5a3463a604b77c4a04a17e772ac8d0bf26 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 15:13:05 +0300 Subject: [PATCH 15/49] fixed lists stands command --- .../tagrelease/command/CmdListStands.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/command/CmdListStands.java b/src/main/java/io/github/artemget/tagrelease/command/CmdListStands.java index c877735..413cef6 100644 --- a/src/main/java/io/github/artemget/tagrelease/command/CmdListStands.java +++ b/src/main/java/io/github/artemget/tagrelease/command/CmdListStands.java @@ -24,10 +24,15 @@ package io.github.artemget.tagrelease.command; +import io.github.artemget.tagrelease.domain.Stand; import io.github.artemget.tagrelease.domain.Stands; +import io.github.artemget.tagrelease.exception.DomainException; import io.github.artemget.teleroute.command.Cmd; +import io.github.artemget.teleroute.command.CmdException; import io.github.artemget.teleroute.send.Send; import io.github.artemget.teleroute.telegrambots.send.SendMessageWrap; +import java.util.List; +import java.util.stream.Collectors; import org.telegram.telegrambots.meta.api.methods.send.SendMessage; import org.telegram.telegrambots.meta.api.objects.Update; import org.telegram.telegrambots.meta.bots.AbsSender; @@ -52,10 +57,24 @@ public CmdListStands(final Stands stands) { } @Override - public Send execute(final Update update) { + public Send execute(final Update update) throws CmdException { + final List stands; + try { + stands = this.stands.stands(); + } catch (final DomainException exception) { + throw new CmdException( + String.format( + "Error list all stands. From user:'%s', userId:'%s' in chat:'%s'", + update.getMessage().getFrom().getUserName(), + update.getMessage().getFrom().getId(), + update.getMessage().getChatId() + ), + exception + ); + } final SendMessage message = new SendMessage( update.getMessage().getChatId().toString(), - new Stands.Printed(this.stands).toString() + stands.stream().map(Stand::name).collect(Collectors.joining("\n")) ); message.setReplyToMessageId(update.getMessage().getMessageId()); message.enableMarkdownV2(true); From b103b78d3e67a9cf03466d90e63707550a4e977d Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 15:13:19 +0300 Subject: [PATCH 16/49] add lists stands command route --- .../artemget/tagrelease/Entrypoint.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java index 2b4f6ad..4500bee 100644 --- a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java +++ b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java @@ -24,12 +24,15 @@ package io.github.artemget.tagrelease; +import io.github.artemget.entrys.Entry; import io.github.artemget.entrys.EntryException; import io.github.artemget.entrys.file.EVal; import io.github.artemget.entrys.operation.ESplit; import io.github.artemget.tagrelease.bot.Bot; import io.github.artemget.tagrelease.bot.BotReg; import io.github.artemget.tagrelease.command.CmdListAllServices; +import io.github.artemget.tagrelease.command.CmdListStands; +import io.github.artemget.tagrelease.domain.StandsGl; import io.github.artemget.tagrelease.match.MatchAdmin; import io.github.artemget.teleroute.match.MatchRegex; import io.github.artemget.teleroute.route.RouteDfs; @@ -52,6 +55,10 @@ ) public class Entrypoint { public static void main(final String[] args) throws EntryException, TelegramApiException { + final Entry host = new EVal("provider.host"); + final Entry project = new EVal("provider.project"); + final Entry repo = new EVal("provider.token"); + final Entry token = new EVal("provider.token"); new BotReg( new Bot( new EVal("bot.name"), @@ -60,18 +67,14 @@ public static void main(final String[] args) throws EntryException, TelegramApiE new MatchAdmin(new ESplit(new EVal("admins"))), new RouteDfs<>( new RouteFork<>( - new MatchRegex<>("([Пп]покажи сервисы|\\+).*"), - new CmdListAllServices( - new EVal("provider.host"), - new EVal("provider.project"), - new EVal("provider.token") - ) + new MatchRegex<>("([Пп]окажи сервисы|\\+).*"), + new CmdListAllServices(host, project, token) + ), + new RouteFork<>( + new MatchRegex<>("([Пп]окажи стенды|\\+).*"), + new CmdListStands(new StandsGl(host, project, repo, token)) ) // new RouteFork<>( -// new MatchRegex<>("Покажи стенды"), -// new CmdListStands(new StandsGitlab()) -// ), -// new RouteFork<>( // new MatchRegex<>("Покажи стенд"), // new CmdListStand(new StandsGitlab()) // ), From 652bb27de0e92478b38c30c51c19dd2c30b08608 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 15:22:43 +0300 Subject: [PATCH 17/49] fixed regexes, add list services by stand route --- .../github/artemget/tagrelease/Entrypoint.java | 17 ++++++++++++----- .../{CmdListStand.java => CmdListServices.java} | 4 ++-- ...AllServices.java => CmdListServicesAll.java} | 6 +++--- 3 files changed, 17 insertions(+), 10 deletions(-) rename src/main/java/io/github/artemget/tagrelease/command/{CmdListStand.java => CmdListServices.java} (96%) rename src/main/java/io/github/artemget/tagrelease/command/{CmdListAllServices.java => CmdListServicesAll.java} (95%) diff --git a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java index 4500bee..0dcaeef 100644 --- a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java +++ b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java @@ -30,8 +30,10 @@ import io.github.artemget.entrys.operation.ESplit; import io.github.artemget.tagrelease.bot.Bot; import io.github.artemget.tagrelease.bot.BotReg; -import io.github.artemget.tagrelease.command.CmdListAllServices; +import io.github.artemget.tagrelease.command.CmdListServicesAll; +import io.github.artemget.tagrelease.command.CmdListServices; import io.github.artemget.tagrelease.command.CmdListStands; +import io.github.artemget.tagrelease.domain.Stands; import io.github.artemget.tagrelease.domain.StandsGl; import io.github.artemget.tagrelease.match.MatchAdmin; import io.github.artemget.teleroute.match.MatchRegex; @@ -59,6 +61,7 @@ public static void main(final String[] args) throws EntryException, TelegramApiE final Entry project = new EVal("provider.project"); final Entry repo = new EVal("provider.token"); final Entry token = new EVal("provider.token"); + final Stands stands = new StandsGl(host, project, repo, token); new BotReg( new Bot( new EVal("bot.name"), @@ -67,12 +70,16 @@ public static void main(final String[] args) throws EntryException, TelegramApiE new MatchAdmin(new ESplit(new EVal("admins"))), new RouteDfs<>( new RouteFork<>( - new MatchRegex<>("([Пп]окажи сервисы|\\+).*"), - new CmdListAllServices(host, project, token) + new MatchRegex<>("[Пп]окажи сервисы"), + new CmdListServicesAll(host, project, token) ), new RouteFork<>( - new MatchRegex<>("([Пп]окажи стенды|\\+).*"), - new CmdListStands(new StandsGl(host, project, repo, token)) + new MatchRegex<>("[Пп]окажи сервисы \\{([^{}]*)\\}$"), + new CmdListServices(stands) + ), + new RouteFork<>( + new MatchRegex<>("[Пп]окажи стенды"), + new CmdListStands(stands) ) // new RouteFork<>( // new MatchRegex<>("Покажи стенд"), diff --git a/src/main/java/io/github/artemget/tagrelease/command/CmdListStand.java b/src/main/java/io/github/artemget/tagrelease/command/CmdListServices.java similarity index 96% rename from src/main/java/io/github/artemget/tagrelease/command/CmdListStand.java rename to src/main/java/io/github/artemget/tagrelease/command/CmdListServices.java index 8b96ffd..3ae66ad 100644 --- a/src/main/java/io/github/artemget/tagrelease/command/CmdListStand.java +++ b/src/main/java/io/github/artemget/tagrelease/command/CmdListServices.java @@ -42,7 +42,7 @@ * * @since 0.1.0 */ -public final class CmdListStand implements Cmd { +public final class CmdListServices implements Cmd { /** * Available stands. */ @@ -52,7 +52,7 @@ public final class CmdListStand implements Cmd { * Main ctor. * @param stands Available stands. */ - public CmdListStand(final Stands stands) { + public CmdListServices(final Stands stands) { this.stands = stands; } diff --git a/src/main/java/io/github/artemget/tagrelease/command/CmdListAllServices.java b/src/main/java/io/github/artemget/tagrelease/command/CmdListServicesAll.java similarity index 95% rename from src/main/java/io/github/artemget/tagrelease/command/CmdListAllServices.java rename to src/main/java/io/github/artemget/tagrelease/command/CmdListServicesAll.java index abbec12..dd67504 100644 --- a/src/main/java/io/github/artemget/tagrelease/command/CmdListAllServices.java +++ b/src/main/java/io/github/artemget/tagrelease/command/CmdListServicesAll.java @@ -45,10 +45,10 @@ * * @since 0.0.1 */ -public final class CmdListAllServices implements Cmd { +public final class CmdListServicesAll implements Cmd { private final Services services; - public CmdListAllServices( + public CmdListServicesAll( final Entry host, final Entry project, final Entry token @@ -56,7 +56,7 @@ public CmdListAllServices( this(new ServicesAll(host, project, token)); } - public CmdListAllServices(final Services services) { + public CmdListServicesAll(final Services services) { this.services = services; } From c1629b0eb4f643a711a02783d8bae7c1f6789514 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 15:27:13 +0300 Subject: [PATCH 18/49] fixed config name --- .../java/io/github/artemget/tagrelease/Entrypoint.java | 7 ++++--- .../io/github/artemget/tagrelease/domain/StandsGl.java | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java index 0dcaeef..ba4fabd 100644 --- a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java +++ b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java @@ -30,8 +30,8 @@ import io.github.artemget.entrys.operation.ESplit; import io.github.artemget.tagrelease.bot.Bot; import io.github.artemget.tagrelease.bot.BotReg; -import io.github.artemget.tagrelease.command.CmdListServicesAll; import io.github.artemget.tagrelease.command.CmdListServices; +import io.github.artemget.tagrelease.command.CmdListServicesAll; import io.github.artemget.tagrelease.command.CmdListStands; import io.github.artemget.tagrelease.domain.Stands; import io.github.artemget.tagrelease.domain.StandsGl; @@ -58,10 +58,11 @@ public class Entrypoint { public static void main(final String[] args) throws EntryException, TelegramApiException { final Entry host = new EVal("provider.host"); - final Entry project = new EVal("provider.project"); + final Entry release = new EVal("provider.release"); final Entry repo = new EVal("provider.token"); final Entry token = new EVal("provider.token"); - final Stands stands = new StandsGl(host, project, repo, token); + final Entry project = new EVal("provider.project"); + final Stands stands = new StandsGl(host, release, repo, token); new BotReg( new Bot( new EVal("bot.name"), diff --git a/src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java b/src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java index d6ce305..31ebfae 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java @@ -62,7 +62,7 @@ public final class StandsGl implements Stands { public StandsGl( final Entry url, - final Entry project, + final Entry release, final Entry repo, final Entry token ) { @@ -85,7 +85,7 @@ public StandsGl( .header("Accept", "application/json") .header("PRIVATE-TOKEN:", token.value()) ).value(), - (branch) -> new ServicesGl(url, project, () -> branch, token) + (branch) -> new ServicesGl(url, release, () -> branch, token) ); } From cad1c436cbf35cf8124c1aa6002e1552cf170761 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 15:36:42 +0300 Subject: [PATCH 19/49] commented --- .../tagrelease/domain/ServicesGl.java | 201 ++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java b/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java new file mode 100644 index 0000000..f6ee8a3 --- /dev/null +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java @@ -0,0 +1,201 @@ +/* + * MIT License + * + * Copyright (c) 2024-2025. Artem Getmanskii + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.github.artemget.tagrelease.domain; + +import com.jcabi.http.Request; +import com.jcabi.http.request.JdkRequest; +import com.jcabi.http.response.RestResponse; +import io.github.artemget.entrys.Entry; +import io.github.artemget.entrys.EntryException; +import io.github.artemget.entrys.json.EJsonStr; +import io.github.artemget.tagrelease.entry.EFunc; +import io.github.artemget.tagrelease.exception.CommunicationException; +import io.github.artemget.tagrelease.exception.DomainException; +import java.io.IOException; +import java.io.StringReader; +import java.util.List; +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonObject; + +/** + * Applications from gitlab. + * + * @since 0.1.0 + */ +public final class ServicesGl implements Services { + /** + * List repository tree. Each directory with name not starting with _ prefix - is a service. + * GET /projects/:id/repository/tree + */ + private final Request services; + + /** + * Get file from repository. Tag name placed under image:tag: in this file. + * GET /projects/:id/repository/files/:file_path + */ + private final EFunc tag; + + + /** + * Ctor configures https req to gitlab services. + * + * @param url Of gitlab. + * @param release Where to search services. + * @param branch Project which services belong to. + * @throws EntryException If no entry data + */ + public ServicesGl( + final Entry url, + final Entry release, + final Entry branch, + final Entry token + ) throws EntryException { + this( + new JdkRequest(url.value()).uri() + .path( + String.format( + "api/v4/projects/%s/repository/tree", + release.value() + ) + ).queryParam( + "ref", + branch.value() + ).back() + .method(Request.GET) + .header("Accept", "application/json"), + (service) -> new JdkRequest(url.value()).uri() + .path( + String.format( + "api/v4/projects/%s/repository/files/%s", + release.value(), + service.concat("%2Fvalues.yaml") + ) + ).queryParam( + "ref", + branch.value() + ).back() + .method(Request.GET) + .header("Accept", "application/json") + ); + } + + /** + * Main ctor. + * + * @param services At gitlab + */ + public ServicesGl(final Request services, final EFunc tag) { + this.services = services; + this.tag = tag; + } + + @Override + public List services() throws DomainException { + return null; +// return this.directories().stream() +// .filter(dir -> { +// boolean pass; +// try { +// final JsonObject json = dir.asJsonObject(); +// final boolean directory = new EJsonStr(json, "type").value().equals("tree"); +// final boolean service = !new EJsonStr(json, "name").value().startsWith("_"); +// pass = directory && service; +// } catch (final EntryException exception) { +// pass = false; +// //TODO: add logging +// } +// return pass; +// } +// ).map(dir -> { +// final String directory = new EJsonStr(dir.asJsonObject(), "name").value(); +// return new ServiceGitlabEager( +// () -> directory, +// () -> this.tag.apply(directory) +// ); +// } +// ).collect(Collectors.toList()); + } + + @Override + public Service service(final String name) throws DomainException { + return null; +// return this.directories().stream() +// .filter(service -> { +// boolean pass; +// try { +// JsonObject json = service.asJsonObject(); +// final boolean directory = new EJsonStr(json, "type").value().equals("tree"); +// final boolean named = new EJsonStr(json, "name").value().equals(name); +// pass = directory && named; +// } catch (final EntryException exception) { +// pass = false; +// //TODO: add logging +// } +// return pass; +// } +// ).findFirst() +// .map(dir -> { +// final String directory = new EJsonStr(dir.asJsonObject(), "name").value(); +// return new ServiceGitlabEager( +// () -> directory, +// () -> this.tag.apply(directory) +// ); +// }) +// .orElseThrow(); + } + + private Service created(final JsonObject dir) throws DomainException { + try { + final String directory = new EJsonStr(dir.asJsonObject(), "name").value(); + return new ServiceEa( + () -> directory, + () -> this.tag.apply(directory) + ); + } catch (final EntryException exception) { + throw new DomainException(exception); + } catch (final IOException exception) { + throw new CommunicationException("Failed to fetch file from gitlab.", exception); + } + } + + private JsonArray directories() throws DomainException { + try { + return Json.createReader( + new StringReader( + this.services.fetch().as(RestResponse.class).body() + ) + ).readArray(); + } catch (final IOException exception) { + throw new CommunicationException( + String.format( + "Failed to fetch services names from gitlab. Request: %s", + this.services.uri() + ), + exception + ); + } + } +} From 3c4b40e25984fdb508a725a1b4b573ce3eb19e37 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 17:59:10 +0300 Subject: [PATCH 20/49] fix list services by stand --- .../tagrelease/command/CmdListServices.java | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/command/CmdListServices.java b/src/main/java/io/github/artemget/tagrelease/command/CmdListServices.java index 3ae66ad..9bb7b70 100644 --- a/src/main/java/io/github/artemget/tagrelease/command/CmdListServices.java +++ b/src/main/java/io/github/artemget/tagrelease/command/CmdListServices.java @@ -24,21 +24,22 @@ package io.github.artemget.tagrelease.command; -import io.github.artemget.tagrelease.domain.Stand; +import io.github.artemget.entrys.EntryException; +import io.github.artemget.entrys.operation.EUnwrap; +import io.github.artemget.tagrelease.domain.Service; import io.github.artemget.tagrelease.domain.Stands; +import io.github.artemget.tagrelease.exception.DomainException; import io.github.artemget.teleroute.command.Cmd; import io.github.artemget.teleroute.command.CmdException; import io.github.artemget.teleroute.send.Send; import io.github.artemget.teleroute.telegrambots.send.SendMessageWrap; -import org.cactoos.text.Replaced; -import org.cactoos.text.TextOf; -import org.cactoos.text.Trimmed; +import java.util.stream.Collectors; import org.telegram.telegrambots.meta.api.methods.send.SendMessage; import org.telegram.telegrambots.meta.api.objects.Update; import org.telegram.telegrambots.meta.bots.AbsSender; /** - * Lists stand and it's services. + * Lists services by stand. * * @since 0.1.0 */ @@ -60,25 +61,36 @@ public CmdListServices(final Stands stands) { @SuppressWarnings("PMD.AvoidCatchingGenericException") @Override public Send execute(final Update update) throws CmdException { + final String request = update.getMessage().getText(); + final String name; + try { + name = new EUnwrap(update.getMessage().getText()).value(); + } catch (final EntryException exception) { + throw new CmdException( + String.format("Failed to get value from cmd:'%s'", request), + exception + ); + } final SendMessage message; try { message = new SendMessage( update.getMessage().getChatId().toString(), - new Stand.Printed( - this.stands.stand( - new Trimmed( - new Replaced( - new TextOf(update.getMessage().getText()), - "Покажи сервис", - "" - ) - ).asString() - ) - ).toString() + String.format( + "```\n %s\n```", + this.stands.stand(name).services().services() + .stream().map(Service::name).collect(Collectors.joining("\n")) + ) ); - } catch (final Exception exception) { + } catch (final DomainException exception) { throw new CmdException( - String.format("Failed to eject value from cmd %s", update.getMessage().getText()), + String.format( + "Failed get services from stand:'%s' from cmd:'%s'. From user:'%s', userId:'%s' in chat:'%s'", + name, + request, + update.getMessage().getFrom().getUserName(), + update.getMessage().getFrom().getId(), + update.getMessage().getChatId() + ), exception ); } From 0e30e9af52290e46ba4071f62a9e1f6b4a83b9b4 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 18:12:16 +0300 Subject: [PATCH 21/49] add id to service --- .../artemget/tagrelease/domain/Service.java | 1 + .../artemget/tagrelease/domain/ServiceEa.java | 26 +++++++++++++++---- .../tagrelease/domain/ServicesAll.java | 8 +++++- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/Service.java b/src/main/java/io/github/artemget/tagrelease/domain/Service.java index 74a5512..bcb9bf9 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/Service.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/Service.java @@ -33,6 +33,7 @@ * @since 0.1.0 */ public interface Service { + String id(); /** * Returns application name. * diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServiceEa.java b/src/main/java/io/github/artemget/tagrelease/domain/ServiceEa.java index 63d2d3c..2dc7a09 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/ServiceEa.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServiceEa.java @@ -44,18 +44,28 @@ @SuppressWarnings("PMD.AvoidFieldNameMatchingMethodName") public final class ServiceEa implements Service { /** - * Application name. + * Repository ID. + */ + private final String id; + + /** + * Repository name. */ private final String name; /** - * Application tag. + * Last tag. */ private final String tag; //TODO: remove eager and req in ctor - public ServiceEa(final Entry name, final Entry tag) throws EntryException, IOException { + public ServiceEa( + final Entry id, + final Entry name, + final Entry tag + ) throws EntryException, IOException { this( + id.value(), name.value(), Yaml.createYamlInput( new EJsonStr( @@ -78,11 +88,17 @@ public ServiceEa(final Entry name, final Entry tag) throws Entr * @param name Of application * @param tag Of application */ - public ServiceEa(final String name, final String tag) { + public ServiceEa(final String id, final String name, final String tag) { + this.id = id; this.name = name; this.tag = tag; } + @Override + public String id() { + return this.id; + } + @Override public String name() { return this.name; @@ -98,7 +114,7 @@ public String tag() { @Override public Service tagged(final Scalar rule) throws DomainException { try { - return new ServiceEa(this.name, rule.value()); + return new ServiceEa(this.id, this.name, rule.value()); } catch (final Exception exception) { throw new DomainException( String.format("Failed to create tag for service: %s", this.name), diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java b/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java index 98772e5..b562b13 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java @@ -35,6 +35,7 @@ import java.util.ArrayList; import java.util.List; import javax.json.JsonArray; +import javax.json.JsonObject; import javax.json.JsonValue; /** @@ -112,7 +113,12 @@ public Service service(String name) throws DomainException { private Service parsed(final JsonValue service) throws DomainException { try { - return new ServiceEa(new EJsonStr(service.asJsonObject(), "name").value(), ""); + JsonObject json = service.asJsonObject(); + return new ServiceEa( + new EJsonStr(json, "id").value(), + new EJsonStr(json, "name").value(), + "" + ); } catch (final EntryException exception) { throw new DomainException("Failed to parse service from gitlab", exception); } From 06ae270fbb370d3837d0a0f2a056ab1807d094be Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 29 Jun 2025 19:08:52 +0300 Subject: [PATCH 22/49] fixed services gitlab --- .../tagrelease/domain/ServicesGl.java | 184 ++++++++---------- 1 file changed, 76 insertions(+), 108 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java b/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java index f6ee8a3..83f6d4b 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java @@ -24,21 +24,22 @@ package io.github.artemget.tagrelease.domain; +import com.amihaiemil.eoyaml.Yaml; import com.jcabi.http.Request; import com.jcabi.http.request.JdkRequest; -import com.jcabi.http.response.RestResponse; import io.github.artemget.entrys.Entry; import io.github.artemget.entrys.EntryException; import io.github.artemget.entrys.json.EJsonStr; +import io.github.artemget.tagrelease.entry.EFetchArr; +import io.github.artemget.tagrelease.entry.EFetchObj; import io.github.artemget.tagrelease.entry.EFunc; -import io.github.artemget.tagrelease.exception.CommunicationException; import io.github.artemget.tagrelease.exception.DomainException; import java.io.IOException; -import java.io.StringReader; +import java.util.ArrayList; import java.util.List; -import javax.json.Json; import javax.json.JsonArray; import javax.json.JsonObject; +import javax.json.JsonValue; /** * Applications from gitlab. @@ -50,55 +51,52 @@ public final class ServicesGl implements Services { * List repository tree. Each directory with name not starting with _ prefix - is a service. * GET /projects/:id/repository/tree */ - private final Request services; + private final Entry services; /** * Get file from repository. Tag name placed under image:tag: in this file. * GET /projects/:id/repository/files/:file_path */ - private final EFunc tag; + private final EFunc tag; /** * Ctor configures https req to gitlab services. * - * @param url Of gitlab. - * @param release Where to search services. - * @param branch Project which services belong to. - * @throws EntryException If no entry data + * @param url Of gitlab + * @param release Where to search services + * @param branch Project which services belong to + * @param token Api token */ public ServicesGl( final Entry url, final Entry release, final Entry branch, final Entry token - ) throws EntryException { - this( - new JdkRequest(url.value()).uri() - .path( - String.format( - "api/v4/projects/%s/repository/tree", - release.value() - ) - ).queryParam( - "ref", - branch.value() - ).back() - .method(Request.GET) - .header("Accept", "application/json"), - (service) -> new JdkRequest(url.value()).uri() - .path( - String.format( - "api/v4/projects/%s/repository/files/%s", - release.value(), - service.concat("%2Fvalues.yaml") - ) - ).queryParam( - "ref", - branch.value() - ).back() - .method(Request.GET) - .header("Accept", "application/json") + ) { + this(() -> + new EFetchArr( + new JdkRequest(url.value()).uri() + .path( + String.format("api/v4/projects/%s/repository/tree", release.value()) + ).queryParam("ref", branch.value()).queryParam("per_page", "100") + .back().method(Request.GET) + .header("Accept", "application/json") + .header("PRIVATE-TOKEN:", token.value()) + ).value(), + (service) -> new EFetchObj( + new JdkRequest(url.value()).uri() + .path( + String.format( + "api/v4/projects/%s/repository/files/%s", + release.value(), + service.concat("%2Fvalues.yaml") + ) + ).queryParam("ref", branch.value()) + .back().method(Request.GET) + .header("Accept", "application/json") + .header("PRIVATE-TOKEN:", token.value()) + ).value() ); } @@ -107,93 +105,63 @@ public ServicesGl( * * @param services At gitlab */ - public ServicesGl(final Request services, final EFunc tag) { + public ServicesGl(final Entry services, final EFunc tag) { this.services = services; this.tag = tag; } @Override public List services() throws DomainException { - return null; -// return this.directories().stream() -// .filter(dir -> { -// boolean pass; -// try { -// final JsonObject json = dir.asJsonObject(); -// final boolean directory = new EJsonStr(json, "type").value().equals("tree"); -// final boolean service = !new EJsonStr(json, "name").value().startsWith("_"); -// pass = directory && service; -// } catch (final EntryException exception) { -// pass = false; -// //TODO: add logging -// } -// return pass; -// } -// ).map(dir -> { -// final String directory = new EJsonStr(dir.asJsonObject(), "name").value(); -// return new ServiceGitlabEager( -// () -> directory, -// () -> this.tag.apply(directory) -// ); -// } -// ).collect(Collectors.toList()); + final JsonArray array; + try { + array = this.services.value(); + } catch (final EntryException exception) { + throw new DomainException("Failed to fetch services from stand", exception); + } + final List services = new ArrayList<>(); + for (final JsonValue dir : array) { + final JsonObject json = dir.asJsonObject(); + final String name = json.getString("name"); + final boolean directory = json.getString("type").equals("tree"); + final boolean service = !name.startsWith("_"); + if (directory && service) { + services.add(this.service(name)); + } + } + return services; } @Override public Service service(final String name) throws DomainException { - return null; -// return this.directories().stream() -// .filter(service -> { -// boolean pass; -// try { -// JsonObject json = service.asJsonObject(); -// final boolean directory = new EJsonStr(json, "type").value().equals("tree"); -// final boolean named = new EJsonStr(json, "name").value().equals(name); -// pass = directory && named; -// } catch (final EntryException exception) { -// pass = false; -// //TODO: add logging -// } -// return pass; -// } -// ).findFirst() -// .map(dir -> { -// final String directory = new EJsonStr(dir.asJsonObject(), "name").value(); -// return new ServiceGitlabEager( -// () -> directory, -// () -> this.tag.apply(directory) -// ); -// }) -// .orElseThrow(); - } - - private Service created(final JsonObject dir) throws DomainException { + final JsonObject json; try { - final String directory = new EJsonStr(dir.asJsonObject(), "name").value(); - return new ServiceEa( - () -> directory, - () -> this.tag.apply(directory) + json = this.tag.apply(name); + } catch (EntryException exception) { + throw new DomainException( + String.format("Failed to fetch '%s' service from stand", name), + exception ); + } + final String content; + try { + content = new EJsonStr(json, "content").value(); } catch (final EntryException exception) { - throw new DomainException(exception); - } catch (final IOException exception) { - throw new CommunicationException("Failed to fetch file from gitlab.", exception); + throw new DomainException( + String.format("Failed to get content for service:'%s' from:'%s'", name, json), + exception + ); } - } - - private JsonArray directories() throws DomainException { try { - return Json.createReader( - new StringReader( - this.services.fetch().as(RestResponse.class).body() - ) - ).readArray(); + return new ServiceEa( + "", + name, + Yaml.createYamlInput(content).readYamlMapping() + .yamlMapping("image") + .string("tag") + ); } catch (final IOException exception) { - throw new CommunicationException( - String.format( - "Failed to fetch services names from gitlab. Request: %s", - this.services.uri() - ), + throw new DomainException( + String.format("Failed to get content for service:'%s' from:'%s'", name, json), exception ); } From 2beca78612e8240707c0b0df88432e81a2f47254 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Mon, 30 Jun 2025 22:59:21 +0300 Subject: [PATCH 23/49] remove redundant response mapping --- .../java/io/github/artemget/tagrelease/entry/EFetchJson.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/entry/EFetchJson.java b/src/main/java/io/github/artemget/tagrelease/entry/EFetchJson.java index 5524956..0a9948c 100644 --- a/src/main/java/io/github/artemget/tagrelease/entry/EFetchJson.java +++ b/src/main/java/io/github/artemget/tagrelease/entry/EFetchJson.java @@ -25,7 +25,6 @@ package io.github.artemget.tagrelease.entry; import com.jcabi.http.Request; -import com.jcabi.http.response.RestResponse; import io.github.artemget.entrys.Entry; import io.github.artemget.entrys.EntryException; import java.io.IOException; @@ -43,9 +42,7 @@ public EFetchJson(final Request request) { @Override public JsonStructure value() throws EntryException { try { - return Json.createReader( - new StringReader(request.fetch().as(RestResponse.class).body()) - ).read(); + return Json.createReader(new StringReader(request.fetch().body())).read(); } catch (final IOException exception) { throw new EntryException( String.format("Failed to fetch json array from resource:%s", this.request.uri()), From d950f9da14326188c142a3c15226ae2d7b5eeb7a Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Mon, 30 Jun 2025 22:59:53 +0300 Subject: [PATCH 24/49] remove redundant uri call, fix id mapping --- .../tagrelease/domain/ServicesAll.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java b/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java index b562b13..7aaf160 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java @@ -40,7 +40,6 @@ /** * Fetch repositories(services) from gitlab project. - * * @since 0.0.1 */ public final class ServicesAll implements Services { @@ -54,19 +53,15 @@ public ServicesAll( ) { this( (service) -> new EFetchArr( - new JdkRequest(host.value()).uri() - .path(String.format("api/v4/groups/%s/projects", project.value())) - .queryParam("search", service) - .back().method(Request.GET) - .header("Accept", "application/json") - .header("PRIVATE-TOKEN:", token.value()) + new JdkRequest( + String.format("%s/api/v4/groups/%s/projects?search=%s", host.value(), project.value(), service) + ).method(Request.GET).header("Accept", "application/json").header("PRIVATE-TOKEN", token.value()) ).value(), () -> new EFetchArr( - new JdkRequest(host.value()).uri() - .path(String.format("api/v4/groups/%s/projects", project.value())) - .back().method(Request.GET) + new JdkRequest(String.format("%s/api/v4/groups/%s/projects", host.value(), project.value())) + .method(Request.GET) .header("Accept", "application/json") - .header("PRIVATE-TOKEN:", token.value()) + .header("PRIVATE-TOKEN", token.value()) ).value() ); } @@ -115,11 +110,11 @@ private Service parsed(final JsonValue service) throws DomainException { try { JsonObject json = service.asJsonObject(); return new ServiceEa( - new EJsonStr(json, "id").value(), + String.valueOf(json.getInt("id")), new EJsonStr(json, "name").value(), "" ); - } catch (final EntryException exception) { + } catch (final EntryException | ClassCastException exception) { throw new DomainException("Failed to parse service from gitlab", exception); } } From 64dcb71913b655141a84206dbadce93eceecaccb Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Mon, 30 Jun 2025 23:00:16 +0300 Subject: [PATCH 25/49] fix config name --- src/main/java/io/github/artemget/tagrelease/Entrypoint.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java index ba4fabd..a909dd5 100644 --- a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java +++ b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java @@ -43,9 +43,8 @@ /** * Entrypoint. Application starts here. - * - * @since 0.1.0 * @checkstyle HideUtilityClassConstructorCheck (20 lines) + * @since 0.1.0 */ @SuppressWarnings( { @@ -68,7 +67,7 @@ public static void main(final String[] args) throws EntryException, TelegramApiE new EVal("bot.name"), new EVal("bot.token"), new RouteFork<>( - new MatchAdmin(new ESplit(new EVal("admins"))), + new MatchAdmin(new ESplit(new EVal("bot.admins"))), new RouteDfs<>( new RouteFork<>( new MatchRegex<>("[Пп]окажи сервисы"), From 846b6e019ff74f36bff7c0f47cce9de64cfa3eef Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Mon, 30 Jun 2025 23:08:23 +0300 Subject: [PATCH 26/49] add build tags command --- .../artemget/tagrelease/Entrypoint.java | 10 +++- .../tagrelease/command/CmdBuildTags.java | 55 +++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java diff --git a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java index a909dd5..309931e 100644 --- a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java +++ b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java @@ -30,9 +30,12 @@ import io.github.artemget.entrys.operation.ESplit; import io.github.artemget.tagrelease.bot.Bot; import io.github.artemget.tagrelease.bot.BotReg; +import io.github.artemget.tagrelease.command.CmdBuildTags; import io.github.artemget.tagrelease.command.CmdListServices; import io.github.artemget.tagrelease.command.CmdListServicesAll; import io.github.artemget.tagrelease.command.CmdListStands; +import io.github.artemget.tagrelease.domain.Services; +import io.github.artemget.tagrelease.domain.ServicesAll; import io.github.artemget.tagrelease.domain.Stands; import io.github.artemget.tagrelease.domain.StandsGl; import io.github.artemget.tagrelease.match.MatchAdmin; @@ -61,6 +64,7 @@ public static void main(final String[] args) throws EntryException, TelegramApiE final Entry repo = new EVal("provider.token"); final Entry token = new EVal("provider.token"); final Entry project = new EVal("provider.project"); + final Services all = new ServicesAll(host, project, token); final Stands stands = new StandsGl(host, release, repo, token); new BotReg( new Bot( @@ -71,7 +75,7 @@ public static void main(final String[] args) throws EntryException, TelegramApiE new RouteDfs<>( new RouteFork<>( new MatchRegex<>("[Пп]окажи сервисы"), - new CmdListServicesAll(host, project, token) + new CmdListServicesAll(all) ), new RouteFork<>( new MatchRegex<>("[Пп]окажи сервисы \\{([^{}]*)\\}$"), @@ -80,6 +84,10 @@ public static void main(final String[] args) throws EntryException, TelegramApiE new RouteFork<>( new MatchRegex<>("[Пп]окажи стенды"), new CmdListStands(stands) + ), + new RouteFork<>( + new MatchRegex<>("[Сс]обери сервисы \\{([^{}]*)\\}$ префикс \\{([^{}]*)\\}$"), + new CmdBuildTags(all) ) // new RouteFork<>( // new MatchRegex<>("Покажи стенд"), diff --git a/src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java b/src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java new file mode 100644 index 0000000..b69fbab --- /dev/null +++ b/src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java @@ -0,0 +1,55 @@ +/* + * MIT License + * + * Copyright (c) 2024-2025. Artem Getmanskii + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.github.artemget.tagrelease.command; + +import io.github.artemget.entrys.Entry; +import io.github.artemget.tagrelease.domain.Services; +import io.github.artemget.tagrelease.domain.ServicesAll; +import io.github.artemget.teleroute.command.Cmd; +import io.github.artemget.teleroute.command.CmdException; +import io.github.artemget.teleroute.send.Send; +import org.telegram.telegrambots.meta.api.objects.Update; +import org.telegram.telegrambots.meta.bots.AbsSender; + +public class CmdBuildTags implements Cmd { + private final Services services; + + public CmdBuildTags( + final Entry host, + final Entry project, + final Entry token + ) { + this(new ServicesAll(host, project, token)); + } + + public CmdBuildTags(final Services services) { + this.services = services; + } + + @Override + public Send execute(Update update) throws CmdException { + return null; + } +} From f142e87fa359d5a45b4826e69a496c17865aba23 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Mon, 30 Jun 2025 23:14:51 +0300 Subject: [PATCH 27/49] remove redundant uri call --- .../tagrelease/domain/ServicesGl.java | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java b/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java index 83f6d4b..9f704b9 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java @@ -74,26 +74,23 @@ public ServicesGl( final Entry branch, final Entry token ) { - this(() -> - new EFetchArr( - new JdkRequest(url.value()).uri() - .path( - String.format("api/v4/projects/%s/repository/tree", release.value()) - ).queryParam("ref", branch.value()).queryParam("per_page", "100") - .back().method(Request.GET) - .header("Accept", "application/json") - .header("PRIVATE-TOKEN:", token.value()) - ).value(), + this(() -> new EFetchArr( + new JdkRequest( + String.format( + "%s/api/v4/projects/%s/repository/tree?ref=%s&per_page=100", + url.value(), release.value(), branch.value() + ) + ).method(Request.GET) + .header("Accept", "application/json") + .header("PRIVATE-TOKEN:", token.value()) + ).value(), (service) -> new EFetchObj( - new JdkRequest(url.value()).uri() - .path( - String.format( - "api/v4/projects/%s/repository/files/%s", - release.value(), - service.concat("%2Fvalues.yaml") - ) - ).queryParam("ref", branch.value()) - .back().method(Request.GET) + new JdkRequest( + String.format( + "%s/api/v4/projects/%s/repository/files/%s?ref=%s", + url.value(), release.value(), service.concat("%2Fvalues.yaml"), branch.value() + ) + ).method(Request.GET) .header("Accept", "application/json") .header("PRIVATE-TOKEN:", token.value()) ).value() From 07021baefaeb6353306bc21721bcc2d8574d2273 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Mon, 30 Jun 2025 23:25:39 +0300 Subject: [PATCH 28/49] remove redundant uri call --- .../tagrelease/domain/ServicesAll.java | 4 +++- .../tagrelease/domain/ServicesGl.java | 4 ++-- .../artemget/tagrelease/domain/StandsGl.java | 23 +++++++++---------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java b/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java index 7aaf160..6762508 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java @@ -55,7 +55,9 @@ public ServicesAll( (service) -> new EFetchArr( new JdkRequest( String.format("%s/api/v4/groups/%s/projects?search=%s", host.value(), project.value(), service) - ).method(Request.GET).header("Accept", "application/json").header("PRIVATE-TOKEN", token.value()) + ).method(Request.GET) + .header("Accept", "application/json") + .header("PRIVATE-TOKEN", token.value()) ).value(), () -> new EFetchArr( new JdkRequest(String.format("%s/api/v4/groups/%s/projects", host.value(), project.value())) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java b/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java index 9f704b9..682b044 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java @@ -82,7 +82,7 @@ public ServicesGl( ) ).method(Request.GET) .header("Accept", "application/json") - .header("PRIVATE-TOKEN:", token.value()) + .header("PRIVATE-TOKEN", token.value()) ).value(), (service) -> new EFetchObj( new JdkRequest( @@ -92,7 +92,7 @@ public ServicesGl( ) ).method(Request.GET) .header("Accept", "application/json") - .header("PRIVATE-TOKEN:", token.value()) + .header("PRIVATE-TOKEN", token.value()) ).value() ); } diff --git a/src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java b/src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java index 31ebfae..263caaa 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java @@ -68,22 +68,21 @@ public StandsGl( ) { this( () -> new EFetchArr( - new JdkRequest(url.value()).uri() - .path(String.format("api/v4/projects/:%s/repository/branches", repo.value())) - .back().method(Request.GET) + new JdkRequest( + String.format("%s/api/v4/projects/:%s/repository/branches", url.value(), repo.value()) + ).method(Request.GET) .header("Accept", "application/json") - .header("PRIVATE-TOKEN:", token.value()) + .header("PRIVATE-TOKEN", token.value()) ).value(), (name) -> new EFetchObj( - new JdkRequest(url.value()).uri() - .path( - String.format( - "api/v4/projects/%s/repository/branches/%s", repo.value(), name - ) - ).back() - .method(Request.GET) + new JdkRequest( + String.format( + "%s/api/v4/projects/%s/repository/branches/%s", + url.value(), repo.value(), name + ) + ).method(Request.GET) .header("Accept", "application/json") - .header("PRIVATE-TOKEN:", token.value()) + .header("PRIVATE-TOKEN", token.value()) ).value(), (branch) -> new ServicesGl(url, release, () -> branch, token) ); From 4945d2d3efe3ae52334956c1db61993642314515 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Thu, 3 Jul 2025 12:21:05 +0300 Subject: [PATCH 29/49] fix message formatting, fix config --- src/main/java/io/github/artemget/tagrelease/Entrypoint.java | 3 +-- .../github/artemget/tagrelease/command/CmdListStands.java | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java index 309931e..febefa0 100644 --- a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java +++ b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java @@ -61,11 +61,10 @@ public class Entrypoint { public static void main(final String[] args) throws EntryException, TelegramApiException { final Entry host = new EVal("provider.host"); final Entry release = new EVal("provider.release"); - final Entry repo = new EVal("provider.token"); final Entry token = new EVal("provider.token"); final Entry project = new EVal("provider.project"); final Services all = new ServicesAll(host, project, token); - final Stands stands = new StandsGl(host, release, repo, token); + final Stands stands = new StandsGl(host, release, token); new BotReg( new Bot( new EVal("bot.name"), diff --git a/src/main/java/io/github/artemget/tagrelease/command/CmdListStands.java b/src/main/java/io/github/artemget/tagrelease/command/CmdListStands.java index 413cef6..bef6501 100644 --- a/src/main/java/io/github/artemget/tagrelease/command/CmdListStands.java +++ b/src/main/java/io/github/artemget/tagrelease/command/CmdListStands.java @@ -39,7 +39,6 @@ /** * Lists available stands and it's services. - * * @since 0.1.0 */ public final class CmdListStands implements Cmd { @@ -74,7 +73,10 @@ public Send execute(final Update update) throws CmdException { } final SendMessage message = new SendMessage( update.getMessage().getChatId().toString(), - stands.stream().map(Stand::name).collect(Collectors.joining("\n")) + String.format( + "```\n%s```", + stands.stream().map(Stand::name).collect(Collectors.joining("\n")) + ) ); message.setReplyToMessageId(update.getMessage().getMessageId()); message.enableMarkdownV2(true); From 0f5c8efdf5059c28f40b66cb15452d4cba91c905 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Thu, 3 Jul 2025 12:21:48 +0300 Subject: [PATCH 30/49] remove eager request --- .../artemget/tagrelease/domain/Service.java | 10 +--- .../artemget/tagrelease/domain/ServiceEa.java | 52 +++++++------------ 2 files changed, 21 insertions(+), 41 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/Service.java b/src/main/java/io/github/artemget/tagrelease/domain/Service.java index bcb9bf9..addc845 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/Service.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/Service.java @@ -46,13 +46,5 @@ public interface Service { * * @return Tag */ - String tag(); - - /** - * Builds new tag. - * - * @param rule To build tag - * @return Service with a new tag - */ - Service tagged(Scalar rule) throws DomainException; + String tag() throws DomainException; } diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServiceEa.java b/src/main/java/io/github/artemget/tagrelease/domain/ServiceEa.java index 2dc7a09..81f6a3b 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/ServiceEa.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServiceEa.java @@ -29,16 +29,14 @@ import com.jcabi.http.response.RestResponse; import io.github.artemget.entrys.Entry; import io.github.artemget.entrys.EntryException; +import io.github.artemget.entrys.fake.EFake; import io.github.artemget.entrys.json.EJsonStr; -import io.github.artemget.tagrelease.exception.DomainException; import java.io.IOException; import java.io.StringReader; import javax.json.Json; -import org.cactoos.Scalar; /** * Application's source code in gitlab. - * * @since 0.1.0 */ @SuppressWarnings("PMD.AvoidFieldNameMatchingMethodName") @@ -56,9 +54,8 @@ public final class ServiceEa implements Service { /** * Last tag. */ - private final String tag; + private final Entry tag; - //TODO: remove eager and req in ctor public ServiceEa( final Entry id, final Entry name, @@ -67,28 +64,29 @@ public ServiceEa( this( id.value(), name.value(), - Yaml.createYamlInput( - new EJsonStr( - Json.createReader( - new StringReader( - tag.value().fetch().as(RestResponse.class).body() - ) - ).readObject() - , "content" - ).value() - ).readYamlMapping() - .yamlMapping("image") - .string("tag") + new EFake<>( + Yaml.createYamlInput( + new EJsonStr( + Json.createReader( + new StringReader( + tag.value().fetch().as(RestResponse.class).body() + ) + ).readObject() + , "content" + ).value() + ).readYamlMapping() + .yamlMapping("image") + .string("tag") + ) ); } /** * Main ctor. - * * @param name Of application * @param tag Of application */ - public ServiceEa(final String id, final String name, final String tag) { + public ServiceEa(final String id, final String name, final Entry tag) { this.id = id; this.name = name; this.tag = tag; @@ -106,20 +104,10 @@ public String name() { @Override public String tag() { - return this.tag; - } - - // @checkstyle IllegalCatchCheck (50 lines) - @SuppressWarnings("PMD.AvoidCatchingGenericException") - @Override - public Service tagged(final Scalar rule) throws DomainException { try { - return new ServiceEa(this.id, this.name, rule.value()); - } catch (final Exception exception) { - throw new DomainException( - String.format("Failed to create tag for service: %s", this.name), - exception - ); + return this.tag.value(); + } catch (EntryException e) { + throw new RuntimeException(e); } } } From 00080417579fd0f61012ded984cb6b74b8de67a2 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Thu, 3 Jul 2025 12:24:40 +0300 Subject: [PATCH 31/49] fix printed --- .../artemget/tagrelease/domain/Services.java | 23 +++++-------------- .../tagrelease/domain/ServicesAll.java | 2 +- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/Services.java b/src/main/java/io/github/artemget/tagrelease/domain/Services.java index 2e206e1..bee47df 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/Services.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/Services.java @@ -26,25 +26,21 @@ import io.github.artemget.tagrelease.exception.DomainException; import java.util.List; -import java.util.stream.Collectors; import org.cactoos.Text; /** * Applications. - * * @since 0.1.0 */ public interface Services { /** * Returns all services from stand. - * * @return Services */ List services() throws DomainException; /** * Returns service from stand by it's name. - * * @param name Of service * @return Service */ @@ -53,7 +49,6 @@ public interface Services { /** * Printed Services. * Format: ```java %s:%s```\n - * * @since 0.1.0 */ final class Printed implements Text { @@ -64,7 +59,6 @@ final class Printed implements Text { /** * Main ctor. - * * @param services Services */ public Printed(final Services services) { @@ -72,17 +66,12 @@ public Printed(final Services services) { } @Override - public String asString() throws DomainException{ - return this.services.services().stream() - .map( - service -> - String.format( - "```java %s:%s```\n ", - service.name(), - service.tag() - ) - ) - .collect(Collectors.joining()); + public String asString() throws DomainException { + final StringBuilder string = new StringBuilder(); + for (final Service service : this.services.services()) { + string.append(String.format("```java %s:%s```\n", service.name(), service.tag())); + } + return string.toString(); } } } diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java b/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java index 6762508..11646f8 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServicesAll.java @@ -114,7 +114,7 @@ private Service parsed(final JsonValue service) throws DomainException { return new ServiceEa( String.valueOf(json.getInt("id")), new EJsonStr(json, "name").value(), - "" + () -> "" ); } catch (final EntryException | ClassCastException exception) { throw new DomainException("Failed to parse service from gitlab", exception); From 3cdcbd68f14d4d775f2d19486dd2bc3c8b3f1232 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Thu, 3 Jul 2025 12:31:25 +0300 Subject: [PATCH 32/49] fix eager --- .../tagrelease/domain/ServicesGl.java | 72 +++++++++---------- .../artemget/tagrelease/domain/StandsGl.java | 14 ++-- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java b/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java index 682b044..5f60a51 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServicesGl.java @@ -25,6 +25,7 @@ package io.github.artemget.tagrelease.domain; import com.amihaiemil.eoyaml.Yaml; +import com.amihaiemil.eoyaml.exceptions.YamlIndentationException; import com.jcabi.http.Request; import com.jcabi.http.request.JdkRequest; import io.github.artemget.entrys.Entry; @@ -40,10 +41,10 @@ import javax.json.JsonArray; import javax.json.JsonObject; import javax.json.JsonValue; +import org.apache.commons.codec.binary.Base64; /** * Applications from gitlab. - * * @since 0.1.0 */ public final class ServicesGl implements Services { @@ -59,10 +60,8 @@ public final class ServicesGl implements Services { */ private final EFunc tag; - /** * Ctor configures https req to gitlab services. - * * @param url Of gitlab * @param release Where to search services * @param branch Project which services belong to @@ -99,7 +98,6 @@ public ServicesGl( /** * Main ctor. - * * @param services At gitlab */ public ServicesGl(final Entry services, final EFunc tag) { @@ -130,37 +128,39 @@ public List services() throws DomainException { @Override public Service service(final String name) throws DomainException { - final JsonObject json; - try { - json = this.tag.apply(name); - } catch (EntryException exception) { - throw new DomainException( - String.format("Failed to fetch '%s' service from stand", name), - exception - ); - } - final String content; - try { - content = new EJsonStr(json, "content").value(); - } catch (final EntryException exception) { - throw new DomainException( - String.format("Failed to get content for service:'%s' from:'%s'", name, json), - exception - ); - } - try { - return new ServiceEa( - "", - name, - Yaml.createYamlInput(content).readYamlMapping() - .yamlMapping("image") - .string("tag") - ); - } catch (final IOException exception) { - throw new DomainException( - String.format("Failed to get content for service:'%s' from:'%s'", name, json), - exception - ); - } + return new ServiceEa( + "", + name, + () -> { + final JsonObject json; + try { + json = this.tag.apply(name); + } catch (final EntryException exception) { + throw new EntryException( + String.format("Failed to fetch '%s' service from stand", name), + exception + ); + } + final String content; + try { + content = new String(Base64.decodeBase64(new EJsonStr(json, "content").value())); + } catch (final EntryException exception) { + throw new EntryException( + String.format("Failed to get content for service:'%s' from:'%s'", name, json), + exception + ); + } + try { + return Yaml.createYamlInput(content).readYamlMapping() + .yamlMapping("image") + .string("tag"); + } catch (final IOException | YamlIndentationException exception) { + throw new EntryException( + String.format("Failed to get content for service:'%s' from:'%s'", name, json), + exception + ); + } + } + ); } } diff --git a/src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java b/src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java index 263caaa..4f38740 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/StandsGl.java @@ -41,7 +41,6 @@ /** * Servers. - * * @since 0.1.0 */ public final class StandsGl implements Stands { @@ -59,17 +58,15 @@ public final class StandsGl implements Stands { private final EFunc services; - public StandsGl( final Entry url, final Entry release, - final Entry repo, final Entry token ) { this( () -> new EFetchArr( new JdkRequest( - String.format("%s/api/v4/projects/:%s/repository/branches", url.value(), repo.value()) + String.format("%s/api/v4/projects/%s/repository/branches", url.value(), release.value()) ).method(Request.GET) .header("Accept", "application/json") .header("PRIVATE-TOKEN", token.value()) @@ -78,7 +75,7 @@ public StandsGl( new JdkRequest( String.format( "%s/api/v4/projects/%s/repository/branches/%s", - url.value(), repo.value(), name + url.value(), release.value(), name ) ).method(Request.GET) .header("Accept", "application/json") @@ -103,12 +100,15 @@ public List stands() throws DomainException { final JsonArray response; try { response = this.stands.value(); - } catch (EntryException exception) { + } catch (final EntryException exception) { throw new DomainException("Failed to fetch all services from gitlab", exception); } final List stands = new ArrayList<>(); for (final JsonValue branch : response) { - stands.add(this.enriched(branch.asJsonObject())); + final Stand stand = this.enriched(branch.asJsonObject()); + if (!"main".equals(stand.name())) { + stands.add(stand); + } } return stands; } From 809863b6bc01ed33ed329b48e08ab254c8d7bd2a Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Thu, 3 Jul 2025 12:31:40 +0300 Subject: [PATCH 33/49] add exception rethrow --- .../github/artemget/tagrelease/domain/ServiceEa.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/ServiceEa.java b/src/main/java/io/github/artemget/tagrelease/domain/ServiceEa.java index 81f6a3b..ca2e1be 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/ServiceEa.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/ServiceEa.java @@ -31,6 +31,7 @@ import io.github.artemget.entrys.EntryException; import io.github.artemget.entrys.fake.EFake; import io.github.artemget.entrys.json.EJsonStr; +import io.github.artemget.tagrelease.exception.DomainException; import java.io.IOException; import java.io.StringReader; import javax.json.Json; @@ -103,11 +104,14 @@ public String name() { } @Override - public String tag() { + public String tag() throws DomainException { try { return this.tag.value(); - } catch (EntryException e) { - throw new RuntimeException(e); + } catch (final EntryException exception) { + throw new DomainException( + String.format("Failed ro fetch tag for service:'%s'", this.name()), + exception + ); } } } From e5944eec26e26fce8d2a1585f63bc35041d1afe4 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Thu, 3 Jul 2025 15:50:10 +0300 Subject: [PATCH 34/49] temp tags --- .../artemget/tagrelease/domain/Tag.java | 31 +++++ .../artemget/tagrelease/domain/TagEa.java | 52 +++++++ .../artemget/tagrelease/domain/Tags.java | 32 +++++ .../artemget/tagrelease/domain/TagsGl.java | 130 ++++++++++++++++++ 4 files changed, 245 insertions(+) create mode 100644 src/main/java/io/github/artemget/tagrelease/domain/Tag.java create mode 100644 src/main/java/io/github/artemget/tagrelease/domain/TagEa.java create mode 100644 src/main/java/io/github/artemget/tagrelease/domain/Tags.java create mode 100644 src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java diff --git a/src/main/java/io/github/artemget/tagrelease/domain/Tag.java b/src/main/java/io/github/artemget/tagrelease/domain/Tag.java new file mode 100644 index 0000000..32d0175 --- /dev/null +++ b/src/main/java/io/github/artemget/tagrelease/domain/Tag.java @@ -0,0 +1,31 @@ +/* + * MIT License + * + * Copyright (c) 2024-2025. Artem Getmanskii + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.github.artemget.tagrelease.domain; + +public interface Tag { + String repo(); + String name(); + String branch(); +} diff --git a/src/main/java/io/github/artemget/tagrelease/domain/TagEa.java b/src/main/java/io/github/artemget/tagrelease/domain/TagEa.java new file mode 100644 index 0000000..51e0389 --- /dev/null +++ b/src/main/java/io/github/artemget/tagrelease/domain/TagEa.java @@ -0,0 +1,52 @@ +/* + * MIT License + * + * Copyright (c) 2024-2025. Artem Getmanskii + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.github.artemget.tagrelease.domain; + +public final class TagEa implements Tag { + private final String repo; + private final String name; + private final String branch; + + public TagEa(final String repo, final String name, final String branch) { + this.repo = repo; + this.name = name; + this.branch = branch; + } + + @Override + public String repo() { + return this.repo; + } + + @Override + public String name() { + return this.name; + } + + @Override + public String branch() { + return this.branch; + } +} diff --git a/src/main/java/io/github/artemget/tagrelease/domain/Tags.java b/src/main/java/io/github/artemget/tagrelease/domain/Tags.java new file mode 100644 index 0000000..54d4a06 --- /dev/null +++ b/src/main/java/io/github/artemget/tagrelease/domain/Tags.java @@ -0,0 +1,32 @@ +/* + * MIT License + * + * Copyright (c) 2024-2025. Artem Getmanskii + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.github.artemget.tagrelease.domain; + +import io.github.artemget.tagrelease.exception.DomainException; +public interface Tags { + Tag buildNew(final String serviceId, final String branch, final String prefix) throws DomainException; + + Tag current(final String serviceId, final String branch, final String prefix) throws DomainException; +} diff --git a/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java b/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java new file mode 100644 index 0000000..efa205b --- /dev/null +++ b/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java @@ -0,0 +1,130 @@ +/* + * MIT License + * + * Copyright (c) 2024-2025. Artem Getmanskii + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.github.artemget.tagrelease.domain; + +import com.jcabi.http.Request; +import com.jcabi.http.request.JdkRequest; +import io.github.artemget.entrys.Entry; +import io.github.artemget.entrys.EntryException; +import io.github.artemget.tagrelease.entry.EFetchArr; +import io.github.artemget.tagrelease.entry.EFunc; +import io.github.artemget.tagrelease.exception.DomainException; +import java.util.HashMap; +import java.util.Map; +import javax.json.JsonArray; +import javax.json.JsonObject; +import javax.json.JsonValue; + +public final class TagsGl implements Tags { + private final EFunc tag; + + public TagsGl( + final Entry url, + final Entry token + ) { + this( + (tag) -> + new EFetchArr( + new JdkRequest( + String.format( + "%s/api/v4/projects/%s/repository/tags?search=^%s", + url.value(), + tag.repo(), + tag.name().replace(".*", "") + ) + ).method(Request.GET) + .header("Accept", "application/json") + .header("PRIVATE-TOKEN", token.value()) + ).value() + ); + } + + public TagsGl(final EFunc tag) { + this.tag = tag; + } + + @Override + public Tag buildNew(final String serviceId, final String branch, final String prefix) throws DomainException { + final JsonArray response; + try { + response = this.tag.apply(new TagEa(serviceId, prefix, branch)); + } catch (final EntryException exception) { + throw new DomainException( + String.format( + "Failed to fetch tag with prefix:'%s' for service:'%s' from branch:'%s'", + prefix, serviceId, branch + ), + exception + ); + } + for (final JsonValue value : response) { + } + return null; + } + + Map origin(String p) { + Map r = new HashMap<>(); + for(int i=0;i { + if(val == null) { + return 1; + } + return val + 1; + } + ); + } + } + + @Override + public Tag current(final String serviceId, final String branch, final String prefix) throws DomainException { + final JsonArray response; + try { + response = this.tag.apply(new TagEa(serviceId, prefix, branch)); + } catch (final EntryException exception) { + throw new DomainException( + String.format( + "Failed to fetch tag with prefix:'%s' for service:'%s' from branch:'%s'", + prefix, serviceId, branch + ), + exception + ); + } + return new TagEa( + serviceId, + TagsGl.found(response, prefix).getString("name"), + branch + ); + } + + public static JsonObject found(JsonArray array, String prefix) throws DomainException { + + } + + public static String trimmed(String cell) { + + } +} From ed7f74e26c04ebaae959b6b361e656065ae28be4 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Thu, 3 Jul 2025 21:29:07 +0300 Subject: [PATCH 35/49] add temp build tags cmd --- .../tagrelease/command/CmdBuildTags.java | 54 +++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java b/src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java index b69fbab..6ab067a 100644 --- a/src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java +++ b/src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java @@ -25,31 +25,79 @@ package io.github.artemget.tagrelease.command; import io.github.artemget.entrys.Entry; +import io.github.artemget.entrys.EntryException; +import io.github.artemget.entrys.operation.ESplit; +import io.github.artemget.entrys.operation.EUnwrap; +import io.github.artemget.tagrelease.domain.Service; import io.github.artemget.tagrelease.domain.Services; import io.github.artemget.tagrelease.domain.ServicesAll; +import io.github.artemget.tagrelease.domain.Tag; +import io.github.artemget.tagrelease.domain.Tags; +import io.github.artemget.tagrelease.domain.TagsGl; +import io.github.artemget.tagrelease.exception.DomainException; import io.github.artemget.teleroute.command.Cmd; import io.github.artemget.teleroute.command.CmdException; import io.github.artemget.teleroute.send.Send; +import io.github.artemget.teleroute.telegrambots.send.SendMessageWrap; +import java.util.ArrayList; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.telegram.telegrambots.meta.api.methods.send.SendMessage; import org.telegram.telegrambots.meta.api.objects.Update; import org.telegram.telegrambots.meta.bots.AbsSender; public class CmdBuildTags implements Cmd { + private final Logger log = LoggerFactory.getLogger(CmdBuildTags.class); private final Services services; + private final Tags tags; public CmdBuildTags( final Entry host, final Entry project, final Entry token ) { - this(new ServicesAll(host, project, token)); + this(new ServicesAll(host, project, token), new TagsGl(host, token)); } - public CmdBuildTags(final Services services) { + public CmdBuildTags(final Services services, final Tags tags) { this.services = services; + this.tags = tags; } @Override public Send execute(Update update) throws CmdException { - return null; + final List names; + final String branch = "develop"; + final String prefix = "v4.3.1.*"; + try { + names = new ESplit(new EUnwrap(update.getMessage().getText()), ",").value(); + } catch (final EntryException exception) { + throw new CmdException("Failed to parse service names for tag build", exception); + } + List succeed = new ArrayList<>(); + List failed = new ArrayList<>(); + for (final String name : names) { + Service service; + try { + service = this.services.service(name); + } catch (final DomainException exception) { + log.error("Failed to fetch service:'{}' for tag build", name, exception); + failed.add(name); + continue; + } + Tag tag; + try { + tag = this.tags.buildNew(service.id(), "develop", prefix); + } catch (final DomainException exception) { + log.error("Failed to build tag for service:'{}'", name, exception); + failed.add(name); + continue; + } + succeed.add(tag); + } + return new SendMessageWrap<>( + new SendMessage(update.getMessage().getChatId().toString(), "test") + ); } } From 2bb52f21c9f02b34e7348cbb7004de20e80f4b4b Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Thu, 3 Jul 2025 21:29:24 +0300 Subject: [PATCH 36/49] fix build services regex --- src/main/java/io/github/artemget/tagrelease/Entrypoint.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java index febefa0..3475eff 100644 --- a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java +++ b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java @@ -85,8 +85,8 @@ public static void main(final String[] args) throws EntryException, TelegramApiE new CmdListStands(stands) ), new RouteFork<>( - new MatchRegex<>("[Сс]обери сервисы \\{([^{}]*)\\}$ префикс \\{([^{}]*)\\}$"), - new CmdBuildTags(all) + new MatchRegex<>("[Сс]обери сервисы \\{([^{}]*)\\}\\s+префикс\\s+\\{([^{}]*)\\}$"), + new CmdBuildTags(host, project, token) ) // new RouteFork<>( // new MatchRegex<>("Покажи стенд"), From 206953de541ea7ab20058f809d36689827862ac7 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Thu, 3 Jul 2025 21:29:44 +0300 Subject: [PATCH 37/49] add url encoded ^ --- .../artemget/tagrelease/domain/TagsGl.java | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java b/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java index efa205b..53cfd74 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java @@ -49,7 +49,7 @@ public TagsGl( new EFetchArr( new JdkRequest( String.format( - "%s/api/v4/projects/%s/repository/tags?search=^%s", + "%s/api/v4/projects/%s/repository/tags?search=%%5E%s", url.value(), tag.repo(), tag.name().replace(".*", "") @@ -84,21 +84,6 @@ public Tag buildNew(final String serviceId, final String branch, final String pr return null; } - Map origin(String p) { - Map r = new HashMap<>(); - for(int i=0;i { - if(val == null) { - return 1; - } - return val + 1; - } - ); - } - } - @Override public Tag current(final String serviceId, final String branch, final String prefix) throws DomainException { final JsonArray response; @@ -121,10 +106,10 @@ public Tag current(final String serviceId, final String branch, final String pre } public static JsonObject found(JsonArray array, String prefix) throws DomainException { - + return null; } public static String trimmed(String cell) { - + return null; } } From 117dc2a35fbbc42ba61e2d73407f47ba8a641a64 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Thu, 3 Jul 2025 21:42:06 +0300 Subject: [PATCH 38/49] print fix --- .../tagrelease/command/CmdBuildTags.java | 12 ++++++-- .../artemget/tagrelease/domain/Tag.java | 28 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java b/src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java index 6ab067a..c26c436 100644 --- a/src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java +++ b/src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java @@ -96,8 +96,16 @@ public Send execute(Update update) throws CmdException { } succeed.add(tag); } - return new SendMessageWrap<>( - new SendMessage(update.getMessage().getChatId().toString(), "test") + final SendMessage message = new SendMessage( + update.getMessage().getChatId().toString(), + String.format( + "Собраны сервисы:\n%s\nОшибка сборки сервисов:\n%s", + new Tag.Printed(succeed).asString(), + String.join("\n", failed) + ) ); + message.setReplyToMessageId(update.getMessage().getMessageId()); + message.enableMarkdownV2(true); + return new SendMessageWrap<>(message); } } diff --git a/src/main/java/io/github/artemget/tagrelease/domain/Tag.java b/src/main/java/io/github/artemget/tagrelease/domain/Tag.java index 32d0175..7bad605 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/Tag.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/Tag.java @@ -24,8 +24,36 @@ package io.github.artemget.tagrelease.domain; +import java.util.List; +import org.cactoos.Text; public interface Tag { String repo(); + String name(); + String branch(); + + final class Printed implements Text { + /** + * Tags. + */ + private final List tags; + + /** + * Main ctor. + * @param tags Built + */ + public Printed(final List tags) { + this.tags = tags; + } + + @Override + public String asString() { + final StringBuilder string = new StringBuilder(); + for (final Tag tag : this.tags) { + string.append(String.format("```%s:%s```\n", tag.repo(), tag.name())); + } + return string.toString(); + } + } } From 585cb74f0af88d8de08ca20061cb4b6a0930940f Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Thu, 3 Jul 2025 21:58:48 +0300 Subject: [PATCH 39/49] get branch and prefix attributes --- .../tagrelease/command/CmdBuildTags.java | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java b/src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java index c26c436..f8d566a 100644 --- a/src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java +++ b/src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java @@ -41,6 +41,7 @@ import io.github.artemget.teleroute.telegrambots.send.SendMessageWrap; import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.telegram.telegrambots.meta.api.methods.send.SendMessage; @@ -68,15 +69,30 @@ public CmdBuildTags(final Services services, final Tags tags) { @Override public Send execute(Update update) throws CmdException { final List names; - final String branch = "develop"; - final String prefix = "v4.3.1.*"; + final String branch; + final String prefix; + final String[] values = StringUtils.substringsBetween(update.getMessage().getText(), "{", "}"); try { - names = new ESplit(new EUnwrap(update.getMessage().getText()), ",").value(); + names = new ESplit(new EUnwrap(values[0]), ",").value(); } catch (final EntryException exception) { throw new CmdException("Failed to parse service names for tag build", exception); } - List succeed = new ArrayList<>(); - List failed = new ArrayList<>(); + try { + prefix = new EUnwrap(values[1]).value(); + } catch (final EntryException exception) { + throw new CmdException("Failed to parse prefix name for tag build", exception); + } + try { + if (values.length >= 3) { + branch = new EUnwrap(values[2]).value(); + } else { + branch = "develop"; + } + } catch (final EntryException exception) { + throw new CmdException("Failed to parse branch name for tag build", exception); + } + final List succeed = new ArrayList<>(); + final List failed = new ArrayList<>(); for (final String name : names) { Service service; try { @@ -86,9 +102,9 @@ public Send execute(Update update) throws CmdException { failed.add(name); continue; } - Tag tag; + final Tag tag; try { - tag = this.tags.buildNew(service.id(), "develop", prefix); + tag = this.tags.buildNew(service.id(), branch, prefix); } catch (final DomainException exception) { log.error("Failed to build tag for service:'{}'", name, exception); failed.add(name); From 9016c6c82130ee6babdf7a9a3d5fa475c4941806 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Fri, 4 Jul 2025 16:34:54 +0300 Subject: [PATCH 40/49] add echo --- .../artemget/tagrelease/Entrypoint.java | 11 +++++ .../artemget/tagrelease/command/CmdEcho.java | 44 +++++++++++++++++++ .../tagrelease/command/CmdEchoReply.java | 44 +++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 src/main/java/io/github/artemget/tagrelease/command/CmdEcho.java create mode 100644 src/main/java/io/github/artemget/tagrelease/command/CmdEchoReply.java diff --git a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java index 3475eff..955f510 100644 --- a/src/main/java/io/github/artemget/tagrelease/Entrypoint.java +++ b/src/main/java/io/github/artemget/tagrelease/Entrypoint.java @@ -31,6 +31,8 @@ import io.github.artemget.tagrelease.bot.Bot; import io.github.artemget.tagrelease.bot.BotReg; import io.github.artemget.tagrelease.command.CmdBuildTags; +import io.github.artemget.tagrelease.command.CmdEcho; +import io.github.artemget.tagrelease.command.CmdEchoReply; import io.github.artemget.tagrelease.command.CmdListServices; import io.github.artemget.tagrelease.command.CmdListServicesAll; import io.github.artemget.tagrelease.command.CmdListStands; @@ -39,6 +41,7 @@ import io.github.artemget.tagrelease.domain.Stands; import io.github.artemget.tagrelease.domain.StandsGl; import io.github.artemget.tagrelease.match.MatchAdmin; +import io.github.artemget.tagrelease.match.MatchReply; import io.github.artemget.teleroute.match.MatchRegex; import io.github.artemget.teleroute.route.RouteDfs; import io.github.artemget.teleroute.route.RouteFork; @@ -72,6 +75,14 @@ public static void main(final String[] args) throws EntryException, TelegramApiE new RouteFork<>( new MatchAdmin(new ESplit(new EVal("bot.admins"))), new RouteDfs<>( + new RouteFork<>( + new MatchRegex<>("[Э]эхо"), + new RouteFork<>( + new MatchReply(), + new CmdEchoReply(), + new CmdEcho() + ) + ), new RouteFork<>( new MatchRegex<>("[Пп]окажи сервисы"), new CmdListServicesAll(all) diff --git a/src/main/java/io/github/artemget/tagrelease/command/CmdEcho.java b/src/main/java/io/github/artemget/tagrelease/command/CmdEcho.java new file mode 100644 index 0000000..db50e29 --- /dev/null +++ b/src/main/java/io/github/artemget/tagrelease/command/CmdEcho.java @@ -0,0 +1,44 @@ +/* + * MIT License + * + * Copyright (c) 2024-2025. Artem Getmanskii + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.github.artemget.tagrelease.command; + +import io.github.artemget.teleroute.command.Cmd; +import io.github.artemget.teleroute.command.CmdException; +import io.github.artemget.teleroute.send.Send; +import io.github.artemget.teleroute.telegrambots.send.SendMessageWrap; +import org.telegram.telegrambots.meta.api.methods.send.SendMessage; +import org.telegram.telegrambots.meta.api.objects.Update; +import org.telegram.telegrambots.meta.bots.AbsSender; +public class CmdEcho implements Cmd { + @Override + public Send execute(Update update) throws CmdException { + return new SendMessageWrap<>( + new SendMessage( + update.getMessage().getChatId().toString(), + update.getMessage().getFrom().getId().toString() + ) + ); + } +} diff --git a/src/main/java/io/github/artemget/tagrelease/command/CmdEchoReply.java b/src/main/java/io/github/artemget/tagrelease/command/CmdEchoReply.java new file mode 100644 index 0000000..cf62b59 --- /dev/null +++ b/src/main/java/io/github/artemget/tagrelease/command/CmdEchoReply.java @@ -0,0 +1,44 @@ +/* + * MIT License + * + * Copyright (c) 2024-2025. Artem Getmanskii + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.github.artemget.tagrelease.command; + +import io.github.artemget.teleroute.command.Cmd; +import io.github.artemget.teleroute.command.CmdException; +import io.github.artemget.teleroute.send.Send; +import io.github.artemget.teleroute.telegrambots.send.SendMessageWrap; +import org.telegram.telegrambots.meta.api.methods.send.SendMessage; +import org.telegram.telegrambots.meta.api.objects.Update; +import org.telegram.telegrambots.meta.bots.AbsSender; +public class CmdEchoReply implements Cmd { + @Override + public Send execute(Update update) throws CmdException { + return new SendMessageWrap<>( + new SendMessage( + update.getMessage().getChatId().toString(), + update.getMessage().getReplyToMessage().getFrom().getId().toString() + ) + ); + } +} \ No newline at end of file From 00ae3b8c23eaedc07d8cd840b7766ead3c0701ef Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Fri, 4 Jul 2025 16:35:21 +0300 Subject: [PATCH 41/49] temp tags gl --- .../artemget/tagrelease/domain/TagsGl.java | 21 +++++++++-- .../artemget/tagrelease/match/MatchReply.java | 35 +++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 src/main/java/io/github/artemget/tagrelease/match/MatchReply.java diff --git a/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java b/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java index 53cfd74..159a65f 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java @@ -31,14 +31,13 @@ import io.github.artemget.tagrelease.entry.EFetchArr; import io.github.artemget.tagrelease.entry.EFunc; import io.github.artemget.tagrelease.exception.DomainException; -import java.util.HashMap; -import java.util.Map; import javax.json.JsonArray; import javax.json.JsonObject; import javax.json.JsonValue; public final class TagsGl implements Tags { private final EFunc tag; + private final EFunc create; public TagsGl( final Entry url, @@ -57,12 +56,26 @@ public TagsGl( ).method(Request.GET) .header("Accept", "application/json") .header("PRIVATE-TOKEN", token.value()) + ).value(), + (tag) -> + new EFetchArr( + new JdkRequest( + String.format( + "%s/api/v4/projects/%s/repository/tags?ref=%s&tag_name=%s", + url.value(), + tag.repo(), + tag.name().replace(".*", "") + ) + ).method(Request.POST) + .header("Accept", "application/json") + .header("PRIVATE-TOKEN", token.value()) ).value() ); } - public TagsGl(final EFunc tag) { + public TagsGl(final EFunc tag, final EFunc create) { this.tag = tag; + this.create = create; } @Override @@ -80,6 +93,8 @@ public Tag buildNew(final String serviceId, final String branch, final String pr ); } for (final JsonValue value : response) { + String tag = value.asJsonObject().getString("name"); + } return null; } diff --git a/src/main/java/io/github/artemget/tagrelease/match/MatchReply.java b/src/main/java/io/github/artemget/tagrelease/match/MatchReply.java new file mode 100644 index 0000000..13948c1 --- /dev/null +++ b/src/main/java/io/github/artemget/tagrelease/match/MatchReply.java @@ -0,0 +1,35 @@ +/* + * MIT License + * + * Copyright (c) 2024-2025. Artem Getmanskii + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.github.artemget.tagrelease.match; + +import io.github.artemget.teleroute.update.Wrap; +import java.util.function.Predicate; +import org.telegram.telegrambots.meta.api.objects.Update; +public class MatchReply implements Predicate> { + @Override + public boolean test(Wrap wrap) { + return wrap.src().getMessage().getReplyToMessage() != null; + } +} From 9d571b54a6d675adb4b2238148c0954798e0e1dc Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Fri, 4 Jul 2025 23:26:30 +0300 Subject: [PATCH 42/49] add commit to tag and message --- .../github/artemget/tagrelease/domain/Tag.java | 4 ++++ .../github/artemget/tagrelease/domain/TagEa.java | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/Tag.java b/src/main/java/io/github/artemget/tagrelease/domain/Tag.java index 7bad605..0a80afc 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/Tag.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/Tag.java @@ -33,6 +33,10 @@ public interface Tag { String branch(); + String fromCommit(); + + String message(); + final class Printed implements Text { /** * Tags. diff --git a/src/main/java/io/github/artemget/tagrelease/domain/TagEa.java b/src/main/java/io/github/artemget/tagrelease/domain/TagEa.java index 51e0389..0bb6af0 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/TagEa.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/TagEa.java @@ -28,11 +28,15 @@ public final class TagEa implements Tag { private final String repo; private final String name; private final String branch; + private final String commit; + private final String message; - public TagEa(final String repo, final String name, final String branch) { + public TagEa(final String repo, final String name, final String branch, final String commit, final String message) { this.repo = repo; this.name = name; this.branch = branch; + this.commit = commit; + this.message = message; } @Override @@ -49,4 +53,14 @@ public String name() { public String branch() { return this.branch; } + + @Override + public String fromCommit() { + return this.commit; + } + + @Override + public String message() { + return this.message; + } } From fb19f25601770838ac633e1cacfeac39fdeeb35c Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Fri, 4 Jul 2025 23:27:28 +0300 Subject: [PATCH 43/49] implement next commit compute, fix build tag req --- .../artemget/tagrelease/domain/TagsGl.java | 70 +++++++++++++------ 1 file changed, 47 insertions(+), 23 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java b/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java index 159a65f..bb87317 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java @@ -29,15 +29,15 @@ import io.github.artemget.entrys.Entry; import io.github.artemget.entrys.EntryException; import io.github.artemget.tagrelease.entry.EFetchArr; +import io.github.artemget.tagrelease.entry.EFetchObj; import io.github.artemget.tagrelease.entry.EFunc; import io.github.artemget.tagrelease.exception.DomainException; import javax.json.JsonArray; import javax.json.JsonObject; -import javax.json.JsonValue; public final class TagsGl implements Tags { private final EFunc tag; - private final EFunc create; + private final EFunc create; public TagsGl( final Entry url, @@ -58,13 +58,14 @@ public TagsGl( .header("PRIVATE-TOKEN", token.value()) ).value(), (tag) -> - new EFetchArr( + new EFetchObj( new JdkRequest( String.format( "%s/api/v4/projects/%s/repository/tags?ref=%s&tag_name=%s", url.value(), tag.repo(), - tag.name().replace(".*", "") + tag.branch(), + tag.name() ) ).method(Request.POST) .header("Accept", "application/json") @@ -73,37 +74,48 @@ public TagsGl( ); } - public TagsGl(final EFunc tag, final EFunc create) { + public TagsGl(final EFunc tag, final EFunc create) { this.tag = tag; this.create = create; } @Override public Tag buildNew(final String serviceId, final String branch, final String prefix) throws DomainException { - final JsonArray response; + final Tag current = this.current(serviceId, branch, prefix); + final JsonObject created; try { - response = this.tag.apply(new TagEa(serviceId, prefix, branch)); + created = this.create.apply( + new TagEa( + current.repo(), + TagsGl.next(current.name(), prefix), + current.branch(), + current.fromCommit(), + "" //TODO: fetch all PRs from current tag's commit to HEAD branch commit. + ) + ); } catch (final EntryException exception) { throw new DomainException( String.format( - "Failed to fetch tag with prefix:'%s' for service:'%s' from branch:'%s'", - prefix, serviceId, branch + "Failed to create tag with prefix:'%s' for service:'%s' from branch:'%s'. Latest tag:%s", + prefix, serviceId, branch, current.name() ), exception ); } - for (final JsonValue value : response) { - String tag = value.asJsonObject().getString("name"); - - } - return null; + return new TagEa( + serviceId, + created.getString("name"), + branch, + created.getJsonObject("commit").getString("id"), + created.getJsonObject("commit").getString("message") + ); } @Override public Tag current(final String serviceId, final String branch, final String prefix) throws DomainException { final JsonArray response; try { - response = this.tag.apply(new TagEa(serviceId, prefix, branch)); + response = this.tag.apply(new TagEa(serviceId, prefix, branch, "", "")); } catch (final EntryException exception) { throw new DomainException( String.format( @@ -113,18 +125,30 @@ public Tag current(final String serviceId, final String branch, final String pre exception ); } + final JsonObject current = response.getJsonObject(0); return new TagEa( serviceId, - TagsGl.found(response, prefix).getString("name"), - branch + current.getString("name"), + branch, + current.getJsonObject("commit").getString("id"), + current.getJsonObject("commit").getString("message") ); } - public static JsonObject found(JsonArray array, String prefix) throws DomainException { - return null; - } - - public static String trimmed(String cell) { - return null; + public static String next(final String current, final String prefix) { + final String trimmed = prefix.replace("*", ""); + final StringBuilder next = new StringBuilder(); + for (int index = 0; index < current.toCharArray().length; index++) { + if (trimmed.length() == index) { + next.append(Character.getNumericValue(current.charAt(index)) + 1); + continue; + } + if (trimmed.length() < index && Character.isDigit(current.charAt(index))) { + next.append('0'); + } else { + next.append(current.charAt(index)); + } + } + return next.toString(); } } From d8f1ea666d9bb436121b44da50bbd49242889cac Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Fri, 4 Jul 2025 23:27:35 +0300 Subject: [PATCH 44/49] add tests --- .../tagrelease/domain/TagsGlTest.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/test/java/io/github/artemget/tagrelease/domain/TagsGlTest.java diff --git a/src/test/java/io/github/artemget/tagrelease/domain/TagsGlTest.java b/src/test/java/io/github/artemget/tagrelease/domain/TagsGlTest.java new file mode 100644 index 0000000..f2d330a --- /dev/null +++ b/src/test/java/io/github/artemget/tagrelease/domain/TagsGlTest.java @@ -0,0 +1,63 @@ +/* + * MIT License + * + * Copyright (c) 2024-2025. Artem Getmanskii + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.github.artemget.tagrelease.domain; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class TagsGlTest { + + @Test + void returnsLastIncremented() { + Assertions.assertEquals( + "4.3.1.1", + TagsGl.next("4.3.1.0", "4.3.1.*") + ); + } + + @Test + void returnsThirdIncremented() { + Assertions.assertEquals( + "4.3.2.0", + TagsGl.next("4.3.1.0", "4.3.*") + ); + } + + @Test + void returnsSecondIncremented() { + Assertions.assertEquals( + "4.4.0.0", + TagsGl.next("4.3.1.0", "4.*") + ); + } + + @Test + void returnsFirstIncremented() { + Assertions.assertEquals( + "5.0.0.0", + TagsGl.next("4.3.1.0", "*") + ); + } +} From e978663cab94c5caf3e46b2ae03fa77ca747cd07 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 6 Jul 2025 19:23:14 +0300 Subject: [PATCH 45/49] fixed 10 -> 11 --- .../artemget/tagrelease/domain/TagsGl.java | 13 ++++++-- .../tagrelease/domain/TagsGlTest.java | 32 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java b/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java index bb87317..2f826fd 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java @@ -138,9 +138,18 @@ public Tag current(final String serviceId, final String branch, final String pre public static String next(final String current, final String prefix) { final String trimmed = prefix.replace("*", ""); final StringBuilder next = new StringBuilder(); - for (int index = 0; index < current.toCharArray().length; index++) { + final int length = current.toCharArray().length; + for (int index = 0; index < length; index++) { if (trimmed.length() == index) { - next.append(Character.getNumericValue(current.charAt(index)) + 1); + final StringBuilder digit = new StringBuilder(); + while (index < length && Character.isDigit(current.charAt(index))) { + digit.append(current.charAt(index)); + index++; + } + next.append(Integer.parseInt(digit.toString()) + 1); + if (index < length) { + next.append(current.charAt(index)); + } continue; } if (trimmed.length() < index && Character.isDigit(current.charAt(index))) { diff --git a/src/test/java/io/github/artemget/tagrelease/domain/TagsGlTest.java b/src/test/java/io/github/artemget/tagrelease/domain/TagsGlTest.java index f2d330a..6dc9940 100644 --- a/src/test/java/io/github/artemget/tagrelease/domain/TagsGlTest.java +++ b/src/test/java/io/github/artemget/tagrelease/domain/TagsGlTest.java @@ -37,6 +37,14 @@ void returnsLastIncremented() { ); } + @Test + void returnsLastIncrementedOverPlaceNumber() { + Assertions.assertEquals( + "4.3.1.11", + TagsGl.next("4.3.1.10", "4.3.1.*") + ); + } + @Test void returnsThirdIncremented() { Assertions.assertEquals( @@ -45,6 +53,14 @@ void returnsThirdIncremented() { ); } + @Test + void returnsThirdIncrementedOverPlaceNumber() { + Assertions.assertEquals( + "4.3.11.0", + TagsGl.next("4.3.10.0", "4.3.*") + ); + } + @Test void returnsSecondIncremented() { Assertions.assertEquals( @@ -60,4 +76,20 @@ void returnsFirstIncremented() { TagsGl.next("4.3.1.0", "*") ); } + + @Test + void returnsFirstIncrementedOver() { + Assertions.assertEquals( + "10.0.0.0", + TagsGl.next("9.3.1.0", "*") + ); + } + + @Test + void returnsFirstIncrementedOverPlaceNumber() { + Assertions.assertEquals( + "11.0.0.0", + TagsGl.next("10.3.1.0", "*") + ); + } } From bc0dccde7565f88707f1b1f8cfdff5de6bd8acca Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Sun, 6 Jul 2025 19:25:01 +0300 Subject: [PATCH 46/49] add tests for starting and trailing text --- .../artemget/tagrelease/domain/TagsGl.java | 1 + .../artemget/tagrelease/domain/TagsGlTest.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java b/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java index 2f826fd..74dca6b 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java @@ -125,6 +125,7 @@ public Tag current(final String serviceId, final String branch, final String pre exception ); } + //TODO: add branch check final JsonObject current = response.getJsonObject(0); return new TagEa( serviceId, diff --git a/src/test/java/io/github/artemget/tagrelease/domain/TagsGlTest.java b/src/test/java/io/github/artemget/tagrelease/domain/TagsGlTest.java index 6dc9940..d6ecad8 100644 --- a/src/test/java/io/github/artemget/tagrelease/domain/TagsGlTest.java +++ b/src/test/java/io/github/artemget/tagrelease/domain/TagsGlTest.java @@ -37,6 +37,22 @@ void returnsLastIncremented() { ); } + @Test + void returnsLastIncrementedWithStarting() { + Assertions.assertEquals( + "v4.3.1.1", + TagsGl.next("v4.3.1.0", "v4.3.1.*") + ); + } + + @Test + void returnsLastIncrementedWithVersionAndTrailingText() { + Assertions.assertEquals( + "v4.3.1.1_bla_bla", + TagsGl.next("v4.3.1.0_bla_bla", "v4.3.1.*") + ); + } + @Test void returnsLastIncrementedOverPlaceNumber() { Assertions.assertEquals( From 3f187e506da0d07aac5e77c7076bd6d879783fad Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Mon, 7 Jul 2025 01:26:58 +0300 Subject: [PATCH 47/49] add created --- .../github/artemget/tagrelease/domain/Tag.java | 2 ++ .../github/artemget/tagrelease/domain/TagEa.java | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/Tag.java b/src/main/java/io/github/artemget/tagrelease/domain/Tag.java index 0a80afc..288098f 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/Tag.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/Tag.java @@ -37,6 +37,8 @@ public interface Tag { String message(); + String created(); + final class Printed implements Text { /** * Tags. diff --git a/src/main/java/io/github/artemget/tagrelease/domain/TagEa.java b/src/main/java/io/github/artemget/tagrelease/domain/TagEa.java index 0bb6af0..93da690 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/TagEa.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/TagEa.java @@ -30,13 +30,22 @@ public final class TagEa implements Tag { private final String branch; private final String commit; private final String message; + private final String created; - public TagEa(final String repo, final String name, final String branch, final String commit, final String message) { + public TagEa( + final String repo, + final String name, + final String branch, + final String commit, + final String message, + final String created + ) { this.repo = repo; this.name = name; this.branch = branch; this.commit = commit; this.message = message; + this.created = created; } @Override @@ -63,4 +72,9 @@ public String fromCommit() { public String message() { return this.message; } + + @Override + public String created() { + return this.created; + } } From 633efc605ef9c9ef9c258ee52fe1e768b7dae836 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Mon, 7 Jul 2025 01:27:06 +0300 Subject: [PATCH 48/49] add release notes --- .../artemget/tagrelease/domain/TagsGl.java | 93 +++++++++++++++++-- 1 file changed, 83 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java b/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java index 74dca6b..26e5cf0 100644 --- a/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java +++ b/src/main/java/io/github/artemget/tagrelease/domain/TagsGl.java @@ -34,10 +34,15 @@ import io.github.artemget.tagrelease.exception.DomainException; import javax.json.JsonArray; import javax.json.JsonObject; +import javax.json.JsonValue; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class TagsGl implements Tags { + private final Logger log = LoggerFactory.getLogger(TagsGl.class); private final EFunc tag; private final EFunc create; + private final EFunc message; public TagsGl( final Entry url, @@ -70,17 +75,46 @@ public TagsGl( ).method(Request.POST) .header("Accept", "application/json") .header("PRIVATE-TOKEN", token.value()) - ).value() + ).value(), + (tag) -> { + final StringBuilder message = new StringBuilder(); + int page = 1; + boolean isFound = false; + while (page <= 5 && !isFound) { + for (final JsonValue value : TagsGl.mrs(tag, url.value(), token.value(), String.valueOf(page))) { + final JsonObject mr = value.asJsonObject(); + final boolean isSquash = !mr.isNull("squash_commit_sha") + && tag.fromCommit().equals(mr.getString("squash_commit_sha")); + final boolean isMerge = !mr.isNull("merge_commit_sha") + && tag.fromCommit().equals(mr.getString("merge_commit_sha")); + final boolean isMr = !mr.isNull("sha") + && tag.fromCommit().equals(mr.getString("sha")); + if (isMerge && isSquash && isMr) { + isFound = true; + break; + } + message.append(mr.getString("title")).append("\n\n"); + page++; + } + } + return message.toString(); + } ); } - public TagsGl(final EFunc tag, final EFunc create) { + public TagsGl( + final EFunc tag, + final EFunc create, + EFunc message + ) { this.tag = tag; this.create = create; + this.message = message; } @Override - public Tag buildNew(final String serviceId, final String branch, final String prefix) throws DomainException { + public Tag buildNew(final String serviceId, final String branch, final String prefix) throws + DomainException { final Tag current = this.current(serviceId, branch, prefix); final JsonObject created; try { @@ -90,7 +124,8 @@ public Tag buildNew(final String serviceId, final String branch, final String pr TagsGl.next(current.name(), prefix), current.branch(), current.fromCommit(), - "" //TODO: fetch all PRs from current tag's commit to HEAD branch commit. + current.message(), + current.created() ) ); } catch (final EntryException exception) { @@ -102,20 +137,37 @@ public Tag buildNew(final String serviceId, final String branch, final String pr exception ); } + final JsonObject commit = created.getJsonObject("commit"); + String message; + try { + message = this.message.apply(current); + } catch (final EntryException exception) { + message = ""; + log.error( + "Failed to fetch merge requests for service:'{}', branch:'{}'. Between tags '{}' - '{}'", + serviceId, + branch, + current.name(), + created.getString("name"), + exception + ); + } return new TagEa( serviceId, created.getString("name"), branch, - created.getJsonObject("commit").getString("id"), - created.getJsonObject("commit").getString("message") + commit.getString("id"), + message, + commit.getString("created_at") ); } @Override - public Tag current(final String serviceId, final String branch, final String prefix) throws DomainException { + public Tag current(final String serviceId, final String branch, final String prefix) throws + DomainException { final JsonArray response; try { - response = this.tag.apply(new TagEa(serviceId, prefix, branch, "", "")); + response = this.tag.apply(new TagEa(serviceId, prefix, branch, "", "", "")); } catch (final EntryException exception) { throw new DomainException( String.format( @@ -127,12 +179,14 @@ public Tag current(final String serviceId, final String branch, final String pre } //TODO: add branch check final JsonObject current = response.getJsonObject(0); + final JsonObject commit = current.getJsonObject("commit"); return new TagEa( serviceId, current.getString("name"), branch, - current.getJsonObject("commit").getString("id"), - current.getJsonObject("commit").getString("message") + commit.getString("id"), + commit.getString("message"), + commit.getString("created_at") ); } @@ -161,4 +215,23 @@ public static String next(final String current, final String prefix) { } return next.toString(); } + + private static JsonArray mrs(final Tag tag, String url, String token, String page) throws + EntryException { + return new EFetchArr( + new JdkRequest( + String.format( + "%s/api/v4/projects/%s/merge_requests?state=merged&scope=all&created_after=%s&target_branch=%s&per_page=%s&page=%s", + url, + tag.repo(), + tag.created(), + tag.branch(), + "20", + page + ) + ).method(Request.POST) + .header("Accept", "application/json") + .header("PRIVATE-TOKEN", token) + ).value(); + } } From 088b0af907f24ad4aee31b21a72bacaad1fb70c0 Mon Sep 17 00:00:00 2001 From: Artem Getmanskii Date: Mon, 7 Jul 2025 01:40:22 +0300 Subject: [PATCH 49/49] removed qulice from ci --- .github/workflows/maven.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml index fb14674..3a326c5 100644 --- a/.github/workflows/maven.yaml +++ b/.github/workflows/maven.yaml @@ -20,4 +20,4 @@ jobs: distribution: 'temurin' cache: maven - name: Build with Maven - run: mvn clean install -Pqulice --batch-mode --update-snapshots + run: mvn clean install --batch-mode --update-snapshots