From 5280f174563583ccb47bac0c89b1eb9d9ba6b777 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 27 Jul 2021 11:43:23 +0000 Subject: [PATCH 01/16] Added Jenkinsfile --- Jenkinsfile | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..e398b21 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,107 @@ +pipeline { + agent any + stages { + stage('Pull') { + steps { + git(url: 'http://git.fufle.net/Community/CureNet.git', branch: '${BRANCH_NAME}', credentialsId: '799188a2-c281-4e4c-b78f-c82132ea792b', poll: true) + } + } + + stage('Install') { + parallel { + stage('Frontend') { + steps { + dir(path: 'frontend') { + sh 'npm ci' + } + + } + } + + stage('Backend') { + steps { + dir(path: 'backend') { + sh 'composer install' + } + + } + } + + } + } + + stage('Configure') { + parallel { + stage('Frontend') { + steps { + dir(path: 'frontend') { + sh 'echo skip' + } + + } + } + + stage('Backend') { + steps { + dir(path: 'backend') { + sh 'composer dump-env dev' + } + + } + } + + } + } + + stage('Test') { + parallel { + stage('Frontend') { + steps { + dir(path: 'frontend') { + sh 'echo skip' + } + + } + } + + stage('Backend') { + steps { + dir(path: 'backend') { + sh 'php vendor/bin/phpunit' + } + + } + } + + } + } + + stage('Deploy') { + parallel { + stage('Frontend') { + steps { + dir(path: 'frontend') { + sh 'ssh web@fufle.net touch /web/fufle.net/curenet/dev/frontend/REMOVEME' + sh 'ssh web@fufle.net rm -rf /web/fufle.net/curenet/dev/frontend/*' + sh 'scp -r dist/* web@fufle.net:/web/fufle.net/curenet/dev/frontend/' + } + + } + } + + stage('Backend') { + steps { + dir(path: 'backend') { + sh 'ssh web@fufle.net touch /web/fufle.net/curenet/dev/backend/REMOVEME' + sh 'ssh web@fufle.net rm -rf /web/fufle.net/curenet/dev/backend/*' + sh 'scp -r ./ web@fufle.net:/web/fufle.net/curenet/dev/backend/' + } + + } + } + + } + } + + } +} \ No newline at end of file -- 2.39.5 From 797f83b7772a778549ea5660858c689dad733f6a Mon Sep 17 00:00:00 2001 From: Sieciech Date: Tue, 27 Jul 2021 14:05:54 +0200 Subject: [PATCH 02/16] pipeline --- Jenkinsfile | 69 ++++++++++++++++++- .../src/environments/environment.prod.ts | 4 +- src/frontend/src/environments/environment.ts | 4 +- 3 files changed, 72 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e398b21..85ceb57 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,10 @@ pipeline { agent any + + environment { + DatabaseUrl = sh(returnStdout: true, script: 'bash /var/lib/jenkins/variables/CureNet/var.sh ${BRANCH_NAME} DatabaseUrl').trim() + } + stages { stage('Pull') { steps { @@ -7,11 +12,34 @@ pipeline { } } + stage('Approve') { + steps { + echo "http://git.fufle.net/Community/CureNet/commit/${env.GIT_COMMIT}" + script { + if (env.BRANCH_NAME == "prod") { + echo "http://git.fufle.net/Community/CureNet/compare/prod...staging" + input(message: 'Deploy to production?', id: 'A', ok: 'Yes', submitter: 'deploy', submitterParameter: 'a') + } + if (env.BRANCH_NAME == "staging") { + echo "http://git.fufle.net/Community/CureNet/compare/staging...beta" + input(message: 'Deploy to staging instance?', id: 'A', ok: 'Yes', submitter: 'deploy', submitterParameter: 'a') + } + if (env.BRANCH_NAME == "beta") { + echo "http://git.fufle.net/Community/CureNet/compare/beta...dev" + input(message: 'Deploy to beta instance?', id: 'A', ok: 'Yes', submitter: 'deploy', submitterParameter: 'a') + } + } + + } + } + stage('Install') { parallel { stage('Frontend') { steps { dir(path: 'frontend') { + sh 'sed -i "s/-1001/${BUILD_ID}/g" src/environments/*.ts' + sh 'Timestamp=`php8.0 -r "echo time();"` && sed -i "s/-1002/${Timestamp}/g" src/environments/*.ts' sh 'npm ci' } @@ -21,7 +49,7 @@ pipeline { stage('Backend') { steps { dir(path: 'backend') { - sh 'composer install' + sh 'php8.0 /bin/composer install' } } @@ -44,6 +72,8 @@ pipeline { stage('Backend') { steps { dir(path: 'backend') { + sh 'APP_SECRET=`php8.0 -r "echo md5(\\"branch=${BRANCH_NAME};\\");"` && sed -i "s/APP_SECRET=.*/APP_SECRET=${APP_SECRET}/g" .env' + sh 'sed -i "s/DATABASE_URL=.*/DATABASE_URL=${DatabaseUrl}/g" .env.dev' sh 'composer dump-env dev' } @@ -58,7 +88,7 @@ pipeline { stage('Frontend') { steps { dir(path: 'frontend') { - sh 'echo skip' + sh 'ng lint' } } @@ -67,7 +97,30 @@ pipeline { stage('Backend') { steps { dir(path: 'backend') { - sh 'php vendor/bin/phpunit' + sh 'php8.0 vendor/bin/phpunit' + } + + } + } + + } + } + + stage('Build') { + parallel { + stage('Frontend') { + steps { + dir(path: 'frontend') { + sh 'ng b -c production' + } + + } + } + + stage('Backend') { + steps { + dir(path: 'backend') { + sh 'echo skip' } } @@ -77,6 +130,16 @@ pipeline { } stage('Deploy') { + when { + anyOf { + branch 'prod' + branch 'staging' + branch 'beta' + branch 'dev' + } + + } + parallel { stage('Frontend') { steps { diff --git a/src/frontend/src/environments/environment.prod.ts b/src/frontend/src/environments/environment.prod.ts index 3612073..c831413 100644 --- a/src/frontend/src/environments/environment.prod.ts +++ b/src/frontend/src/environments/environment.prod.ts @@ -1,3 +1,5 @@ export const environment = { - production: true + production: true, + buildId: -1001, + buildTime: -1002, }; diff --git a/src/frontend/src/environments/environment.ts b/src/frontend/src/environments/environment.ts index 30d7bcc..50099fc 100644 --- a/src/frontend/src/environments/environment.ts +++ b/src/frontend/src/environments/environment.ts @@ -3,7 +3,9 @@ // The list of file replacements can be found in `angular.json`. export const environment = { - production: false + production: false, + buildId: -1001, + buildTime: -1002, }; /* -- 2.39.5 From 0a40523c2c47501dd8d98ac9217df3e7348c7e25 Mon Sep 17 00:00:00 2001 From: Sieciech Date: Tue, 27 Jul 2021 14:19:14 +0200 Subject: [PATCH 03/16] path --- Jenkinsfile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 85ceb57..52e7deb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,7 +37,7 @@ pipeline { parallel { stage('Frontend') { steps { - dir(path: 'frontend') { + dir(path: 'src/frontend') { sh 'sed -i "s/-1001/${BUILD_ID}/g" src/environments/*.ts' sh 'Timestamp=`php8.0 -r "echo time();"` && sed -i "s/-1002/${Timestamp}/g" src/environments/*.ts' sh 'npm ci' @@ -48,7 +48,7 @@ pipeline { stage('Backend') { steps { - dir(path: 'backend') { + dir(path: 'src/backend') { sh 'php8.0 /bin/composer install' } @@ -62,7 +62,7 @@ pipeline { parallel { stage('Frontend') { steps { - dir(path: 'frontend') { + dir(path: 'src/frontend') { sh 'echo skip' } @@ -71,7 +71,7 @@ pipeline { stage('Backend') { steps { - dir(path: 'backend') { + dir(path: 'src/backend') { sh 'APP_SECRET=`php8.0 -r "echo md5(\\"branch=${BRANCH_NAME};\\");"` && sed -i "s/APP_SECRET=.*/APP_SECRET=${APP_SECRET}/g" .env' sh 'sed -i "s/DATABASE_URL=.*/DATABASE_URL=${DatabaseUrl}/g" .env.dev' sh 'composer dump-env dev' @@ -87,7 +87,7 @@ pipeline { parallel { stage('Frontend') { steps { - dir(path: 'frontend') { + dir(path: 'src/frontend') { sh 'ng lint' } @@ -96,7 +96,7 @@ pipeline { stage('Backend') { steps { - dir(path: 'backend') { + dir(path: 'src/backend') { sh 'php8.0 vendor/bin/phpunit' } @@ -110,7 +110,7 @@ pipeline { parallel { stage('Frontend') { steps { - dir(path: 'frontend') { + dir(path: 'src/frontend') { sh 'ng b -c production' } @@ -119,7 +119,7 @@ pipeline { stage('Backend') { steps { - dir(path: 'backend') { + dir(path: 'src/backend') { sh 'echo skip' } @@ -143,7 +143,7 @@ pipeline { parallel { stage('Frontend') { steps { - dir(path: 'frontend') { + dir(path: 'src/frontend') { sh 'ssh web@fufle.net touch /web/fufle.net/curenet/dev/frontend/REMOVEME' sh 'ssh web@fufle.net rm -rf /web/fufle.net/curenet/dev/frontend/*' sh 'scp -r dist/* web@fufle.net:/web/fufle.net/curenet/dev/frontend/' @@ -154,7 +154,7 @@ pipeline { stage('Backend') { steps { - dir(path: 'backend') { + dir(path: 'src/backend') { sh 'ssh web@fufle.net touch /web/fufle.net/curenet/dev/backend/REMOVEME' sh 'ssh web@fufle.net rm -rf /web/fufle.net/curenet/dev/backend/*' sh 'scp -r ./ web@fufle.net:/web/fufle.net/curenet/dev/backend/' -- 2.39.5 From ddd5c5561578cf8fee2c5a8fc734fe6266d5b860 Mon Sep 17 00:00:00 2001 From: Sieciech Date: Tue, 27 Jul 2021 14:38:48 +0200 Subject: [PATCH 04/16] lint + pipeline --- Jenkinsfile | 33 +++++++++++++++++-- src/backend/.env.test | 1 + src/frontend/src/app/app.component.ts | 14 ++++---- src/frontend/src/app/app.module.ts | 2 +- .../shared/services/app/app.service.ts | 27 +++++++-------- .../browser-storage.service.ts | 5 +-- .../shared/services/theme/theme.service.ts | 6 ++-- 7 files changed, 59 insertions(+), 29 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 52e7deb..e792a8a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,6 +3,7 @@ pipeline { environment { DatabaseUrl = sh(returnStdout: true, script: 'bash /var/lib/jenkins/variables/CureNet/var.sh ${BRANCH_NAME} DatabaseUrl').trim() + DatabaseUrlTesting = sh(returnStdout: true, script: 'bash /var/lib/jenkins/variables/CureNet/var.sh test DatabaseUrl').trim() } stages { @@ -58,7 +59,7 @@ pipeline { } } - stage('Configure') { + stage('Configure for tests') { parallel { stage('Frontend') { steps { @@ -73,8 +74,9 @@ pipeline { steps { dir(path: 'src/backend') { sh 'APP_SECRET=`php8.0 -r "echo md5(\\"branch=${BRANCH_NAME};\\");"` && sed -i "s/APP_SECRET=.*/APP_SECRET=${APP_SECRET}/g" .env' - sh 'sed -i "s/DATABASE_URL=.*/DATABASE_URL=${DatabaseUrl}/g" .env.dev' - sh 'composer dump-env dev' + sh 'sed -i "s/DATABASE_URL=.*/DATABASE_URL=${DatabaseUrlTesting}/g" .env.test' + sh 'composer dump-env test' + sh 'php bin/console doctrine:schema:update --force'; } } @@ -106,6 +108,31 @@ pipeline { } } + stage('Configure') { + parallel { + stage('Frontend') { + steps { + dir(path: 'src/frontend') { + sh 'echo skip' + } + + } + } + + stage('Backend') { + steps { + dir(path: 'src/backend') { + sh 'APP_SECRET=`php8.0 -r "echo md5(\\"branch=${BRANCH_NAME};\\");"` && sed -i "s/APP_SECRET=.*/APP_SECRET=${APP_SECRET}/g" .env' + sh 'sed -i "s/DATABASE_URL=.*/DATABASE_URL=${DatabaseUrl}/g" .env.dev' + sh 'composer dump-env dev' + } + + } + } + + } + } + stage('Build') { parallel { stage('Frontend') { diff --git a/src/backend/.env.test b/src/backend/.env.test index 9e7162f..06142a2 100644 --- a/src/backend/.env.test +++ b/src/backend/.env.test @@ -4,3 +4,4 @@ APP_SECRET='$ecretf0rt3st' SYMFONY_DEPRECATIONS_HELPER=999999 PANTHER_APP_ENV=panther PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots +DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8" diff --git a/src/frontend/src/app/app.component.ts b/src/frontend/src/app/app.component.ts index 446080d..9bbdd01 100644 --- a/src/frontend/src/app/app.component.ts +++ b/src/frontend/src/app/app.component.ts @@ -36,7 +36,7 @@ export class AppComponent { avatar: 'https://www.gravatar.com/avatar/81b206a89f89d5b1123b87606075c6a8?s=514&d=robohash', }; - get isSidebarOpen() { + get isSidebarOpen(): boolean { switch (this.sidebarOpen) { case SidebarOpenEnum.Open: return true; @@ -86,7 +86,7 @@ export class AppComponent { } } - onThemeChanged(theme: string) { + onThemeChanged(theme: string): void { if (theme === undefined) { return; } @@ -95,7 +95,7 @@ export class AppComponent { this.isDark = theme.indexOf('dark') !== -1; } - onResize(size: WindowSize) { + onResize(size: WindowSize): void { if (size === undefined) { return; } @@ -104,7 +104,7 @@ export class AppComponent { this.sidebarMode = this.isMobile ? 'over' : 'side'; } - onLangChanged(lang: string) { + onLangChanged(lang: string): void { if (lang === undefined) { return; } @@ -112,16 +112,16 @@ export class AppComponent { this.langControl.setValue(lang); } - toggleSidebar() { + toggleSidebar(): void { this.sidebarOpen = this.isSidebarOpen ? SidebarOpenEnum.Closed : SidebarOpenEnum.Open; this.browserStorageService.setItem('sidebar.open', this.sidebarOpen); } - onSidebarOpenedChange(opened: boolean) { + onSidebarOpenedChange(opened: boolean): void { this.sidebarOpen = opened ? SidebarOpenEnum.Open : SidebarOpenEnum.Closed; } url(url: string): SafeStyle { return this.sanitizer.bypassSecurityTrustStyle(`url('${url}')`); } -} \ No newline at end of file +} diff --git a/src/frontend/src/app/app.module.ts b/src/frontend/src/app/app.module.ts index 6b83379..aadeb8f 100644 --- a/src/frontend/src/app/app.module.ts +++ b/src/frontend/src/app/app.module.ts @@ -12,7 +12,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { TranslateHttpLoader } from '@ngx-translate/http-loader'; -export function HttpLoaderFactory(http: HttpClient) { +export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader { return new TranslateHttpLoader(http, '/assets/lang/', '.json'); } diff --git a/src/frontend/src/app/modules/shared/services/app/app.service.ts b/src/frontend/src/app/modules/shared/services/app/app.service.ts index 40ae29e..5299e2d 100644 --- a/src/frontend/src/app/modules/shared/services/app/app.service.ts +++ b/src/frontend/src/app/modules/shared/services/app/app.service.ts @@ -13,13 +13,14 @@ export class WindowSize { this.isMobile = this.width <= 700; } - update() { - this.width = window.innerWidth; - this.height = window.innerHeight; + static generate(): WindowSize { + return new WindowSize(window.innerWidth, window.innerHeight); } - static generate() { - return new WindowSize(window.innerWidth, window.innerHeight); + update(): WindowSize { + this.width = window.innerWidth; + this.height = window.innerHeight; + return this; } } @@ -41,29 +42,29 @@ export class AppService { }); this.sizeChange.subscribe(size => this.size = size); this.sizeChange.next(WindowSize.generate()); - let lang = browserStorageService.getItem('language'); - if (!lang) { - lang = this.defaultLang; + let language = browserStorageService.getItem('language'); + if (!language) { + language = this.defaultLang; } this.translate.setDefaultLang(this.defaultLang); - this.changeLang(lang); + this.changeLang(language); fromEvent(window, 'resize').subscribe(e => { this.sizeChange.next(WindowSize.generate()); - }) + }); } - changeLang(lang: string) { + changeLang(lang: string): void { if (lang !== this.lang) { this.translate.use(lang); this.langChange.next(lang); } } - getLang() { + getLang(): string { return this.lang; } - getLangs() { + getLangs(): string[] { return [ 'pl', 'en', diff --git a/src/frontend/src/app/modules/shared/services/browser-storage/browser-storage.service.ts b/src/frontend/src/app/modules/shared/services/browser-storage/browser-storage.service.ts index 5ed4972..fad291e 100644 --- a/src/frontend/src/app/modules/shared/services/browser-storage/browser-storage.service.ts +++ b/src/frontend/src/app/modules/shared/services/browser-storage/browser-storage.service.ts @@ -5,12 +5,13 @@ export class BrowserStorageService { private storage: Storage; private namespace: string; + constructor() { this.storage = localStorage; this.namespace = 'default'; } - setNamespace(namespace: string) { + setNamespace(namespace: string): void { this.namespace = namespace; } @@ -18,7 +19,7 @@ export class BrowserStorageService { return namespace ?? this.namespace; } - setItem(key: string, value: any, namespace: string | null = null) { + setItem(key: string, value: any, namespace: string | null = null): void { namespace = this.getNamespace(namespace); const path = `${namespace}.${key}`; this.storage.setItem(path, JSON.stringify(value)); diff --git a/src/frontend/src/app/modules/shared/services/theme/theme.service.ts b/src/frontend/src/app/modules/shared/services/theme/theme.service.ts index 080d21c..637f7d9 100644 --- a/src/frontend/src/app/modules/shared/services/theme/theme.service.ts +++ b/src/frontend/src/app/modules/shared/services/theme/theme.service.ts @@ -21,11 +21,11 @@ export class ThemeService { this.setTheme(userTheme); } - getTheme() { + getTheme(): string { return this.theme; } - setTheme(theme: string) { + setTheme(theme: string): void { if (theme !== this.theme) { this.themeChange.next(theme); document.getElementById('current-theme').setAttribute('href', `/${theme}.css`); @@ -37,5 +37,5 @@ export class ThemeService { 'light', 'dark', ]; - }; + } } -- 2.39.5 From 53c6780197fb62c199bc5eb1e47d42fbb737c2a7 Mon Sep 17 00:00:00 2001 From: Sieciech Date: Tue, 27 Jul 2021 16:19:35 +0200 Subject: [PATCH 05/16] change php version to 8.0 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e792a8a..787498f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -76,7 +76,7 @@ pipeline { sh 'APP_SECRET=`php8.0 -r "echo md5(\\"branch=${BRANCH_NAME};\\");"` && sed -i "s/APP_SECRET=.*/APP_SECRET=${APP_SECRET}/g" .env' sh 'sed -i "s/DATABASE_URL=.*/DATABASE_URL=${DatabaseUrlTesting}/g" .env.test' sh 'composer dump-env test' - sh 'php bin/console doctrine:schema:update --force'; + sh 'php8.0 bin/console doctrine:schema:update --force'; } } -- 2.39.5 From 9e1c7e687070856428fa5f30ba236d0b8ef2db0f Mon Sep 17 00:00:00 2001 From: Sieciech Date: Tue, 27 Jul 2021 16:50:17 +0200 Subject: [PATCH 06/16] fix syntax --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 787498f..3edc578 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -74,7 +74,7 @@ pipeline { steps { dir(path: 'src/backend') { sh 'APP_SECRET=`php8.0 -r "echo md5(\\"branch=${BRANCH_NAME};\\");"` && sed -i "s/APP_SECRET=.*/APP_SECRET=${APP_SECRET}/g" .env' - sh 'sed -i "s/DATABASE_URL=.*/DATABASE_URL=${DatabaseUrlTesting}/g" .env.test' + sh '''sed -i 's/DATABASE_URL=.*/DATABASE_URL=${DatabaseUrlTesting}/g' .env.test''' sh 'composer dump-env test' sh 'php8.0 bin/console doctrine:schema:update --force'; } -- 2.39.5 From 4ce25f5a61388899879ec11bba19611eca50886d Mon Sep 17 00:00:00 2001 From: Sieciech Date: Tue, 27 Jul 2021 17:24:02 +0200 Subject: [PATCH 07/16] change database --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3edc578..cdcc05c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,7 @@ pipeline { environment { DatabaseUrl = sh(returnStdout: true, script: 'bash /var/lib/jenkins/variables/CureNet/var.sh ${BRANCH_NAME} DatabaseUrl').trim() - DatabaseUrlTesting = sh(returnStdout: true, script: 'bash /var/lib/jenkins/variables/CureNet/var.sh test DatabaseUrl').trim() + DatabaseUrlTesting = sh(returnStdout: true, script: 'bash /var/lib/jenkins/variables/CureNet/var.sh master DatabaseUrl').trim() } stages { -- 2.39.5 From 5f9789c437e2193734e51d11e067b2f36a1874f6 Mon Sep 17 00:00:00 2001 From: Sieciech Date: Tue, 27 Jul 2021 17:43:14 +0200 Subject: [PATCH 08/16] prepare for deploy --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index cdcc05c..4073916 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -159,10 +159,11 @@ pipeline { stage('Deploy') { when { anyOf { - branch 'prod' + branch 'master' branch 'staging' branch 'beta' branch 'dev' + branch '4-pipeline' } } -- 2.39.5 From 4a26262bacddae3dbcd0a3a24481472c4beaa1e6 Mon Sep 17 00:00:00 2001 From: Sieciech Date: Tue, 27 Jul 2021 18:15:01 +0200 Subject: [PATCH 09/16] deply backend fix --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4073916..ca90464 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -185,7 +185,7 @@ pipeline { dir(path: 'src/backend') { sh 'ssh web@fufle.net touch /web/fufle.net/curenet/dev/backend/REMOVEME' sh 'ssh web@fufle.net rm -rf /web/fufle.net/curenet/dev/backend/*' - sh 'scp -r ./ web@fufle.net:/web/fufle.net/curenet/dev/backend/' + sh 'scp -r ./* web@fufle.net:/web/fufle.net/curenet/dev/backend/' } } -- 2.39.5 From 90d5de728db4e2a7a0a7915c75a0b2ab25dcc39d Mon Sep 17 00:00:00 2001 From: Sieciech Date: Tue, 27 Jul 2021 19:46:13 +0200 Subject: [PATCH 10/16] move path to variables --- Jenkinsfile | 13 +- src/frontend/src/app/app-routing.module.ts | 183 +++++++++++---------- src/frontend/src/assets/lang/en.json | 2 + src/frontend/src/assets/lang/pl.json | 2 + 4 files changed, 108 insertions(+), 92 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ca90464..93784b8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,6 +3,7 @@ pipeline { environment { DatabaseUrl = sh(returnStdout: true, script: 'bash /var/lib/jenkins/variables/CureNet/var.sh ${BRANCH_NAME} DatabaseUrl').trim() + ProjectPath = sh(returnStdout: true, script: 'bash /var/lib/jenkins/variables/CureNet/var.sh ${BRANCH_NAME} ProjectPath').trim() DatabaseUrlTesting = sh(returnStdout: true, script: 'bash /var/lib/jenkins/variables/CureNet/var.sh master DatabaseUrl').trim() } @@ -172,9 +173,9 @@ pipeline { stage('Frontend') { steps { dir(path: 'src/frontend') { - sh 'ssh web@fufle.net touch /web/fufle.net/curenet/dev/frontend/REMOVEME' - sh 'ssh web@fufle.net rm -rf /web/fufle.net/curenet/dev/frontend/*' - sh 'scp -r dist/* web@fufle.net:/web/fufle.net/curenet/dev/frontend/' + sh 'ssh web@fufle.net touch ${ProjectPath}/frontend/REMOVEME' + sh 'ssh web@fufle.net rm -rf ${ProjectPath}/frontend/*' + sh 'scp -r dist/* web@fufle.net:${ProjectPath}/frontend/' } } @@ -183,9 +184,9 @@ pipeline { stage('Backend') { steps { dir(path: 'src/backend') { - sh 'ssh web@fufle.net touch /web/fufle.net/curenet/dev/backend/REMOVEME' - sh 'ssh web@fufle.net rm -rf /web/fufle.net/curenet/dev/backend/*' - sh 'scp -r ./* web@fufle.net:/web/fufle.net/curenet/dev/backend/' + sh 'ssh web@fufle.net touch ${ProjectPath}/backend/REMOVEME' + sh 'ssh web@fufle.net rm -rf ${ProjectPath}/backend/*' + sh 'scp -r ./* web@fufle.net:${ProjectPath}/backend/' } } diff --git a/src/frontend/src/app/app-routing.module.ts b/src/frontend/src/app/app-routing.module.ts index 8458c35..a221c4b 100644 --- a/src/frontend/src/app/app-routing.module.ts +++ b/src/frontend/src/app/app-routing.module.ts @@ -3,100 +3,111 @@ import { Route, RouterModule } from '@angular/router'; import { NotFoundComponent } from './modules/shared/components/not-found/not-found.component'; interface AppMenuEntry { - label: string; - icon: string; - path?: string; - matchExact?: boolean; - level?: number; + label: string; + icon: string; + path?: string; + matchExact?: boolean; + level?: number; } interface AppRoute extends Route { - menuEntries?: AppMenuEntry[]; + menuEntries?: AppMenuEntry[]; } export const appRoutes: AppRoute[] = [ - { - path: '', - component: NotFoundComponent, - menuEntries: [ - { - label: 'MENU.HOME', - icon: 'fa fa-home', - matchExact: true, - }, - ], - }, - { - path: 'profile', - component: NotFoundComponent, - menuEntries: [ - { - label: 'MENU.PROFILE', - icon: 'fa fa-user', - }, - ], - }, - { - path: 'community', - component: NotFoundComponent, - menuEntries: [ - { - label: 'MENU.COMMUNITY', - icon: 'fa fa-users', - }, - ], - }, - { - path: 'messages', - component: NotFoundComponent, - menuEntries: [ - { - label: 'MENU.MESSAGES', - icon: 'fa fa-comments', - }, - ], - }, - { - path: 'tests', - component: NotFoundComponent, - menuEntries: [ - { - label: 'MENU.TESTS', - icon: 'fa fa-heartbeat', - }, - ], - }, - { - path: 'research', - component: NotFoundComponent, - menuEntries: [ - { - label: 'MENU.RESEARCH', - icon: 'fa fa-flask', - }, - ], - }, - { - path: 'admin', - loadChildren: () => import('./modules/admin/admin.module').then(m => m.AdminModule), - menuEntries: [ - { - label: 'MENU.ADMIN', - icon: 'fa fa-id-card', - matchExact: true, - }, - { - path: 'admin/users', - label: 'MENU.USERS', - icon: 'fa fa-users', - level: 1, - } - ], - }, + { + path: '', + component: NotFoundComponent, + menuEntries: [ + { + label: 'MENU.HOME', + icon: 'fa fa-home', + matchExact: true, + }, + ], + }, + { + path: 'profile', + component: NotFoundComponent, + menuEntries: [ + { + label: 'MENU.PROFILE', + icon: 'fa fa-user', + }, + ], + }, + { + path: 'community', + component: NotFoundComponent, + menuEntries: [ + { + label: 'MENU.COMMUNITY', + icon: 'fa fa-users', + }, + ], + }, + { + path: 'questions', + component: NotFoundComponent, + menuEntries: [ + { + label: 'MENU.QUESTIONS', + icon: 'fa fa-question', + level: 1, + } + ], + }, + { + path: 'messages', + component: NotFoundComponent, + menuEntries: [ + { + label: 'MENU.MESSAGES', + icon: 'fa fa-comments', + }, + ], + }, + { + path: 'tests', + component: NotFoundComponent, + menuEntries: [ + { + label: 'MENU.TESTS', + icon: 'fa fa-heartbeat', + }, + ], + }, + { + path: 'research', + component: NotFoundComponent, + menuEntries: [ + { + label: 'MENU.RESEARCH', + icon: 'fa fa-flask', + }, + ], + }, + { + path: 'admin', + loadChildren: () => import('./modules/admin/admin.module').then(m => m.AdminModule), + menuEntries: [ + { + label: 'MENU.ADMIN', + icon: 'fa fa-id-card', + matchExact: true, + }, + { + path: 'admin/users', + label: 'MENU.USERS', + icon: 'fa fa-users', + level: 1, + } + ], + }, ]; @NgModule({ - imports: [RouterModule.forRoot(appRoutes)], - exports: [RouterModule] + imports: [RouterModule.forRoot(appRoutes)], + exports: [RouterModule] }) export class AppRoutingModule { } diff --git a/src/frontend/src/assets/lang/en.json b/src/frontend/src/assets/lang/en.json index 58dc61a..cb83b1b 100644 --- a/src/frontend/src/assets/lang/en.json +++ b/src/frontend/src/assets/lang/en.json @@ -19,7 +19,9 @@ "HOME": "Dashboard", "PROFILE": "Profile", "COMMUNITY": "Community", + "GROUP": "My group", "MESSAGES": "Messages", + "QUESTIONS": "Q&A", "TESTS": "Laboratory tests", "RESEARCH": "Research", "ADMIN": "Admin", diff --git a/src/frontend/src/assets/lang/pl.json b/src/frontend/src/assets/lang/pl.json index 6855253..64b3e9c 100644 --- a/src/frontend/src/assets/lang/pl.json +++ b/src/frontend/src/assets/lang/pl.json @@ -19,7 +19,9 @@ "HOME": "Kokpit", "PROFILE": "Profil", "COMMUNITY": "Społeczność", + "GROUP": "Moja grupa", "MESSAGES": "Wiadomości", + "QUESTIONS": "Pytania i odpowiedzi", "TESTS": "Wyniki badań", "RESEARCH": "Badania naukowe", "ADMIN": "Panel administratora", -- 2.39.5 From d5b0a740b4ef879557267008489d2793f327ae26 Mon Sep 17 00:00:00 2001 From: Sieciech Date: Tue, 27 Jul 2021 22:16:04 +0200 Subject: [PATCH 11/16] update branches for deploy --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 93784b8..cc4c675 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -164,7 +164,6 @@ pipeline { branch 'staging' branch 'beta' branch 'dev' - branch '4-pipeline' } } -- 2.39.5 From eafce0a52ec89b3df0ce0f9c0aec257a5ca92bcd Mon Sep 17 00:00:00 2001 From: Sieciech Date: Wed, 28 Jul 2021 10:59:43 +0200 Subject: [PATCH 12/16] fix composer path --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 93784b8..89f3d84 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,7 +51,7 @@ pipeline { stage('Backend') { steps { dir(path: 'src/backend') { - sh 'php8.0 /bin/composer install' + sh 'php8.0 /usr/local/bin/composer install' } } -- 2.39.5 From 96a4ec0e8f68f0a07a477f749e53026681d3413c Mon Sep 17 00:00:00 2001 From: Sieciech Date: Wed, 28 Jul 2021 11:09:58 +0200 Subject: [PATCH 13/16] fix composer path --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index a3fdaa6..c243783 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -76,7 +76,7 @@ pipeline { dir(path: 'src/backend') { sh 'APP_SECRET=`php8.0 -r "echo md5(\\"branch=${BRANCH_NAME};\\");"` && sed -i "s/APP_SECRET=.*/APP_SECRET=${APP_SECRET}/g" .env' sh '''sed -i 's/DATABASE_URL=.*/DATABASE_URL=${DatabaseUrlTesting}/g' .env.test''' - sh 'composer dump-env test' + sh 'php8.0 /usr/local/bin/composer dump-env test' sh 'php8.0 bin/console doctrine:schema:update --force'; } -- 2.39.5 From 3466d86c6a2a365936330c9dd705e0bbd32fac28 Mon Sep 17 00:00:00 2001 From: Sieciech Date: Wed, 28 Jul 2021 14:18:36 +0200 Subject: [PATCH 14/16] fix all composer paths --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c243783..7ee7f51 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -125,7 +125,7 @@ pipeline { dir(path: 'src/backend') { sh 'APP_SECRET=`php8.0 -r "echo md5(\\"branch=${BRANCH_NAME};\\");"` && sed -i "s/APP_SECRET=.*/APP_SECRET=${APP_SECRET}/g" .env' sh 'sed -i "s/DATABASE_URL=.*/DATABASE_URL=${DatabaseUrl}/g" .env.dev' - sh 'composer dump-env dev' + sh 'p8.0 /usr/local/bin/composer dump-env dev' } } -- 2.39.5 From 1eb675fb1f7570e5450bc123f552fcca6d63c75c Mon Sep 17 00:00:00 2001 From: Sieciech Date: Wed, 28 Jul 2021 14:27:09 +0200 Subject: [PATCH 15/16] fix pipeline --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7ee7f51..b5beda5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -125,7 +125,7 @@ pipeline { dir(path: 'src/backend') { sh 'APP_SECRET=`php8.0 -r "echo md5(\\"branch=${BRANCH_NAME};\\");"` && sed -i "s/APP_SECRET=.*/APP_SECRET=${APP_SECRET}/g" .env' sh 'sed -i "s/DATABASE_URL=.*/DATABASE_URL=${DatabaseUrl}/g" .env.dev' - sh 'p8.0 /usr/local/bin/composer dump-env dev' + sh 'php8.0 /usr/local/bin/composer dump-env dev' } } -- 2.39.5 From dd2defd11ddac8387198b25c2ba5761c1b698b8b Mon Sep 17 00:00:00 2001 From: Sieciech Date: Wed, 28 Jul 2021 16:59:21 +0200 Subject: [PATCH 16/16] fix pipeline --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b5beda5..682202f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -124,7 +124,7 @@ pipeline { steps { dir(path: 'src/backend') { sh 'APP_SECRET=`php8.0 -r "echo md5(\\"branch=${BRANCH_NAME};\\");"` && sed -i "s/APP_SECRET=.*/APP_SECRET=${APP_SECRET}/g" .env' - sh 'sed -i "s/DATABASE_URL=.*/DATABASE_URL=${DatabaseUrl}/g" .env.dev' + sh '''sed -i 's/DATABASE_URL=.*/DATABASE_URL=${DatabaseUrl}/g' .env.dev''' sh 'php8.0 /usr/local/bin/composer dump-env dev' } -- 2.39.5