Skip to content

Commit ee21e50

Browse files
committed
CI/CD update
1 parent 8450b9d commit ee21e50

File tree

2 files changed

+43
-33
lines changed

2 files changed

+43
-33
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,43 @@
1-
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3-
4-
# This workflow uses actions that are not certified by GitHub.
5-
# They are provided by a third-party and are governed by
6-
# separate terms of service, privacy policy, and support
7-
# documentation.
8-
9-
name: Java CI with Maven
1+
name: CI
102

113
on:
124
push:
13-
branches: [ "master" ]
5+
branches:
6+
- main
147
pull_request:
15-
branches: [ "master" ]
168

17-
jobs:
18-
build:
9+
concurrency:
10+
group: ci-${{ github.ref }}
11+
cancel-in-progress: true
1912

13+
jobs:
14+
build-and-test:
2015
runs-on: ubuntu-latest
2116

2217
steps:
23-
- uses: actions/checkout@v4
24-
- name: Set up JDK 17
25-
uses: actions/setup-java@v4
26-
with:
27-
java-version: '17'
28-
distribution: 'temurin'
29-
cache: maven
30-
- name: Build with Maven
31-
run: mvn -B package --file pom.xml
32-
33-
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
34-
- name: Update dependency graph
35-
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Set up JDK 17
25+
uses: actions/setup-java@v4
26+
with:
27+
distribution: temurin
28+
java-version: 17
29+
cache: maven
30+
31+
- name: Make Maven wrapper executable
32+
run: chmod +x mvnw
33+
34+
- name: Validate Docker availability
35+
run: docker info
36+
37+
- name: Build application image
38+
run: docker build -t avito-test-app .
39+
40+
- name: Run unit and integration tests
41+
env:
42+
MAVEN_OPTS: "-Dmaven.repo.local=${{ github.workspace }}/.m2/repository"
43+
run: ./mvnw -B -ntp verify

Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@ FROM maven:3.9-eclipse-temurin-17 AS build
22
WORKDIR /app
33

44
COPY pom.xml .
5-
COPY avito-test-domain/pom.xml ./avito-test-domain/
6-
COPY avito-test-db/pom.xml ./avito-test-db/
7-
COPY avito-test-impl/pom.xml ./avito-test-impl/
5+
COPY avito-test-domain/pom.xml avito-test-domain/
6+
COPY avito-test-db/pom.xml avito-test-db/
7+
COPY avito-test-impl/pom.xml avito-test-impl/
88

9-
COPY avito-test-domain/src ./avito-test-domain/src
10-
COPY avito-test-db/src ./avito-test-db/src
11-
COPY avito-test-impl/src ./avito-test-impl/src
9+
RUN mvn -B dependency:go-offline
10+
11+
COPY avito-test-domain/src avito-test-domain/src
12+
COPY avito-test-db/src avito-test-db/src
13+
COPY avito-test-impl/src avito-test-impl/src
1214

13-
WORKDIR /app
1415
RUN mvn clean install -DskipTests
1516

1617
FROM eclipse-temurin:17-jre
1718
WORKDIR /app
1819
COPY --from=build /app/avito-test-impl/target/*.jar app.jar
1920
EXPOSE 8080
2021
ENTRYPOINT ["java", "-jar", "app.jar"]
22+

0 commit comments

Comments
 (0)