Skip to content

Commit

Permalink
feat: add github action ci
Browse files Browse the repository at this point in the history
  • Loading branch information
sumitkolhe committed Mar 16, 2024
1 parent da841a3 commit 5c85120
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI
on: [push, pull_request]
jobs:
vercel:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Cache Dependencies
uses: actions/cache@v1
with:
path: ~/.bun
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: ${{ runner.os }}-bun-

- name: Install Bun
run: |
curl -fsSL https://bun.sh/install | bash
- name: Build
run: |
bun install
bun run bundle
- name: Run Tests Locally
run: bun test

- name: Deploy to Staging
id: deploy-vercel-staging
uses: amondnet/vercel-action@v20
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID_TL_ENGINE }}
scope: ${{ secrets.VERCEL_ORG_ID }}

- name: Run Tests Against Vercel
env:
VERCEL_URL: ${{ steps.deploy-vercel-staging.outputs.preview-url }}
run: bun run test

- name: Deploy to Production
uses: amondnet/vercel-action@v20
id: deploy-vercel-production
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID_TL_ENGINE }}
vercel-args: --prod
scope: ${{ secrets.VERCEL_ORG_ID }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { beforeAll, describe, expect, test } from 'bun:test'
import { GetSongByIdUseCase } from '#modules/songs/use-cases'

describe('GetSongById', () => {
let getSongById: GetSongByIdUseCase

beforeAll(() => {
getSongById = new GetSongByIdUseCase()
})

test('should return a song by id', async () => {
const song = await getSongById.execute({ songIds: '3IoDK8qI' })
expect(song).toBeDefined()
expect(song).toHaveLength(1)
})
})

0 comments on commit 5c85120

Please sign in to comment.