Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
582ab4b
add deps
ArtemGet Jun 29, 2025
fd7a749
add config file
ArtemGet Jun 29, 2025
371ef81
add EFunc, remove ESplit
ArtemGet Jun 29, 2025
b187648
rename exception
ArtemGet Jun 29, 2025
be2339a
add Services All
ArtemGet Jun 29, 2025
16c65ba
add Services All command
ArtemGet Jun 29, 2025
3bcf58b
fixed types
ArtemGet Jun 29, 2025
587488a
add token
ArtemGet Jun 29, 2025
02a61db
add route to list all services, replace env to yaml config
ArtemGet Jun 29, 2025
af2b4c0
add entry fetch
ArtemGet Jun 29, 2025
b1e60ab
add fetch json obj/arr
ArtemGet Jun 29, 2025
21fe1de
add release repo id to config
ArtemGet Jun 29, 2025
aba0034
implement stand in gitlab
ArtemGet Jun 29, 2025
ca48670
implement stands in gitlab
ArtemGet Jun 29, 2025
9225bf5
fixed lists stands command
ArtemGet Jun 29, 2025
b103b78
add lists stands command route
ArtemGet Jun 29, 2025
652bb27
fixed regexes, add list services by stand route
ArtemGet Jun 29, 2025
c1629b0
fixed config name
ArtemGet Jun 29, 2025
cad1c43
commented
ArtemGet Jun 29, 2025
3c4b40e
fix list services by stand
ArtemGet Jun 29, 2025
0e30e9a
add id to service
ArtemGet Jun 29, 2025
06ae270
fixed services gitlab
ArtemGet Jun 29, 2025
2beca78
remove redundant response mapping
ArtemGet Jun 30, 2025
d950f9d
remove redundant uri call, fix id mapping
ArtemGet Jun 30, 2025
64dcb71
fix config name
ArtemGet Jun 30, 2025
846b6e0
add build tags command
ArtemGet Jun 30, 2025
f142e87
remove redundant uri call
ArtemGet Jun 30, 2025
07021ba
remove redundant uri call
ArtemGet Jun 30, 2025
4945d2d
fix message formatting, fix config
ArtemGet Jul 3, 2025
0f5c8ef
remove eager request
ArtemGet Jul 3, 2025
0008041
fix printed
ArtemGet Jul 3, 2025
3cdcbd6
fix eager
ArtemGet Jul 3, 2025
809863b
add exception rethrow
ArtemGet Jul 3, 2025
e5944ee
temp tags
ArtemGet Jul 3, 2025
ed7f74e
add temp build tags cmd
ArtemGet Jul 3, 2025
2bb52f2
fix build services regex
ArtemGet Jul 3, 2025
206953d
add url encoded ^
ArtemGet Jul 3, 2025
117dc2a
print fix
ArtemGet Jul 3, 2025
585cb74
get branch and prefix attributes
ArtemGet Jul 3, 2025
9016c6c
add echo
ArtemGet Jul 4, 2025
00ae3b8
temp tags gl
ArtemGet Jul 4, 2025
9d571b5
add commit to tag and message
ArtemGet Jul 4, 2025
fb19f25
implement next commit compute, fix build tag req
ArtemGet Jul 4, 2025
d8f1ea6
add tests
ArtemGet Jul 4, 2025
e978663
fixed 10 -> 11
ArtemGet Jul 6, 2025
bc0dccd
add tests for starting and trailing text
ArtemGet Jul 6, 2025
3f187e5
add created
ArtemGet Jul 6, 2025
633efc6
add release notes
ArtemGet Jul 6, 2025
088b0af
removed qulice from ci
ArtemGet Jul 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 11 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,20 @@
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-http</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.json</artifactId>
<version>1.1.6</version>
</dependency>
<dependency>
<groupId>com.github.ArtemGet</groupId>
<artifactId>entrys</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>com.github.ArtemGet</groupId>
Expand Down
78 changes: 53 additions & 25 deletions src/main/java/io/github/artemget/tagrelease/Entrypoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,33 @@

package io.github.artemget.tagrelease;

import io.github.artemget.entrys.Entry;
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.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;
import io.github.artemget.tagrelease.domain.StandsGitlab;
import io.github.artemget.tagrelease.entry.ESplit;
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;
import io.github.artemget.tagrelease.match.MatchChats;
import io.github.artemget.teleroute.match.MatchAll;
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.RouteEnd;
import io.github.artemget.teleroute.route.RouteFork;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;

/**
* Entrypoint. Application starts here.
*
* @since 0.1.0
* @checkstyle HideUtilityClassConstructorCheck (20 lines)
* @since 0.1.0
*/
@SuppressWarnings(
{
Expand All @@ -57,32 +62,55 @@
)
public class Entrypoint {
public static void main(final String[] args) throws EntryException, TelegramApiException {
final Entry<String> host = new EVal("provider.host");
final Entry<String> release = new EVal("provider.release");
final Entry<String> token = new EVal("provider.token");
final Entry<String> project = new EVal("provider.project");
final Services all = new ServicesAll(host, project, token);
final Stands stands = new StandsGl(host, release, token);
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("bot.admins"))),
new RouteDfs<>(
new RouteFork<>(
new MatchRegex<>("Покажи сервисы"),
new CmdListStands(new StandsGitlab())
new MatchRegex<>("[Э]эхо"),
new RouteFork<>(
new MatchReply(),
new CmdEchoReply(),
new CmdEcho()
)
),
new RouteFork<>(
new MatchRegex<>("Покажи сервис"),
new CmdListStand(new StandsGitlab())
new MatchRegex<>("[Пп]окажи сервисы"),
new CmdListServicesAll(all)
),
new RouteFork<>(
new MatchRegex<>("Собери тэги по стенду"),
new RouteEnd<>(),
new RouteFork<>(
new MatchRegex<>("Собери тэг"),
new RouteEnd<>()
)
new MatchRegex<>("[Пп]окажи сервисы \\{([^{}]*)\\}$"),
new CmdListServices(stands)
),
new RouteFork<>(
new MatchRegex<>("[Пп]окажи стенды"),
new CmdListStands(stands)
),
new RouteFork<>(
new MatchRegex<>("[Сс]обери сервисы \\{([^{}]*)\\}\\s+префикс\\s+\\{([^{}]*)\\}$"),
new CmdBuildTags(host, project, token)
)
// new RouteFork<>(
// new MatchRegex<>("Покажи стенд"),
// new CmdListStand(new StandsGitlab())
// ),
// new RouteFork<>(
// new MatchRegex<>("Собери тэги по стенду"),
// new RouteEnd<>(),
// new RouteFork<>(
// new MatchRegex<>("Собери тэг"),
// new RouteEnd<>()
// )
// )
)
)
)
Expand Down
127 changes: 127 additions & 0 deletions src/main/java/io/github/artemget/tagrelease/command/CmdBuildTags.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* 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.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.apache.commons.lang3.StringUtils;
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<Update, AbsSender> {
private final Logger log = LoggerFactory.getLogger(CmdBuildTags.class);
private final Services services;
private final Tags tags;

public CmdBuildTags(
final Entry<String> host,
final Entry<String> project,
final Entry<String> token
) {
this(new ServicesAll(host, project, token), new TagsGl(host, token));
}

public CmdBuildTags(final Services services, final Tags tags) {
this.services = services;
this.tags = tags;
}

@Override
public Send<AbsSender> execute(Update update) throws CmdException {
final List<String> names;
final String branch;
final String prefix;
final String[] values = StringUtils.substringsBetween(update.getMessage().getText(), "{", "}");
try {
names = new ESplit(new EUnwrap(values[0]), ",").value();
} catch (final EntryException exception) {
throw new CmdException("Failed to parse service names for tag build", exception);
}
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<Tag> succeed = new ArrayList<>();
final List<String> 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;
}
final Tag tag;
try {
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);
continue;
}
succeed.add(tag);
}
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);
}
}
44 changes: 44 additions & 0 deletions src/main/java/io/github/artemget/tagrelease/command/CmdEcho.java
Original file line number Diff line number Diff line change
@@ -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<Update, AbsSender> {
@Override
public Send<AbsSender> execute(Update update) throws CmdException {
return new SendMessageWrap<>(
new SendMessage(
update.getMessage().getChatId().toString(),
update.getMessage().getFrom().getId().toString()
)
);
}
}
Original file line number Diff line number Diff line change
@@ -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<Update, AbsSender> {
@Override
public Send<AbsSender> execute(Update update) throws CmdException {
return new SendMessageWrap<>(
new SendMessage(
update.getMessage().getChatId().toString(),
update.getMessage().getReplyToMessage().getFrom().getId().toString()
)
);
}
}
Loading