Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
feat: apply ci pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
jspark2000 committed Mar 1, 2024
1 parent 5cd3167 commit 5f016fe
Show file tree
Hide file tree
Showing 10 changed files with 296 additions and 3 deletions.
129 changes: 129 additions & 0 deletions .github/workflows/CI-backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: CI-Backend

on:
pull_request:
types: [opened, edited, synchronize, reopened]
paths:
- 'backend/**'

push:
branches:
- main

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node: [20]

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Generate Prisma Client
run: pnpm --filter backend exec prisma generate

- name: Build Backend
run: |
pnpm --filter backend build
- name: Cache dist
uses: actions/cache@v4
with:
path: ./*/dist
key: ${{ matrix.os }}-node-v${{ matrix.node }}-${{ github.sha }}

lint:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node: [20]

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Lint pull request title
if: ${{ github.event_name == 'pull_request' }}
run: echo "${{ github.event.pull_request.title }}" | pnpm commitlint --verbose

- name: Check style
run: pnpm --filter backend format:check

- name: Lint
run: pnpm --filter backend lint

test:
runs-on: ${{ matrix.os }}

env:
DATABASE_URL: postgresql://postgres:1234@localhost:5432/royals?schema=public

strategy:
matrix:
os: [ubuntu-latest]
node: [20]

services:
postgres:
image: postgres:15-alpine
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 1234
POSTGRES_DB: royals

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Check Prisma Migration
run: |
pnpm --filter backend exec prisma migrate diff \
--from-migrations ./prisma/migrations \
--to-schema-datamodel ./prisma/schema.prisma \
--shadow-database-url ${{ env.DATABASE_URL }} \
--exit-code ||
echo "::error::Prisma migration is not up to date. Please run `pnpm prisma migrate dev` locally and commit the changes."
- name: Migrate Prisma
run: pnpm --filter backend exec prisma migrate reset --force

- name: Check types in Typescript (Backend)
run: pnpm --filter backend exec tsc --noEmit

- name: Test
run: pnpm --filter backend test
97 changes: 97 additions & 0 deletions .github/workflows/CI-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: CI-Frontend

on:
pull_request:
types: [opened, edited, synchronize, reopened]
paths:
- 'frontend/**'

push:
branches:
- main

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node: [20]

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Build Frontend
run: pnpm --filter frontend build

- name: Cache dist
uses: actions/cache@v4
with:
path: ./*/dist
key: ${{ matrix.os }}-node-v${{ matrix.node }}-${{ github.sha }}

lint:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node: [20]

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Lint pull request title
if: ${{ github.event_name == 'pull_request' }}
run: echo "${{ github.event.pull_request.title }}" | pnpm commitlint --verbose

- name: Check style
run: pnpm --filter frontend format:check

- name: Lint
run: pnpm --filter frontend lint

test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node: [20]

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Check types in Typescript
run: pnpm --filter frontend exec tsc --noEmit
63 changes: 63 additions & 0 deletions .github/workflows/CI-infra.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI-Infra

on:
pull_request:
types: [opened, edited, synchronize, reopened]
paths:
- 'aws/**'
- 'backend/**'

push:
branches:
- main

permissions:
id-token: write
contents: read

env:
AWS_REGION: ap-northeast-2

jobs:
validation:
name: validate terraform
runs-on: ubuntu-latest
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v4

- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_GITHUB_ACTION_ROLE }}
aws-region: ${{ env.AWS_REGION }}

- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.5.2

- name: Terraform Init
working-directory: ./aws
run: terraform init

- name: Terraform Validation
working-directory: ./aws
run: terraform validate

docker-build:
name: build docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build image
uses: docker/build-push-action@v5
with:
file: ./backend/Dockerfile
push: false
tags: skku-royals/api:latest
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ node_modules/
*.md
pnpm-lock.yaml
.pnpm-store/
thunder-tests
.next/
components.json
2 changes: 1 addition & 1 deletion backend/app/src/app.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('AppController', () => {

describe('root', () => {
it('should return "Hello World!"', () => {
expect(appController.getHello()).toBe('Hello World!')
expect(appController.healthCheck()).toBe('Hello World!')
})
})
})
Empty file.
Empty file.
3 changes: 2 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"scripts": {
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"format:check": "prettier --check .",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"lint": "eslint \"{src,apps,libs}/**/*.ts\" --fix",
"test": "vitest run",
"test:cov": "vitest run --coverage"
},
Expand Down
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"format:check": "prettier --check .",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"scripts": {
"lint": "eslint . --ext .js,.ts,.jsx,.tsx",
"format": "prettier --write .",
"format:check": "prettier --check .",
"setup-minio": "ts-node scripts/setup-minio.ts"
},
"packageManager": "[email protected]",
Expand Down

0 comments on commit 5f016fe

Please sign in to comment.