Skip to content

Commit

Permalink
feat: update actions with db
Browse files Browse the repository at this point in the history
  • Loading branch information
ManasC478 committed Oct 9, 2024
1 parent 2814c36 commit 7a390d7
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 57 deletions.
95 changes: 38 additions & 57 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,57 @@ name: CI

on:
push:
branches:
- "**" # currently run on all branches
pull_request:
types: [opened, synchronize, reopened]

jobs:
test:
runs-on: ubuntu-latest

typecheck:
runs-on: ubunut-latest
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup
with:
os: ${{ runner.os }}

- name: Run tests
run: |
cd server
bun test
- uses: actions/checkout@v4

- name: Typecheck
run: |
docker build --target=typecheck --no-cache .
lint:
runs-on: ubuntu-latest
runs-on: ubunut-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

- uses: ./.github/actions/setup
with:
os: ${{ runner.os }}
- uses: actions/checkout@v4

- name: Lint check
run: |
docker build --target=lint --no-cache .
- name: Lint fix
run: |
cd server/
bun lint --fix
- name: Commit lint fix
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
if ! git diff --exit-code > /dev/null
then
git commit -a -m "lint fix"
git push
fi
test:
runs-on: ubuntu-latest
services:
db:
image: postgres:latest
ports:
- 5432:5432
volumes:
- acm_website_db_data:/var/lib/postgresql/data
- ./db-scripts:/docker-entrypoint-initdb.d/
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 5s
--health-timeout 5s
--health-retries 5
--health-start-period 15s
--env-file .env
steps:
- uses: actions/checkout@v4

- name: Run linter
- name: Test
run: |
cd server
bun run lint
docker build --target=test --no-cache .
typecheck:
build:
needs: [typecheck, lint, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup
with:
os: ${{ runner.os }}

- name: Run typecheck
- name: Build
run: |
cd server
bun run typecheck
pr-check:
if: github.event_name == 'pull_request'
needs: [test, lint, typecheck]
runs-on: ubuntu-latest
steps:
- name: PR is ready to be merged
run: echo "All checks passed. PR is ready to be merged."
docker build --target=run --no-cache .
21 changes: 21 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM oven/bun:alpine as base
RUN apk --no-cache add curl
WORKDIR /app

FROM base as install
COPY package.json bun.lockb ./
RUN bun install
COPY . /app

FROM install as typecheck
RUN bun run typecheck

FROM install as lint
RUN bun run lint

FROM install as test
RUN bun test

FROM install as run
EXPOSE 5001
CMD ["bun", "run", "dev"]

0 comments on commit 7a390d7

Please sign in to comment.