From 9a6f5218d05499d2a2444646802a49792c337110 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Sat, 9 Dec 2023 10:40:39 +0530 Subject: [PATCH] Datenbank Umstellung --- .github/workflows/build-and-test.yml | 20 +++++ .../workflows/{cd.yml => dev-pipeline.yml} | 6 +- .github/workflows/prod-pipeline.yml | 27 ++++++ README.md | 19 ++--- cypress.config.ts | 8 ++ cypress/e2e/Verbrauchsausweis/index.cy.ts | 5 ++ docker-compose.yml | 5 +- package.json | 5 +- src/layouts/Layout.astro | 6 +- src/lib/User/index.ts | 44 +++++++--- src/lib/client/Ausweis/Verbrauchsausweis.ts | 85 +++++++++++-------- src/lib/shared.ts | 2 +- src/pages/api/building/images.json.ts | 26 ++++-- src/pages/api/image.jpg.ts | 27 +++--- src/pages/api/image.json.ts | 53 ++++++++---- src/pages/index.astro | 3 +- src/style/576.scss | 6 +- src/style/global.scss | 1 - 18 files changed, 242 insertions(+), 106 deletions(-) create mode 100644 .github/workflows/build-and-test.yml rename .github/workflows/{cd.yml => dev-pipeline.yml} (86%) create mode 100644 .github/workflows/prod-pipeline.yml create mode 100644 cypress.config.ts create mode 100644 cypress/e2e/Verbrauchsausweis/index.cy.ts diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 00000000..0e190ff6 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,20 @@ +name: Build and Test + +on: + push: + branches: [ dev ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Build the application + uses: actions/checkout@v3 + - uses: oven-sh/setup-bun@v1 + with: + bun-version: "latest" + - run: bun install + - run: bun run build + - run: bun run test:unit + - run: bun run test:e2e diff --git a/.github/workflows/cd.yml b/.github/workflows/dev-pipeline.yml similarity index 86% rename from .github/workflows/cd.yml rename to .github/workflows/dev-pipeline.yml index 631fc2b8..d0486c82 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/dev-pipeline.yml @@ -1,15 +1,15 @@ -name: Node.js CD +name: Dev Pipeline on: push: - branches: [ main ] + branches: [ dev ] jobs: build: runs-on: ubuntu-latest steps: - - name: Deploy using ssh + - name: Deploy dev changes. uses: appleboy/ssh-action@master with: host: "212.227.155.91" diff --git a/.github/workflows/prod-pipeline.yml b/.github/workflows/prod-pipeline.yml new file mode 100644 index 00000000..4934f554 --- /dev/null +++ b/.github/workflows/prod-pipeline.yml @@ -0,0 +1,27 @@ +name: Production Deployment + +on: + release: + types: [ created ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Deploy to production. + uses: appleboy/ssh-action@master + with: + host: "212.227.155.91" + username: "root" + password: "!2Zc727cI1" + port: 22 + script: | + cd ~/apps/online-energieausweis + git reset --hard HEAD + git clean -f -d + git pull origin main + git status + npm install -g bun + bun install + bash build.sh diff --git a/README.md b/README.md index 8e13104b..9c1d7290 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,6 @@ - [License](#license) - [Kontakt](#kontakt) - ## Beschreibung Dies ist das Repository für das Online-Energieausweis Projekt des IBCornelsen. Eine Demo kann direkt über GitHub heruntergeladen und mit **Docker** gestartet werden. @@ -41,10 +40,10 @@ Die meisten unserer Systeme sind für Ubuntu gedacht und darauf getestet worden. Für dieses Projekt benötigst du: -* docker - * Installationsanleitungen für **docker** kannst du [hier](https://docs.docker.com/engine/install/) finden. -* Einen Package Manger deiner Wahl, du kannst **NPM**, **pNPM** oder auch **Yarn** verwenden. Wir empfehlen allerdings **bun** aufgrund der verbesserten Geschwindigkeit und dem gelieferten Feature Set, da **bun** sowohl einen Package Manager als auch einen Task Runner beinhaltet. - * Installationsanleitungen für **bun** kannst du [hier](https://bun.sh/) finden. +- docker + - Installationsanleitungen für **docker** kannst du [hier](https://docs.docker.com/engine/install/) finden. +- Einen Package Manger deiner Wahl, du kannst **NPM**, **pNPM** oder auch **Yarn** verwenden. Wir empfehlen allerdings **bun** aufgrund der verbesserten Geschwindigkeit und dem gelieferten Feature Set, da **bun** sowohl einen Package Manager als auch einen Task Runner beinhaltet. + - Installationsanleitungen für **bun** kannst du [hier](https://bun.sh/) finden. ### Installation @@ -64,10 +63,10 @@ Für dieses Projekt benötigst du: ## Nächste Schritte -* [ ] Funktionierender Checkout Flow -* [ ] Performance Optimierungen -* [ ] Automatische Tests -* [ ] Dokumentation +- [ ] Funktionierender Checkout Flow +- [ ] Performance Optimierungen +- [ ] Automatische Tests +- [ ] Dokumentation Siehe alle [offenen issues](https://github.com/IBCornelsen/online-energieausweis/issues) für eine Liste der vorgeschlagenen Features (und bekannten Probleme). @@ -89,4 +88,4 @@ Veröffentlicht unter der GPL-3.0 Lizenz. Siehe `LICENSE` für mehr Information. IBCornelsen - [info@ibcornelsen.de](mailto://info@ibcornelsen.de) -Organisation: [https://github.com/IBCornelsen](https://github.com/IBCornelsen) \ No newline at end of file +Organisation: [https://github.com/IBCornelsen](https://github.com/IBCornelsen) diff --git a/cypress.config.ts b/cypress.config.ts new file mode 100644 index 00000000..ed29bbe8 --- /dev/null +++ b/cypress.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'cypress' + +export default defineConfig({ + e2e: { + baseUrl: 'http://localhost:3000', + supportFile: false + }, +}) \ No newline at end of file diff --git a/cypress/e2e/Verbrauchsausweis/index.cy.ts b/cypress/e2e/Verbrauchsausweis/index.cy.ts new file mode 100644 index 00000000..6c50bf7b --- /dev/null +++ b/cypress/e2e/Verbrauchsausweis/index.cy.ts @@ -0,0 +1,5 @@ +describe('The Home page.', () => { + it("successfully loads", () => { + cy.visit("/") + }) +}) \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 92e3f836..dfc9894c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,18 +8,21 @@ services: - database environment: PORT: 3000 - DB_CONNECTION: "postgresql://main:hHMP8cd^N3SnzGRR@database:5432/main" + DB_CONNECTION: ${DATABASE_URL} NODE_ENV: "development" ports: - 3000:3000 volumes: - ./:/online-energieausweis - ./node_modules/@ibcornelsen/ui:/online-energieausweis/node_modules/@ibcornelsen/ui + - ./node_modules/@ibcornelsen/database:/online-energieausweis/node_modules/@ibcornelsen/database - ./persistent:/persistent networks: - postgres database: build: ../database + env_file: + - ../database/.env ports: - "5436:5432" networks: diff --git a/package.json b/package.json index c79cb1fd..18343998 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "test:unit": "bun test", "format": "prettier --write .", "build:production": "astro build && bun --bun server.js", - "i18n:generate": "bunx astro-i18next generate" + "i18n:generate": "bunx astro-i18next generate", + "prisma:studio": "bunx prisma studio --schema=./node_modules/@ibcornelsen/database/prisma/schema.prisma" }, "private": true, "dependencies": { @@ -20,6 +21,7 @@ "@astrojs/node": "^5.1.4", "@astrojs/svelte": "^2.2.0", "@astrojs/tailwind": "^3.1.3", + "@ibcornelsen/database": "link:@ibcornelsen/database", "@ibcornelsen/ui": "^0.0.2", "@mollie/api-client": "^3.7.0", "astro": "^2.5.1", @@ -50,6 +52,7 @@ "@types/uuid": "^9.0.1", "@typescript-eslint/eslint-plugin": "^5.59.6", "@typescript-eslint/parser": "^5.59.6", + "cypress": "^13.6.1", "eslint": "~8.15.0", "eslint-config-prettier": "8.1.0", "prettier": "^2.8.8", diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 948adbf1..0240d48e 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -1,6 +1,5 @@ --- import i18next from "i18next"; -import { HeadHrefLangs } from "astro-i18next/components"; import "../style/global.scss"; import Footer from "../components/Footer.astro"; @@ -108,6 +107,11 @@ const schema = JSON.stringify({