Skip to content

Commit

Permalink
🏗️ change to bun (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
woohm402 authored Aug 15, 2024
1 parent 7ca2c1b commit 1408b29
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 2,584 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
node-version: '20.11.1'
bun-version: 1.1.13
- name: Install dependencies
run: yarn
run: bun install
- name: Check Type
run: yarn tsc
run: bun tsc
- name: Check format
run: yarn format
run: bun format
- name: Check lint
run: yarn lint
- name: Run tests
run: yarn test
run: bun lint
18 changes: 5 additions & 13 deletions .github/workflows/weekly-dashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,17 @@ jobs:
cron:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
fetch-depth: 2

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: '20.15.0'
cache: 'yarn'
bun-version: 1.1.13

# cron job을 실행합니다.
- name: run script
run: |
yarn install
bun install
SLACK_WEEKLY_CHANNEL_ID=C06M9K1LT36 \
SLACK_AUTH_TOKEN=${{ secrets.SLACK_AUTH_TOKEN }} \
GHP_ACCESS_TOKEN=${{ secrets.GHP_ACCESS_TOKEN }} \
GITHUB_ORGANIZATION=wafflestudio \
yarn send:weekly-dashboard
env:
NODE_OPTIONS: --max_old_space_size=4096
bun send:weekly-dashboard
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20.11.1-alpine
FROM oven/bun:1.1.13
ARG SLACK_BOT_TOKEN
ARG SLACK_AUTH_TOKEN
ARG SLACK_WATCHER_CHANNEL_ID
Expand All @@ -10,7 +10,7 @@ RUN echo "SLACK_AUTH_TOKEN=${SLACK_AUTH_TOKEN}" >> .env.local
RUN echo "SLACK_WATCHER_CHANNEL_ID=${SLACK_WATCHER_CHANNEL_ID}" >> .env.local
RUN echo "DEPLOY_WATCHER_CHANNEL_ID=${DEPLOY_WATCHER_CHANNEL_ID}" >> .env.local
RUN echo "OPENAI_API_KEY=${OPENAI_API_KEY}" >> .env.local
RUN yarn install
CMD ["yarn", "start:server"]
RUN bun install
CMD ["bun", "start:server"]

EXPOSE 3000
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

## setup

먼저 [`bun`](https://bun.sh/) 이 설치되어 있어야 합니다.

아래 환경변수들을 `.env.local` 에 세팅해주세요.

```env
Expand All @@ -40,21 +42,21 @@ OPENAI_API_KEY=sk-...
서버를 띄우려면 아래와 같이 수행해주세요.

```bash
yarn start:server
bun start:server
```

weekly dashboard 전송을 테스트하려면 아래와 같이 수행해주세요.

```bash
yarn send:weekly-dashboard
bun send:weekly-dashboard
```

## deploy

서버를 배포하려면 아래와 같이 수행해주세요.

```bash
yarn deploy:server
bun deploy:server
```

weekly dashboard 는 github actions 로 수행되기에 별도의 배포가 필요하지 않습니다.
Binary file added bun.lockb
Binary file not shown.
12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,25 @@
"private": false,
"scripts": {
"start:server": "tsx src/server.ts",
"deploy:server": "scripts/deploy.sh",
"deploy:server": "./scripts/deploy.sh",
"send:weekly-dashboard": "tsx src/weekly-dashboard.ts",
"test": "vitest --run",
"lint": "eslint ./src",
"format": "prettier . --check"
},
"engines": {
"node": ">=20.11.1"
},
"dependencies": {
"express": "4.19.2",
"octokit": "4.0.2",
"openai": "4.55.7"
},
"devDependencies": {
"@types/bun": "1.1.6",
"@types/express": "4.17.21",
"@types/node": "22.3.0",
"@woohm402/eslint-config-base": "0.7.0",
"dotenv": "16.4.5",
"eslint": "9.9.0",
"knip": "5.27.2",
"prettier": "3.3.3",
"tsx": "4.17.0",
"typescript": "5.5.4",
"vitest": "2.0.5"
"typescript": "5.5.4"
}
}
2 changes: 1 addition & 1 deletion src/services/DashboardService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Member } from '../entities/Member';
import { getScore } from '../entities/Score';
import { MessengerPresenter } from '../presenters/MessengerPresenter';

export type DashboardService = {
type DashboardService = {
sendWeeklyDashboard: (organization: string) => Promise<void>;
};

Expand Down
2 changes: 1 addition & 1 deletion src/services/SlackEventService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type SlackEvent } from '../entities/Slack';
import { MessengerPresenter } from '../presenters/MessengerPresenter';

export type SlackEventService = {
type SlackEventService = {
handleVerification: (body: { challenge: string }) => string;
handleEvent: (event: SlackEvent) => Promise<void>;
};
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"allowArbitraryExtensions": true,
"esModuleInterop": true,
"skipLibCheck": true,
"noUncheckedIndexedAccess": true,
"types": ["vitest/globals"]
"noUncheckedIndexedAccess": true
}
}
5 changes: 0 additions & 5 deletions vitest.config.ts

This file was deleted.

Loading

0 comments on commit 1408b29

Please sign in to comment.