From 8098ee7abd125e41b8c08a024d15502433403bd5 Mon Sep 17 00:00:00 2001 From: Jessica Date: Sun, 4 Feb 2024 13:43:23 -0500 Subject: [PATCH] set up github workflows --- .gitattributes | 1 + .github/PULL_REQUEST_TEMPLATE.md | 25 ++++++++ .github/workflows/firebase-hosting-merge.yml | 33 ++++++++++ .../firebase-hosting-pull-request.yml | 31 ++++++++++ .github/workflows/lint.yml | 60 +++++++++++++++++++ backend/typescript/prisma/index.ts | 4 ++ backend/typescript/prisma/schema.prisma | 10 ++++ docker-compose.yml | 1 + 8 files changed, 165 insertions(+) create mode 100644 .gitattributes create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/firebase-hosting-merge.yml create mode 100644 .github/workflows/firebase-hosting-pull-request.yml create mode 100644 .github/workflows/lint.yml create mode 100644 backend/typescript/prisma/index.ts create mode 100644 backend/typescript/prisma/schema.prisma diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8cfbd30 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +db-init/create-multiple-dbs.sh eol=lf diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..515b394 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,25 @@ +## Notion ticket link + +[Ticket Name](https://www.notion.so/uwblueprintexecs/Task-Board-86718c51ea274d06803384b2f8f5d201?p=b3af65cb12b44158895dfc77ff938436&pm=s) + + + +## Implementation description +* + + + +## Steps to test +1. + + + +## What should reviewers focus on? +* + + +## Checklist +- [ ] My PR name is descriptive and in imperative tense +- [ ] My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits +- [ ] I have run the appropriate linter(s) +- [ ] I have requested a review from the PL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml new file mode 100644 index 0000000..bf8ff36 --- /dev/null +++ b/.github/workflows/firebase-hosting-merge.yml @@ -0,0 +1,33 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy frontend to Firebase Hosting + +on: + push: + branches: + - main + paths: + - "frontend/**" + +defaults: + run: + working-directory: frontend + +jobs: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: echo "REACT_APP_BACKEND_URL=${{ secrets.DEV_BACKEND_URL }}" > .env + auth { + - run: echo "REACT_APP_OAUTH_CLIENT_ID=${{ secrets.DEV_OAUTH_CLIENT_ID }}" >> .env + } auth + - run: rm -rf node_modules && yarn install --frozen-lockfile && yarn build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: "${{ secrets.GITHUB_TOKEN }}" + firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_UW_BLUEPRINT_STARTER_CODE }}" + channelId: live + projectId: "${{ secrets.DEV_PROJECT_ID }}" + entryPoint: ./frontend \ No newline at end of file diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml new file mode 100644 index 0000000..122ee8a --- /dev/null +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -0,0 +1,31 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy frontend to Firebase Hosting preview + +on: + pull_request: + paths: + - "frontend/**" + +defaults: + run: + working-directory: frontend + +jobs: + build_and_preview: + if: "${{ github.event.pull_request.head.repo.full_name == github.repository && github.base_ref == 'dev' }}" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: echo "REACT_APP_BACKEND_URL=${{ secrets.PREVIEW_BACKEND_URL }}" > .env + auth { + - run: echo "REACT_APP_OAUTH_CLIENT_ID=${{ secrets.DEV_OAUTH_CLIENT_ID }}" >> .env + } auth + - run: rm -rf node_modules && yarn install --frozen-lockfile && yarn build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: "${{ secrets.GITHUB_TOKEN }}" + firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_UW_BLUEPRINT_STARTER_CODE }}" + projectId: "${{ secrets.DEV_PROJECT_ID }}" + entryPoint: ./frontend \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..bee422f --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,60 @@ +name: Lint codebase + +on: + push: + branches: + - dev + paths: + - "frontend/**" + - "backend/typescript/**" + pull_request: + branches: + - dev + paths: + - "frontend/**" + - "backend/typescript/**" + +jobs: + run-lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Filter changed files + uses: dorny/paths-filter@v2 + id: changes + with: + filters: | + frontend: + - "frontend/**" + typescript-backend: + - "backend/typescript/**" + + - name: Set up Node.js + if: steps.changes.outputs.frontend == 'true' || steps.changes.outputs.typescript-backend == 'true' + uses: actions/setup-node@v2 + with: + node-version: "18.18.2" + cache: "yarn" + cache-dependency-path: | + frontend/yarn.lock + backend/typescript/yarn.lock + + - name: Install Node.js dependencies + if: steps.changes.outputs.frontend == 'true' || steps.changes.outputs.typescript-backend == 'true' + run: yarn --cwd ./frontend --prefer-offline && yarn --cwd ./backend/typescript --prefer-offline + + - name: Generate Prisma Data Models + working-directory: ./ + run: npx prisma generate && yarn tsc + + - name: Lint frontend + if: steps.changes.outputs.frontend == 'true' + working-directory: ./frontend + run: yarn lint + + - name: Lint TypeScript backend + if: steps.changes.outputs.typescript-backend == 'true' + working-directory: ./backend/typescript + run: yarn lint \ No newline at end of file diff --git a/backend/typescript/prisma/index.ts b/backend/typescript/prisma/index.ts new file mode 100644 index 0000000..63f8bbd --- /dev/null +++ b/backend/typescript/prisma/index.ts @@ -0,0 +1,4 @@ +import { PrismaClient } from "@prisma/client"; + +const prisma = new PrismaClient(); +export default prisma; diff --git a/backend/typescript/prisma/schema.prisma b/backend/typescript/prisma/schema.prisma new file mode 100644 index 0000000..7bdb315 --- /dev/null +++ b/backend/typescript/prisma/schema.prisma @@ -0,0 +1,10 @@ +generator client { + provider = "prisma-client-js" +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} + + diff --git a/docker-compose.yml b/docker-compose.yml index 3e416c4..f81c11f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,6 +34,7 @@ services: condition: service_healthy env_file: - ./.env + - ./backend/typescript/.env db: # TODO: rename container for your project container_name: scv2_db