mirror of
https://github.com/pischule/memevizor.git
synced 2026-02-04 09:00:52 +00:00
Compare commits
7 Commits
8291c72b0d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 8c0e339aab | |||
| e463e880be | |||
| 58f876bf7f | |||
| 8bcee3a225 | |||
|
|
61a6b6608e | ||
| f055a7f82f | |||
| f6c90b071e |
7
.github/workflows/release.yaml
vendored
7
.github/workflows/release.yaml
vendored
@@ -16,12 +16,9 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
- uses: jdx/mise-action@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
cache: 'gradle'
|
||||
version: 2025.12.12
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
|
||||
11
.github/workflows/test.yaml
vendored
11
.github/workflows/test.yaml
vendored
@@ -11,13 +11,8 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
- uses: jdx/mise-action@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
cache: 'gradle'
|
||||
|
||||
version: 2025.12.12
|
||||
- name: Test with Gradle
|
||||
run: ./gradlew check
|
||||
run: mise run test
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -41,6 +41,7 @@ out/
|
||||
|
||||
|
||||
src/main/resources/application-local.properties
|
||||
src/main/resources/application-local.yaml
|
||||
|
||||
src/main/resources/static
|
||||
!src/main/resources/static/index.html
|
||||
|
||||
31
.src.ci.yaml
31
.src.ci.yaml
@@ -1,31 +0,0 @@
|
||||
on:
|
||||
push:
|
||||
- workflows: build-package-workflow
|
||||
filter:
|
||||
branches: ["main"]
|
||||
pull_request:
|
||||
- workflows: build-package-workflow
|
||||
filter:
|
||||
source_branches: ["**", "!test**"]
|
||||
target_branches: "main"
|
||||
|
||||
workflows:
|
||||
build-package-workflow:
|
||||
tasks:
|
||||
- build-package-task
|
||||
|
||||
tasks:
|
||||
- name: build-package-task
|
||||
cubes:
|
||||
- name: setup-jdk
|
||||
script:
|
||||
- sudo apt install openjdk-17-jdk -y
|
||||
- name: test
|
||||
script:
|
||||
- ./gradlew check
|
||||
- name: package
|
||||
script:
|
||||
- ./gradlew assemble
|
||||
artifacts:
|
||||
paths:
|
||||
- build/libs/memevizor-0.0.1-SNAPSHOT.jar
|
||||
@@ -1,12 +1,15 @@
|
||||
FROM docker.io/eclipse-temurin:21
|
||||
|
||||
ARG USER_ID=10001
|
||||
ARG GROUP_ID=10001
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y ffmpeg \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN groupadd --system app \
|
||||
&& useradd --no-log-init --system --shell /sbin/nologin --gid app app
|
||||
RUN groupadd -g ${GROUP_ID} app \
|
||||
&& useradd --no-log-init -u ${USER_ID} -g app --shell /sbin/nologin app
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -14,7 +17,7 @@ ARG JAR_FILE=build/libs/*.jar
|
||||
COPY --chown=app:app ${JAR_FILE} app.jar
|
||||
COPY --chown=app:app build/resources/main/static BOOT-INF/classes/static
|
||||
|
||||
USER app:app
|
||||
USER ${USER_ID}:${GROUP_ID}
|
||||
|
||||
ENTRYPOINT ["java","-jar","app.jar"]
|
||||
|
||||
|
||||
@@ -32,10 +32,13 @@ dependencies {
|
||||
implementation("io.github.kotlin-telegram-bot.kotlin-telegram-bot:telegram:6.3.0")
|
||||
implementation("io.github.oshai:kotlin-logging-jvm:7.0.3")
|
||||
implementation(awssdk.services.s3)
|
||||
implementation("org.springframework.boot:spring-boot-starter-actuator")
|
||||
implementation("org.springframework.boot:spring-boot-starter-webmvc")
|
||||
developmentOnly("org.springframework.boot:spring-boot-devtools")
|
||||
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
|
||||
testImplementation("io.kotest:kotest-assertions-core:6.0.7")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
|
||||
|
||||
1
gradle.properties
Normal file
1
gradle.properties
Normal file
@@ -0,0 +1 @@
|
||||
org.gradle.configuration-cache=true
|
||||
@@ -4,3 +4,7 @@ java = "temurin-21"
|
||||
[tasks.fmt]
|
||||
description = 'Fourmat source code'
|
||||
run = './gradlew :spotlessApply'
|
||||
|
||||
[tasks.test]
|
||||
description = 'Run tests'
|
||||
run = './gradlew check'
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
bot.forward-chat-id=<?>
|
||||
bot.approver-user-ids[0]=<?>
|
||||
bot.token=
|
||||
s3.endpoint=https://storage.yandexcloud.net
|
||||
s3.region=ru-central1
|
||||
s3.bucket=memevizor-test
|
||||
s3.access-key-id=<?>
|
||||
s3.secret-access-key=<?>
|
||||
11
src/main/resources/application-local.yaml.dist
Normal file
11
src/main/resources/application-local.yaml.dist
Normal file
@@ -0,0 +1,11 @@
|
||||
bot:
|
||||
forward-chat-id: <?>
|
||||
approver-user-ids:
|
||||
- <?>
|
||||
token: <?>
|
||||
s3:
|
||||
endpoint: https://storage.yandexcloud.net
|
||||
region: ru-central1
|
||||
bucket: memevizor-test
|
||||
access-key-id: <?>
|
||||
secret-access-key: <?>
|
||||
@@ -1,2 +0,0 @@
|
||||
spring.application.name=memevizor
|
||||
|
||||
2
src/main/resources/application.yaml
Normal file
2
src/main/resources/application.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
spring.application.name: memevizor
|
||||
management.server.port: 7900
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.pischule.memevizor.util
|
||||
|
||||
import com.github.kotlintelegrambot.entities.Chat
|
||||
import com.github.kotlintelegrambot.entities.Message
|
||||
import com.github.kotlintelegrambot.entities.files.Document
|
||||
import com.github.kotlintelegrambot.entities.files.PhotoSize
|
||||
import com.github.kotlintelegrambot.entities.files.Video
|
||||
import com.github.kotlintelegrambot.entities.files.VideoNote
|
||||
import io.kotest.matchers.nulls.shouldBeNull
|
||||
import io.kotest.matchers.shouldBe
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class TelegramHelperTest {
|
||||
private val mockChat = Chat(id = 1L, type = "private")
|
||||
|
||||
@Test
|
||||
fun `getMedia should return photo from PhotoSize`() {
|
||||
val message =
|
||||
Message(
|
||||
messageId = 1L,
|
||||
chat = mockChat,
|
||||
date = 123,
|
||||
photo = listOf(PhotoSize("p1", "p1u", 100, 100), PhotoSize("p2", "p2u", 200, 200)),
|
||||
)
|
||||
|
||||
val result = message.getMedia()
|
||||
|
||||
result shouldBe MessageMedia(fileId = "p2", type = MessageMedia.Type.PHOTO)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getMedia should return video from Video`() {
|
||||
val message =
|
||||
Message(
|
||||
messageId = 1L,
|
||||
chat = mockChat,
|
||||
date = 123,
|
||||
video = Video("v1", "v1u", 100, 100, 10),
|
||||
)
|
||||
|
||||
val result = message.getMedia()
|
||||
|
||||
result shouldBe MessageMedia(fileId = "v1", type = MessageMedia.Type.VIDEO)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getMedia should return video from VideoNote`() {
|
||||
val message =
|
||||
Message(
|
||||
messageId = 1L,
|
||||
chat = mockChat,
|
||||
date = 123,
|
||||
videoNote = VideoNote("vn1", "vn1u", 100, 10),
|
||||
)
|
||||
|
||||
val result = message.getMedia()
|
||||
|
||||
result shouldBe MessageMedia(fileId = "vn1", type = MessageMedia.Type.VIDEO)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getMedia should return video from Document with video mimeType`() {
|
||||
val message =
|
||||
Message(
|
||||
messageId = 1L,
|
||||
chat = mockChat,
|
||||
date = 123,
|
||||
document = Document("d1", "d1u", mimeType = "video/mp4"),
|
||||
)
|
||||
|
||||
val result = message.getMedia()
|
||||
|
||||
result shouldBe MessageMedia(fileId = "d1", type = MessageMedia.Type.VIDEO)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getMedia should return null for Document with non-video mimeType`() {
|
||||
val message =
|
||||
Message(
|
||||
messageId = 1L,
|
||||
chat = mockChat,
|
||||
date = 123,
|
||||
document = Document("d1", "d1u", mimeType = "image/jpeg"),
|
||||
)
|
||||
|
||||
val result = message.getMedia()
|
||||
|
||||
result.shouldBeNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getMedia should return null for message with no media`() {
|
||||
val message = Message(messageId = 1L, chat = mockChat, date = 123, text = "hello")
|
||||
|
||||
val result = message.getMedia()
|
||||
|
||||
result.shouldBeNull()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user