Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created Separate Production Environment and Added Linter to Backend #17

Merged
merged 9 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 0 additions & 73 deletions .github/workflows/build_test.yml

This file was deleted.

56 changes: 42 additions & 14 deletions .github/workflows/deploy_dev.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,51 @@
name: Deploy Backend to Dev Environment
name: Deploy Backend to Development Environment

on:
push:
branches:
- dev

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: aws-actions/setup-sam@v2
- uses: aws-actions/[email protected]
with:
role-to-assume: arn:aws:iam::122610496633:role/GitHubDeployRole
aws-region: us-east-2
- run: cd backend && npm run build && sam build --use-container --template-file template.yml
- run: cd backend && sam deploy --no-confirm-changeset --no-fail-on-empty-changeset --template-file template.yml
deploy-dev:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Sam CLI
uses: aws-actions/setup-sam@v2

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: backend/node_modules
key: ${{ runner.os }}-backend-node-${{ hashFiles('backend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-backend-node-

- name: Install dependencies
working-directory: backend
run: npm install

- name: Build
working-directory: backend
run: npm run build && sam build --use-container

- name: Configure AWS Credentials for Development Account
uses: aws-actions/[email protected]
with:
role-to-assume: arn:aws:iam::122610496633:role/GitHubDeployRole
aws-region: us-east-2

- name: Deploy to Development
working-directory: backend
run: sam deploy --no-confirm-changeset --no-fail-on-empty-changeset --parameter-overrides Stage=dev
51 changes: 51 additions & 0 deletions .github/workflows/deploy_prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Deploy Backend to Production Environment

on:
push:
branches:
- main

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

jobs:
deploy-prod:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Sam CLI
uses: aws-actions/setup-sam@v2

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: backend/node_modules
key: ${{ runner.os }}-backend-node-${{ hashFiles('backend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-backend-node-

- name: Install dependencies
working-directory: backend
run: npm install

- name: Build
working-directory: backend
run: npm run build && sam build --use-container

- name: Configure AWS Credentials for Production Account
uses: aws-actions/[email protected]
with:
role-to-assume: arn:aws:iam::864899856155:oidc-provider/token.actions.githubusercontent.com
aws-region: us-east-2

- name: Deploy to Production
working-directory: backend
run: sam deploy --no-confirm-changeset --no-fail-on-empty-changeset --parameter-overrides Stage=prod
51 changes: 51 additions & 0 deletions .github/workflows/test_backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Test Backend

on:
pull_request:
branches:
- main
- dev

permissions:
contents: read
actions: read
repository-projects: read
issues: read
pull-requests: read

jobs:
test-backend:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: backend/node_modules
key: ${{ runner.os }}-backend-node-${{ hashFiles('backend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-backend-node-

- name: Install dependencies
working-directory: backend
run: npm install

- name: Lint Backend
working-directory: backend
run: npm run lint

- name: Run Backend Tests
working-directory: backend
run: npm run test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LOG_FILE: test.log
LOG_LEVEL: 2
54 changes: 54 additions & 0 deletions .github/workflows/test_frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and Test Frontend

on:
pull_request:
branches:
- main
- dev

permissions:
contents: read
actions: read

jobs:
test-frontend:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: frontend/node_modules
key: ${{ runner.os }}-frontend-node-${{ hashFiles('frontend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-frontend-node-

- name: Install dependencies
working-directory: frontend
run: npm install

- name: Lint
working-directory: frontend
run: npm run lint

- name: Cache Next.js build
uses: actions/cache@v4
with:
path: |
~/.npm
${{ github.workspace }}/frontend/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('frontend/package-lock.json') }}-${{ hashFiles('frontend/**/*.{js,jsx,ts,tsx}') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('frontend/package-lock.json') }}-

- name: Build
working-directory: frontend
run: npm run build
14 changes: 14 additions & 0 deletions backend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";


/** @type {import('eslint').Linter.Config[]} */
export default [
{files: ["**/*.{js,mjs,cjs,ts}"]},
{files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}},
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
{ignores: ["**/node_modules/**", "**/dist/**", "**/build/**"]},
];
Loading
Loading