ci: include backend integration tests

This commit is contained in:
Rainer Killinger
2023-06-14 16:04:44 +02:00
committed by Thea Schöbl
parent 3b8a344d73
commit d61d16e752
8 changed files with 36 additions and 28 deletions

View File

@@ -1,3 +1,5 @@
include: '/backend/backend/.gitlab-ci.yml'
default: default:
image: registry.gitlab.com/openstapps/projectmanagement/builder:v18 image: registry.gitlab.com/openstapps/projectmanagement/builder:v18
tags: tags:
@@ -7,12 +9,14 @@ default:
- echo TURBO_TOKEN=$TURBO_TOKEN >> .env.local - echo TURBO_TOKEN=$TURBO_TOKEN >> .env.local
- echo TURBO_TEAM=$TURBO_TEAM >> .env.local - echo TURBO_TEAM=$TURBO_TEAM >> .env.local
- pnpm config set store-dir .pnpm-store - pnpm config set store-dir .pnpm-store
cache: cache: &pnpm_cache
key: key:
files: files:
- pnpm-lock.yaml - pnpm-lock.yaml
paths: paths:
- .pnpm-store - .pnpm-store/
- node-modules/
policy: pull
stages: stages:
- build - build
@@ -29,6 +33,9 @@ build:
artifacts: artifacts:
paths: paths:
- www - www
cache:
<<: *pnpm_cache
policy: pull-push
# rules: # rules:
# - if: $CI_COMMIT_BRANCH == "develop" # - if: $CI_COMMIT_BRANCH == "develop"
# when: never # when: never

View File

@@ -3,16 +3,10 @@ FROM registry.gitlab.com/openstapps/projectmanagement/node:v18 as workspace
USER root USER root
RUN apk add --update python3 py3-pip make g++ gcompat RUN apk add --update python3 py3-pip make g++ gcompat
WORKDIR app/ WORKDIR /build
COPY pnpm-lock.yaml \ COPY pnpm-lock.yaml ./
package.json \
pnpm-workspace.yaml ./
RUN pnpm fetch --prod RUN pnpm fetch --prod
COPY backend/ backend/ ADD . ./
COPY configuration/ configuration/
COPY examples/ examples/
COPY frontend/ frontend/
COPY packages/ packages/
RUN pnpm install -r --offline --prod RUN pnpm install -r --offline --prod

View File

@@ -0,0 +1,15 @@
integration:backend:
image: registry.gitlab.com/openstapps/projectmanagement/builder:v18
stage: test
dependencies:
- build
variables:
DOCKER_DRIVER: overlay2
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- pnpm install --offline
- pnpm test:integration
tags:
- secrecy

View File

@@ -1,12 +1,8 @@
FROM openstapps:workspace as pruned
USER root
RUN pnpm --filter @openstapps/backend --prod deploy /pruned
FROM registry.gitlab.com/openstapps/projectmanagement/node:v18 FROM registry.gitlab.com/openstapps/projectmanagement/node:v18
USER node USER node
ENV NODE_ENV=production ENV NODE_ENV=production
WORKDIR /app
COPY --chown=node:node --from=pruned pruned . COPY --chown=node:node --from=pruned pruned .

View File

@@ -1,7 +1,7 @@
version: '3' version: '3'
services: services:
backend: backend:
image: openstapps:backend build: .
ports: ports:
- '3000:3000' - '3000:3000'
environment: environment:
@@ -13,12 +13,12 @@ services:
ES_ADDR: 'http://elasticsearch:9200' ES_ADDR: 'http://elasticsearch:9200'
elasticsearch: elasticsearch:
image: openstapps:database build: ../database
ports: ports:
- '9200:9200' - '9200:9200'
api-cli: api-cli:
image: openstapps:api-cli build: ../../packages/api-cli
environment: environment:
STAPPS_LOG_LEVEL: '31' STAPPS_LOG_LEVEL: '31'
STAPPS_EXIT_LEVEL: '8' STAPPS_EXIT_LEVEL: '8'

View File

@@ -26,16 +26,16 @@
], ],
"scripts": { "scripts": {
"build": "tsup-node", "build": "tsup-node",
"build:docker": "docker build -t openstapps:backend .",
"dev": "tsup --watch --onSuccess \"pnpm run start\"", "dev": "tsup --watch --onSuccess \"pnpm run start\"",
"format": "prettier . -c --ignore-path ../../.gitignore", "format": "prettier . -c --ignore-path ../../.gitignore",
"format:fix": "prettier --write . --ignore-path ../../.gitignore", "format:fix": "prettier --write . --ignore-path ../../.gitignore",
"lint": "tsc --noEmit && eslint --ext .ts src/", "lint": "tsc --noEmit && eslint --ext .ts src/",
"lint:fix": "eslint --fix --ext .ts src/", "lint:fix": "eslint --fix --ext .ts src/",
"prune:integration": "pnpm --filter=backend --prod deploy pruned && pnpm --filter=api-cli --prod deploy ../../packages/api-cli/pruned",
"start": "cross-env NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true node app.js", "start": "cross-env NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true node app.js",
"start:debug": "cross-env STAPPS_LOG_LEVEL=31 NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true node app.js", "start:debug": "cross-env STAPPS_LOG_LEVEL=31 NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true node app.js",
"test": "pnpm run test:unit", "test": "pnpm run test:unit",
"test:integration": "docker-compose -f integration-test.yml up --abort-on-container-exit --exit-code-from api-cli", "test:integration": "pnpm prune:integration && docker-compose -f integration-test.yml up --abort-on-container-exit --exit-code-from api-cli",
"test:unit": "cross-env NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true STAPPS_LOG_LEVEL=0 mocha --exit" "test:unit": "cross-env NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true STAPPS_LOG_LEVEL=0 mocha --exit"
}, },
"dependencies": { "dependencies": {

View File

@@ -1,7 +1,7 @@
{ {
"extends": ["//"], "extends": ["//"],
"pipeline": { "pipeline": {
"test:integration": { "TODO:test:integration": {
"dependsOn": [ "dependsOn": [
"@openstapps/database#build:docker", "@openstapps/database#build:docker",
"@openstapps/backend#build:docker", "@openstapps/backend#build:docker",

View File

@@ -1,14 +1,10 @@
FROM openstapps:workspace as pruned
USER root
RUN pnpm --filter @openstapps/api-cli --prod deploy /pruned
FROM registry.gitlab.com/openstapps/projectmanagement/node:v18 FROM registry.gitlab.com/openstapps/projectmanagement/node:v18
USER node USER node
ENV NODE_ENV=production ENV NODE_ENV=production
WORKDIR /app
COPY --chown=node:node --from=pruned pruned . COPY --chown=node:node pruned .
ENTRYPOINT ["node", "app.js"] ENTRYPOINT ["node", "app.js"]
CMD ["--help"] CMD ["--help"]