From f9259f558b2ba2611c81e850686d02c6da49c017 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Sat, 17 Dec 2022 18:49:38 +0300 Subject: [PATCH] =?UTF-8?q?=20=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B0=20CICD=20=D1=81=20=D0=BF=D0=BE=D0=BC=D0=BE=D1=89?= =?UTF-8?q?=D1=8C=D1=8E=20Drone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 24 ++++++-- .../service/parser/MergeRequestParser.java | 4 +- .../core/service/parser/PipelineParser.java | 8 +-- .../bot/gitlab/core/utils/PoolUtils.java | 60 ------------------- pom.xml | 4 +- 5 files changed, 27 insertions(+), 73 deletions(-) delete mode 100644 bot-core/src/main/java/dev/struchkov/bot/gitlab/core/utils/PoolUtils.java diff --git a/.drone.yml b/.drone.yml index 1a25d46..e45e3bd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,17 +5,31 @@ name: gitlab-notify steps: - name: package image: maven:3.8.6-eclipse-temurin-17 - commands: - - mvn -U clean package volumes: - name: m2 - path: /root/.m2 + path: /root/.m2/repository + commands: + - mvn -U clean package + + - name: docker-publish + image: upagge/docker-buildx:latest + environment: + DOCKER_REGISTRY_TOKEN: + from_secret: DOCKER_REGISTRY_TOKEN + DOCKER_IMAGE_NAME: + from_secret: DOCKER_IMAGE_NAME + DOCKER_REGISTRY_USER: + from_secret: DOCKER_REGISTRY_USER + commands: + - echo "$DOCKER_REGISTRY_TOKEN" | docker login docker.io --username $DOCKER_REGISTRY_USER --password-stdin + - docker buildx create --use + - docker buildx build --push --platform linux/amd64,linux/arm64/v8 -t "$DOCKER_IMAGE_NAME:develop" . trigger: branch: - - master + - develop volumes: - name: m2 host: - path: $MAVEN_REPO \ No newline at end of file + path: /drone/volume/m2 \ No newline at end of file diff --git a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/parser/MergeRequestParser.java b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/parser/MergeRequestParser.java index ec40b77..e409b20 100644 --- a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/parser/MergeRequestParser.java +++ b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/parser/MergeRequestParser.java @@ -10,7 +10,6 @@ import dev.struchkov.bot.gitlab.context.service.ProjectService; import dev.struchkov.bot.gitlab.core.config.properties.GitlabProperty; import dev.struchkov.bot.gitlab.core.config.properties.PersonProperty; import dev.struchkov.bot.gitlab.core.service.parser.forktask.GetMergeRequestTask; -import dev.struchkov.bot.gitlab.core.utils.PoolUtils; import dev.struchkov.bot.gitlab.core.utils.StringUtils; import dev.struchkov.bot.gitlab.sdk.domain.CommitJson; import dev.struchkov.bot.gitlab.sdk.domain.MergeRequestJson; @@ -33,6 +32,7 @@ import java.util.stream.Stream; import static dev.struchkov.haiti.utils.Checker.checkNotEmpty; import static dev.struchkov.haiti.utils.Checker.checkNotNull; +import static dev.struchkov.haiti.utils.concurrent.ForkJoinUtils.pullTaskResults; import static dev.struchkov.haiti.utils.network.HttpParse.ACCEPT; @Slf4j @@ -134,7 +134,7 @@ public class MergeRequestParser { .map(forkJoinPool::submit) .collect(Collectors.toList()); - return PoolUtils.pullTaskResults(tasks); + return pullTaskResults(tasks); } private static void personMapping(List newMergeRequests) { diff --git a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/parser/PipelineParser.java b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/parser/PipelineParser.java index 729dec3..c988513 100644 --- a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/parser/PipelineParser.java +++ b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/parser/PipelineParser.java @@ -35,10 +35,10 @@ import static dev.struchkov.bot.gitlab.context.domain.PipelineStatus.PENDING; import static dev.struchkov.bot.gitlab.context.domain.PipelineStatus.PREPARING; import static dev.struchkov.bot.gitlab.context.domain.PipelineStatus.RUNNING; import static dev.struchkov.bot.gitlab.context.domain.PipelineStatus.WAITING_FOR_RESOURCE; -import static dev.struchkov.bot.gitlab.core.utils.PoolUtils.pullTaskResult; -import static dev.struchkov.bot.gitlab.core.utils.PoolUtils.pullTaskResults; import static dev.struchkov.haiti.context.exception.ConvertException.convertException; import static dev.struchkov.haiti.utils.Checker.checkNotEmpty; +import static dev.struchkov.haiti.utils.concurrent.ForkJoinUtils.pullTaskResult; +import static dev.struchkov.haiti.utils.concurrent.ForkJoinUtils.pullTaskResults; import static dev.struchkov.haiti.utils.network.HttpParse.ACCEPT; /** @@ -137,7 +137,7 @@ public class PipelineParser { public void scanOldPipeline() { - log.debug("Старт обработки старых папйплайнов"); + log.debug("Старт обработки старых пайплайнов"); int page = 0; Page pipelineSheet = pipelineService.getAllByStatuses(oldStatus, PageRequest.of(page, COUNT)); @@ -159,7 +159,7 @@ public class PipelineParser { pipelineSheet = pipelineService.getAllByStatuses(oldStatus, PageRequest.of(++page, COUNT)); } - log.debug("Конец обработки старых папйплайнов"); + log.debug("Конец обработки старых пайплайнов"); } } diff --git a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/utils/PoolUtils.java b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/utils/PoolUtils.java deleted file mode 100644 index e5caeec..0000000 --- a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/utils/PoolUtils.java +++ /dev/null @@ -1,60 +0,0 @@ -package dev.struchkov.bot.gitlab.core.utils; - -import lombok.experimental.UtilityClass; -import lombok.extern.slf4j.Slf4j; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ForkJoinTask; - -@Slf4j -@UtilityClass -public class PoolUtils { - - public static List pullTaskResults(List>> tasks) { - final List results = new ArrayList<>(); - Iterator>> iterator = tasks.iterator(); - while (!tasks.isEmpty()) { - while (iterator.hasNext()) { - final ForkJoinTask> task = iterator.next(); - if (task.isDone()) { - final List jsons; - try { - jsons = task.get(); - results.addAll(jsons); - } catch (InterruptedException | ExecutionException e) { - log.error(e.getMessage(), e); - Thread.currentThread().interrupt(); - } - iterator.remove(); - } - } - iterator = tasks.iterator(); - } - return results; - } - - public static List pullTaskResult(List> tasks) { - final List results = new ArrayList<>(); - Iterator> iterator = tasks.iterator(); - while (!tasks.isEmpty()) { - while (iterator.hasNext()) { - final ForkJoinTask task = iterator.next(); - if (task.isDone()) { - try { - results.add(task.get()); - } catch (InterruptedException | ExecutionException e) { - log.error(e.getMessage(), e); - Thread.currentThread().interrupt(); - } - iterator.remove(); - } - } - iterator = tasks.iterator(); - } - return results; - } - -} diff --git a/pom.xml b/pom.xml index 5a7cab9..53e21d0 100644 --- a/pom.xml +++ b/pom.xml @@ -104,13 +104,13 @@ dev.struchkov.haiti haiti-utils - 2.0.0 + 2.3.4 dev.struchkov.haiti haiti-exception - 2.0.0 + 2.3.4