Resolve "lint, test and build for frontend image"

This commit is contained in:
ekresse
2024-01-12 13:58:52 +00:00
parent 718d190a04
commit d4d0c5199c
16 changed files with 1970 additions and 150 deletions

View File

@ -1,8 +1,20 @@
stages:
- lint
- build
- test
- docker
lint-frontend:
image: node:lts
stage: lint
rules:
- changes:
- frontend/**/*
script:
- cd frontend
- npm i
- npm run lint-no-fix
build-backend:
image: golang:1.21-alpine
stage: build
@ -18,7 +30,7 @@ build-backend:
- backend/go.sum
- backend/go.mod
test:
test-backend:
image: golang:1.21-alpine
stage: test
rules:
@ -30,6 +42,19 @@ test:
dependencies:
- build-backend
test-frontend:
image: node:lts
stage: test
rules:
- changes:
- frontend/**/*
script:
- cd frontend
- npm i
- npm run test
dependencies:
- lint-frontend
build-backend-image:
stage: docker
image: docker:20.10.16
@ -53,3 +78,27 @@ build-backend-image:
only:
- main
- development
build-frontend-image:
stage: docker
image: docker:20.10.16
services:
- name: docker:20.10.16-dind
alias: docker
tags:
- image
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_TLS_VERIFY: 1
DOCKER_CERT_PATH: "/certs/client"
script:
- cd frontend
- docker login -u $CI_DOCKER_REGISTRY_USER -p $CI_DOCKER_REGISTRY_PASSWORD $CI_DOCKER_REGISTRY
- docker build -f Dockerfile_prod -t htwkalender-frontend$IMAGE_TAG .
- docker tag htwkalender-frontend$IMAGE_TAG $CI_DOCKER_REGISTRY_USER/htwkalender:frontend
- docker push $CI_DOCKER_REGISTRY_USER/htwkalender:frontend
only:
- main
- development