mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2025-12-10 08:16:22 +00:00
126 lines
3.4 KiB
YAML
126 lines
3.4 KiB
YAML
# `rules: if $CI_PIPELINE_SOURCE == 'merge_request_event'` seems to convert the whole
|
|
# workflow into a merge request pipeline, effectively removing all the jobs.
|
|
# To work around that, add:
|
|
# ```
|
|
# rules:
|
|
# when: on_success
|
|
# ```
|
|
# To your pipeline.
|
|
# https://docs.gitlab.com/ee/ci/pipelines/merge_request_pipelines.html#use-rules-to-add-jobs
|
|
|
|
.limit_pipelines:
|
|
rules:
|
|
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == 'main' || $CI_COMMIT_BRANCH == 'develop'
|
|
when: on_success
|
|
- when: never
|
|
|
|
include:
|
|
- local: /backend/backend/.gitlab-ci.yml
|
|
- local: /frontend/app/.gitlab-ci.yml
|
|
- local: /.gitlab/schedules.gitlab-ci.yml
|
|
- local: /.gitlab/publishing.gitlab-ci.yml
|
|
|
|
variables:
|
|
TURBO_CACHE_BYPASS: "--force --no-cache"
|
|
|
|
default:
|
|
image: registry.gitlab.com/openstapps/openstapps/node-builder
|
|
tags:
|
|
- saas-linux-xlarge-amd64
|
|
interruptible: true
|
|
before_script:
|
|
- corepack enable
|
|
- corepack prepare pnpm@latest-10 --activate
|
|
- pnpm config set store-dir .pnpm-store
|
|
cache: &pnpm_cache
|
|
key:
|
|
files:
|
|
- pnpm-lock.yaml
|
|
paths:
|
|
- .pnpm-store/
|
|
policy: pull
|
|
|
|
stages:
|
|
- setup
|
|
- build
|
|
- test
|
|
- audit
|
|
- publish
|
|
|
|
build:
|
|
stage: build
|
|
script:
|
|
# - pnpm config set recursive-install false
|
|
# - pnpm i --prefer-offline
|
|
# - pnpm build:full:skip || pnpm i -r --prefer-offline
|
|
- pnpm install
|
|
# TODO: whats the benefit for CI? something doesn't work with git here...
|
|
# "🦋 error Error: Failed to find where HEAD diverged from master. Does master exist?"
|
|
# - pnpm changeset:status
|
|
- pnpm build:full $TURBO_CACHE_BYPASS
|
|
- .gitlab/ci/enableGitlabReviewToolbar.sh frontend/app/www/browser/index.html "$CI_PROJECT_ID" "$CI_OPEN_MERGE_REQUESTS"
|
|
- cp frontend/app/www/browser/index.html frontend/app/www/browser/200.html
|
|
- pnpm dlx surge -p frontend/app/www/browser -d https://$CI_PROJECT_NAME-$DEPLOY_ID.surge.sh/
|
|
cache:
|
|
<<: *pnpm_cache
|
|
policy: pull-push
|
|
environment:
|
|
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_IID
|
|
- if: $CI_COMMIT_BRANCH == 'main'
|
|
variables:
|
|
DEPLOY_ID: production
|
|
- if: $CI_COMMIT_BRANCH == 'develop'
|
|
variables:
|
|
DEPLOY_ID: staging
|
|
- !reference [.limit_pipelines, rules]
|
|
|
|
stop review:
|
|
stage: build
|
|
needs: ['build']
|
|
script:
|
|
- pnpm dlx surge teardown $CI_PROJECT_NAME-$DEPLOY_ID.surge.sh
|
|
environment:
|
|
name: review/$DEPLOY_ID
|
|
action: stop
|
|
when: manual
|
|
rules: *deploy-rules
|
|
|
|
unit:
|
|
image: registry.gitlab.com/openstapps/openstapps/app-builder
|
|
stage: test
|
|
needs: ['build']
|
|
script:
|
|
- pnpm install
|
|
- pnpm test $TURBO_CACHE_BYPASS
|
|
coverage: '/Statements[^:]*\:[^:]*\s+([\d\.]+)%/'
|
|
artifacts:
|
|
when: on_failure
|
|
paths:
|
|
- report-junit.xml
|
|
- coverage.xml
|
|
reports:
|
|
junit:
|
|
- report-junit.xml
|
|
coverage_report:
|
|
coverage_format: cobertura
|
|
path: coverage.xml
|
|
rules:
|
|
- !reference [.limit_pipelines, rules]
|
|
|
|
audit:
|
|
stage: audit
|
|
allow_failure: true
|
|
needs: []
|
|
script:
|
|
- pnpm audit --prod --audit-level critical
|
|
rules:
|
|
- if: $CI_COMMIT_BRANCH == 'main'
|
|
allow_failure: false
|
|
- !reference [.limit_pipelines, rules]
|