refactor: speed up the pipeline by directly deploying the review app from the build step

This commit is contained in:
2023-06-28 11:37:39 +02:00
parent 6a8b3d2fe2
commit f1bc41c4df
16 changed files with 344 additions and 296 deletions

View File

@@ -15,12 +15,23 @@ include:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
variables:
TURBO_CACHE_BYPASS:
value: ''
options:
- '--force'
- '--no-cache'
- ''
description: Bypass turbo cache
default:
image: registry.gitlab.com/openstapps/projectmanagement/builder:v18
tags:
- performance
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
@@ -37,34 +48,59 @@ stages:
- version
- build
- test
- review
- 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 build:full
- mv frontend/app/www www
artifacts:
paths:
- www
# - pnpm config set recursive-install false
# - pnpm i --prefer-offline
# - pnpm build:full:skip || pnpm i -r --prefer-offline
- pnpm install
- pnpm build:full $TURBO_CACHE_BYPASS
# pretty sure this is deprecated?
# TODO: - .gitlab/ci/enableGitlabReviewToolbar.sh 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
rules:
- when: on_success
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_SOURCE_BRANCH_NAME
- if: $CI_COMMIT_BRANCH == 'main'
variables:
DEPLOY_ID: production
- if: $CI_COMMIT_BRANCH == 'develop'
variables:
DEPLOY_ID: staging
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:
stage: test
needs: ['build']
script:
- pnpm config set recursive-install false
- pnpm i --prefer-offline
- pnpm test:skip || pnpm i -r --prefer-offline
- pnpm test
# - pnpm config set recursive-install false
# - pnpm i --prefer-offline
# - pnpm test:skip || pnpm i -r --prefer-offline
- pnpm install
- pnpm rb --filter=@openstapps/app
- pnpm test $TURBO_CACHE_BYPASS
coverage: '/Statements[^:]*\:[^:]*\s+([\d\.]+)%/'
artifacts:
when: always

2
.npmrc
View File

@@ -1,2 +1,2 @@
auto-install-peers=true
recursive-install=false
package-import-method=hardlink

View File

@@ -9,7 +9,7 @@ integration:
- name: registry.gitlab.com/openstapps/database:latest
alias: elasticsearch
script:
- pnpm --filter=@openstapps/backend install --prefer-offline
- pnpm --filter=@openstapps/backend install
- pnpm test:integration:backend
artifacts:
when: always

View File

@@ -43,3 +43,4 @@ Thumbs.db
UserInterfaceState.xcuserstate
docs
bundle-info.html

View File

@@ -1,12 +1,8 @@
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:
- pnpm --filter=@openstapps/app install --prefer-offline
- pnpm --filter=@openstapps/app install
- pnpm --filter=@openstapps/app exec cypress install
- pnpm test:integration:app
artifacts:
@@ -24,37 +20,3 @@ e2e:
- BROWSER: firefox
rules:
- when: on_success
review:
stage: review
needs: ['build']
script:
# 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
- pnpm dlx surge -p ./www -d https://$CI_PROJECT_NAME-$DEPLOY_ID.surge.sh/
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_SOURCE_BRANCH_NAME
- if: $CI_COMMIT_BRANCH == 'main'
variables:
DEPLOY_ID: production
- if: $CI_COMMIT_BRANCH == 'develop'
variables:
DEPLOY_ID: staging
stop review:
stage: review
needs: ['review']
script:
- pnpm dlx surge teardown $CI_PROJECT_NAME-$DEPLOY_ID.surge.sh
environment:
name: review/$DEPLOY_ID
action: stop
when: manual
rules: *deploy-rules

View File

@@ -1 +0,0 @@
engine-strict=true

View File

@@ -1,5 +1,5 @@
{
"$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"defaultProject": "app",
"newProjectRoot": "projects",
@@ -19,6 +19,8 @@
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"allowedCommonJsDependencies": ["moment", "opening_hours"],
"assets": [
{
"glob": "**/*",
@@ -203,6 +205,7 @@
}
},
"cli": {
"packageManager": "pnpm",
"defaultCollection": "@ionic/angular-toolkit",
"analytics": false
},

View File

@@ -0,0 +1,11 @@
import {process} from '@angular/compiler-cli/ngcc';
import path from 'path';
const legacyViewEngineLibraries = [
['@awesome-cordova-plugins', 'calendar'],
['@ionic-native', 'core'],
];
for (const basePath of legacyViewEngineLibraries) {
process({basePath: path.resolve(path.join('node_modules', ...basePath))});
}

View File

@@ -14,7 +14,7 @@
],
"scripts": {
"analyze": "webpack-bundle-analyzer www/stats.json",
"build": "ng build",
"build": "ng build --configuration=production --stats-json && webpack-bundle-analyzer www/stats.json --mode static --report www/bundle-info.html",
"build:analyze": "npm run build:stats && npm run analyze",
"build:android": "ionic capacitor build android --no-open && cd android && ./gradlew clean assembleDebug && cd ..",
"build:prod": "ng build --configuration=production",
@@ -37,7 +37,7 @@
"lint:fix": "eslint --fix -c .eslintrc.json --ignore-path .eslintignore --ext .ts,.html src/",
"minify-icons": "ts-node scripts/minify-icon-font.ts",
"ng": "ng",
"postinstall": "jetify || echo \"skipping jetify in production mode\"",
"postinstall": "(jetify && node ngcc-postinstall.mjs) || echo \"skipping jetify in production mode\"",
"preview": "http-server www --p 8101 -o",
"push": "git push && git push origin \"v$npm_package_version\"",
"resources:android": "cordova-res android --skip-config --copy",
@@ -50,13 +50,13 @@
"test:integration": "sh integration-test.sh"
},
"dependencies": {
"@angular/animations": "13.3.11",
"@angular/animations": "13.4.0",
"@angular/cdk": "13.3.9",
"@angular/common": "13.3.11",
"@angular/core": "13.3.11",
"@angular/forms": "13.3.11",
"@angular/platform-browser": "13.3.11",
"@angular/router": "13.3.11",
"@angular/common": "13.4.0",
"@angular/core": "13.4.0",
"@angular/forms": "13.4.0",
"@angular/platform-browser": "13.4.0",
"@angular/router": "13.4.0",
"@asymmetrik/ngx-leaflet": "13.0.2",
"@asymmetrik/ngx-leaflet-markercluster": "13.0.1",
"@awesome-cordova-plugins/calendar": "5.45.0",
@@ -97,7 +97,7 @@
"leaflet.markercluster": "1.5.3",
"material-symbols": "0.4.1",
"moment": "2.29.4",
"ngx-logger": "4.3.3",
"ngx-logger": "5.0.12",
"ngx-markdown": "13.1.0",
"ngx-moment": "6.0.2",
"opening_hours": "3.8.0",
@@ -107,19 +107,19 @@
"zone.js": "0.12.0"
},
"devDependencies": {
"@angular-devkit/architect": "0.1303.9",
"@angular-devkit/build-angular": "13.3.9",
"@angular-devkit/core": "13.3.9",
"@angular-devkit/schematics": "13.3.9",
"@angular-devkit/architect": "0.1303.11",
"@angular-devkit/build-angular": "13.3.11",
"@angular-devkit/core": "13.3.11",
"@angular-devkit/schematics": "13.3.11",
"@angular-eslint/builder": "13.5.0",
"@angular-eslint/eslint-plugin": "13.5.0",
"@angular-eslint/eslint-plugin-template": "13.5.0",
"@angular-eslint/schematics": "13.5.0",
"@angular-eslint/template-parser": "13.5.0",
"@angular/cli": "13.3.9",
"@angular/compiler": "13.3.11",
"@angular/compiler-cli": "13.3.11",
"@angular/language-service": "13.3.11",
"@angular/cli": "13.3.11",
"@angular/compiler": "13.4.0",
"@angular/compiler-cli": "13.4.0",
"@angular/language-service": "13.4.0",
"@capacitor/android": "4.6.1",
"@capacitor/cli": "4.6.1",
"@capacitor/ios": "4.6.1",

View File

@@ -24,6 +24,6 @@ div {
height: fit-content;
display: flex;
flex-direction: row;
justify-content: end;
justify-content: flex-end;
align-items: center;
}

View File

@@ -16,7 +16,7 @@ ion-note {
list-style: none;
display: flex;
flex-direction: row-reverse;
justify-content: start;
justify-content: flex-start;
}
abbr {

View File

@@ -31,6 +31,6 @@ ion-label + ion-label.distance::before {
.in-place {
display: flex;
justify-content: end;
justify-content: flex-end;
align-items: center;
}

View File

@@ -6,6 +6,7 @@
"outDir": "./dist/out-tsc",
"declaration": false,
"emitDecoratorMetadata": true,
"skipLibCheck": false,
"strictPropertyInitialization": false,
"resolveJsonModule": true,
"downlevelIteration": true,

13
frontend/app/turbo.json Normal file
View File

@@ -0,0 +1,13 @@
{
"extends": ["//"],
"pipeline": {
"build": {
"outputs": ["www/**", ".angular/**"]
},
"test:integration": {
"env": ["BROWSER"],
"dependsOn": ["^build"],
"outputs": ["cypress/videos", "cypress/screenshots", "coverage/integration-report-junit.xml"]
}
}
}

441
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,16 +1,17 @@
{
"globalDependencies": [".gitlab-ci.yml", ".npmrc", ".c8rc.json", ".mocharc.json"],
"pipeline": {
"build": {
"dependsOn": ["^build"],
"outputs": ["lib/**", "www/**", ".angular/**"],
"outputs": ["lib/**"],
"cache": true
},
"deploy": {
"dependsOn": ["build", "^deploy"],
"dependsOn": ["build"],
"cache": false
},
"docs": {
"dependsOn": ["build", "^docs"],
"dependsOn": ["^build"],
"outputs": ["docs/**"]
},
"format": {},
@@ -18,14 +19,14 @@
"cache": false
},
"lint": {
"dependsOn": ["build"]
"dependsOn": ["^build"]
},
"lint:fix": {
"dependsOn": ["build", "^lint:fix"],
"dependsOn": ["^build", "^lint:fix"],
"cache": false
},
"test": {
"dependsOn": ["build"],
"dependsOn": ["^build"],
"outputs": ["coverage/cobertura-coverage.xml", "coverage/report-junit.xml"]
},
"test:integration": {
@@ -38,10 +39,6 @@
},
"//#syncpack": {
"dependsOn": []
},
"//#build:docker-workspace": {
"dependsOn": ["^build"],
"cache": false
}
}
}