From 980da55162eb5e8e8492aab16d92bcfdeb650280 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 03:52:26 +0100 Subject: [PATCH 01/34] - split ci jobs to make them run in parallel - include backend unit tests --- .github/workflows/ci.yml | 142 ++++++++++++++++++++++++++------------- 1 file changed, 97 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 551f91c43..d9929de3d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,20 +1,38 @@ -name: CI +name: ocelot.social CI + on: [push] jobs: - build: - name: Continuous Integration + ############################################################################## + # JOB: PREPARE ##################################################### + ############################################################################## + prepare: + name: Prepare runs-on: ubuntu-latest + # needs: nothing steps: + ########################################################################## + # CHECKOUT CODE ########################################################## + ########################################################################## - name: Checkout code uses: actions/checkout@v2 - + ########################################################################## + # TODO: DO STUFF ??? ##################################################### + ########################################################################## - name: Check translation files run: | scripts/translations/sort.sh scripts/translations/missing-keys.sh + ############################################################################## + # JOB: DOCKER BUILD TEST ##################################################### + ############################################################################## + build_test: + name: Docker Build Test + runs-on: ubuntu-latest + needs: prepare + steps: ########################################################################## # NEO4J ################################################################## ########################################################################## @@ -25,7 +43,80 @@ jobs: tags: latest path: neo4j/ push: false - + + ########################################################################## + # BUILD BACKEND DOCKER IMAGE (build) ##################################### + ########################################################################## + - name: backend | Build `build` image + uses: docker/build-push-action@v1.1.0 + with: + repository: ocelotsocialnetwork/backend + tags: build + target: build + path: backend/ + push: false + + ########################################################################## + # BUILD WEBAPP DOCKER IMAGE (build) ###################################### + ########################################################################## + - name: webapp | Build `build` image + uses: docker/build-push-action@v1.1.0 + with: + repository: ocelotsocialnetwork/webapp + tags: build + target: build + path: webapp/ + push: false + + ############################################################################## + # JOB: LINT ################################################################## + ############################################################################## + lint: + name: Lint + runs-on: ubuntu-latest + needs: build_test + steps: + ########################################################################## + # LINT BACKEND ########################################################### + ########################################################################## + - name: backend | Lint + run: docker run --rm ocelotsocialnetwork/backend:build yarn run lint + ########################################################################## + # LINT WEBAPP ############################################################ + ########################################################################## + - name: webapp | Lint + run: docker run --rm ocelotsocialnetwork/webapp:build yarn run lint + + ############################################################################## + # JOB: UNIT TESTS ############################################################ + ############################################################################## + unit_tests: + name: Lint + runs-on: ubuntu-latest + needs: build_test + steps: + ########################################################################## + # UNIT TESTS BACKEND ##################################################### + ########################################################################## + - name: backend | docker-compose + run: docker-compose up + - name: backend | Unit tests + run: docker-compose exec backend yarn test + #run: docker run --network container:webapp-frontend appropriate/curl -s --retry 10 --retry-connrefused http://localhost:5000/ + ########################################################################## + # UNIT TESTS WEBAPP ##################################################### + ########################################################################## + - name: webapp | Unit tests + run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test + + ############################################################################## + # JOB: DOCKER BUILD PRODUCTION & PUSH ######################################## + ############################################################################## + #build_production: + # name: Docker Build Production & Push + # runs-on: ubuntu-latest + # needs: prepare + # steps: ########################################################################## # BACKEND ################################################################ ########################################################################## @@ -39,26 +130,6 @@ jobs: # path: backend/ # push: false - # Build Docker Image (build) - - name: backend | Build `build` image - uses: docker/build-push-action@v1.1.0 - with: - repository: ocelotsocialnetwork/backend - tags: build - target: build - path: backend/ - push: false - - # Lint - - name: backend | Lint - run: docker run --rm ocelotsocialnetwork/backend:build yarn run lint - - # Unit Tests - #- name: backend | Unit tests - # run: | - # docker-compose up - # docker-compose exec backend yarn test - ########################################################################## # WEBAPP ################################################################# ########################################################################## @@ -70,23 +141,4 @@ jobs: # tags: production # target: production # path: webapp/ - # push: false - - # Build Docker Image (build) - - name: webapp | Build `build` image - uses: docker/build-push-action@v1.1.0 - with: - repository: ocelotsocialnetwork/webapp - tags: build - target: build - path: webapp/ - push: false - - # Lint - - name: webapp | Lint - run: docker run --rm ocelotsocialnetwork/webapp:build yarn run lint - - # Unit Tests - - name: webapp | Unit tests - run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test - + # push: false \ No newline at end of file From 5050174eb149e6fd43c2e7073fa4b5a84699381f Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 03:53:27 +0100 Subject: [PATCH 02/34] - fixed typo --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d9929de3d..85c2f6437 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,7 +91,7 @@ jobs: # JOB: UNIT TESTS ############################################################ ############################################################################## unit_tests: - name: Lint + name: Unit Tests runs-on: ubuntu-latest needs: build_test steps: From 129339e11fcfcf77379b397b58aafc1e9e0f0c4a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 03:58:48 +0100 Subject: [PATCH 03/34] - checkout code is not persistent between jobs --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85c2f6437..2554c0c85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,6 +34,11 @@ jobs: needs: prepare steps: ########################################################################## + # CHECKOUT CODE ########################################################## + ########################################################################## + - name: Checkout code + uses: actions/checkout@v2 + ########################################################################## # NEO4J ################################################################## ########################################################################## - name: Neo4J | Build `community` image @@ -43,7 +48,6 @@ jobs: tags: latest path: neo4j/ push: false - ########################################################################## # BUILD BACKEND DOCKER IMAGE (build) ##################################### ########################################################################## @@ -55,7 +59,6 @@ jobs: target: build path: backend/ push: false - ########################################################################## # BUILD WEBAPP DOCKER IMAGE (build) ###################################### ########################################################################## @@ -74,9 +77,14 @@ jobs: lint: name: Lint runs-on: ubuntu-latest - needs: build_test + needs: prepare steps: ########################################################################## + # CHECKOUT CODE ########################################################## + ########################################################################## + - name: Checkout code + uses: actions/checkout@v2 + ########################################################################## # LINT BACKEND ########################################################### ########################################################################## - name: backend | Lint @@ -93,9 +101,14 @@ jobs: unit_tests: name: Unit Tests runs-on: ubuntu-latest - needs: build_test + needs: prepare steps: ########################################################################## + # CHECKOUT CODE ########################################################## + ########################################################################## + - name: Checkout code + uses: actions/checkout@v2 + ########################################################################## # UNIT TESTS BACKEND ##################################################### ########################################################################## - name: backend | docker-compose @@ -117,6 +130,11 @@ jobs: # runs-on: ubuntu-latest # needs: prepare # steps: + ########################################################################## + # CHECKOUT CODE ########################################################## + ########################################################################## + #- name: Checkout code + # uses: actions/checkout@v2 ########################################################################## # BACKEND ################################################################ ########################################################################## From b202241ff1dd437bcab7026b3e154f0784fb69d4 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 04:03:12 +0100 Subject: [PATCH 04/34] - workflow jobs aint gonna do the job for now --- .github/workflows/ci.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2554c0c85..9155ac7c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,11 +74,11 @@ jobs: ############################################################################## # JOB: LINT ################################################################## ############################################################################## - lint: - name: Lint - runs-on: ubuntu-latest - needs: prepare - steps: + #lint: + # name: Lint + # runs-on: ubuntu-latest + # needs: prepare + # steps: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## @@ -98,11 +98,11 @@ jobs: ############################################################################## # JOB: UNIT TESTS ############################################################ ############################################################################## - unit_tests: - name: Unit Tests - runs-on: ubuntu-latest - needs: prepare - steps: + #unit_tests: + # name: Unit Tests + # runs-on: ubuntu-latest + # needs: prepare + # steps: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## From bac01693b03c05f070c72fe171167081b082de7f Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 04:04:58 +0100 Subject: [PATCH 05/34] - removed duplicate code checkouts --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9155ac7c0..c8e494703 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,8 +82,8 @@ jobs: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - - name: Checkout code - uses: actions/checkout@v2 + #- name: Checkout code + # uses: actions/checkout@v2 ########################################################################## # LINT BACKEND ########################################################### ########################################################################## @@ -106,8 +106,8 @@ jobs: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - - name: Checkout code - uses: actions/checkout@v2 + #- name: Checkout code + # uses: actions/checkout@v2 ########################################################################## # UNIT TESTS BACKEND ##################################################### ########################################################################## From 742227aa871272ab1b8e8e0595a277cc29382b80 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 04:18:12 +0100 Subject: [PATCH 06/34] - copy .env file --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8e494703..a75a42683 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,6 +111,8 @@ jobs: ########################################################################## # UNIT TESTS BACKEND ##################################################### ########################################################################## + - name: backend | copy env file (webapp) + run: cp webapp/.env.template webapp/.env - name: backend | docker-compose run: docker-compose up - name: backend | Unit tests From 161ae450db3d6a73f03e2123bbf92d86140f34ea Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 04:49:42 +0100 Subject: [PATCH 07/34] - try to make jobs parallel again using github artifacts --- .github/workflows/ci.yml | 163 +++++++++++++++++++++++++++++++++------ 1 file changed, 138 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a75a42683..61cc5a5c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: prepare: name: Prepare runs-on: ubuntu-latest - # needs: nothing + # needs: [nothing] steps: ########################################################################## # CHECKOUT CODE ########################################################## @@ -25,19 +25,44 @@ jobs: scripts/translations/sort.sh scripts/translations/missing-keys.sh - ############################################################################## - # JOB: DOCKER BUILD TEST ##################################################### - ############################################################################## - build_test: - name: Docker Build Test + test_latest_version_v1: + needs: docker_build runs-on: ubuntu-latest - needs: prepare + name: latest v1 + env: + AWS_CLI_VERSION: 1 + steps: + - name: Download Docker Image (Artifact) + uses: actions/download-artifact@v2 + with: + name: docker-artifact + path: path/to/artifacts + - name: Run test in Docker + run: | + cd path/to/artifacts + docker load < docker-image.tar + export DOCKER_FULLTAG=$(cat docker-tag) + docker run --rm "$DOCKER_FULLTAG" $AWS_CLI_VERSION + - uses: actions/checkout@v2 + - name: Run test on Runner + run: | + sudo ./entrypoint.sh + + + ############################################################################## + # JOB: DOCKER BUILD TEST NEO4J ############################################### + ############################################################################## + build_test_neo4j: + name: Docker Build Test - Neo4J + runs-on: ubuntu-latest + needs: [prepare] steps: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - - name: Checkout code + - name: Checkout code & create output folder uses: actions/checkout@v2 + run: mkdir -p /docker ########################################################################## # NEO4J ################################################################## ########################################################################## @@ -48,6 +73,26 @@ jobs: tags: latest path: neo4j/ push: false + outputs: type=local,dest=/docker/neo4j.tar + uses: actions/upload-artifact@v2 + with: + name: docker-neo4j-image + path: /docker/neo4j.tar + + ############################################################################## + # JOB: DOCKER BUILD TEST BACKEND ############################################# + ############################################################################## + build_test_backend: + name: Docker Build Test - Backend + runs-on: ubuntu-latest + needs: [prepare] + steps: + ########################################################################## + # CHECKOUT CODE ########################################################## + ########################################################################## + - name: Checkout code & create output folder + uses: actions/checkout@v2 + run: mkdir -p /docker ########################################################################## # BUILD BACKEND DOCKER IMAGE (build) ##################################### ########################################################################## @@ -59,6 +104,26 @@ jobs: target: build path: backend/ push: false + outputs: type=local,dest=/docker/backend.tar + uses: actions/upload-artifact@v2 + with: + name: docker-backend-image + path: /docker/backend.tar + + ############################################################################## + # JOB: DOCKER BUILD TEST WEBAPP ############################################## + ############################################################################## + build_test_webapp: + name: Docker Build Test - WebApp + runs-on: ubuntu-latest + needs: [prepare] + steps: + ########################################################################## + # CHECKOUT CODE ########################################################## + ########################################################################## + - name: Checkout code & create output folder + uses: actions/checkout@v2 + run: mkdir -p /docker ########################################################################## # BUILD WEBAPP DOCKER IMAGE (build) ###################################### ########################################################################## @@ -70,25 +135,72 @@ jobs: target: build path: webapp/ push: false - + outputs: type=local,dest=/docker/webapp.tar + uses: actions/upload-artifact@v2 + with: + name: docker-webapp-image + path: /docker/webapp.tar + ############################################################################## - # JOB: LINT ################################################################## + # JOB: AFTER DOCKER BUILD #################################################### ############################################################################## - #lint: - # name: Lint - # runs-on: ubuntu-latest - # needs: prepare - # steps: + after_docker_build: + name: After Build + runs-on: ubuntu-latest + needs: [build_test_neo4j, build_test_backend, build_test_webapp] + + ############################################################################## + # JOB: LINT BACKEND ########################################################## + ############################################################################## + lint_backend: + name: Lint backend + runs-on: ubuntu-latest + needs: after_docker_build + steps: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - #- name: Checkout code - # uses: actions/checkout@v2 + - name: Checkout code & create artifact folder + uses: actions/checkout@v2 + run: mkdir -p /docker + ########################################################################## + # DOWNLOAD DOCKER IMAGE ################################################## + ########################################################################## + - name: Download Docker Image (Artifact) + uses: actions/download-artifact@v2 + with: + name: docker-backend-image + path: /docker/backend.tar + run: docker load < /docker/backend.tar ########################################################################## # LINT BACKEND ########################################################### ########################################################################## - name: backend | Lint run: docker run --rm ocelotsocialnetwork/backend:build yarn run lint + + ############################################################################## + # JOB: LINT WEBAPP ########################################################### + ############################################################################## + lint_webapp: + name: Lint backend + runs-on: ubuntu-latest + needs: after_docker_build + steps: + ########################################################################## + # CHECKOUT CODE ########################################################## + ########################################################################## + - name: Checkout code & create artifact folder + uses: actions/checkout@v2 + run: mkdir -p /docker + ########################################################################## + # DOWNLOAD DOCKER IMAGE ################################################## + ########################################################################## + - name: Download Docker Image (Artifact) + uses: actions/download-artifact@v2 + with: + name: docker-webapp-image + path: /docker/webapp.tar + run: docker load < /docker/webapp.tar ########################################################################## # LINT WEBAPP ############################################################ ########################################################################## @@ -111,18 +223,19 @@ jobs: ########################################################################## # UNIT TESTS BACKEND ##################################################### ########################################################################## - - name: backend | copy env file (webapp) - run: cp webapp/.env.template webapp/.env - - name: backend | docker-compose - run: docker-compose up - - name: backend | Unit tests - run: docker-compose exec backend yarn test + #- name: backend | copy env files (webapp, backend) + # run: cp webapp/.env.template webapp/.env + # run: cp backend/.env.template backend/.env + #- name: backend | docker-compose + # run: docker-compose up + #- name: backend | Unit tests + # run: docker-compose exec backend yarn test #run: docker run --network container:webapp-frontend appropriate/curl -s --retry 10 --retry-connrefused http://localhost:5000/ ########################################################################## # UNIT TESTS WEBAPP ##################################################### ########################################################################## - - name: webapp | Unit tests - run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test + #- name: webapp | Unit tests + # run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test ############################################################################## # JOB: DOCKER BUILD PRODUCTION & PUSH ######################################## From e2265858890549011b7ea4ec8e4266fb19adb25f Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 04:52:31 +0100 Subject: [PATCH 08/34] - fixed syntax --- .github/workflows/ci.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61cc5a5c6..c36e3937f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,8 +60,9 @@ jobs: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - - name: Checkout code & create output folder + - name: Checkout code uses: actions/checkout@v2 + - name: Create output folder run: mkdir -p /docker ########################################################################## # NEO4J ################################################################## @@ -90,8 +91,9 @@ jobs: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - - name: Checkout code & create output folder + - name: Checkout code uses: actions/checkout@v2 + - name: Create output folder run: mkdir -p /docker ########################################################################## # BUILD BACKEND DOCKER IMAGE (build) ##################################### @@ -121,8 +123,9 @@ jobs: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - - name: Checkout code & create output folder + - name: Checkout code uses: actions/checkout@v2 + - name: Create output folder run: mkdir -p /docker ########################################################################## # BUILD WEBAPP DOCKER IMAGE (build) ###################################### @@ -160,8 +163,9 @@ jobs: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - - name: Checkout code & create artifact folder + - name: Checkout code uses: actions/checkout@v2 + - name: Create artifact folder run: mkdir -p /docker ########################################################################## # DOWNLOAD DOCKER IMAGE ################################################## @@ -189,8 +193,9 @@ jobs: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - - name: Checkout code & create artifact folder + - name: Checkout code uses: actions/checkout@v2 + - name: Create artifact folder run: mkdir -p /docker ########################################################################## # DOWNLOAD DOCKER IMAGE ################################################## From 78021a0eae44aaf64ffa836c31bb4c58a6de3d23 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 04:57:42 +0100 Subject: [PATCH 09/34] - more syntax fixes --- .github/workflows/ci.yml | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c36e3937f..4e2b76d01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,30 +25,6 @@ jobs: scripts/translations/sort.sh scripts/translations/missing-keys.sh - test_latest_version_v1: - needs: docker_build - runs-on: ubuntu-latest - name: latest v1 - env: - AWS_CLI_VERSION: 1 - steps: - - name: Download Docker Image (Artifact) - uses: actions/download-artifact@v2 - with: - name: docker-artifact - path: path/to/artifacts - - name: Run test in Docker - run: | - cd path/to/artifacts - docker load < docker-image.tar - export DOCKER_FULLTAG=$(cat docker-tag) - docker run --rm "$DOCKER_FULLTAG" $AWS_CLI_VERSION - - uses: actions/checkout@v2 - - name: Run test on Runner - run: | - sudo ./entrypoint.sh - - ############################################################################## # JOB: DOCKER BUILD TEST NEO4J ############################################### ############################################################################## @@ -175,6 +151,7 @@ jobs: with: name: docker-backend-image path: /docker/backend.tar + - name: Load Docker Image run: docker load < /docker/backend.tar ########################################################################## # LINT BACKEND ########################################################### @@ -205,6 +182,7 @@ jobs: with: name: docker-webapp-image path: /docker/webapp.tar + - name: Load Docker Image run: docker load < /docker/webapp.tar ########################################################################## # LINT WEBAPP ############################################################ From f5005a9637e09f9ae90c853e7259d34c4b3b6eee Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 04:58:48 +0100 Subject: [PATCH 10/34] more syntax --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e2b76d01..7c131d408 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,6 +127,9 @@ jobs: name: After Build runs-on: ubuntu-latest needs: [build_test_neo4j, build_test_backend, build_test_webapp] + steps: + - name: Do nothing + run: echo "I do nothing" ############################################################################## # JOB: LINT BACKEND ########################################################## From b8d5382aa1bfa4bf1e696b92380bc5a72d46b939 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 05:00:24 +0100 Subject: [PATCH 11/34] - more syntax fixes --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c131d408..bb1ac7ee5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,6 +51,7 @@ jobs: path: neo4j/ push: false outputs: type=local,dest=/docker/neo4j.tar + - name: Upload Artifact uses: actions/upload-artifact@v2 with: name: docker-neo4j-image @@ -83,6 +84,7 @@ jobs: path: backend/ push: false outputs: type=local,dest=/docker/backend.tar + - name: Upload Artifact uses: actions/upload-artifact@v2 with: name: docker-backend-image @@ -115,6 +117,7 @@ jobs: path: webapp/ push: false outputs: type=local,dest=/docker/webapp.tar + - name: Upload Artifact uses: actions/upload-artifact@v2 with: name: docker-webapp-image From ae957b0aad7a079f46a6effd93c8dd6e4fb3c838 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 05:03:04 +0100 Subject: [PATCH 12/34] - corrected path (permission denied) --- .github/workflows/ci.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb1ac7ee5..37b409f07 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - name: Create output folder - run: mkdir -p /docker + run: mkdir -p ./docker ########################################################################## # NEO4J ################################################################## ########################################################################## @@ -50,12 +50,12 @@ jobs: tags: latest path: neo4j/ push: false - outputs: type=local,dest=/docker/neo4j.tar + outputs: type=local,dest=./docker/neo4j.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: name: docker-neo4j-image - path: /docker/neo4j.tar + path: ./docker/neo4j.tar ############################################################################## # JOB: DOCKER BUILD TEST BACKEND ############################################# @@ -71,7 +71,7 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - name: Create output folder - run: mkdir -p /docker + run: mkdir -p ./docker ########################################################################## # BUILD BACKEND DOCKER IMAGE (build) ##################################### ########################################################################## @@ -83,12 +83,12 @@ jobs: target: build path: backend/ push: false - outputs: type=local,dest=/docker/backend.tar + outputs: type=local,dest=./docker/backend.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: name: docker-backend-image - path: /docker/backend.tar + path: ./docker/backend.tar ############################################################################## # JOB: DOCKER BUILD TEST WEBAPP ############################################## @@ -104,7 +104,7 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - name: Create output folder - run: mkdir -p /docker + run: mkdir -p ./docker ########################################################################## # BUILD WEBAPP DOCKER IMAGE (build) ###################################### ########################################################################## @@ -116,12 +116,12 @@ jobs: target: build path: webapp/ push: false - outputs: type=local,dest=/docker/webapp.tar + outputs: type=local,dest=./docker/webapp.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: name: docker-webapp-image - path: /docker/webapp.tar + path: ./docker/webapp.tar ############################################################################## # JOB: AFTER DOCKER BUILD #################################################### @@ -148,7 +148,7 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - name: Create artifact folder - run: mkdir -p /docker + run: mkdir -p ./docker ########################################################################## # DOWNLOAD DOCKER IMAGE ################################################## ########################################################################## @@ -156,9 +156,9 @@ jobs: uses: actions/download-artifact@v2 with: name: docker-backend-image - path: /docker/backend.tar + path: ./docker/backend.tar - name: Load Docker Image - run: docker load < /docker/backend.tar + run: docker load < ./docker/backend.tar ########################################################################## # LINT BACKEND ########################################################### ########################################################################## @@ -179,7 +179,7 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - name: Create artifact folder - run: mkdir -p /docker + run: mkdir -p ./docker ########################################################################## # DOWNLOAD DOCKER IMAGE ################################################## ########################################################################## @@ -187,9 +187,9 @@ jobs: uses: actions/download-artifact@v2 with: name: docker-webapp-image - path: /docker/webapp.tar + path: ./docker/webapp.tar - name: Load Docker Image - run: docker load < /docker/webapp.tar + run: docker load < ./docker/webapp.tar ########################################################################## # LINT WEBAPP ############################################################ ########################################################################## From 98813b9f827944c5404d136860f76e5a4de2f20e Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 05:08:23 +0100 Subject: [PATCH 13/34] - updated docker/build-push-action@v1.1.0 to docker/build-push-action@v2 --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37b409f07..d568ecd4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: # NEO4J ################################################################## ########################################################################## - name: Neo4J | Build `community` image - uses: docker/build-push-action@v1.1.0 + uses: docker/build-push-action@v2 with: repository: ocelotsocialnetwork/neo4j tags: latest @@ -76,7 +76,7 @@ jobs: # BUILD BACKEND DOCKER IMAGE (build) ##################################### ########################################################################## - name: backend | Build `build` image - uses: docker/build-push-action@v1.1.0 + uses: docker/build-push-action@v2 with: repository: ocelotsocialnetwork/backend tags: build @@ -109,7 +109,7 @@ jobs: # BUILD WEBAPP DOCKER IMAGE (build) ###################################### ########################################################################## - name: webapp | Build `build` image - uses: docker/build-push-action@v1.1.0 + uses: docker/build-push-action@v2 with: repository: ocelotsocialnetwork/webapp tags: build @@ -244,7 +244,7 @@ jobs: ########################################################################## # TODO: We want to push this to dockerhub #- name: Build backend production image - # uses: docker/build-push-action@v1.1.0 + # uses: docker/build-push-action@v2 # with: # repository: ocelotsocialnetwork/backend # tags: production @@ -257,7 +257,7 @@ jobs: ########################################################################## # TODO: We want to push this to dockerhub #- name: Build webapp production image - # uses: docker/build-push-action@v1.1.0 + # uses: docker/build-push-action@v2 # with: # repository: ocelotsocialnetwork/webapp # tags: production From 368ec8ff230995959e8d8ff5ad51778b66e1a664 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 05:13:52 +0100 Subject: [PATCH 14/34] - try to fix v2 of build and push --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d568ecd4f..9cfa0e6ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,10 @@ jobs: tags: latest path: neo4j/ push: false + load: true outputs: type=local,dest=./docker/neo4j.tar + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache - name: Upload Artifact uses: actions/upload-artifact@v2 with: @@ -83,7 +86,10 @@ jobs: target: build path: backend/ push: false + load: true outputs: type=local,dest=./docker/backend.tar + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache - name: Upload Artifact uses: actions/upload-artifact@v2 with: @@ -116,7 +122,10 @@ jobs: target: build path: webapp/ push: false + load: true outputs: type=local,dest=./docker/webapp.tar + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache - name: Upload Artifact uses: actions/upload-artifact@v2 with: From d23aec3cbd001a010bf7edc375e9463ec7d4ca77 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 05:17:30 +0100 Subject: [PATCH 15/34] - fix conflict local output and load --- .github/workflows/ci.yml | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9cfa0e6ed..8655c4d69 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,8 +38,6 @@ jobs: ########################################################################## - name: Checkout code uses: actions/checkout@v2 - - name: Create output folder - run: mkdir -p ./docker ########################################################################## # NEO4J ################################################################## ########################################################################## @@ -50,15 +48,14 @@ jobs: tags: latest path: neo4j/ push: false - load: true - outputs: type=local,dest=./docker/neo4j.tar + outputs: type=local,dest=/tmp/neo4j.tar cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - name: Upload Artifact uses: actions/upload-artifact@v2 with: name: docker-neo4j-image - path: ./docker/neo4j.tar + path: /tmp/neo4j.tar ############################################################################## # JOB: DOCKER BUILD TEST BACKEND ############################################# @@ -73,8 +70,6 @@ jobs: ########################################################################## - name: Checkout code uses: actions/checkout@v2 - - name: Create output folder - run: mkdir -p ./docker ########################################################################## # BUILD BACKEND DOCKER IMAGE (build) ##################################### ########################################################################## @@ -86,15 +81,14 @@ jobs: target: build path: backend/ push: false - load: true - outputs: type=local,dest=./docker/backend.tar + outputs: type=local,dest=/tmp/backend.tar cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - name: Upload Artifact uses: actions/upload-artifact@v2 with: name: docker-backend-image - path: ./docker/backend.tar + path: /tmp/backend.tar ############################################################################## # JOB: DOCKER BUILD TEST WEBAPP ############################################## @@ -109,8 +103,6 @@ jobs: ########################################################################## - name: Checkout code uses: actions/checkout@v2 - - name: Create output folder - run: mkdir -p ./docker ########################################################################## # BUILD WEBAPP DOCKER IMAGE (build) ###################################### ########################################################################## @@ -123,14 +115,14 @@ jobs: path: webapp/ push: false load: true - outputs: type=local,dest=./docker/webapp.tar + outputs: type=local,dest=/tmp/webapp.tar cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - name: Upload Artifact uses: actions/upload-artifact@v2 with: name: docker-webapp-image - path: ./docker/webapp.tar + path: /tmp/webapp.tar ############################################################################## # JOB: AFTER DOCKER BUILD #################################################### @@ -156,8 +148,6 @@ jobs: ########################################################################## - name: Checkout code uses: actions/checkout@v2 - - name: Create artifact folder - run: mkdir -p ./docker ########################################################################## # DOWNLOAD DOCKER IMAGE ################################################## ########################################################################## @@ -165,9 +155,9 @@ jobs: uses: actions/download-artifact@v2 with: name: docker-backend-image - path: ./docker/backend.tar + path: /tmp/backend.tar - name: Load Docker Image - run: docker load < ./docker/backend.tar + run: docker load < /tmp/backend.tar ########################################################################## # LINT BACKEND ########################################################### ########################################################################## @@ -187,8 +177,6 @@ jobs: ########################################################################## - name: Checkout code uses: actions/checkout@v2 - - name: Create artifact folder - run: mkdir -p ./docker ########################################################################## # DOWNLOAD DOCKER IMAGE ################################################## ########################################################################## @@ -196,9 +184,9 @@ jobs: uses: actions/download-artifact@v2 with: name: docker-webapp-image - path: ./docker/webapp.tar + path: /tmp/webapp.tar - name: Load Docker Image - run: docker load < ./docker/webapp.tar + run: docker load < /tmp/webapp.tar ########################################################################## # LINT WEBAPP ############################################################ ########################################################################## From 37621f1bac206be3a407e93b19e2bab0e22e25c3 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 05:40:21 +0100 Subject: [PATCH 16/34] - just do it manually - its better anyways... --- .github/workflows/ci.yml | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8655c4d69..f21375133 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,15 +42,9 @@ jobs: # NEO4J ################################################################## ########################################################################## - name: Neo4J | Build `community` image - uses: docker/build-push-action@v2 - with: - repository: ocelotsocialnetwork/neo4j - tags: latest - path: neo4j/ - push: false - outputs: type=local,dest=/tmp/neo4j.tar - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + run: | + docker build -t "ocelotsocialnetwork/neo4j:latest" neo4j/ + docker save "ocelotsocialnetwork/neo4j:latest" > /tmp/neo4j.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: @@ -74,7 +68,7 @@ jobs: # BUILD BACKEND DOCKER IMAGE (build) ##################################### ########################################################################## - name: backend | Build `build` image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v1.1.0 with: repository: ocelotsocialnetwork/backend tags: build @@ -82,8 +76,6 @@ jobs: path: backend/ push: false outputs: type=local,dest=/tmp/backend.tar - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - name: Upload Artifact uses: actions/upload-artifact@v2 with: @@ -107,17 +99,14 @@ jobs: # BUILD WEBAPP DOCKER IMAGE (build) ###################################### ########################################################################## - name: webapp | Build `build` image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v1.1.0 with: repository: ocelotsocialnetwork/webapp tags: build target: build path: webapp/ push: false - load: true outputs: type=local,dest=/tmp/webapp.tar - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - name: Upload Artifact uses: actions/upload-artifact@v2 with: @@ -241,7 +230,7 @@ jobs: ########################################################################## # TODO: We want to push this to dockerhub #- name: Build backend production image - # uses: docker/build-push-action@v2 + # uses: docker/build-push-action@v1.1.0 # with: # repository: ocelotsocialnetwork/backend # tags: production @@ -254,7 +243,7 @@ jobs: ########################################################################## # TODO: We want to push this to dockerhub #- name: Build webapp production image - # uses: docker/build-push-action@v2 + # uses: docker/build-push-action@v1.1.0 # with: # repository: ocelotsocialnetwork/webapp # tags: production From 6638e2d414381fc23422e93f6e54a222ca15c71a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 05:47:53 +0100 Subject: [PATCH 17/34] - build manually - seems to work better --- .github/workflows/ci.yml | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f21375133..8ccf09bad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: ########################################################################## - name: Neo4J | Build `community` image run: | - docker build -t "ocelotsocialnetwork/neo4j:latest" neo4j/ + docker build --target community -t "ocelotsocialnetwork/neo4j:latest" neo4j/ docker save "ocelotsocialnetwork/neo4j:latest" > /tmp/neo4j.tar - name: Upload Artifact uses: actions/upload-artifact@v2 @@ -68,14 +68,9 @@ jobs: # BUILD BACKEND DOCKER IMAGE (build) ##################################### ########################################################################## - name: backend | Build `build` image - uses: docker/build-push-action@v1.1.0 - with: - repository: ocelotsocialnetwork/backend - tags: build - target: build - path: backend/ - push: false - outputs: type=local,dest=/tmp/backend.tar + run: | + docker build --target build -t "ocelotsocialnetwork/backend:latest" backend/ + docker save "ocelotsocialnetwork/backend:latest" > /tmp/backend.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: @@ -99,14 +94,9 @@ jobs: # BUILD WEBAPP DOCKER IMAGE (build) ###################################### ########################################################################## - name: webapp | Build `build` image - uses: docker/build-push-action@v1.1.0 - with: - repository: ocelotsocialnetwork/webapp - tags: build - target: build - path: webapp/ - push: false - outputs: type=local,dest=/tmp/webapp.tar + run: | + docker build --target build -t "ocelotsocialnetwork/webapp:latest" webapp/ + docker save "ocelotsocialnetwork/webapp:latest" > /tmp/webapp.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: From 6805863ac93735d3a40925510c2632f84aa70d40 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 05:56:56 +0100 Subject: [PATCH 18/34] - refactored dependencies - removed forced step between building and testing --- .github/workflows/ci.yml | 96 ++++++++++++++++++++++++++-------------- 1 file changed, 63 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ccf09bad..664948828 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -102,17 +102,6 @@ jobs: with: name: docker-webapp-image path: /tmp/webapp.tar - - ############################################################################## - # JOB: AFTER DOCKER BUILD #################################################### - ############################################################################## - after_docker_build: - name: After Build - runs-on: ubuntu-latest - needs: [build_test_neo4j, build_test_backend, build_test_webapp] - steps: - - name: Do nothing - run: echo "I do nothing" ############################################################################## # JOB: LINT BACKEND ########################################################## @@ -120,7 +109,7 @@ jobs: lint_backend: name: Lint backend runs-on: ubuntu-latest - needs: after_docker_build + needs: [build_test_backend] steps: ########################################################################## # CHECKOUT CODE ########################################################## @@ -130,7 +119,7 @@ jobs: ########################################################################## # DOWNLOAD DOCKER IMAGE ################################################## ########################################################################## - - name: Download Docker Image (Artifact) + - name: Download Docker Image (Backend) uses: actions/download-artifact@v2 with: name: docker-backend-image @@ -147,9 +136,9 @@ jobs: # JOB: LINT WEBAPP ########################################################### ############################################################################## lint_webapp: - name: Lint backend + name: Lint webapp runs-on: ubuntu-latest - needs: after_docker_build + needs: [build_test_webapp] steps: ########################################################################## # CHECKOUT CODE ########################################################## @@ -159,7 +148,7 @@ jobs: ########################################################################## # DOWNLOAD DOCKER IMAGE ################################################## ########################################################################## - - name: Download Docker Image (Artifact) + - name: Download Docker Image (Webapp) uses: actions/download-artifact@v2 with: name: docker-webapp-image @@ -173,34 +162,75 @@ jobs: run: docker run --rm ocelotsocialnetwork/webapp:build yarn run lint ############################################################################## - # JOB: UNIT TESTS ############################################################ + # JOB: UNIT TEST BACKEND ##################################################### ############################################################################## - #unit_tests: - # name: Unit Tests - # runs-on: ubuntu-latest - # needs: prepare - # steps: + unit_test_backend: + name: Unit tests - backend + runs-on: ubuntu-latest + needs: [build_test_neo4j,build_test_backend] + steps: ########################################################################## # CHECKOUT CODE ########################################################## ########################################################################## - #- name: Checkout code - # uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v2 + ########################################################################## + # DOWNLOAD DOCKER IMAGES ################################################# + ########################################################################## + - name: Download Docker Image (Neo4J) + uses: actions/download-artifact@v2 + with: + name: docker-neo4j-image + path: /tmp/neo4j.tar + - name: Load Docker Image + run: docker load < /tmp/neo4j.tar + - name: Download Docker Image (Backend) + uses: actions/download-artifact@v2 + with: + name: docker-backend-image + path: /tmp/backend.tar + - name: Load Docker Image + run: docker load < /tmp/backend.tar ########################################################################## # UNIT TESTS BACKEND ##################################################### ########################################################################## - #- name: backend | copy env files (webapp, backend) - # run: cp webapp/.env.template webapp/.env - # run: cp backend/.env.template backend/.env - #- name: backend | docker-compose - # run: docker-compose up - #- name: backend | Unit tests - # run: docker-compose exec backend yarn test + - name: backend | copy env files (webapp, backend) + run: cp webapp/.env.template webapp/.env + run: cp backend/.env.template backend/.env + - name: backend | docker-compose + run: docker-compose up + - name: backend | Unit tests + run: docker-compose exec backend yarn test #run: docker run --network container:webapp-frontend appropriate/curl -s --retry 10 --retry-connrefused http://localhost:5000/ + + ############################################################################## + # JOB: UNIT TEST WEBAPP ###################################################### + ############################################################################## + unit_test_webapp: + name: Unit tests - webapp + runs-on: ubuntu-latest + needs: [build_test_webapp] + steps: + ########################################################################## + # CHECKOUT CODE ########################################################## + ########################################################################## + - name: Checkout code + uses: actions/checkout@v2 + ########################################################################## + # DOWNLOAD DOCKER IMAGES ################################################# + ########################################################################## + - name: Download Docker Image (Webapp) + uses: actions/download-artifact@v2 + with: + name: docker-webapp-image + path: /tmp/webapp.tar + - name: Load Docker Image + run: docker load < /tmp/webapp.tar ########################################################################## # UNIT TESTS WEBAPP ##################################################### ########################################################################## - #- name: webapp | Unit tests - # run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test + - name: webapp | Unit tests + run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test ############################################################################## # JOB: DOCKER BUILD PRODUCTION & PUSH ######################################## From 7b58b1277e91d83cb859ddaf12dbf247d58cbafd Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 05:57:59 +0100 Subject: [PATCH 19/34] - fixed syntax --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 664948828..8f2eb5d30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -194,8 +194,9 @@ jobs: ########################################################################## # UNIT TESTS BACKEND ##################################################### ########################################################################## - - name: backend | copy env files (webapp, backend) + - name: backend | copy env files webapp run: cp webapp/.env.template webapp/.env + - name: backend | copy env files backend run: cp backend/.env.template backend/.env - name: backend | docker-compose run: docker-compose up From 1aab1d23775f59d9efbe7584b7c07ee0a494b290 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 06:06:53 +0100 Subject: [PATCH 20/34] - artifacts seem to be directories --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f2eb5d30..4dbf1c4a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -123,7 +123,7 @@ jobs: uses: actions/download-artifact@v2 with: name: docker-backend-image - path: /tmp/backend.tar + path: /tmp - name: Load Docker Image run: docker load < /tmp/backend.tar ########################################################################## @@ -152,7 +152,7 @@ jobs: uses: actions/download-artifact@v2 with: name: docker-webapp-image - path: /tmp/webapp.tar + path: /tmp - name: Load Docker Image run: docker load < /tmp/webapp.tar ########################################################################## @@ -181,14 +181,14 @@ jobs: uses: actions/download-artifact@v2 with: name: docker-neo4j-image - path: /tmp/neo4j.tar + path: /tmp - name: Load Docker Image run: docker load < /tmp/neo4j.tar - name: Download Docker Image (Backend) uses: actions/download-artifact@v2 with: name: docker-backend-image - path: /tmp/backend.tar + path: /tmp - name: Load Docker Image run: docker load < /tmp/backend.tar ########################################################################## @@ -224,7 +224,7 @@ jobs: uses: actions/download-artifact@v2 with: name: docker-webapp-image - path: /tmp/webapp.tar + path: /tmp - name: Load Docker Image run: docker load < /tmp/webapp.tar ########################################################################## From a530e5151a6d7500df56b0870f3d8203b38a0aa8 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 06:15:10 +0100 Subject: [PATCH 21/34] - corrected docker image tags for webapp and backend --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4dbf1c4a3..2d954d18c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,8 +69,8 @@ jobs: ########################################################################## - name: backend | Build `build` image run: | - docker build --target build -t "ocelotsocialnetwork/backend:latest" backend/ - docker save "ocelotsocialnetwork/backend:latest" > /tmp/backend.tar + docker build --target build -t "ocelotsocialnetwork/backend:build" backend/ + docker save "ocelotsocialnetwork/backend:build" > /tmp/backend.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: @@ -95,8 +95,8 @@ jobs: ########################################################################## - name: webapp | Build `build` image run: | - docker build --target build -t "ocelotsocialnetwork/webapp:latest" webapp/ - docker save "ocelotsocialnetwork/webapp:latest" > /tmp/webapp.tar + docker build --target build -t "ocelotsocialnetwork/webapp:build" webapp/ + docker save "ocelotsocialnetwork/webapp:build" > /tmp/webapp.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: From dec17d0e8dface64ea8988ac7314732f5cca4eb9 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 06:36:28 +0100 Subject: [PATCH 22/34] - ci fixes - docker-compose.test.yml - fixed nuxt permissions in dev environment(docker) --- .github/workflows/ci.yml | 20 +++++++++------- docker-compose.override.yml | 2 +- docker-compose.test.yml | 47 +++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 docker-compose.test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d954d18c..ca8e8a3f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,8 +43,8 @@ jobs: ########################################################################## - name: Neo4J | Build `community` image run: | - docker build --target community -t "ocelotsocialnetwork/neo4j:latest" neo4j/ - docker save "ocelotsocialnetwork/neo4j:latest" > /tmp/neo4j.tar + docker build --target community -t "ocelotsocialnetwork/neo4j:community" neo4j/ + docker save "ocelotsocialnetwork/neo4j:community" > /tmp/neo4j.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: @@ -194,15 +194,14 @@ jobs: ########################################################################## # UNIT TESTS BACKEND ##################################################### ########################################################################## - - name: backend | copy env files webapp - run: cp webapp/.env.template webapp/.env - - name: backend | copy env files backend - run: cp backend/.env.template backend/.env + #- name: backend | copy env files webapp + # run: cp webapp/.env.template webapp/.env + #- name: backend | copy env files backend + # run: cp backend/.env.template backend/.env - name: backend | docker-compose - run: docker-compose up + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up neo4j backend - name: backend | Unit tests run: docker-compose exec backend yarn test - #run: docker run --network container:webapp-frontend appropriate/curl -s --retry 10 --retry-connrefused http://localhost:5000/ ############################################################################## # JOB: UNIT TEST WEBAPP ###################################################### @@ -230,8 +229,11 @@ jobs: ########################################################################## # UNIT TESTS WEBAPP ##################################################### ########################################################################## + - name: backend | docker-compose + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up webapp - name: webapp | Unit tests - run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test + #run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test + run: docker-compose exec webapp yarn test ############################################################################## # JOB: DOCKER BUILD PRODUCTION & PUSH ######################################## diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 5c0280667..8d1bb96f2 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -11,7 +11,7 @@ services: environment: - NODE_ENV="development" # - DEBUG=true - # - NUXT_BUILD=/tmp/nuxt # avoid file permission issues when `rm -rf .nuxt/` + - NUXT_BUILD=/tmp/nuxt # avoid file permission issues when `rm -rf .nuxt/` volumes: # This makes sure the docker container has its own node modules. # Therefore it is possible to have a different node version on the host machine diff --git a/docker-compose.test.yml b/docker-compose.test.yml new file mode 100644 index 000000000..2dfc30a6f --- /dev/null +++ b/docker-compose.test.yml @@ -0,0 +1,47 @@ +version: "3.4" + +services: + ######################################################## + # WEBAPP ############################################### + ######################################################## + webapp: + image: ocelotsocialnetwork/webapp:build + build: + target: build + environment: + - NODE_ENV="test" + + ######################################################## + # BACKEND ############################################## + ######################################################## + backend: + image: ocelotsocialnetwork/backend:build + build: + target: build + environment: + - NODE_ENV="test" + + ######################################################## + # NEO4J ################################################ + ######################################################## + neo4j: + image: ocelotsocialnetwork/neo4j:community + + ######################################################## + # MAINTENANCE ########################################## + ######################################################## + maintenance: + image: ocelotsocialnetwork/maintenance:build + + ######################################################## + # MAILSERVER TO FAKE SMTP ############################## + ######################################################## + mailserver: + image: djfarrelly/maildev + ports: + - 1080:80 + networks: + - external-net +volumes: + webapp_node_modules: + backend_node_modules: From 32bd8cca0294eea20f31f7f9e1e5b7528fab72c3 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 06:45:22 +0100 Subject: [PATCH 23/34] - copy .env files again (not sure this is correct?) --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca8e8a3f1..b5e024187 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -194,10 +194,10 @@ jobs: ########################################################################## # UNIT TESTS BACKEND ##################################################### ########################################################################## - #- name: backend | copy env files webapp - # run: cp webapp/.env.template webapp/.env - #- name: backend | copy env files backend - # run: cp backend/.env.template backend/.env + - name: backend | copy env files webapp + run: cp webapp/.env.template webapp/.env + - name: backend | copy env files backend + run: cp backend/.env.template backend/.env - name: backend | docker-compose run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up neo4j backend - name: backend | Unit tests From 71176cb11d52bc7d932700b524a3fa18cb5823ac Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 06:47:47 +0100 Subject: [PATCH 24/34] - include .envs also in webapp docker-compose ... --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5e024187..000d3f985 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -194,6 +194,7 @@ jobs: ########################################################################## # UNIT TESTS BACKEND ##################################################### ########################################################################## + # TODO: Why do we need those .envs? - name: backend | copy env files webapp run: cp webapp/.env.template webapp/.env - name: backend | copy env files backend @@ -229,6 +230,11 @@ jobs: ########################################################################## # UNIT TESTS WEBAPP ##################################################### ########################################################################## + # TODO: Why do we need those .envs? + - name: backend | copy env files webapp + run: cp webapp/.env.template webapp/.env + - name: backend | copy env files backend + run: cp backend/.env.template backend/.env - name: backend | docker-compose run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up webapp - name: webapp | Unit tests From 792ac8cc41f5672277f154b2e59bc02d7355527a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 07:05:37 +0100 Subject: [PATCH 25/34] - optimize docker-compose (ci) --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 000d3f985..1643ae95e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -200,8 +200,8 @@ jobs: - name: backend | copy env files backend run: cp backend/.env.template backend/.env - name: backend | docker-compose - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up neo4j backend - - name: backend | Unit tests + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml --detach --no-deps up neo4j backend + - name: backend | Unit test run: docker-compose exec backend yarn test ############################################################################## @@ -236,7 +236,7 @@ jobs: - name: backend | copy env files backend run: cp backend/.env.template backend/.env - name: backend | docker-compose - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up webapp + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml --detach --no-deps up webapp - name: webapp | Unit tests #run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test run: docker-compose exec webapp yarn test From 8379d8484c25f904ae4c29600aa9a0ab7ea60b49 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 07:16:25 +0100 Subject: [PATCH 26/34] - command order for docker-compose up --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1643ae95e..f088265e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -200,7 +200,7 @@ jobs: - name: backend | copy env files backend run: cp backend/.env.template backend/.env - name: backend | docker-compose - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml --detach --no-deps up neo4j backend + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps neo4j backend - name: backend | Unit test run: docker-compose exec backend yarn test @@ -236,7 +236,7 @@ jobs: - name: backend | copy env files backend run: cp backend/.env.template backend/.env - name: backend | docker-compose - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml --detach --no-deps up webapp + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp - name: webapp | Unit tests #run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test run: docker-compose exec webapp yarn test From c1b58c065103f974840c885dc03fa4cd8d8e9c2a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 07:31:17 +0100 Subject: [PATCH 27/34] - try to chain the docker-compose commands --- .github/workflows/ci.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f088265e7..74a00bd0d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -200,9 +200,11 @@ jobs: - name: backend | copy env files backend run: cp backend/.env.template backend/.env - name: backend | docker-compose - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps neo4j backend - - name: backend | Unit test - run: docker-compose exec backend yarn test + run: | + docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps neo4j backend + docker-compose exec backend yarn test + #- name: backend | Unit test + # run: docker-compose exec backend yarn test ############################################################################## # JOB: UNIT TEST WEBAPP ###################################################### @@ -235,11 +237,13 @@ jobs: run: cp webapp/.env.template webapp/.env - name: backend | copy env files backend run: cp backend/.env.template backend/.env - - name: backend | docker-compose - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp - - name: webapp | Unit tests + - name: backend | docker-compose & unit-tests + run: | + docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp + docker-compose exec webapp yarn test + #- name: webapp | Unit tests #run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test - run: docker-compose exec webapp yarn test + # run: docker-compose exec webapp yarn test ############################################################################## # JOB: DOCKER BUILD PRODUCTION & PUSH ######################################## From 51321ee4e1d1c799dd2f5121d1a00217cceca26b Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 07:41:46 +0100 Subject: [PATCH 28/34] - build development target not build --- .github/workflows/ci.yml | 18 +++++++++--------- docker-compose.test.yml | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74a00bd0d..153626587 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,12 +65,12 @@ jobs: - name: Checkout code uses: actions/checkout@v2 ########################################################################## - # BUILD BACKEND DOCKER IMAGE (build) ##################################### + # BUILD BACKEND DOCKER IMAGE (development) ############################### ########################################################################## - - name: backend | Build `build` image + - name: backend | Build `development` image run: | - docker build --target build -t "ocelotsocialnetwork/backend:build" backend/ - docker save "ocelotsocialnetwork/backend:build" > /tmp/backend.tar + docker build --target development -t "ocelotsocialnetwork/backend:development" backend/ + docker save "ocelotsocialnetwork/backend:development" > /tmp/backend.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: @@ -91,12 +91,12 @@ jobs: - name: Checkout code uses: actions/checkout@v2 ########################################################################## - # BUILD WEBAPP DOCKER IMAGE (build) ###################################### + # BUILD WEBAPP DOCKER IMAGE (development) ################################ ########################################################################## - name: webapp | Build `build` image run: | - docker build --target build -t "ocelotsocialnetwork/webapp:build" webapp/ - docker save "ocelotsocialnetwork/webapp:build" > /tmp/webapp.tar + docker build --target development -t "ocelotsocialnetwork/webapp:development" webapp/ + docker save "ocelotsocialnetwork/webapp:development" > /tmp/webapp.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: @@ -130,7 +130,7 @@ jobs: # LINT BACKEND ########################################################### ########################################################################## - name: backend | Lint - run: docker run --rm ocelotsocialnetwork/backend:build yarn run lint + run: docker run --rm ocelotsocialnetwork/backend:development yarn run lint ############################################################################## # JOB: LINT WEBAPP ########################################################### @@ -159,7 +159,7 @@ jobs: # LINT WEBAPP ############################################################ ########################################################################## - name: webapp | Lint - run: docker run --rm ocelotsocialnetwork/webapp:build yarn run lint + run: docker run --rm ocelotsocialnetwork/webapp:development yarn run lint ############################################################################## # JOB: UNIT TEST BACKEND ##################################################### diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 2dfc30a6f..4a9514c2d 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -5,9 +5,9 @@ services: # WEBAPP ############################################### ######################################################## webapp: - image: ocelotsocialnetwork/webapp:build + image: ocelotsocialnetwork/webapp:test build: - target: build + target: development environment: - NODE_ENV="test" @@ -15,9 +15,9 @@ services: # BACKEND ############################################## ######################################################## backend: - image: ocelotsocialnetwork/backend:build + image: ocelotsocialnetwork/backend:test build: - target: build + target: development environment: - NODE_ENV="test" From 27188f0b7ceaa63569fad6a4bdc4d367d8c32b7e Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 07:43:33 +0100 Subject: [PATCH 29/34] - sepperate commands againa --- .github/workflows/ci.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 153626587..123a7c2f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -200,11 +200,9 @@ jobs: - name: backend | copy env files backend run: cp backend/.env.template backend/.env - name: backend | docker-compose - run: | - docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps neo4j backend - docker-compose exec backend yarn test - #- name: backend | Unit test - # run: docker-compose exec backend yarn test + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps neo4j backend + - name: backend | Unit test + run: docker-compose exec backend yarn test ############################################################################## # JOB: UNIT TEST WEBAPP ###################################################### @@ -238,12 +236,10 @@ jobs: - name: backend | copy env files backend run: cp backend/.env.template backend/.env - name: backend | docker-compose & unit-tests - run: | - docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp - docker-compose exec webapp yarn test - #- name: webapp | Unit tests + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp + - name: webapp | Unit tests #run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test - # run: docker-compose exec webapp yarn test + run: docker-compose exec webapp yarn test ############################################################################## # JOB: DOCKER BUILD PRODUCTION & PUSH ######################################## From f633daef7723ed89cac70bb728daff6b880162d7 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 07:47:20 +0100 Subject: [PATCH 30/34] - revert some changes --- .github/workflows/ci.yml | 20 ++++++++++---------- docker-compose.test.yml | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 123a7c2f7..f088265e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,12 +65,12 @@ jobs: - name: Checkout code uses: actions/checkout@v2 ########################################################################## - # BUILD BACKEND DOCKER IMAGE (development) ############################### + # BUILD BACKEND DOCKER IMAGE (build) ##################################### ########################################################################## - - name: backend | Build `development` image + - name: backend | Build `build` image run: | - docker build --target development -t "ocelotsocialnetwork/backend:development" backend/ - docker save "ocelotsocialnetwork/backend:development" > /tmp/backend.tar + docker build --target build -t "ocelotsocialnetwork/backend:build" backend/ + docker save "ocelotsocialnetwork/backend:build" > /tmp/backend.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: @@ -91,12 +91,12 @@ jobs: - name: Checkout code uses: actions/checkout@v2 ########################################################################## - # BUILD WEBAPP DOCKER IMAGE (development) ################################ + # BUILD WEBAPP DOCKER IMAGE (build) ###################################### ########################################################################## - name: webapp | Build `build` image run: | - docker build --target development -t "ocelotsocialnetwork/webapp:development" webapp/ - docker save "ocelotsocialnetwork/webapp:development" > /tmp/webapp.tar + docker build --target build -t "ocelotsocialnetwork/webapp:build" webapp/ + docker save "ocelotsocialnetwork/webapp:build" > /tmp/webapp.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: @@ -130,7 +130,7 @@ jobs: # LINT BACKEND ########################################################### ########################################################################## - name: backend | Lint - run: docker run --rm ocelotsocialnetwork/backend:development yarn run lint + run: docker run --rm ocelotsocialnetwork/backend:build yarn run lint ############################################################################## # JOB: LINT WEBAPP ########################################################### @@ -159,7 +159,7 @@ jobs: # LINT WEBAPP ############################################################ ########################################################################## - name: webapp | Lint - run: docker run --rm ocelotsocialnetwork/webapp:development yarn run lint + run: docker run --rm ocelotsocialnetwork/webapp:build yarn run lint ############################################################################## # JOB: UNIT TEST BACKEND ##################################################### @@ -235,7 +235,7 @@ jobs: run: cp webapp/.env.template webapp/.env - name: backend | copy env files backend run: cp backend/.env.template backend/.env - - name: backend | docker-compose & unit-tests + - name: backend | docker-compose run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp - name: webapp | Unit tests #run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 4a9514c2d..2dfc30a6f 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -5,9 +5,9 @@ services: # WEBAPP ############################################### ######################################################## webapp: - image: ocelotsocialnetwork/webapp:test + image: ocelotsocialnetwork/webapp:build build: - target: development + target: build environment: - NODE_ENV="test" @@ -15,9 +15,9 @@ services: # BACKEND ############################################## ######################################################## backend: - image: ocelotsocialnetwork/backend:test + image: ocelotsocialnetwork/backend:build build: - target: development + target: build environment: - NODE_ENV="test" From 8a0b3a2826f24e29abd911e895b99b3cbe2a856a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 19:25:39 +0100 Subject: [PATCH 31/34] - build test images --- .github/workflows/ci.yml | 24 ++++++++++++------------ backend/Dockerfile | 8 ++++++++ docker-compose.test.yml | 10 +++++----- webapp/Dockerfile | 8 ++++++++ 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f088265e7..5cb21a371 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,14 +67,14 @@ jobs: ########################################################################## # BUILD BACKEND DOCKER IMAGE (build) ##################################### ########################################################################## - - name: backend | Build `build` image + - name: backend | Build `test` image run: | - docker build --target build -t "ocelotsocialnetwork/backend:build" backend/ - docker save "ocelotsocialnetwork/backend:build" > /tmp/backend.tar + docker build --target test -t "ocelotsocialnetwork/backend:test" backend/ + docker save "ocelotsocialnetwork/backend:test" > /tmp/backend.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: - name: docker-backend-image + name: docker-backend-test path: /tmp/backend.tar ############################################################################## @@ -93,14 +93,14 @@ jobs: ########################################################################## # BUILD WEBAPP DOCKER IMAGE (build) ###################################### ########################################################################## - - name: webapp | Build `build` image + - name: webapp | Build `test` image run: | - docker build --target build -t "ocelotsocialnetwork/webapp:build" webapp/ - docker save "ocelotsocialnetwork/webapp:build" > /tmp/webapp.tar + docker build --target test -t "ocelotsocialnetwork/webapp:test" webapp/ + docker save "ocelotsocialnetwork/webapp:test" > /tmp/webapp.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: - name: docker-webapp-image + name: docker-webapp-test path: /tmp/webapp.tar ############################################################################## @@ -122,7 +122,7 @@ jobs: - name: Download Docker Image (Backend) uses: actions/download-artifact@v2 with: - name: docker-backend-image + name: docker-backend-test path: /tmp - name: Load Docker Image run: docker load < /tmp/backend.tar @@ -151,7 +151,7 @@ jobs: - name: Download Docker Image (Webapp) uses: actions/download-artifact@v2 with: - name: docker-webapp-image + name: docker-webapp-test path: /tmp - name: Load Docker Image run: docker load < /tmp/webapp.tar @@ -187,7 +187,7 @@ jobs: - name: Download Docker Image (Backend) uses: actions/download-artifact@v2 with: - name: docker-backend-image + name: docker-backend-test path: /tmp - name: Load Docker Image run: docker load < /tmp/backend.tar @@ -223,7 +223,7 @@ jobs: - name: Download Docker Image (Webapp) uses: actions/download-artifact@v2 with: - name: docker-webapp-image + name: docker-webapp-test path: /tmp - name: Load Docker Image run: docker load < /tmp/webapp.tar diff --git a/backend/Dockerfile b/backend/Dockerfile index b1cd52b30..ba14e6586 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -68,6 +68,14 @@ RUN yarn install --production=false --frozen-lockfile --non-interactive # yarn build RUN yarn run build +################################################################################## +# TEST ########################################################################### +################################################################################## +FROM build as test + +# Run command +CMD /bin/sh -c "yarn run dev" + ################################################################################## # PRODUCTION (Does contain only "binary"- and static-files to reduce image size) # ################################################################################## diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 2dfc30a6f..2d382d606 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -5,9 +5,9 @@ services: # WEBAPP ############################################### ######################################################## webapp: - image: ocelotsocialnetwork/webapp:build + image: ocelotsocialnetwork/webapp:test build: - target: build + target: test environment: - NODE_ENV="test" @@ -15,9 +15,9 @@ services: # BACKEND ############################################## ######################################################## backend: - image: ocelotsocialnetwork/backend:build + image: ocelotsocialnetwork/backend:test build: - target: build + target: test environment: - NODE_ENV="test" @@ -31,7 +31,7 @@ services: # MAINTENANCE ########################################## ######################################################## maintenance: - image: ocelotsocialnetwork/maintenance:build + image: ocelotsocialnetwork/maintenance:test ######################################################## # MAILSERVER TO FAKE SMTP ############################## diff --git a/webapp/Dockerfile b/webapp/Dockerfile index a82e51f94..bf13d1db2 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -68,6 +68,14 @@ RUN yarn install --production=false --frozen-lockfile --non-interactive # yarn build RUN yarn run build +################################################################################## +# TEST ########################################################################### +################################################################################## +FROM build as test + +# Run command +CMD /bin/sh -c "yarn run dev" + ################################################################################## # PRODUCTION (Does contain only "binary"- and static-files to reduce image size) # ################################################################################## From d61820dc4f9424aa4f15548219921c6fa392f9eb Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 19:35:58 +0100 Subject: [PATCH 32/34] - fixed linting - fixed tty error on docker-compose exec --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5cb21a371..63ae925e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -130,7 +130,7 @@ jobs: # LINT BACKEND ########################################################### ########################################################################## - name: backend | Lint - run: docker run --rm ocelotsocialnetwork/backend:build yarn run lint + run: docker run --rm ocelotsocialnetwork/backend:test yarn run lint ############################################################################## # JOB: LINT WEBAPP ########################################################### @@ -159,7 +159,7 @@ jobs: # LINT WEBAPP ############################################################ ########################################################################## - name: webapp | Lint - run: docker run --rm ocelotsocialnetwork/webapp:build yarn run lint + run: docker run --rm ocelotsocialnetwork/webapp:test yarn run lint ############################################################################## # JOB: UNIT TEST BACKEND ##################################################### @@ -202,7 +202,7 @@ jobs: - name: backend | docker-compose run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps neo4j backend - name: backend | Unit test - run: docker-compose exec backend yarn test + run: docker-compose exec -T backend yarn test ############################################################################## # JOB: UNIT TEST WEBAPP ###################################################### @@ -239,7 +239,7 @@ jobs: run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp - name: webapp | Unit tests #run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test - run: docker-compose exec webapp yarn test + run: docker-compose exec -T webapp yarn test ############################################################################## # JOB: DOCKER BUILD PRODUCTION & PUSH ######################################## From 35549b7032e6c1a88bd1cacbe4b36bcb51a54880 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 20:07:57 +0100 Subject: [PATCH 33/34] - initialize database (unique constraint) --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63ae925e9..421ee24d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -201,6 +201,8 @@ jobs: run: cp backend/.env.template backend/.env - name: backend | docker-compose run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps neo4j backend + - name: backend | Initialize Database + run: docker-compose exec -T backend yarn db:init - name: backend | Unit test run: docker-compose exec -T backend yarn test From abdb53bf9002b3ff82453db5fa449e0456c271da Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 30 Jan 2021 20:23:31 +0100 Subject: [PATCH 34/34] - use the right command for db initialize --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 421ee24d5..4ebded0dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -202,7 +202,7 @@ jobs: - name: backend | docker-compose run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps neo4j backend - name: backend | Initialize Database - run: docker-compose exec -T backend yarn db:init + run: docker-compose exec -T backend yarn db:migrate init - name: backend | Unit test run: docker-compose exec -T backend yarn test