From 934d7bfe1679ec8a6e8143a4b6a965a08bd1ff8b Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Mon, 16 Oct 2023 17:40:02 +0200 Subject: [PATCH 01/18] added a mono demo image --- .../workflows/Build_and_Publish_Images.yaml | 19 ++- Dockerfile | 108 ++++++++++++++++++ backend/src/database/insertExampleData.js | 104 +++++++++++++++++ 3 files changed, 229 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 backend/src/database/insertExampleData.js diff --git a/.github/workflows/Build_and_Publish_Images.yaml b/.github/workflows/Build_and_Publish_Images.yaml index 3f1b563d5..d364da0da 100644 --- a/.github/workflows/Build_and_Publish_Images.yaml +++ b/.github/workflows/Build_and_Publish_Images.yaml @@ -3,7 +3,7 @@ name: Build and Publish Docker Image on: push: tags: - - 'Seed-Test_v*' + - "Seed-Test_v*" jobs: build-and-publish: @@ -50,4 +50,19 @@ jobs: - name: Push Docker Image to Docker Hub run: | docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:${{ steps.get_tag_name.outputs.version }} - docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:latest \ No newline at end of file + docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:latest + + # SINGLE QUICK DEMO CONTAINER + - name: Build Docker Image as Latest + run: | + docker build -t seed-test-demo:${{ steps.get_tag_name.outputs.version }} . + + - name: Tag Docker Image as Latest + run: | + docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }} + docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:latest + + - name: Push Docker Image to Docker Hub + run: | + docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }} + docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..c3a8b13e9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,108 @@ +FROM node:18.13 + +RUN apt-get update +RUN yes | apt-get install wget + +# Set DATABASE_URI to be localhost +ENV DATABASE_URI=mongodb://localhost:27017 + +# Create app directory +WORKDIR /usr/src/app + +# install mongoDB +RUN yes | apt-get install gnupg curl +RUN curl -fsSL https://pgp.mongodb.com/server-7.0.asc | \ + gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \ + --dearmor +RUN echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] http://repo.mongodb.org/apt/debian bullseye/mongodb-org/7.0 main" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list +RUN apt-get update +RUN apt-get install -y mongodb-org +RUN mkdir /data +RUN mkdir /data/db +RUN mongod --fork --logpath /var/log/mongodb.log + +# ----- BACKEND (from /backend dockerfile) ----------------------------------------------------------------------- + +# install chrome +RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb +RUN yes | apt install ./google-chrome-stable_current_amd64.deb +RUN rm -f google-chrome-stable_current_amd64.deb + +# install chromedriver +RUN google-chrome --version | grep -oP '\d+\.\d+\.\d+\.\d+' > chromeversion.txt +RUN apt-get install -yqq unzip curl +RUN wget -O /tmp/chromedriverzip.zip https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/$(cat chromeversion.txt)/linux64/chromedriver-linux64.zip +RUN unzip /tmp/chromedriverzip.zip chromedriver-linux64/chromedriver -d /usr/local/bin/ +RUN mv /usr/local/bin/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver + +# install firefox +RUN wget -O ~/FirefoxSetup.tar.bz2 "https://download.mozilla.org/?product=firefox-latest&os=linux64" +RUN tar xjf ~/FirefoxSetup.tar.bz2 -C /opt/ +RUN ln -s /opt/firefox/firefox /usr/local/bin/ +RUN apt-get update && apt-get install -y wget bzip2 libxtst6 libgtk-3-0 libx11-xcb-dev libdbus-glib-1-2 libxt6 libpci-dev && rm -rf /var/lib/apt/lists/* + +# install edge +RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg +RUN install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/ +RUN sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list' +RUN rm microsoft.gpg +RUN apt update && yes | apt install microsoft-edge-stable +# include in path +RUN export PATH=$PATH:/opt/microsoft/msedge/ +ENV PATH="${PATH}:/opt/microsoft/msedge/" + +# install msedgedriver +# # Extract the latest stable version of edge +RUN msedge --version | sed 's/.*Edge \([0-9.]*\).*/\1/' > latest_stable.txt + +# # Remove the driver-pagehtml +RUN wget -O /tmp/msedgedriver.zip https://msedgedriver.azureedge.net/$(cat latest_stable.txt)/edgedriver_linux64.zip +RUN unzip /tmp/msedgedriver.zip msedgedriver -d /usr/local/bin/ +RUN rm -f latest_stable.txt + +WORKDIR /usr/src/app/backend +# Bundle app source +COPY ./backend . + +RUN npm ci +# If you are building your code for production +# RUN npm ci --only=production + +EXPOSE 8080 + +# Start dbus-daemon for google-chrome +RUN service dbus start + +# ----- FRONTEND (from /frontend dockerfile) --------------------------------------------------------------------- + +# Create app directory +WORKDIR /usr/src/app/frontend + +# Copy package.json and package-lock.json +COPY ./frontend/package*.json ./ + +# Install dependencies +RUN npm ci --ignore-scripts + +# Install Angular CLI +RUN npm install --ignore-scripts -g @angular/cli + +COPY ./frontend . + +EXPOSE 4200 +EXPOSE 27017-27019 +RUN npm run build + +# ----------------------------------------------------------------------------------------------------------------- + +# Create a startup script +RUN echo "#!/bin/sh" > /usr/src/app/start.sh && \ + echo "mongod --fork --logpath /var/log/mongodb.log" >> /usr/src/app/start.sh && \ + echo "cd /usr/src/app/backend && npm run database && npm run database-examples && npm run start &" >> /usr/src/app/start.sh && \ + echo "cd /usr/src/app/frontend && node server.js" >> /usr/src/app/start.sh + +# Make the script executable +RUN chmod +x /usr/src/app/start.sh + +# Set the script as the ENTRYPOINT +ENTRYPOINT ["/usr/src/app/start.sh"] \ No newline at end of file diff --git a/backend/src/database/insertExampleData.js b/backend/src/database/insertExampleData.js new file mode 100644 index 000000000..2e59adfbb --- /dev/null +++ b/backend/src/database/insertExampleData.js @@ -0,0 +1,104 @@ +const { exit } = require('process'); +const bcrypt = require('bcrypt'); +const dbService = require('./DbServices'); +require('dotenv').config(); + +const exampleUser = 'seed@test.de'; +const examplePassword = 'seedtest'; +const exampleStory = 'Example Story'; +const exampleDescription = 'Example Description'; +const exampleScenario = { + scenario_id: 1, + name: 'Example Scenario', + comment: null, + stepDefinitions: { + given: [ + { + id: 1, + mid: '', + pre: 'I am on the website:', + stepType: 'given', + type: 'Website / URL', + values: [ + 'https://www.youtube.com/' + ], + isExample: [ + false + ] + } + ], + when: [], + then: [ + { + id: 1, + mid: '', + pre: 'I take a screenshot. Optionally: Focus the page on the element', + stepType: 'then', + type: 'Screenshot', + values: [ + '' + ], + isExample: [ + false + ] + } + ], + example: [] + }, + browser: 'chrome', + lastTestPassed: null +}; + +const uri = process.env.DATABASE_URI || 'mongodb://SeedAdmin:SeedTest@localhost:27017'; + +async function insertExampleUser() { + try { + // eslint-disable-next-line max-len + const result = await dbService.registerUser({ email: exampleUser, password: bcrypt.hashSync(examplePassword, bcrypt.genSaltSync(10)) }); + console.log('\x1b[32mExample-User inserted! \n\x1b[0m'); + return result; + } catch (error) { + console.log(`\x1b[31m${error} \x1b[0m`); + return dbService.getUserByEmail(exampleUser); + } +} + +async function insertExampleTest(user) { + try { + // createRepository + const repoId = await dbService.createRepo(user.insertedId, 'Test Repo'); + console.log('\x1b[32mExample-Repo inserted! \n\x1b[0m'); + // createStory + const storyId = await dbService.createStory(exampleStory, exampleDescription, repoId); + await dbService.insertStoryIdIntoRepo(storyId, repoId); + console.log('\x1b[32mExample-Story inserted! \n\x1b[0m'); + // fillTestScenario + await dbService.updateScenario(storyId, exampleScenario); + console.log('\x1b[32mExample-Scenario-Data inserted! \n\x1b[0m'); + } catch (error) { + console.log(`\x1b[31m${error} \x1b[0m`); + } +} + +async function insertExampleData() { + // wait to give establishConnection enough time to establish connection xD + await new Promise((resolve) => { + setTimeout(() => { + resolve(); + }, 1500); + }); + console.log(`\x1b[33mSetting Up DB-Exampel-Data in: ${uri}\n\x1b[0m`); + console.log('\x1b[34mInserting Example User: \x1b[0m'); + const user = await insertExampleUser(); + console.log('\x1b[34mInserting Example Test: \x1b[0m'); + await insertExampleTest(user); + console.log('\x1b[32mExample-Data set up! \x1b[0m'); +} + +insertExampleData().then(() => { + exit(); +}) + .catch((err) => { + console.error(err); + exit(1); + }); From 6e53f06ce33c5405f785cd94052cd8b2412821eb Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Mon, 16 Oct 2023 18:17:34 +0200 Subject: [PATCH 02/18] added demo --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 148694c5e..1a2548e65 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,36 @@ Seed-Test is a website user interface testing tool, which uses approaches of beh Please contact us via mail seed-test@adesso.de +Seed-Test can be installed via docker or by hand. + +## **Give Seed-Test Demo a Try!** + +Seed-Test offers a handy demo version that's ready for you to dive into. If you're just looking to test out Seed-Test, you can easily do so by installing this demo. + +**Prerequisites** + +Before you begin, make sure you have [Docker](https://www.docker.com/products/docker-desktop/) installed. + +**Installation** + +Follow these simple steps to get up and running: + +- Open your terminal and run this command: + + ``` + docker run seedtest/seed-test-demo:latest + ``` + +**Try Seed-Test in Your Browser** + +Now, you can try out Seed-Test in your web browser by visiting `http://localhost:4200/login`. + +Have Fun! + +**Important Note** + +⚠️ Please note that Seed-Test's demo version is for testing purposes only and should not be used in a production environment. For production use, consider using the full version of Seed-Test.Test completely check out the Installation section bellow. + ## Installation Seed-Test can be installed via docker or by hand. From 66888ef161741f3b3074c3e956d6cc8d185dccf2 Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Tue, 17 Oct 2023 10:28:39 +0200 Subject: [PATCH 03/18] Typo --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1a2548e65..862fcf924 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,11 @@ Seed-Test can be installed via docker or by hand. Seed-Test offers a handy demo version that's ready for you to dive into. If you're just looking to test out Seed-Test, you can easily do so by installing this demo. -**Prerequisites** +#### Prerequisites Before you begin, make sure you have [Docker](https://www.docker.com/products/docker-desktop/) installed. -**Installation** +#### Installation Follow these simple steps to get up and running: @@ -40,9 +40,9 @@ Now, you can try out Seed-Test in your web browser by visiting `http://localhost Have Fun! -**Important Note** +#### Important Note -⚠️ Please note that Seed-Test's demo version is for testing purposes only and should not be used in a production environment. For production use, consider using the full version of Seed-Test.Test completely check out the Installation section bellow. +⚠️ Please note that Seed-Test's demo version is for testing purposes only and should not be used in a production environment. For production use, consider using the full version of Seed-Test. Check out the Installation section bellow. ## Installation From 40dce4c374e4e21926fbec9594ab1ec7e6cdaa2f Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Tue, 17 Oct 2023 10:29:23 +0200 Subject: [PATCH 04/18] Typo --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 862fcf924..49cac4f01 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,9 @@ Now, you can try out Seed-Test in your web browser by visiting `http://localhost Have Fun! -#### Important Note +#### ⚠️ Important Note -⚠️ Please note that Seed-Test's demo version is for testing purposes only and should not be used in a production environment. For production use, consider using the full version of Seed-Test. Check out the Installation section bellow. +Please note that Seed-Test's demo version is for testing purposes only and should not be used in a production environment. For production use, consider using the full version of Seed-Test. Check out the Installation section bellow. ## Installation From 20f2aad51d74648abdb2377f49f42715aca07db4 Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Tue, 17 Oct 2023 10:41:09 +0200 Subject: [PATCH 05/18] Updated action to trigger on test realeases --- .github/workflows/Build_and_Publish_Images.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/Build_and_Publish_Images.yaml b/.github/workflows/Build_and_Publish_Images.yaml index d364da0da..9638ebb20 100644 --- a/.github/workflows/Build_and_Publish_Images.yaml +++ b/.github/workflows/Build_and_Publish_Images.yaml @@ -4,6 +4,7 @@ on: push: tags: - "Seed-Test_v*" + - "Test_v*" jobs: build-and-publish: From 1518de2c24c941b297f36dc025729fb5226ec12f Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Tue, 17 Oct 2023 11:08:54 +0200 Subject: [PATCH 06/18] added test publish action --- .../workflows/Build_and_Publish_Images.yaml | 1 - .../Test_Build_and_Publish_Images.yaml | 68 +++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/Test_Build_and_Publish_Images.yaml diff --git a/.github/workflows/Build_and_Publish_Images.yaml b/.github/workflows/Build_and_Publish_Images.yaml index 9638ebb20..d364da0da 100644 --- a/.github/workflows/Build_and_Publish_Images.yaml +++ b/.github/workflows/Build_and_Publish_Images.yaml @@ -4,7 +4,6 @@ on: push: tags: - "Seed-Test_v*" - - "Test_v*" jobs: build-and-publish: diff --git a/.github/workflows/Test_Build_and_Publish_Images.yaml b/.github/workflows/Test_Build_and_Publish_Images.yaml new file mode 100644 index 000000000..b12f3d68e --- /dev/null +++ b/.github/workflows/Test_Build_and_Publish_Images.yaml @@ -0,0 +1,68 @@ +name: Build and Publish Docker Image + +on: + push: + tags: + - "Test_v*" + +jobs: + build-and-publish: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Get Tag Name + id: get_tag_name + run: | + version=$(echo $GITHUB_REF) + echo "version=${version}" >> ${GITHUB_OUTPUT} + + # BACKEND + - name: Build Docker Image + run: docker build -t seed-test-backend:${{ steps.get_tag_name.outputs.version }} ./backend + + - name: Tag Docker Image as Latest + run: | + docker tag seed-test-backend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:${{ steps.get_tag_name.outputs.version }} + docker tag seed-test-backend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:latest + + - name: Push Docker Image to Docker Hub + run: | + docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:${{ steps.get_tag_name.outputs.version }} + docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:latest + + # FRONTEND + - name: Build Docker Image + run: docker build -t seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ./frontend + + - name: Tag Docker Image as Latest + run: | + docker tag seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:${{ steps.get_tag_name.outputs.version }} + docker tag seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:latest + + - name: Push Docker Image to Docker Hub + run: | + docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:${{ steps.get_tag_name.outputs.version }} + docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:latest + + # SINGLE QUICK DEMO CONTAINER + - name: Build Docker Image as Latest + run: | + docker build -t seed-test-demo:${{ steps.get_tag_name.outputs.version }} . + + - name: Tag Docker Image as Latest + run: | + docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }} + docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:latest + + - name: Push Docker Image to Docker Hub + run: | + docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }} + docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:latest From 2aa99d88c1992e218bc9dd16ec3a31cbe6feae38 Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Tue, 17 Oct 2023 15:05:15 +0200 Subject: [PATCH 07/18] added example data script --- README.md | 11 ++++++++--- backend/package.json | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 49cac4f01..61635bf73 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Please contact us via mail seed-test@adesso.de Seed-Test can be installed via docker or by hand. -## **Give Seed-Test Demo a Try!** +## 🚀Give Seed-Test Demo a Try! Seed-Test offers a handy demo version that's ready for you to dive into. If you're just looking to test out Seed-Test, you can easily do so by installing this demo. @@ -36,9 +36,14 @@ Follow these simple steps to get up and running: **Try Seed-Test in Your Browser** -Now, you can try out Seed-Test in your web browser by visiting `http://localhost:4200/login`. +Now, you can experience Seed-Test in your web browser at http://localhost:4200. -Have Fun! +An example user account is ready for you to explore. + +- E-Mail: `seed@test.de` +- Password: `seedtest` + +Have Fun! 🚀🌟 #### ⚠️ Important Note diff --git a/backend/package.json b/backend/package.json index f185e42a5..6815717cd 100644 --- a/backend/package.json +++ b/backend/package.json @@ -9,6 +9,7 @@ "test": "jest --verbose", "test-coverage": "jest --coverage", "database": "node src/database/installDatabase.js", + "database-examples": "node src/database/insertExampleData.js", "clean": "rimraf ./dist", "tsc": "tsc", "lint": "./node_modules/.bin/eslint src/database --fix", @@ -69,6 +70,8 @@ "/spec/serverHelper.spec.js", "/node_modules/" ], - "setupFiles": ["./spec/setupTest.js"] + "setupFiles": [ + "./spec/setupTest.js" + ] } } From 31c4bc46c01311ad1bbae1251f2be147667cd94d Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Tue, 17 Oct 2023 15:13:34 +0200 Subject: [PATCH 08/18] readme update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 61635bf73..4abe63f25 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Follow these simple steps to get up and running: - Open your terminal and run this command: ``` - docker run seedtest/seed-test-demo:latest + docker run -p 4200:4200 -p 8080:8080 seedtest/seed-test-demo:latest ``` **Try Seed-Test in Your Browser** From 168afa010f4d924bb611fa27fe52e759b7772df1 Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Tue, 17 Oct 2023 15:28:24 +0200 Subject: [PATCH 09/18] updated triggers for building images --- .github/workflows/Build_and_Publish_Images.yaml | 8 ++++++-- .github/workflows/Test_Build_and_Publish_Images.yaml | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Build_and_Publish_Images.yaml b/.github/workflows/Build_and_Publish_Images.yaml index d364da0da..51661d67f 100644 --- a/.github/workflows/Build_and_Publish_Images.yaml +++ b/.github/workflows/Build_and_Publish_Images.yaml @@ -1,8 +1,12 @@ name: Build and Publish Docker Image on: - push: - tags: + release: + types: + - published + - edited + - deleted + name: - "Seed-Test_v*" jobs: diff --git a/.github/workflows/Test_Build_and_Publish_Images.yaml b/.github/workflows/Test_Build_and_Publish_Images.yaml index b12f3d68e..b29e1aae2 100644 --- a/.github/workflows/Test_Build_and_Publish_Images.yaml +++ b/.github/workflows/Test_Build_and_Publish_Images.yaml @@ -1,8 +1,12 @@ name: Build and Publish Docker Image on: - push: - tags: + release: + types: + - published + - edited + - deleted + name: - "Test_v*" jobs: From 43219c67dc3c096ff3acf0ebf74c46270fc2c64f Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Tue, 17 Oct 2023 15:32:38 +0200 Subject: [PATCH 10/18] Revert "updated triggers for building images" This reverts commit 168afa010f4d924bb611fa27fe52e759b7772df1. --- .github/workflows/Build_and_Publish_Images.yaml | 8 ++------ .github/workflows/Test_Build_and_Publish_Images.yaml | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/Build_and_Publish_Images.yaml b/.github/workflows/Build_and_Publish_Images.yaml index 51661d67f..d364da0da 100644 --- a/.github/workflows/Build_and_Publish_Images.yaml +++ b/.github/workflows/Build_and_Publish_Images.yaml @@ -1,12 +1,8 @@ name: Build and Publish Docker Image on: - release: - types: - - published - - edited - - deleted - name: + push: + tags: - "Seed-Test_v*" jobs: diff --git a/.github/workflows/Test_Build_and_Publish_Images.yaml b/.github/workflows/Test_Build_and_Publish_Images.yaml index b29e1aae2..b12f3d68e 100644 --- a/.github/workflows/Test_Build_and_Publish_Images.yaml +++ b/.github/workflows/Test_Build_and_Publish_Images.yaml @@ -1,12 +1,8 @@ name: Build and Publish Docker Image on: - release: - types: - - published - - edited - - deleted - name: + push: + tags: - "Test_v*" jobs: From e41e29ec4b536bf703edfe958444536ebc1ff5ba Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Tue, 17 Oct 2023 15:45:35 +0200 Subject: [PATCH 11/18] updated triggers --- .github/workflows/Build_and_Publish_Images.yaml | 7 +++++-- .github/workflows/Test_Build_and_Publish_Images.yaml | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Build_and_Publish_Images.yaml b/.github/workflows/Build_and_Publish_Images.yaml index d364da0da..23417357b 100644 --- a/.github/workflows/Build_and_Publish_Images.yaml +++ b/.github/workflows/Build_and_Publish_Images.yaml @@ -1,8 +1,11 @@ name: Build and Publish Docker Image on: - push: - tags: + release: + types: + - published + - edited + name: - "Seed-Test_v*" jobs: diff --git a/.github/workflows/Test_Build_and_Publish_Images.yaml b/.github/workflows/Test_Build_and_Publish_Images.yaml index b12f3d68e..076b906fb 100644 --- a/.github/workflows/Test_Build_and_Publish_Images.yaml +++ b/.github/workflows/Test_Build_and_Publish_Images.yaml @@ -1,8 +1,11 @@ name: Build and Publish Docker Image on: - push: - tags: + release: + types: + - published + - edited + name: - "Test_v*" jobs: From ac313d04ecd72cb74934f8d835f2d679ac8fa384 Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Tue, 17 Oct 2023 16:26:04 +0200 Subject: [PATCH 12/18] updated build action --- .../workflows/Build_and_Publish_Images.yaml | 81 ++++++++++++++++++- .../Test_Build_and_Publish_Images.yaml | 71 ---------------- 2 files changed, 78 insertions(+), 74 deletions(-) delete mode 100644 .github/workflows/Test_Build_and_Publish_Images.yaml diff --git a/.github/workflows/Build_and_Publish_Images.yaml b/.github/workflows/Build_and_Publish_Images.yaml index 23417357b..318f023d5 100644 --- a/.github/workflows/Build_and_Publish_Images.yaml +++ b/.github/workflows/Build_and_Publish_Images.yaml @@ -5,12 +5,11 @@ on: types: - published - edited - name: - - "Seed-Test_v*" jobs: - build-and-publish: + build-and-publish-release: runs-on: ubuntu-latest + if: startsWith(github.event.release.name, 'Seed-Test_v') steps: - name: Checkout Repository uses: actions/checkout@v2 @@ -69,3 +68,79 @@ jobs: run: | docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }} docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:latest + + - name: Post susccess message + uses: ./actions/notifyTeams + with: + title: "Publish Release DockerHub 🐳🌐" + text: "Published Images for release ${{ github.event.release.name }} successfully." + style: "success" + webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + + - name: Post error message + if: ${{ failure() }} + with: + title: "Publish Release DockerHub 🐳🌐❌" + text: "Published Images for release ${{ github.event.release.name }} failed." + style: "failure" + webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + + build-and-publish-test: + runs-on: ubuntu-latest + if: startsWith(github.event.release.name, 'Test_v') + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Get Tag Name + id: get_tag_name + run: | + version=$(echo $GITHUB_REF | sed 's/refs\/tags\///') + echo "version=${version}" >> ${GITHUB_OUTPUT} + + # BACKEND + - name: Build Docker Image + run: docker build -t seed-test-backend:${{ steps.get_tag_name.outputs.version }} ./backend + + - name: Push Docker Image to Docker Hub + run: | + docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:${{ steps.get_tag_name.outputs.version }} + + # FRONTEND + - name: Build Docker Image + run: docker build -t seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ./frontend + + - name: Push Docker Image to Docker Hub + run: | + docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:${{ steps.get_tag_name.outputs.version }} + + # SINGLE QUICK DEMO CONTAINER + - name: Build Docker Image as Latest + run: | + docker build -t seed-test-demo:${{ steps.get_tag_name.outputs.version }} . + + - name: Push Docker Image to Docker Hub + run: | + docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }} + + - name: Post susccess message + uses: ./actions/notifyTeams + with: + title: "Publish Test-Release DockerHub 🧪🐳🌐" + text: "Published Images for test-release ${{ github.event.release.name }} successfully." + style: "success" + webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + + - name: Post error message + if: ${{ failure() }} + with: + title: "Publish Test-Release DockerHub 🐳🌐❌" + text: "Published Images for test-release ${{ github.event.release.name }} failed." + style: "failure" + webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} diff --git a/.github/workflows/Test_Build_and_Publish_Images.yaml b/.github/workflows/Test_Build_and_Publish_Images.yaml deleted file mode 100644 index 076b906fb..000000000 --- a/.github/workflows/Test_Build_and_Publish_Images.yaml +++ /dev/null @@ -1,71 +0,0 @@ -name: Build and Publish Docker Image - -on: - release: - types: - - published - - edited - name: - - "Test_v*" - -jobs: - build-and-publish: - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Get Tag Name - id: get_tag_name - run: | - version=$(echo $GITHUB_REF) - echo "version=${version}" >> ${GITHUB_OUTPUT} - - # BACKEND - - name: Build Docker Image - run: docker build -t seed-test-backend:${{ steps.get_tag_name.outputs.version }} ./backend - - - name: Tag Docker Image as Latest - run: | - docker tag seed-test-backend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:${{ steps.get_tag_name.outputs.version }} - docker tag seed-test-backend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:latest - - - name: Push Docker Image to Docker Hub - run: | - docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:${{ steps.get_tag_name.outputs.version }} - docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:latest - - # FRONTEND - - name: Build Docker Image - run: docker build -t seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ./frontend - - - name: Tag Docker Image as Latest - run: | - docker tag seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:${{ steps.get_tag_name.outputs.version }} - docker tag seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:latest - - - name: Push Docker Image to Docker Hub - run: | - docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:${{ steps.get_tag_name.outputs.version }} - docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:latest - - # SINGLE QUICK DEMO CONTAINER - - name: Build Docker Image as Latest - run: | - docker build -t seed-test-demo:${{ steps.get_tag_name.outputs.version }} . - - - name: Tag Docker Image as Latest - run: | - docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }} - docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:latest - - - name: Push Docker Image to Docker Hub - run: | - docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }} - docker push ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:latest From 505e7a77752b656f177deb9c18614da7463ef13d Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Tue, 17 Oct 2023 16:44:19 +0200 Subject: [PATCH 13/18] action updated --- .github/workflows/Build_and_Publish_Images.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/Build_and_Publish_Images.yaml b/.github/workflows/Build_and_Publish_Images.yaml index 318f023d5..be2a1c7a0 100644 --- a/.github/workflows/Build_and_Publish_Images.yaml +++ b/.github/workflows/Build_and_Publish_Images.yaml @@ -79,6 +79,7 @@ jobs: - name: Post error message if: ${{ failure() }} + uses: ./actions/notifyTeams with: title: "Publish Release DockerHub 🐳🌐❌" text: "Published Images for release ${{ github.event.release.name }} failed." @@ -139,6 +140,7 @@ jobs: - name: Post error message if: ${{ failure() }} + uses: ./actions/notifyTeams with: title: "Publish Test-Release DockerHub 🐳🌐❌" text: "Published Images for test-release ${{ github.event.release.name }} failed." From 69acdb7e3b5b18ab1d5680b21b82da3ac657142a Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Tue, 17 Oct 2023 17:05:04 +0200 Subject: [PATCH 14/18] action update --- .github/workflows/Build_and_Publish_Images.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/Build_and_Publish_Images.yaml b/.github/workflows/Build_and_Publish_Images.yaml index be2a1c7a0..915edc8ee 100644 --- a/.github/workflows/Build_and_Publish_Images.yaml +++ b/.github/workflows/Build_and_Publish_Images.yaml @@ -14,6 +14,9 @@ jobs: - name: Checkout Repository uses: actions/checkout@v2 + - name: Install Dependencies + run: npm install node-fetch + - name: Login to Docker Hub uses: docker/login-action@v2 with: @@ -93,6 +96,9 @@ jobs: - name: Checkout Repository uses: actions/checkout@v2 + - name: Install Dependencies + run: npm install node-fetch + - name: Login to Docker Hub uses: docker/login-action@v2 with: From 0dbb6a484185b906063eb861b6d681f1593bea4f Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Tue, 17 Oct 2023 17:13:50 +0200 Subject: [PATCH 15/18] update --- .github/workflows/Build_and_Publish_Images.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Build_and_Publish_Images.yaml b/.github/workflows/Build_and_Publish_Images.yaml index 915edc8ee..0930e7e22 100644 --- a/.github/workflows/Build_and_Publish_Images.yaml +++ b/.github/workflows/Build_and_Publish_Images.yaml @@ -113,7 +113,9 @@ jobs: # BACKEND - name: Build Docker Image - run: docker build -t seed-test-backend:${{ steps.get_tag_name.outputs.version }} ./backend + run: | + docker build -t seed-test-backend:${{ steps.get_tag_name.outputs.version }} ./backend + docker tag seed-test-backend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-backend:${{ steps.get_tag_name.outputs.version }} - name: Push Docker Image to Docker Hub run: | @@ -121,7 +123,9 @@ jobs: # FRONTEND - name: Build Docker Image - run: docker build -t seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ./frontend + run: | + docker build -t seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ./frontend + docker tag seed-test-frontend:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-frontend:${{ steps.get_tag_name.outputs.version }} - name: Push Docker Image to Docker Hub run: | @@ -131,6 +135,7 @@ jobs: - name: Build Docker Image as Latest run: | docker build -t seed-test-demo:${{ steps.get_tag_name.outputs.version }} . + docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:latest - name: Push Docker Image to Docker Hub run: | From de387d6c085dd835451c4b3ae3bbfbf2973b37ce Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Tue, 17 Oct 2023 17:28:01 +0200 Subject: [PATCH 16/18] action done --- .github/workflows/Build_and_Publish_Images.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/Build_and_Publish_Images.yaml b/.github/workflows/Build_and_Publish_Images.yaml index 0930e7e22..f117b046c 100644 --- a/.github/workflows/Build_and_Publish_Images.yaml +++ b/.github/workflows/Build_and_Publish_Images.yaml @@ -76,7 +76,7 @@ jobs: uses: ./actions/notifyTeams with: title: "Publish Release DockerHub 🐳🌐" - text: "Published Images for release ${{ github.event.release.name }} successfully." + text: "Publishing Images for release ${{ github.event.release.name }} successfully." style: "success" webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} @@ -85,7 +85,7 @@ jobs: uses: ./actions/notifyTeams with: title: "Publish Release DockerHub 🐳🌐❌" - text: "Published Images for release ${{ github.event.release.name }} failed." + text: "Publishing Images for release ${{ github.event.release.name }} failed." style: "failure" webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} @@ -135,7 +135,7 @@ jobs: - name: Build Docker Image as Latest run: | docker build -t seed-test-demo:${{ steps.get_tag_name.outputs.version }} . - docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:latest + docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:l${{ steps.get_tag_name.outputs.version }} - name: Push Docker Image to Docker Hub run: | @@ -145,7 +145,7 @@ jobs: uses: ./actions/notifyTeams with: title: "Publish Test-Release DockerHub 🧪🐳🌐" - text: "Published Images for test-release ${{ github.event.release.name }} successfully." + text: "Publishing Images for test-release ${{ github.event.release.name }} successfully." style: "success" webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} @@ -154,6 +154,6 @@ jobs: uses: ./actions/notifyTeams with: title: "Publish Test-Release DockerHub 🐳🌐❌" - text: "Published Images for test-release ${{ github.event.release.name }} failed." + text: "Publishing Images for test-release ${{ github.event.release.name }} failed." style: "failure" webhook: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} From 871fa0a04084afba5e618530f76826d7b9dfc040 Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Tue, 17 Oct 2023 17:50:34 +0200 Subject: [PATCH 17/18] typo --- .github/workflows/Build_and_Publish_Images.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build_and_Publish_Images.yaml b/.github/workflows/Build_and_Publish_Images.yaml index f117b046c..13ce5a0b3 100644 --- a/.github/workflows/Build_and_Publish_Images.yaml +++ b/.github/workflows/Build_and_Publish_Images.yaml @@ -135,7 +135,7 @@ jobs: - name: Build Docker Image as Latest run: | docker build -t seed-test-demo:${{ steps.get_tag_name.outputs.version }} . - docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:l${{ steps.get_tag_name.outputs.version }} + docker tag seed-test-demo:${{ steps.get_tag_name.outputs.version }} ${{ secrets.DOCKER_USERNAME }}/seed-test-demo:${{ steps.get_tag_name.outputs.version }} - name: Push Docker Image to Docker Hub run: | From ea2da49b65a31453bf3ada5612bade8e171a414c Mon Sep 17 00:00:00 2001 From: i3rotlher Date: Wed, 18 Oct 2023 18:34:33 +0200 Subject: [PATCH 18/18] sonar issues --- Dockerfile | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index c3a8b13e9..85414fd2c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ FROM node:18.13 -RUN apt-get update -RUN yes | apt-get install wget +RUN apt-get update && apt-get -y install wget # Set DATABASE_URI to be localhost ENV DATABASE_URI=mongodb://localhost:27017 @@ -10,13 +9,12 @@ ENV DATABASE_URI=mongodb://localhost:27017 WORKDIR /usr/src/app # install mongoDB -RUN yes | apt-get install gnupg curl +RUN apt-get -y install gnupg curl RUN curl -fsSL https://pgp.mongodb.com/server-7.0.asc | \ gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \ --dearmor RUN echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] http://repo.mongodb.org/apt/debian bullseye/mongodb-org/7.0 main" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list -RUN apt-get update -RUN apt-get install -y mongodb-org +RUN apt-get update && apt-get -y install mongodb-org RUN mkdir /data RUN mkdir /data/db RUN mongod --fork --logpath /var/log/mongodb.log @@ -25,7 +23,7 @@ RUN mongod --fork --logpath /var/log/mongodb.log # install chrome RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -RUN yes | apt install ./google-chrome-stable_current_amd64.deb +RUN apt-get -y install ./google-chrome-stable_current_amd64.deb RUN rm -f google-chrome-stable_current_amd64.deb # install chromedriver @@ -46,7 +44,7 @@ RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > mic RUN install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/ RUN sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list' RUN rm microsoft.gpg -RUN apt update && yes | apt install microsoft-edge-stable +RUN apt-get update && apt-get install -y microsoft-edge-stable # include in path RUN export PATH=$PATH:/opt/microsoft/msedge/ ENV PATH="${PATH}:/opt/microsoft/msedge/" @@ -60,6 +58,9 @@ RUN wget -O /tmp/msedgedriver.zip https://msedgedriver.azureedge.net/$(cat lates RUN unzip /tmp/msedgedriver.zip msedgedriver -d /usr/local/bin/ RUN rm -f latest_stable.txt +# Clean up the cache after installing all necessary packages +RUN apt-get update && apt-get clean && rm -rf /var/lib/apt/lists/* + WORKDIR /usr/src/app/backend # Bundle app source COPY ./backend .