ci: consolidate active app image builds

This commit is contained in:
lingniu
2026-07-01 04:11:13 +08:00
parent b36f993059
commit f276b6f6f0
2 changed files with 74 additions and 153 deletions

View File

@@ -0,0 +1,49 @@
package com.lingniu.ingest.historyapp;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.assertj.core.api.Assertions.assertThat;
class WoodpeckerPipelineTest {
@Test
void dockerPublishUsesOneProductionAppList() throws IOException {
String pipeline = Files.readString(repositoryRoot().resolve("woodpecker.yml"));
assertThat(pipeline)
.contains("ACTIVE_APPS=\"gb32960-ingest-app jt808-ingest-app yutong-mqtt-app vehicle-history-app vehicle-analytics-app\"")
.contains("- name: docker-build-apps")
.doesNotContain("xinda-push-app")
.doesNotContain("KAFKA_TOPIC_XINDA_PUSH");
assertThat(countOccurrences(pipeline, "- name: docker-build-")).isEqualTo(1);
}
private static int countOccurrences(String value, String needle) {
int count = 0;
int from = 0;
while (true) {
int next = value.indexOf(needle, from);
if (next < 0) {
return count;
}
count++;
from = next + needle.length();
}
}
private static Path repositoryRoot() {
Path current = Path.of(System.getProperty("user.dir")).toAbsolutePath();
while (current != null) {
if (Files.exists(current.resolve("woodpecker.yml"))) {
return current;
}
current = current.getParent();
}
throw new IllegalStateException("repository root not found");
}
}