From 9e951916a6bc8b149ff0dc6196682dda3236d0be Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 13 Sep 2023 20:50:20 +0200 Subject: [PATCH 01/11] [wip] add volume for the build --- .woodpecker.yml | 134 ++++++++++++++++++++++++++---------------------- 1 file changed, 72 insertions(+), 62 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 8aa8e54..c3f993e 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,73 +1,84 @@ variables: - &volumes - node16_cache:/root/.npm + - node16_cache:/root/.npm + - /data/deblan/deblan.io-murph:/data/deblan/deblan.io-murph pipeline: - db-wait: - image: gitnet.fr/deblan/timeout:latest - commands: - - /bin/timeout -t 30 -v -c 'while true; do nc -z -v db 3306 2>&1 | grep succeeded && exit 0; sleep 0.5; done' + # db-wait: + # image: gitnet.fr/deblan/timeout:latest + # commands: + # - /bin/timeout -t 30 -v -c 'while true; do nc -z -v db 3306 2>&1 | grep succeeded && exit 0; sleep 0.5; done' + # + # db-create: + # image: mariadb:10.3 + # secrets: [mysqldump] + # commands: + # - mysql -hdb -uroot -proot -e "CREATE DATABASE app" + # - eval "$MYSQLDUMP" | mysql -hdb -uroot -proot app + # when: + # branch: [master, master-*, develop, develop-*] + # + # app-config: + # image: deblan/php:8.1 + # commands: + # - echo APP_ENV=prod >> .env.local + # - echo APP_SECRET=$(openssl rand -hex 32) >> .env.local + # - echo DATABASE_URL=mysql://root:root@db/app >> .env.local + # when: + # branch: [master, master-*, develop, develop-*] + # + # php-composer: + # image: deblan/php:8.1 + # commands: + # - apt-get update && apt-get -y install git + # - composer install --no-scripts + # + # db-migrate: + # image: deblan/php:8.1 + # environment: + # - PHP=php + # commands: + # - ./bin/doctrine-migrate + # when: + # branch: [master, master-*, develop, develop-*, feature/*] + # + # app-jsroutes: + # image: deblan/php:8.1 + # commands: + # - php bin/console fos:js-routing:dump --format=json --target=public/js/fos_js_routes.json + # when: + # branch: [master, master-*, develop, develop-*, feature/*] + # + # node-build: + # image: node:16-alpine + # environment: + # - CPU_COUNT=3 + # volumes: *volumes + # commands: + # - apk add --no-cache git + # - npm install -g svg2ttf ttf2eot ttf2woff2 + # - svg2ttf assets/fonts/deblan/src/deblan-icon.svg assets/fonts/deblan/deblan-icon.ttf + # - cat assets/fonts/deblan/deblan-icon.ttf | ttf2woff2 > assets/fonts/deblan/deblan-icon.woff2 + # - ttf2eot assets/fonts/deblan/deblan-icon.ttf assets/fonts/deblan/deblan-icon.eot + # - yarn + # - test -f public/js/fos_js_routes.json || echo "{}" > public/js/fos_js_routes.json + # - npm run build + # + # security-check: + # image: gitnet.fr/deblan/osv-detector:v0.9 + # commands: + # - osv-detector composer.lock yarn.lock + # failure: ignore - db-create: - image: mariadb:10.3 - secrets: [mysqldump] - commands: - - mysql -hdb -uroot -proot -e "CREATE DATABASE app" - - eval "$MYSQLDUMP" | mysql -hdb -uroot -proot app - when: - branch: [master, master-*, develop, develop-*] - - app-config: + build_cache: image: deblan/php:8.1 - commands: - - echo APP_ENV=prod >> .env.local - - echo APP_SECRET=$(openssl rand -hex 32) >> .env.local - - echo DATABASE_URL=mysql://root:root@db/app >> .env.local - when: - branch: [master, master-*, develop, develop-*] - - php-composer: - image: deblan/php:8.1 - commands: - - apt-get update && apt-get -y install git - - composer install --no-scripts - - db-migrate: - image: deblan/php:8.1 - environment: - - PHP=php - commands: - - ./bin/doctrine-migrate - when: - branch: [master, master-*, develop, develop-*, feature/*] - - app-jsroutes: - image: deblan/php:8.1 - commands: - - php bin/console fos:js-routing:dump --format=json --target=public/js/fos_js_routes.json - when: - branch: [master, master-*, develop, develop-*, feature/*] - - node-build: - image: node:16-alpine - environment: - - CPU_COUNT=3 volumes: *volumes commands: - - apk add --no-cache git - - npm install -g svg2ttf ttf2eot ttf2woff2 - - svg2ttf assets/fonts/deblan/src/deblan-icon.svg assets/fonts/deblan/deblan-icon.ttf - - cat assets/fonts/deblan/deblan-icon.ttf | ttf2woff2 > assets/fonts/deblan/deblan-icon.woff2 - - ttf2eot assets/fonts/deblan/deblan-icon.ttf assets/fonts/deblan/deblan-icon.eot - - yarn - - test -f public/js/fos_js_routes.json || echo "{}" > public/js/fos_js_routes.json - - npm run build - - security-check: - image: gitnet.fr/deblan/osv-detector:v0.9 - commands: - - osv-detector composer.lock yarn.lock - failure: ignore + - cd /data/deblan/deblan.io-murph/ + - mv "$CI_WORKSPACE" "$CI_COMMIT_SHA" + when: + branch: [master, master-*, develop, develop-*, feature/*] app-deploy: image: deblan/php:8.1 @@ -95,4 +106,3 @@ services: volumes: node16_cache: - temp: {} From 4bb2cc557f7579415c8ddfe38703f6ab63d2341b Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 13 Sep 2023 20:51:41 +0200 Subject: [PATCH 02/11] [wip] tests --- .woodpecker.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index c3f993e..dca32a8 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -19,14 +19,14 @@ pipeline: # when: # branch: [master, master-*, develop, develop-*] # - # app-config: - # image: deblan/php:8.1 - # commands: - # - echo APP_ENV=prod >> .env.local - # - echo APP_SECRET=$(openssl rand -hex 32) >> .env.local - # - echo DATABASE_URL=mysql://root:root@db/app >> .env.local - # when: - # branch: [master, master-*, develop, develop-*] + app-config: + image: deblan/php:8.1 + commands: + - echo APP_ENV=prod >> .env.local + - echo APP_SECRET=$(openssl rand -hex 32) >> .env.local + - echo DATABASE_URL=mysql://root:root@db/app >> .env.local + when: + branch: [master, master-*, develop, develop-*] # # php-composer: # image: deblan/php:8.1 From d8f397986191be9b5eadd5dfe975fb3fe476ff67 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 13 Sep 2023 20:53:15 +0200 Subject: [PATCH 03/11] [wip] tests --- .woodpecker.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index dca32a8..587ac71 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -25,8 +25,6 @@ pipeline: - echo APP_ENV=prod >> .env.local - echo APP_SECRET=$(openssl rand -hex 32) >> .env.local - echo DATABASE_URL=mysql://root:root@db/app >> .env.local - when: - branch: [master, master-*, develop, develop-*] # # php-composer: # image: deblan/php:8.1 From 40670b6bfc1af2329abaee93cdfcf3ec7ed95511 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 13 Sep 2023 20:55:40 +0200 Subject: [PATCH 04/11] [wip] tests --- .woodpecker.yml | 117 +++++++++++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 57 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 587ac71..f5f5e5f 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -5,69 +5,71 @@ variables: - /data/deblan/deblan.io-murph:/data/deblan/deblan.io-murph pipeline: - # db-wait: - # image: gitnet.fr/deblan/timeout:latest - # commands: - # - /bin/timeout -t 30 -v -c 'while true; do nc -z -v db 3306 2>&1 | grep succeeded && exit 0; sleep 0.5; done' - # - # db-create: - # image: mariadb:10.3 - # secrets: [mysqldump] - # commands: - # - mysql -hdb -uroot -proot -e "CREATE DATABASE app" - # - eval "$MYSQLDUMP" | mysql -hdb -uroot -proot app - # when: - # branch: [master, master-*, develop, develop-*] - # + db-wait: + image: gitnet.fr/deblan/timeout:latest + commands: + - /bin/timeout -t 30 -v -c 'while true; do nc -z -v db 3306 2>&1 | grep succeeded && exit 0; sleep 0.5; done' + + db-create: + image: mariadb:10.3 + secrets: [mysqldump] + commands: + - mysql -hdb -uroot -proot -e "CREATE DATABASE app" + - eval "$MYSQLDUMP" | mysql -hdb -uroot -proot app + when: + branch: [master, master-*, develop, develop-*] + app-config: image: deblan/php:8.1 commands: - echo APP_ENV=prod >> .env.local - echo APP_SECRET=$(openssl rand -hex 32) >> .env.local - echo DATABASE_URL=mysql://root:root@db/app >> .env.local - # - # php-composer: - # image: deblan/php:8.1 - # commands: - # - apt-get update && apt-get -y install git - # - composer install --no-scripts - # - # db-migrate: - # image: deblan/php:8.1 - # environment: - # - PHP=php - # commands: - # - ./bin/doctrine-migrate - # when: - # branch: [master, master-*, develop, develop-*, feature/*] - # - # app-jsroutes: - # image: deblan/php:8.1 - # commands: - # - php bin/console fos:js-routing:dump --format=json --target=public/js/fos_js_routes.json - # when: - # branch: [master, master-*, develop, develop-*, feature/*] - # - # node-build: - # image: node:16-alpine - # environment: - # - CPU_COUNT=3 - # volumes: *volumes - # commands: - # - apk add --no-cache git - # - npm install -g svg2ttf ttf2eot ttf2woff2 - # - svg2ttf assets/fonts/deblan/src/deblan-icon.svg assets/fonts/deblan/deblan-icon.ttf - # - cat assets/fonts/deblan/deblan-icon.ttf | ttf2woff2 > assets/fonts/deblan/deblan-icon.woff2 - # - ttf2eot assets/fonts/deblan/deblan-icon.ttf assets/fonts/deblan/deblan-icon.eot - # - yarn - # - test -f public/js/fos_js_routes.json || echo "{}" > public/js/fos_js_routes.json - # - npm run build - # - # security-check: - # image: gitnet.fr/deblan/osv-detector:v0.9 - # commands: - # - osv-detector composer.lock yarn.lock - # failure: ignore + when: + branch: [master, master-*, develop, develop-*, feature/*] + + php-composer: + image: deblan/php:8.1 + commands: + - apt-get update && apt-get -y install git + - composer install --no-scripts + + db-migrate: + image: deblan/php:8.1 + environment: + - PHP=php + commands: + - ./bin/doctrine-migrate + when: + branch: [master, master-*, develop, develop-*, feature/*] + + app-jsroutes: + image: deblan/php:8.1 + commands: + - php bin/console fos:js-routing:dump --format=json --target=public/js/fos_js_routes.json + when: + branch: [master, master-*, develop, develop-*, feature/*] + + node-build: + image: node:16-alpine + environment: + - CPU_COUNT=3 + volumes: *volumes + commands: + - apk add --no-cache git + - npm install -g svg2ttf ttf2eot ttf2woff2 + - svg2ttf assets/fonts/deblan/src/deblan-icon.svg assets/fonts/deblan/deblan-icon.ttf + - cat assets/fonts/deblan/deblan-icon.ttf | ttf2woff2 > assets/fonts/deblan/deblan-icon.woff2 + - ttf2eot assets/fonts/deblan/deblan-icon.ttf assets/fonts/deblan/deblan-icon.eot + - yarn + - test -f public/js/fos_js_routes.json || echo "{}" > public/js/fos_js_routes.json + - npm run build + + security-check: + image: gitnet.fr/deblan/osv-detector:v0.9 + commands: + - osv-detector composer.lock yarn.lock + failure: ignore build_cache: image: deblan/php:8.1 @@ -83,6 +85,7 @@ pipeline: secrets: [ssh_user, ssh_host, ssh_priv_key, app_directory] commands: - apt-get update && apt-get -y install rsync openssh-client + - cd "/data/deblan/deblan.io-murph/$CI_WORKSPACE" - mkdir "$HOME/.ssh" - echo "$SSH_PRIV_KEY" > "$HOME/.ssh/id_ed25519" - chmod 700 "$HOME/.ssh" From ed8319f727284ad73f2b904c2e981695a2f2e2b9 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 13 Sep 2023 20:57:58 +0200 Subject: [PATCH 05/11] [wip] tests --- .woodpecker.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index f5f5e5f..6cd66ec 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -17,7 +17,7 @@ pipeline: - mysql -hdb -uroot -proot -e "CREATE DATABASE app" - eval "$MYSQLDUMP" | mysql -hdb -uroot -proot app when: - branch: [master, master-*, develop, develop-*] + branch: [master, master-*, develop, develop-*, feature/*] app-config: image: deblan/php:8.1 @@ -64,12 +64,16 @@ pipeline: - yarn - test -f public/js/fos_js_routes.json || echo "{}" > public/js/fos_js_routes.json - npm run build + when: + branch: [master, master-*, develop, develop-*, feature/*] security-check: image: gitnet.fr/deblan/osv-detector:v0.9 commands: - osv-detector composer.lock yarn.lock failure: ignore + when: + branch: [master, master-*, develop, develop-*, feature/*] build_cache: image: deblan/php:8.1 From e70764e63dff2553adb816c131f1d47f8e0af3d3 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 13 Sep 2023 21:10:18 +0200 Subject: [PATCH 06/11] [wip] events --- .woodpecker.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 6cd66ec..b36a9fc 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -9,6 +9,9 @@ pipeline: image: gitnet.fr/deblan/timeout:latest commands: - /bin/timeout -t 30 -v -c 'while true; do nc -z -v db 3306 2>&1 | grep succeeded && exit 0; sleep 0.5; done' + when: + event: [push, pull_request, tag, manual] + branch: [master, master-*, develop, develop-*, feature/*] db-create: image: mariadb:10.3 @@ -17,6 +20,7 @@ pipeline: - mysql -hdb -uroot -proot -e "CREATE DATABASE app" - eval "$MYSQLDUMP" | mysql -hdb -uroot -proot app when: + event: [push, pull_request, tag, manual] branch: [master, master-*, develop, develop-*, feature/*] app-config: @@ -26,6 +30,7 @@ pipeline: - echo APP_SECRET=$(openssl rand -hex 32) >> .env.local - echo DATABASE_URL=mysql://root:root@db/app >> .env.local when: + event: [push, pull_request, tag, manual] branch: [master, master-*, develop, develop-*, feature/*] php-composer: @@ -33,6 +38,8 @@ pipeline: commands: - apt-get update && apt-get -y install git - composer install --no-scripts + event: [push, pull_request, tag, manual] + branch: [master, master-*, develop, develop-*, feature/*] db-migrate: image: deblan/php:8.1 @@ -41,6 +48,7 @@ pipeline: commands: - ./bin/doctrine-migrate when: + event: [push, pull_request, tag, manual] branch: [master, master-*, develop, develop-*, feature/*] app-jsroutes: @@ -48,6 +56,7 @@ pipeline: commands: - php bin/console fos:js-routing:dump --format=json --target=public/js/fos_js_routes.json when: + event: [push, pull_request, tag, manual] branch: [master, master-*, develop, develop-*, feature/*] node-build: @@ -65,6 +74,7 @@ pipeline: - test -f public/js/fos_js_routes.json || echo "{}" > public/js/fos_js_routes.json - npm run build when: + event: [push, pull_request, tag, manual] branch: [master, master-*, develop, develop-*, feature/*] security-check: @@ -73,15 +83,17 @@ pipeline: - osv-detector composer.lock yarn.lock failure: ignore when: + event: [push, pull_request, tag, manual] branch: [master, master-*, develop, develop-*, feature/*] - build_cache: + cache-build: image: deblan/php:8.1 volumes: *volumes commands: - cd /data/deblan/deblan.io-murph/ - mv "$CI_WORKSPACE" "$CI_COMMIT_SHA" when: + event: [push, pull_request, tag, manual] branch: [master, master-*, develop, develop-*, feature/*] app-deploy: @@ -103,6 +115,16 @@ pipeline: when: event: [deployment] + cache-clean: + image: deblan/php:8.1 + volumes: *volumes + commands: + - cd /data/deblan/deblan.io-murph/ + - rm * -frv + when: + event: cron + cron: cache-clean + services: db: image: mariadb:10.3 From 35fb777eaafea59045abf7a185022f23a25300bb Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 13 Sep 2023 21:10:50 +0200 Subject: [PATCH 07/11] [wip] events --- .woodpecker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker.yml b/.woodpecker.yml index b36a9fc..6b7d3af 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -38,6 +38,7 @@ pipeline: commands: - apt-get update && apt-get -y install git - composer install --no-scripts + when: event: [push, pull_request, tag, manual] branch: [master, master-*, develop, develop-*, feature/*] From dbbe5d1db54895f4e13f7243b1ab33328ea850d9 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 13 Sep 2023 21:12:13 +0200 Subject: [PATCH 08/11] [wip] tasks --- .woodpecker.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 6b7d3af..62f036c 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -120,8 +120,7 @@ pipeline: image: deblan/php:8.1 volumes: *volumes commands: - - cd /data/deblan/deblan.io-murph/ - - rm * -frv + - rm /data/deblan/deblan.io-murph/* -frv when: event: cron cron: cache-clean From b60a1acd57d09d0993287c607516ecfa7341bee4 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 13 Sep 2023 21:18:22 +0200 Subject: [PATCH 09/11] [wip] deploy task --- .woodpecker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 62f036c..69bb61b 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -102,7 +102,7 @@ pipeline: secrets: [ssh_user, ssh_host, ssh_priv_key, app_directory] commands: - apt-get update && apt-get -y install rsync openssh-client - - cd "/data/deblan/deblan.io-murph/$CI_WORKSPACE" + - cd "/data/deblan/deblan.io-murph/$CI_COMMIT_SHA" - mkdir "$HOME/.ssh" - echo "$SSH_PRIV_KEY" > "$HOME/.ssh/id_ed25519" - chmod 700 "$HOME/.ssh" From eec59acc290df1102d39217804811a5e19a36b17 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 13 Sep 2023 21:25:20 +0200 Subject: [PATCH 10/11] [wip] deploy task --- .woodpecker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker.yml b/.woodpecker.yml index 69bb61b..0100b25 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -100,6 +100,7 @@ pipeline: app-deploy: image: deblan/php:8.1 secrets: [ssh_user, ssh_host, ssh_priv_key, app_directory] + volumes: *volumes commands: - apt-get update && apt-get -y install rsync openssh-client - cd "/data/deblan/deblan.io-murph/$CI_COMMIT_SHA" From 86701a5578d98dd898ddc3eb0ee2e40de0f60687 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 13 Sep 2023 23:04:35 +0200 Subject: [PATCH 11/11] remove cache-clean step --- .woodpecker.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 0100b25..09ee63b 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -117,15 +117,6 @@ pipeline: when: event: [deployment] - cache-clean: - image: deblan/php:8.1 - volumes: *volumes - commands: - - rm /data/deblan/deblan.io-murph/* -frv - when: - event: cron - cron: cache-clean - services: db: image: mariadb:10.3