feat: docker publishing

This commit is contained in:
2023-06-27 12:06:08 +02:00
parent c4260dc882
commit 129f25d1f0
18 changed files with 210 additions and 378 deletions

View File

@@ -1,226 +1,60 @@
image: registry.gitlab.com/openstapps/app
before_script:
- npm ci
default:
tags:
- performance
interruptible: true
stages:
- setup
- build
- test
- publish
- deploy
- ui test
setup:
image: registry.gitlab.com/openstapps/projectmanagement/builder
stage: setup
only:
- schedules
variables:
DOCKER_DRIVER: overlay2
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- docker build -t registry.gitlab.com/openstapps/app .
- docker push registry.gitlab.com/openstapps/app
cache: {} # disable irrelevant cache for this job
before_script: [] # do not run irrelevant before script for this job
tags:
- dind
interruptible: false
build:
stage: build
script:
- npm run build
artifacts:
paths:
- www
except:
- schedules
scheduled-build:
stage: build
script:
- npm run build
only:
- schedules
lint:
stage: build
script:
- npm run lint
format:
stage: build
script:
- npm run format:check
unit:
e2e:
image: cypress/browsers:latest # https://hub.docker.com/r/cypress/browsers/tags/
stage: test
before_script:
- corepack enable
- corepack prepare pnpm@latest-8 --activate
- !reference [default, before_script]
script:
- npm run check-icons
- npm run test -- --watch=false --no-progress --code-coverage
coverage: '/Statements[^:]*\:[^:]*\s+([\d\.]+)%/'
- pnpm --filter=@openstapps/app install --prefer-offline
- pnpm --filter=@openstapps/app exec cypress install
- pnpm test:integration:app
artifacts:
when: always
paths:
- coverage
- frontend/app/cypress/videos
- frontend/app/cypress/screenshots
- frontend/app/coverage/integration-report-junit.xml
reports:
coverage_report:
coverage_format: cobertura
path: coverage/cobertura-coverage.xml
.e2e-chrome:
image: registry.gitlab.com/openstapps/projectmanagement/cypress
stage: test
script:
- npm run e2e -- --watch=false --headless=true --browser=chrome
artifacts:
when: on_failure
paths:
- cypress/videos
- cypress/screenshots
.e2e-firefox:
image: registry.gitlab.com/openstapps/projectmanagement/cypress
stage: test
script:
- npm run e2e -- --watch=false --headless=true --browser=firefox
artifacts:
when: on_failure
paths:
- cypress/videos
- cypress/screenshots
ui-chrome:
extends: .e2e-chrome
junit:
- frontend/app/coverage/integration-report-junit.xml
parallel:
matrix:
- BROWSER: chrome
- BROWSER: firefox
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: ($CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_NAME == "main")
when: always
allow_failure: false
- if: ($CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_NAME != "main")
when: never
ui-firefox:
extends: .e2e-firefox
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: ($CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_NAME == "main")
when: always
allow_failure: false
- if: ($CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_NAME != "main")
when: never
e2e-chrome:
extends: .e2e-chrome
stage: ui test
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: ($CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_NAME == "main")
when: never
- if: ($CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_NAME != "main")
when: manual
allow_failure: false
e2e-firefox:
extends: .e2e-firefox
stage: ui test
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: ($CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_NAME == "main")
when: never
- if: ($CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_NAME != "main")
when: manual
allow_failure: false
audit:
stage: test
script:
- npm audit
allow_failure: true
except:
- schedules
scheduled-audit:
stage: test
script:
- npm audit --production
only:
- schedules
pages:
stage: publish
script:
- npm run documentation
- mv docs public
only:
- main
except:
- schedules
artifacts:
paths:
- public
- when: on_success
review:
stage: deploy
stage: review
needs: ['build']
script:
- npm run build:prod
- .gitlab/ci/enableGitlabReviewToolbar.sh www/index.html "$CI_PROJECT_ID" "$CI_OPEN_MERGE_REQUESTS"
# pretty sure this is deprecated?
# TODO: - .gitlab/ci/enableGitlabReviewToolbar.sh www/index.html "$CI_PROJECT_ID" "$CI_OPEN_MERGE_REQUESTS"
- cp www/index.html www/200.html
- ./node_modules/.bin/surge -p ./www -d https://$CI_PROJECT_PATH_SLUG-$CI_ENVIRONMENT_SLUG.surge.sh/
- pnpm dlx surge -p ./www -d https://$CI_PROJECT_NAME-$DEPLOY_ID.surge.sh/
environment:
name: review/$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_NAME
url: https://$CI_PROJECT_PATH_SLUG-$CI_ENVIRONMENT_SLUG.surge.sh/
on_stop: stop_review
rules:
- if: ($CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_NAME != "main" && $CI_MERGE_REQUEST_EVENT_TYPE != "merge_train" && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "web"))
name: review/$DEPLOY_ID
url: https://$CI_PROJECT_NAME-$DEPLOY_ID.surge.sh/
on_stop: stop review
rules: &deploy-rules
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
variables:
DEPLOY_ID: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
- if: $CI_COMMIT_BRANCH == 'main'
variables:
DEPLOY_ID: production
- if: $CI_COMMIT_BRANCH == 'develop'
variables:
DEPLOY_ID: staging
stop_review:
stage: deploy
stop review:
stage: review
needs: ['review']
script:
- ./node_modules/.bin/surge teardown $CI_PROJECT_PATH_SLUG-$CI_ENVIRONMENT_SLUG.surge.sh
when: manual
- pnpm dlx surge teardown $CI_PROJECT_NAME-$DEPLOY_ID.surge.sh
environment:
name: review/$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_NAME
name: review/$DEPLOY_ID
action: stop
rules:
- if: ($CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_NAME != "main" && $CI_MERGE_REQUEST_EVENT_TYPE != "merge_train" && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "web"))
staging:
stage: deploy
script:
- npm run build:prod
- cp www/index.html www/200.html
- ./node_modules/.bin/surge -p ./www -d https://$CI_PROJECT_PATH_SLUG-staging.surge.sh/
environment:
name: staging
url: https://$CI_PROJECT_PATH_SLUG-staging.surge.sh/
only:
- develop
except:
- schedules
production_demo:
stage: deploy
script:
- npm run build:prod
- cp www/index.html www/200.html
- ./node_modules/.bin/surge -p ./www -d https://$CI_PROJECT_PATH_SLUG.surge.sh/
environment:
name: production
url: https://$CI_PROJECT_PATH_SLUG.surge.sh/
only:
- main
except:
- schedules
when: manual
rules: *deploy-rules