Skip to content

Commit 49a2ebd

Browse files
committed
add CI/CD
1 parent 5a1b5fd commit 49a2ebd

7 files changed

Lines changed: 211 additions & 1 deletion

File tree

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
target/
2+
.git/
3+
.github/
4+
README.md
5+
docker-compose.yml
6+
prometheus.yml
7+
*.md
8+
.idea/
9+
*.iml

.github/workflows/ci-cd.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: CI/CD Pipline
2+
on:
3+
push:
4+
branches: [main, develop]
5+
pull_request:
6+
branches: [main, develop]
7+
env:
8+
REGISTRY:
9+
ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
build-and-test:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up JDK 17
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '17'
24+
distribution: 'temurin'
25+
cache: maven
26+
27+
- name: Run Checkstyle
28+
run: mvn checkstyle:check
29+
30+
- name: Run tests
31+
run: mvn test
32+
33+
- name: Build application
34+
run: mvn clean package -DskipTests
35+
36+
- name: Build Docker image
37+
run: docker build -t ${{ env.IMAGE_NAME }}:${{ github.sha }} .
38+
39+
- name: Run integration tests with Docker Compose
40+
run: |
41+
docker compose up -d
42+
sleep 10
43+
mvn verify -DskipUnitTests
44+
docker compose down -v
45+
46+
docker-push:
47+
needs: build-and-test
48+
runs-on: ubuntu-latest
49+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
50+
permissions:
51+
contents: read
52+
packages: write
53+
54+
steps:
55+
- name: Checkout code
56+
uses: actions/checkout@v4
57+
58+
- name: Log in to Container Registry
59+
uses: docker/login-action@v3
60+
with:
61+
registry: ${{ env.REGISTRY }}
62+
username: ${{ github.actor }}
63+
password: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Extract metadata
66+
id: meta
67+
uses: docker/metadata-action@v5
68+
with:
69+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
70+
tags: |
71+
type=ref,event=branch
72+
type=sha,prefix={{branch}}-
73+
type=semver,pattern={{version}}
74+
type=semver,pattern={{major}}.{{minor}}
75+
76+
- name: Build and push Docker image
77+
uses: docker/build-push-action@v5
78+
with:
79+
context: .
80+
push: true
81+
tags: ${{ steps.meta.outputs.tags }}
82+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
target/
2+
.idea/
3+
*.iml
4+
*.log
5+
.DS_Store

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM maven:3.9.6-eclipse-temurin-17 AS builder
22
WORKDIR /app
33
COPY pom.xml .
44
COPY src ./src
5-
RUN mvn -DskipTests package
5+
RUN mvn clean package
66

77
FROM eclipse-temurin:17-jre
88
WORKDIR /app

config/checkstyle/checkstyle.xml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
6+
<module name="Checker">
7+
8+
<!-- кодировка/концы строк -->
9+
<property name="charset" value="UTF-8"/>
10+
<property name="severity" value="error"/>
11+
12+
<!-- исключаем мусор -->
13+
<module name="SuppressionFilter">
14+
<property name="file" value="${basedir}/config/checkstyle/suppressions.xml"/>
15+
<property name="optional" value="true"/>
16+
</module>
17+
18+
<!-- базовые проверки файлов (file-level checks) -->
19+
<module name="FileTabCharacter"/>
20+
<module name="NewlineAtEndOfFile"/>
21+
22+
<!-- LineLength тоже file-level, поэтому здесь, а не в TreeWalker -->
23+
<module name="LineLength">
24+
<property name="max" value="120"/>
25+
<property name="ignorePattern" value="^package|^import|https?://"/>
26+
</module>
27+
28+
<!-- правила для Java (AST-level checks) -->
29+
<module name="TreeWalker">
30+
<module name="AvoidStarImport"/>
31+
<module name="UnusedImports"/>
32+
<module name="RedundantImport"/>
33+
<module name="ImportOrder">
34+
<property name="ordered" value="true"/>
35+
<property name="separated" value="true"/>
36+
<property name="sortStaticImportsAlphabetically" value="true"/>
37+
</module>
38+
39+
<!-- -->
40+
41+
<module name="NeedBraces"/>
42+
<module name="EmptyBlock"/>
43+
<module name="WhitespaceAround"/>
44+
<module name="WhitespaceAfter"/>
45+
<module name="OneStatementPerLine"/>
46+
47+
<!-- имена -->
48+
<module name="MethodName">
49+
<!-- Разрешаем подчёркивания в именах методов (для тестов) -->
50+
<property name="format" value="^[a-z][a-zA-Z0-9_]*$"/>
51+
</module>
52+
<module name="MemberName"/>
53+
<module name="ParameterName"/>
54+
<module name="LocalVariableName"/>
55+
</module>
56+
</module>

config/checkstyle/suppressions.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE suppressions PUBLIC
3+
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
4+
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
5+
6+
<suppressions>
7+
<!-- отключить ВСЕ проверки для всего, что лежит в target/ -->
8+
<suppress files=".*[/\\]target[/\\].*" checks=".*"/>
9+
</suppressions>

qodana.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#-------------------------------------------------------------------------------#
2+
# Qodana analysis is configured by qodana.yaml file #
3+
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
4+
#-------------------------------------------------------------------------------#
5+
6+
#################################################################################
7+
# WARNING: Do not store sensitive information in this file, #
8+
# as its contents will be included in the Qodana report. #
9+
#################################################################################
10+
version: "1.0"
11+
12+
#Specify inspection profile for code analysis
13+
profile:
14+
name: qodana.starter
15+
16+
#Enable inspections
17+
#include:
18+
# - name: <SomeEnabledInspectionId>
19+
20+
#Disable inspections
21+
#exclude:
22+
# - name: <SomeDisabledInspectionId>
23+
# paths:
24+
# - <path/where/not/run/inspection>
25+
26+
projectJDK: "21" #(Applied in CI/CD pipeline)
27+
28+
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
29+
#bootstrap: sh ./prepare-qodana.sh
30+
31+
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
32+
#plugins:
33+
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
34+
35+
# Quality gate. Will fail the CI/CD pipeline if any condition is not met
36+
# severityThresholds - configures maximum thresholds for different problem severities
37+
# testCoverageThresholds - configures minimum code coverage on a whole project and newly added code
38+
# Code Coverage is available in Ultimate and Ultimate Plus plans
39+
#failureConditions:
40+
# severityThresholds:
41+
# any: 15
42+
# critical: 5
43+
# testCoverageThresholds:
44+
# fresh: 70
45+
# total: 50
46+
47+
#Qodana supports other languages, for example, Python, JavaScript, TypeScript, Go, C#, PHP
48+
#For all supported languages see https://www.jetbrains.com/help/qodana/linters.html
49+
linter: jetbrains/qodana-jvm-community:2025.3

0 commit comments

Comments
 (0)