From fb96a4e8be3cc5c196cbe0b88c2eb4c40a5b48f0 Mon Sep 17 00:00:00 2001 From: Rainer Killinger Date: Tue, 7 Sep 2021 12:58:42 +0200 Subject: [PATCH] ci: add real CI configuration --- .gitlab-ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++-------- Dockerfile | 6 ++++++ package.json | 7 +++++-- 3 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 Dockerfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 85411f2c..4849e031 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,21 @@ image: registry.gitlab.com/openstapps/projectmanagement/node stages: - - test + - build + - audit + - publish - deploy -cache: - key: ${CI_COMMIT_REF_SLUG} - paths: - - node_modules +before_script: + - npm ci + +npm build: + stage: build + script: + - npm run build + artifacts: + paths: + - lib audit: allow_failure: true @@ -15,14 +23,38 @@ audit: - schedules script: - npm audit - stage: test + stage: audit scheduled-audit: only: - schedules script: - - npm audit - stage: test + - npm audit --audit-level=high + stage: audit + +docker image: + image: registry.gitlab.com/openstapps/projectmanagement/builder:latest + dependencies: + - npm build + stage: publish + variables: + DOCKER_DRIVER: overlay2 + services: + - docker:dind + script: + - export CORE_VERSION=$(openstapps-projectmanagement get-used-version @openstapps/core) + - export VERSION=$(echo -n "$CI_BUILD_REF_NAME" | cut -c 2-) + - export IMAGETAG_BASE=$CI_REGISTRY_IMAGE + - export IMAGETAG_CORE_VERSION=$IMAGETAG_BASE:core-$CORE_VERSION + - export IMAGETAG_VERSION=$IMAGETAG_BASE:$VERSION + - export IMAGETAG_LATEST=$IMAGETAG_BASE:latest + - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY + - docker build -t $IMAGETAG_LATEST -t $IMAGETAG_VERSION -t $IMAGETAG_CORE_VERSION . + - docker push $IMAGETAG_BASE + only: + - /^v[0-9]+\.[0-9]+\.[0-9]+$/ + except: + - branches pages: artifacts: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..576b6a64 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM registry.gitlab.com/openstapps/projectmanagement/node + +WORKDIR /app +ENTRYPOINT ["node", "lib/cli.js"] + +ADD . /app diff --git a/package.json b/package.json index d7433f50..9f84daa2 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,10 @@ "description": "Minimal Plugin", "license": "GPL-3.0-only", "author": "Wieland Schöbl", - "contributors": [], + "contributors": [ + "Jovan Krunić ", + "Rainer Killinger " + ], "scripts": { "build": "npm run tslint && npm run compile", "compile": "rimraf lib && tsc && prepend lib/cli.js '#!/usr/bin/env node\n'", @@ -12,7 +15,7 @@ "check-configuration": "openstapps-configuration", "documentation": "typedoc --includeVersion --out docs src", "start": "node lib/cli.js", - "tslint": "tslint 'src/**/*.ts'", + "tslint": "tslint -p tsconfig.json -c tslint.json 'src/**/*.ts'", "prepublishOnly": "npm ci && npm run build", "postversion": "npm run changelog", "preversion": "npm run prepublishOnly",