mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2025-12-11 00:36:14 +00:00
141 lines
3.8 KiB
YAML
141 lines
3.8 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:
|
|
value: ''
|
|
options:
|
|
- '--force'
|
|
- '--no-cache'
|
|
- ''
|
|
description: Bypass turbo 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-8 --activate
|
|
- echo TURBO_API=$TURBO_API >> .env.local
|
|
- echo TURBO_TOKEN=$TURBO_TOKEN >> .env.local
|
|
- echo TURBO_TEAM=$TURBO_TEAM >> .env.local
|
|
- 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 benifit 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/index.html "$CI_PROJECT_ID" "$CI_OPEN_MERGE_REQUESTS"
|
|
- cp frontend/app/www/index.html frontend/app/www/200.html
|
|
- pnpm dlx surge -p frontend/app/www -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 config set recursive-install false
|
|
# - pnpm i --prefer-offline
|
|
# - pnpm test:skip || pnpm i -r --prefer-offline
|
|
- pnpm install
|
|
- cd node_modules/.pnpm/re2*/node_modules/re2
|
|
- npm run install
|
|
- cd $CI_PROJECT_DIR
|
|
- 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]
|