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

View File

@@ -3,16 +3,10 @@ FROM registry.gitlab.com/openstapps/projectmanagement/node:v18 as workspace
USER root
RUN apk add --update python3 py3-pip make g++ gcompat
WORKDIR app/
COPY pnpm-lock.yaml \
package.json \
pnpm-workspace.yaml ./
WORKDIR /build
COPY pnpm-lock.yaml ./
RUN pnpm fetch --prod
COPY backend/ backend/
COPY configuration/ configuration/
COPY examples/ examples/
COPY frontend/ frontend/
COPY packages/ packages/
ADD . ./
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
USER node
ENV NODE_ENV=production
WORKDIR /app
COPY --chown=node:node --from=pruned pruned .

View File

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

View File

@@ -26,16 +26,16 @@
],
"scripts": {
"build": "tsup-node",
"build:docker": "docker build -t openstapps:backend .",
"dev": "tsup --watch --onSuccess \"pnpm run start\"",
"format": "prettier . -c --ignore-path ../../.gitignore",
"format:fix": "prettier --write . --ignore-path ../../.gitignore",
"lint": "tsc --noEmit && eslint --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:debug": "cross-env STAPPS_LOG_LEVEL=31 NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true node app.js",
"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"
},
"dependencies": {

View File

@@ -1,7 +1,7 @@
{
"extends": ["//"],
"pipeline": {
"test:integration": {
"TODO:test:integration": {
"dependsOn": [
"@openstapps/database#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
USER node
ENV NODE_ENV=production
WORKDIR /app
COPY --chown=node:node --from=pruned pruned .
COPY --chown=node:node pruned .
ENTRYPOINT ["node", "app.js"]
CMD ["--help"]