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

Setup GitHub Actions workflow for formatting, linting, and typechecking #17

Merged
merged 6 commits into from
Jan 24, 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
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