From 5eade026c1ee4f30b1137d2e4d027d6243e400fa Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 2 May 2023 17:00:35 +0200 Subject: [PATCH 1/8] move mariadb test jobs to separate workflow file --- .github/file-filters.yml | 3 +++ .github/workflows/test.yml | 26 ----------------------- .github/workflows/test_mariadb.yml | 33 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/test_mariadb.yml diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 6690cdb9d..02ea2709e 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -42,5 +42,8 @@ federation: &federation frontend: &frontend - 'frontend/**/*' +mariadb: &mariadb + - 'mariadb/**/*' + nginx: &nginx - 'nginx/**/*' \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0fcedb4ce..d2e83d8e9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,32 +55,6 @@ jobs: name: docker-database-test_up path: /tmp/database_up.tar - ############################################################################## - # JOB: DOCKER BUILD TEST MARIADB ############################################# - ############################################################################## - build_test_mariadb: - name: Docker Build Test - MariaDB - runs-on: ubuntu-latest - #needs: [nothing] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # BUILD MARIADB DOCKER IMAGE ############################################# - ########################################################################## - - name: mariadb | Build `test` image - run: | - docker build --target mariadb_server -t "gradido/mariadb:test" -f ./mariadb/Dockerfile ./ - docker save "gradido/mariadb:test" > /tmp/mariadb.tar - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - name: docker-mariadb-test - path: /tmp/mariadb.tar - ############################################################################## # JOB: LINT BACKEND ########################################################## ############################################################################## diff --git a/.github/workflows/test_mariadb.yml b/.github/workflows/test_mariadb.yml new file mode 100644 index 000000000..ea260e5db --- /dev/null +++ b/.github/workflows/test_mariadb.yml @@ -0,0 +1,33 @@ +name: Gradido MariaDB Test CI + +on: push + +jobs: + files-changed: + name: Detect File Changes - MariaDB + runs-on: ubuntu-latest + outputs: + docker-compose: ${{ steps.changes.outputs.docker-compose }} + mariadb: ${{ steps.changes.outputs.mariadb }} + steps: + - uses: actions/checkout@v3.3.0 + + - name: Check for frontend file changes + uses: dorny/paths-filter@v2.11.1 + id: changes + with: + token: ${{ github.token }} + filters: .github/file-filters.yml + list-files: shell + + build_test: + if: needs.files-changed.outputs.mariadb == 'true' + name: Docker Build Test - MariaDB + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: MariaDB | Build 'test' image + run: | + docker build --target mariadb_server -t "gradido/mariadb:test" -f ./mariadb/Dockerfile ./ From 583b2f5d8f3be067e7e2674904359c886e0a8ba0 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 2 May 2023 17:00:35 +0200 Subject: [PATCH 2/8] move mariadb test jobs to separate workflow file --- .github/workflows/test_mariadb.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test_mariadb.yml b/.github/workflows/test_mariadb.yml index ea260e5db..585ede680 100644 --- a/.github/workflows/test_mariadb.yml +++ b/.github/workflows/test_mariadb.yml @@ -7,7 +7,6 @@ jobs: name: Detect File Changes - MariaDB runs-on: ubuntu-latest outputs: - docker-compose: ${{ steps.changes.outputs.docker-compose }} mariadb: ${{ steps.changes.outputs.mariadb }} steps: - uses: actions/checkout@v3.3.0 From 5c7a0df7ff3caf08cb45736c46682bcf98479f85 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 2 May 2023 17:00:35 +0200 Subject: [PATCH 3/8] move mariadb test jobs to separate workflow file --- .github/workflows/test_mariadb.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test_mariadb.yml b/.github/workflows/test_mariadb.yml index 585ede680..925884cf5 100644 --- a/.github/workflows/test_mariadb.yml +++ b/.github/workflows/test_mariadb.yml @@ -27,6 +27,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 + - name: MariaDB | Build 'test' image run: | docker build --target mariadb_server -t "gradido/mariadb:test" -f ./mariadb/Dockerfile ./ From 069215adf59f0e55e7098655b34510ad2c393c00 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 2 May 2023 17:43:05 +0200 Subject: [PATCH 4/8] move database test jobs to separate workflow file --- .github/workflows/test.yml | 66 +---------------------------- .github/workflows/test_database.yml | 65 ++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/test_database.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d2e83d8e9..1b245fa2b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,32 +29,6 @@ jobs: name: docker-backend-test path: /tmp/backend.tar - ############################################################################## - # JOB: DOCKER BUILD TEST DATABASE UP ######################################### - ############################################################################## - build_test_database_up: - name: Docker Build Test - Database up - runs-on: ubuntu-latest - #needs: [nothing] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # DATABASE UP ############################################################ - ########################################################################## - - name: Database | Build `test_up` image - run: | - docker build --target test_up -t "gradido/database:test_up" database/ - docker save "gradido/database:test_up" > /tmp/database_up.tar - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - name: docker-database-test_up - path: /tmp/database_up.tar - ############################################################################## # JOB: LINT BACKEND ########################################################## ############################################################################## @@ -91,23 +65,7 @@ jobs: - name: Backend | Locales run: cd backend && yarn && yarn locales - ############################################################################## - # JOB: LINT DATABASE UP ###################################################### - ############################################################################## - lint_database_up: - name: Lint - Database Up - runs-on: ubuntu-latest - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # LINT DATABASE ########################################################## - ########################################################################## - - name: Database | Lint - run: cd database && yarn && yarn run lint + ############################################################################## # JOB: UNIT TEST BACKEND #################################################### @@ -145,25 +103,3 @@ jobs: - name: backend Unit tests | test run: cd database && yarn && yarn build && cd ../backend && yarn && yarn test - ########################################################################## - # DATABASE MIGRATION TEST UP + RESET ##################################### - ########################################################################## - database_migration_test: - name: Database Migration Test - Up + Reset - runs-on: ubuntu-latest - #needs: [nothing] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # DOCKER COMPOSE DATABASE UP + RESET ##################################### - ########################################################################## - - name: database | docker-compose - run: docker-compose -f docker-compose.yml up --detach mariadb - - name: database | up - run: docker-compose -f docker-compose.yml run -T database yarn up - - name: database | reset - run: docker-compose -f docker-compose.yml run -T database yarn reset diff --git a/.github/workflows/test_database.yml b/.github/workflows/test_database.yml new file mode 100644 index 000000000..d39fe5972 --- /dev/null +++ b/.github/workflows/test_database.yml @@ -0,0 +1,65 @@ +name: Gradido Database Test CI + +on: push + +jobs: + files-changed: + name: Detect File Changes - Database + runs-on: ubuntu-latest + outputs: + database: ${{ steps.changes.outputs.database }} + docker-compose: ${{ steps.changes.outputs.docker-compose }} + mariadb: ${{ steps.changes.outputs.mariadb }} + steps: + - uses: actions/checkout@v3.3.0 + + - name: Check for frontend file changes + uses: dorny/paths-filter@v2.11.1 + id: changes + with: + token: ${{ github.token }} + filters: .github/file-filters.yml + list-files: shell + + build: + if: needs.files-changed.outputs.database == 'true' + name: Docker Build Test - Database up + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Database | Build 'test_up' image + run: | + docker build --target test_up -t "gradido/database:test_up" database/ + + database_migration_test: + if: needs.files-changed.outputs.database == 'true' || needs.files-changed.outputs.docker-compose == 'true' || needs.files-changed.outputs.mariadb == 'true' + name: Database Migration Test - Up + Reset + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Database | docker-compose + run: docker-compose -f docker-compose.yml up --detach mariadb + + - name: Database | up + run: docker-compose -f docker-compose.yml run -T database yarn up + + - name: Database | reset + run: docker-compose -f docker-compose.yml run -T database yarn reset + + lint: + if: needs.files-changed.outputs.database == 'true' + name: Lint - Database Up + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Database | Lint + run: cd database && yarn && yarn run lint \ No newline at end of file From 98a02de50acc90c021d49548e333ffe09916f663 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 2 May 2023 20:31:49 +0200 Subject: [PATCH 5/8] move backend test jobs to separate workflow file --- .github/file-filters.yml | 3 + .github/workflows/test.yml | 105 ----------------------------- .github/workflows/test_backend.yml | 81 ++++++++++++++++++++++ 3 files changed, 84 insertions(+), 105 deletions(-) delete mode 100644 .github/workflows/test.yml create mode 100644 .github/workflows/test_backend.yml diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 02ea2709e..f0d38b75b 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -30,6 +30,9 @@ admin: &admin - 'admin/**/*' +backend: &backend + - 'backend/**/*' + dht_node: &dht_node - 'dht-node/**/*' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 1b245fa2b..000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,105 +0,0 @@ -name: gradido test CI - -on: push - -jobs: - ############################################################################## - # JOB: DOCKER BUILD TEST BACKEND ############################################# - ############################################################################## - build_test_backend: - name: Docker Build Test - Backend - runs-on: ubuntu-latest - #needs: [nothing] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # BACKEND ################################################################ - ########################################################################## - - name: Backend | Build `test` image - run: | - docker build -f ./backend/Dockerfile --target test -t "gradido/backend:test" . - docker save "gradido/backend:test" > /tmp/backend.tar - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - name: docker-backend-test - path: /tmp/backend.tar - - ############################################################################## - # JOB: LINT BACKEND ########################################################## - ############################################################################## - lint_backend: - name: Lint - Backend - runs-on: ubuntu-latest - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # LINT BACKEND ########################################################### - ########################################################################## - - name: backend | Lint - run: cd database && yarn && cd ../backend && yarn && yarn run lint - - ############################################################################## - # JOB: LOCALES BACKEND ####################################################### - ############################################################################## - locales_backend: - name: Locales - Backend - runs-on: ubuntu-latest - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # LOCALES BACKEND ##################################################### - ########################################################################## - - name: Backend | Locales - run: cd backend && yarn && yarn locales - - - - ############################################################################## - # JOB: UNIT TEST BACKEND #################################################### - ############################################################################## - unit_test_backend: - name: Unit tests - Backend - runs-on: ubuntu-latest - needs: [build_test_mariadb] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # DOWNLOAD DOCKER IMAGES ################################################# - ########################################################################## - - name: Download Docker Image (Mariadb) - uses: actions/download-artifact@v3 - with: - name: docker-mariadb-test - path: /tmp - - name: Load Docker Image - run: docker load < /tmp/mariadb.tar - ########################################################################## - # UNIT TESTS BACKEND ##################################################### - ########################################################################## - - name: backend | docker-compose mariadb - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps mariadb - - name: Sleep for 30 seconds - run: sleep 30s - shell: bash - - name: backend | docker-compose database - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database - - name: backend Unit tests | test - run: cd database && yarn && yarn build && cd ../backend && yarn && yarn test - diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml new file mode 100644 index 000000000..b517c5186 --- /dev/null +++ b/.github/workflows/test_backend.yml @@ -0,0 +1,81 @@ +name: Gradido Backend Test CI + +on: push + +jobs: + files-changed: + name: Detect File Changes - Backend + runs-on: ubuntu-latest + outputs: + backend: ${{ steps.changes.outputs.backend }} + database: ${{ steps.changes.outputs.database }} + docker-compose: ${{ steps.changes.outputs.docker-compose }} + mariadb: ${{ steps.changes.outputs.mariadb }} + steps: + - uses: actions/checkout@v3.3.0 + + - name: Check for frontend file changes + uses: dorny/paths-filter@v2.11.1 + id: changes + with: + token: ${{ github.token }} + filters: .github/file-filters.yml + list-files: shell + + build_test: + if: needs.files-changed.outputs.backend == 'true' + name: Docker Build Test - Backend + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Backend | Build 'test' image + run: docker build -f ./backend/Dockerfile --target test -t "gradido/backend:test" . + + unit_test: + if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.database == 'true' || needs.files-changed.outputs.docker-compose == 'true' || needs.files-changed.outputs.mariadb == 'true' + name: Unit tests - Backend + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Backend | docker-compose mariadb + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps mariadb + + - name: Sleep for 30 seconds + run: sleep 30s + shell: bash + + - name: Backend | docker-compose database + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database + + - name: Backend | Unit tests + run: cd database && yarn && yarn build && cd ../backend && yarn && yarn test + + lint: + if: needs.files-changed.outputs.backend == 'true' + name: Lint - Backend + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Backend | Lint + run: cd database && yarn && cd ../backend && yarn && yarn run lint + + locales: + if: needs.files-changed.outputs.backend == 'true' + name: Locales - Backend + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Backend | Locales + run: cd backend && yarn && yarn locales \ No newline at end of file From bd4ea0bade627df51f206e6e3e9fecaa4140cc75 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 2 May 2023 20:41:44 +0200 Subject: [PATCH 6/8] clean up --- .github/workflows/test_database.yml | 3 +-- .github/workflows/test_mariadb.yml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_database.yml b/.github/workflows/test_database.yml index d39fe5972..0444a0538 100644 --- a/.github/workflows/test_database.yml +++ b/.github/workflows/test_database.yml @@ -31,8 +31,7 @@ jobs: uses: actions/checkout@v3 - name: Database | Build 'test_up' image - run: | - docker build --target test_up -t "gradido/database:test_up" database/ + run: docker build --target test_up -t "gradido/database:test_up" database/ database_migration_test: if: needs.files-changed.outputs.database == 'true' || needs.files-changed.outputs.docker-compose == 'true' || needs.files-changed.outputs.mariadb == 'true' diff --git a/.github/workflows/test_mariadb.yml b/.github/workflows/test_mariadb.yml index 925884cf5..fe101bc48 100644 --- a/.github/workflows/test_mariadb.yml +++ b/.github/workflows/test_mariadb.yml @@ -29,5 +29,4 @@ jobs: uses: actions/checkout@v3 - name: MariaDB | Build 'test' image - run: | - docker build --target mariadb_server -t "gradido/mariadb:test" -f ./mariadb/Dockerfile ./ + run: docker build --target mariadb_server -t "gradido/mariadb:test" -f ./mariadb/Dockerfile ./ From fd61eb84fed8ee78133ac267ec8c6108aeadd16b Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 2 May 2023 21:38:44 +0200 Subject: [PATCH 7/8] add check for mariadb and database changes to dht node and federation workflow --- .github/workflows/test_dht_node.yml | 3 ++- .github/workflows/test_federation.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_dht_node.yml b/.github/workflows/test_dht_node.yml index bb24f2d2f..b63d1fc0d 100644 --- a/.github/workflows/test_dht_node.yml +++ b/.github/workflows/test_dht_node.yml @@ -7,6 +7,7 @@ jobs: name: Detect File Changes - DHT Node runs-on: ubuntu-latest outputs: + database: ${{ steps.changes.outputs.database }} dht_node: ${{ steps.changes.outputs.dht_node }} docker-compose: ${{ steps.changes.outputs.docker-compose }} steps: @@ -54,7 +55,7 @@ jobs: unit_test: name: Unit Tests - DHT Node - if: needs.files-changed.outputs.dht_node == 'true' || needs.files-changed.outputs.docker-compose == 'true' + if: needs.files-changed.outputs.database == 'true' || needs.files-changed.outputs.dht_node == 'true' || needs.files-changed.outputs.docker-compose == 'true' || needs.files-changed.outputs.mariadb == 'true' needs: [files-changed, build] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test_federation.yml b/.github/workflows/test_federation.yml index 5fd714b00..92ccd95d2 100644 --- a/.github/workflows/test_federation.yml +++ b/.github/workflows/test_federation.yml @@ -54,7 +54,7 @@ jobs: unit_test: name: Unit Tests - Federation - if: needs.files-changed.outputs.docker-compose == 'true' || needs.files-changed.outputs.federation == 'true' + if: needs.files-changed.outputs.database == 'true' || needs.files-changed.outputs.docker-compose == 'true' || needs.files-changed.outputs.federation == 'true' || needs.files-changed.outputs.mariadb == 'true' needs: [files-changed, build] runs-on: ubuntu-latest steps: From 0c820fb53bef2098cd39c08fc668d74f6abb3ab1 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 2 May 2023 21:55:41 +0200 Subject: [PATCH 8/8] clean up mariadb Dockerfile fo check workflow changes --- mariadb/Dockerfile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mariadb/Dockerfile b/mariadb/Dockerfile index 07d2ba368..d3d5937d0 100644 --- a/mariadb/Dockerfile +++ b/mariadb/Dockerfile @@ -2,8 +2,3 @@ # mariadb server ######################################################################################################### FROM mariadb/server:10.5 as mariadb_server - -# ENV DOCKER_WORKDIR="/docker-entrypoint-initdb.d" - -# RUN mkdir -p ${DOCKER_WORKDIR} -# WORKDIR ${DOCKER_WORKDIR}