Skip to content

Commit

Permalink
Setup GitHub Actions workflow for formatting, linting, and typechecki…
Browse files Browse the repository at this point in the history
…ng (#17)
  • Loading branch information
RishikeshNK authored Jan 24, 2024
1 parent a6399f7 commit fef59d9
Show file tree
Hide file tree
Showing 13 changed files with 2,117 additions and 827 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
93 changes: 93 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: CI

on:
push:
branches:
- main
pull_request:

env:
NODE_VERSION: 20
PNPM_VERSION: 8

# Find a workaround to this.
DATABASE_URL: "postgresql://admin:admin@localhost:5432/cooper?schema=public"
NEXTAUTH_URL: "localhost:3000"

jobs:
lint:
name: Run Eslint And Prettier
runs-on: ubuntu-latest
steps:
- name: Code Checkout
uses: actions/checkout@v4

- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
run_install: false

- name: Get pnpm Store Directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm Cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Dependencies
run: pnpm install

- name: Code Linting
run: pnpm run lint

- name: Code Formatting
run: pnpm run format:check

tsc:
name: Run Typescript Compiler
runs-on: ubuntu-latest
steps:
- name: Code Checkout
uses: actions/checkout@v4

- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
run_install: false

- name: Get pnpm Store Directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm Cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Dependencies
run: pnpm install

- name: Code Typechecking
run: pnpm tsc
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ docker compose up -d
> **Note:** The `docker-compose.yml` file sets the `POSTGRES_USER` as "admin", `POSTGRES_PASSWORD` as "admin", and `POSTGRES_DB` as "cooper" by default.
5. Sync the `prisma` schema with the database schema. Do **not** run this in a production environment.

```bash
pnpm dlx prisma db push
```
Expand All @@ -72,4 +73,4 @@ cp .env.example .env
```env
DATABASE_URL="postgresql://admin:admin@localhost:5432/cooper?schema=public"
NEXTAUTH_URL="localhost:3000"
```
```
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.8'
version: "3.8"

services:
postgres:
Expand All @@ -11,6 +11,6 @@ services:
volumes:
- postgres:/var/lib/postgresql/data
ports:
- '5432:5432'
- "5432:5432"
volumes:
postgres:
postgres:
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"dev": "next dev",
"postinstall": "prisma generate",
"lint": "next lint",
"format:check": "prettier --check --ignore-path .gitignore .",
"format": "prettier --write --ignore-path .gitignore .",
"start": "next start"
},
"dependencies": {
Expand Down
Loading

0 comments on commit fef59d9

Please sign in to comment.