ci: integrate frontend tests into Maven build + Docker
Build & Deploy / build-and-deploy (push) Failing after 42s
Build & Deploy / build-and-deploy (push) Failing after 42s
- Add exec-maven-plugin to pom.xml with 3 npm executions: * npm-install (initialize phase) * frontend-build (generate-resources phase) * frontend-test (test phase) - Add skipFrontend and skipFrontendTests Maven properties - Dockerfile now runs npm test in frontend stage - Dockerfile removes -DskipTests and passes -DskipFrontend=true to the Maven stage (frontend already built in its own stage)
This commit is contained in:
+2
-1
@@ -7,6 +7,7 @@ COPY frontend/package.json frontend/package-lock.json ./
|
|||||||
RUN npm ci 2>/dev/null || npm install --legacy-peer-deps
|
RUN npm ci 2>/dev/null || npm install --legacy-peer-deps
|
||||||
COPY frontend/ ./
|
COPY frontend/ ./
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
RUN npm test
|
||||||
|
|
||||||
# ─── 2. Build Quarkus app ────────────────────────
|
# ─── 2. Build Quarkus app ────────────────────────
|
||||||
FROM maven:3-eclipse-temurin-21-alpine AS build
|
FROM maven:3-eclipse-temurin-21-alpine AS build
|
||||||
@@ -15,7 +16,7 @@ COPY pom.xml ./
|
|||||||
COPY src ./src
|
COPY src ./src
|
||||||
# Copy the built frontend into the source tree so maven-resources-plugin picks it up
|
# Copy the built frontend into the source tree so maven-resources-plugin picks it up
|
||||||
COPY --from=frontend /build/dist ./frontend/dist/
|
COPY --from=frontend /build/dist ./frontend/dist/
|
||||||
RUN mvn package -DskipTests -q
|
RUN mvn package -q -DskipFrontend=true
|
||||||
|
|
||||||
# ─── 3. Runtime ──────────────────────────────────
|
# ─── 3. Runtime ──────────────────────────────────
|
||||||
FROM eclipse-temurin:21-jre-alpine
|
FROM eclipse-temurin:21-jre-alpine
|
||||||
|
|||||||
@@ -15,6 +15,10 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<quarkus.platform.version>3.19.2</quarkus.platform.version>
|
<quarkus.platform.version>3.19.2</quarkus.platform.version>
|
||||||
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
|
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
|
||||||
|
<!-- Set to true to skip all frontend npm tasks (install/build/test) -->
|
||||||
|
<skipFrontend>false</skipFrontend>
|
||||||
|
<!-- Set to true to skip only frontend tests (backend tests still run) -->
|
||||||
|
<skipFrontendTests>false</skipFrontendTests>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@@ -97,6 +101,55 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<!-- Run frontend npm tasks during the Maven lifecycle -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>3.5.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>npm-install</id>
|
||||||
|
<phase>initialize</phase>
|
||||||
|
<goals><goal>exec</goal></goals>
|
||||||
|
<configuration>
|
||||||
|
<workingDirectory>frontend</workingDirectory>
|
||||||
|
<executable>npm</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>ci</argument>
|
||||||
|
<argument>--prefer-offline</argument>
|
||||||
|
</arguments>
|
||||||
|
<skip>${skipFrontend}</skip>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>frontend-build</id>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
|
<goals><goal>exec</goal></goals>
|
||||||
|
<configuration>
|
||||||
|
<workingDirectory>frontend</workingDirectory>
|
||||||
|
<executable>npm</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>run</argument>
|
||||||
|
<argument>build</argument>
|
||||||
|
</arguments>
|
||||||
|
<skip>${skipFrontend}</skip>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>frontend-test</id>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals><goal>exec</goal></goals>
|
||||||
|
<configuration>
|
||||||
|
<workingDirectory>frontend</workingDirectory>
|
||||||
|
<executable>npm</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>test</argument>
|
||||||
|
</arguments>
|
||||||
|
<skip>${skipFrontendTests}</skip>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Reference in New Issue
Block a user