feat: add Karma configuration with ChromeHeadlessCI launcher and update test CI pipeline

This commit is contained in:
nessar committed 2026-05-30 15:40:16 +02:00
1 parent 7702efc165
commit 3a105097c3
2 files changed
+125 -74

No files matched your search

+80 -74
View File
@@ -1,109 +1,115 @@
image: oven/bun:latest
stages:
- validate
- test
- build
- security
- docker
- validate
- test
- build
- security
- docker
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ''
cache:
key:
files:
- bun.lockb
paths:
- .bun/
key:
files:
- bun.lockb
paths:
- .bun/
.node_setup:
before_script:
- bun install --frozen-lockfile
before_script:
- bun install --frozen-lockfile
# -- Validate Stage --
lint:
extends: .node_setup
stage: validate
script:
- bunx eslint "src/**/*.ts"
extends: .node_setup
stage: validate
script:
- bunx eslint "src/**/*.ts"
prettier:
extends: .node_setup
stage: validate
script:
- bunx prettier --check "src/**/*.{ts,html,scss,css,json}"
extends: .node_setup
stage: validate
script:
- bunx prettier --check "src/**/*.{ts,html,scss,css,json}"
type-check:
extends: .node_setup
stage: validate
script:
- bunx tsc --noEmit
extends: .node_setup
stage: validate
script:
- bunx tsc --noEmit
# -- Test Stage --
test:
stage: test
before_script:
- apt-get update && apt-get install -y chromium
- echo -e '#!/bin/sh\nexec /usr/bin/chromium --no-sandbox "$@"' > /usr/bin/chromium-no-sandbox
- chmod +x /usr/bin/chromium-no-sandbox
- bun install --frozen-lockfile
variables:
CHROME_BIN: /usr/bin/chromium-no-sandbox
script:
- bun run test -- --watch=false --browsers=ChromeHeadless --code-coverage
artifacts:
when: always
paths:
- coverage/vac-optimizer/
expire_in: 7 days
stage: test
before_script:
- apt-get update && apt-get install -y chromium
- bun install --frozen-lockfile
variables:
CHROME_BIN: /usr/bin/chromium
script:
- bun run test
--watch=false
--browsers=ChromeHeadlessCI
--code-coverage
--no-progress
artifacts:
when: always
paths:
- coverage/
reports:
coverage_report:
coverage_format: cobertura
path: coverage/cobertura-coverage.xml
expire_in: 7 days
# -- Build Stage --
build:
extends: .node_setup
stage: build
script:
- bun run build -- --configuration production
artifacts:
paths:
- dist/
expire_in: 7 days
extends: .node_setup
stage: build
script:
- bun run build -- --configuration production
artifacts:
paths:
- dist/
expire_in: 7 days
# -- Security Stage --
include:
- template: Security/SAST.gitlab-ci.yml
- template: Security/SAST.gitlab-ci.yml
trivy_scan:
stage: security
image:
name: aquasec/trivy:latest
entrypoint: [""]
before_script: [] # override global before_script
script:
# Trivy will scan the project directory
- trivy fs --format sarif --output trivy-results.sarif .
artifacts:
reports:
sast: trivy-results.sarif
expire_in: 7 days
stage: security
image:
name: aquasec/trivy:latest
entrypoint: ['']
before_script: [] # override global before_script
script:
# Trivy will scan the project directory
- trivy fs --format sarif --output trivy-results.sarif .
artifacts:
reports:
sast: trivy-results.sarif
expire_in: 7 days
# -- Docker Stage --
docker-build:
stage: docker
image: docker:24.0.5
services:
- docker:24.0.5-dind
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin
script:
- docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" -t "$CI_REGISTRY_IMAGE:latest" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
- docker push "$CI_REGISTRY_IMAGE:latest"
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
stage: docker
image: docker:24.0.5
services:
- docker:24.0.5-dind
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin
script:
- docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" -t "$CI_REGISTRY_IMAGE:latest" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
- docker push "$CI_REGISTRY_IMAGE:latest"
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+45
View File
@@ -0,0 +1,45 @@
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma'),
],
client: {
jasmine: {},
clearContext: false,
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' },
{ type: 'lcovonly' }, // ← useful for SonarQube / Codecov
],
},
reporters: ['progress', 'kjhtml'],
browsers: ['Chrome'],
// ✅ Custom launcher for CI — no wrapper script needed
customLaunchers: {
ChromeHeadlessCI: {
base: 'ChromeHeadless',
flags: [
'--no-sandbox', // required in Docker / rootless envs
'--disable-gpu',
'--disable-dev-shm-usage', // prevents crashes in containers with small /dev/shm
'--disable-extensions',
'--window-size=1280,720',
],
},
},
singleRun: false,
restartOnFileChange: true,
});
};