diff --git a/apis/openapi-spec/pipeline-service.yaml b/apis/openapi-spec/pipeline-service.yaml index fbfdff56..ac7dbcfa 100644 --- a/apis/openapi-spec/pipeline-service.yaml +++ b/apis/openapi-spec/pipeline-service.yaml @@ -255,6 +255,10 @@ components: type: array items: $ref: "#/components/schemas/Stage" + required: + - id + - name + - stages PipelineBuild: type: object properties: @@ -275,6 +279,16 @@ components: type: array items: $ref: "#/components/schemas/StageBuild" + startedAt: + type: string + format: date-time + required: + - currentState + - id + - pipelineId + - pipelineName + - stageBuilds + - startedAt PipelineExecuteRequest: type: object properties: diff --git a/docker-compose.yml b/docker-compose.yml index 88c44c10..ae88a3d8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -67,12 +67,6 @@ services: - "8016:8016" networks: - app - healthcheck: - test: ["CMD-SHELL", "exec 3<>/dev/tcp/127.0.0.1/8014 && echo -e 'GET /readyz HTTP/1.1\\r\\nHost: localhost\\r\\nConnection: close\\r\\n\\r\\n' >&3 && grep -q 'HTTP/1.1 200' <&3"] - interval: 10s - timeout: 5s - retries: 3 - start_period: 10s pipeline-app: build: context: . @@ -101,15 +95,15 @@ services: auth-service: condition: service_healthy flagd: - condition: service_healthy + condition: service_started pipeline-ui: build: - context: ./pipeline-ui - dockerfile: Dockerfile + context: . + dockerfile: pipeline-ui/Dockerfile args: - VITE_API_BASE_URL: http://pipeline-app:8080/api/v1 + VITE_API_BASE_URL: http://localhost:8080/api/v1 VITE_IDP: keycloak - VITE_KC_URL: http://auth-service:8080 + VITE_KC_URL: http://localhost:8180 VITE_KC_REALM: SpringBootRealm VITE_KC_CLIENTID: pipeline-app image: pipeline-ui @@ -119,4 +113,4 @@ services: - app depends_on: pipeline-app: - condition: service_started \ No newline at end of file + condition: service_started diff --git a/pipeline-ui/Dockerfile b/pipeline-ui/Dockerfile index f57f9fd3..7887a595 100644 --- a/pipeline-ui/Dockerfile +++ b/pipeline-ui/Dockerfile @@ -3,17 +3,21 @@ # FROM node:22-alpine AS build WORKDIR /app -COPY package*.json ./ +RUN apk add --no-cache openjdk17-jre-headless +COPY pipeline-ui/package*.json ./ RUN npm ci -COPY src ./src -COPY public ./public -COPY index.html . -COPY vite.config.ts . -COPY tsconfig*.json ./ -COPY tailwind.config.js postcss.config.js ./ -ARG VITE_API_BASE_URL=http://pipeline-app:8080/api/v1 +COPY pipeline-ui/src ./src +COPY pipeline-ui/public ./public +COPY pipeline-ui/index.html . +COPY pipeline-ui/vite.config.ts . +COPY pipeline-ui/tsconfig*.json ./ +COPY pipeline-ui/tailwind.config.js pipeline-ui/postcss.config.js ./ +COPY pipeline-ui/openapitools.json . +COPY apis/openapi-spec /apis/openapi-spec +RUN npm run generate:client-code +ARG VITE_API_BASE_URL=http://localhost:8080/api/v1 ARG VITE_IDP=keycloak -ARG VITE_KC_URL=http://auth-service:8080 +ARG VITE_KC_URL=http://localhost:8180 ARG VITE_KC_REALM=SpringBootRealm ARG VITE_KC_CLIENTID=pipeline-app ENV VITE_API_BASE_URL=${VITE_API_BASE_URL} diff --git a/pipeline-ui/tsconfig.app.json b/pipeline-ui/tsconfig.app.json index 10570b49..7e1ed649 100644 --- a/pipeline-ui/tsconfig.app.json +++ b/pipeline-ui/tsconfig.app.json @@ -20,7 +20,7 @@ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, - "erasableSyntaxOnly": true, + "erasableSyntaxOnly": false, "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true }, diff --git a/pipeline/src/main/java/com/autobuild/pipeline/configuration/ProtobufOpenApiCustomizer.java b/pipeline/src/main/java/com/autobuild/pipeline/configuration/ProtobufOpenApiCustomizer.java index b7410627..9d43bdaa 100644 --- a/pipeline/src/main/java/com/autobuild/pipeline/configuration/ProtobufOpenApiCustomizer.java +++ b/pipeline/src/main/java/com/autobuild/pipeline/configuration/ProtobufOpenApiCustomizer.java @@ -9,8 +9,11 @@ import org.springframework.stereotype.Component; import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.DateTimeSchema; import io.swagger.v3.oas.models.media.Schema; +//TODO: Remove this as it is a complete anti pattern and makes introducing new fields very difficult + /** * Cleans up the generated OpenAPI spec from proto internals. * @@ -37,7 +40,7 @@ public class ProtobufOpenApiCustomizer implements OpenApiCustomizer { private static final Map> SCHEMA_ALLOWED_PROPERTIES = Map.of( "Pipeline", Set.of("id", "name", "stagesList"), "Stage", Set.of("id", "name", "scriptType", "stageOrder", "command"), - "PipelineBuild", Set.of("id", "pipelineId", "pipelineName", "currentState", "stageBuildsList"), + "PipelineBuild", Set.of("id", "pipelineId", "pipelineName", "currentState", "stageBuildsList", "startedAt"), "StageBuild", Set.of("id", "stageId", "stageName", "stageOrder", "currentState") ); @@ -108,7 +111,26 @@ public void customise(OpenAPI openApi) { } }); - // Step 5: sort schemas alphabetically and sort properties within each schema + // Step 5: override Protobuf Timestamp fields to string/date-time + Schema pipelineBuildSchema = schemas.get("PipelineBuild"); + if (pipelineBuildSchema != null && pipelineBuildSchema.getProperties() != null) { + Map props = (Map) pipelineBuildSchema.getProperties(); + props.put("startedAt", new DateTimeSchema()); + } + + // Step 6: mark required fields so the generated client types are non-optional + Map> requiredFields = Map.of( + "Pipeline", List.of("id", "name", "stages"), + "PipelineBuild", List.of("id", "pipelineId", "pipelineName", "currentState", "startedAt", "stageBuilds") + ); + requiredFields.forEach((schemaName, fields) -> { + Schema schema = schemas.get(schemaName); + if (schema != null) { + schema.setRequired(fields); + } + }); + + // Step 7: sort schemas alphabetically and sort properties within each schema schemas.forEach((name, schema) -> { if (schema.getProperties() != null) { schema.setProperties(new TreeMap<>(schema.getProperties()));