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

Replace NodeJs with Bun #7

Merged
merged 4 commits into from
Sep 9, 2023
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
14 changes: 14 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
bun.lockb
32 changes: 32 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
root: true,
extends: ["eslint:recommended", "plugin:svelte/recommended", "prettier"],
parserOptions: {
sourceType: "module",
ecmaVersion: 2020,
extraFileExtensions: [".svelte"]
},
env: {
browser: true,
es2017: true,
node: true
},
overrides: [
{
files: ["*.svelte"],
parser: "svelte-eslint-parser",
env: { browser: true, node: false },
rules: {
"no-inner-declarations": "off",
"no-self-assign": "off"
}
},
{
files: ["src/**/*.js"],
env: { browser: true, node: false }
}
],
rules: {
"no-unused-vars": "warn"
}
};
176 changes: 96 additions & 80 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,102 @@
name: Karman Web CI
name: Karman Web CI

on:
pull_request:
push:
branches: [ main ]
tags: [ "*" ]
on:
pull_request:
push:
branches: [main]
tags: ["*"]

jobs:
type-check:
name: Type Check
runs-on: ubuntu-latest
steps:
- name: Check Out Code
uses: actions/checkout@v3
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install Dependencies
run: bun install --frozen-lockfile
- name: Run Type Checking
run: bun run check

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check Out Code
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: latest
- name: Install Dependencies
run: npm ci
- name: Run Type Checking
run: npm run check
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check Out Code
uses: actions/checkout@v3
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install Dependencies
run: bun install --frozen-lockfile
- name: Run Linting
run: bun run lint

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Check Out Code
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: latest
- name: Install Dependencies
run: npm ci
- name: Run Tests
run: npm run test
test:
name: Test
runs-on: ubuntu-latest
needs: [type-check, lint]
steps:
- name: Check Out Code
uses: actions/checkout@v3
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install Dependencies
run: bun install --frozen-lockfile
- name: Run Tests
run: bun test

test-build:
name: Test Build
runs-on: ubuntu-latest
steps:
- name: Check Out Code
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: latest
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
test-build:
name: Test Build
runs-on: ubuntu-latest
needs: [type-check, lint]
steps:
- name: Check Out Code
uses: actions/checkout@v3
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install Dependencies
run: bun install --frozen-lockfile
- name: Build
run: bun run build

publish:
name: Publish
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
needs: [test, test-build]
steps:
- name: Docker Meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/Karaoke-Manager/web
flavor: |
latest=false
tags: |
type=edge,enable={{is_default_branch}}
type=semver,pattern=v{{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{version}}
type=semver,pattern=latest
- name: Login To GitHub Container Registry
uses: docker/login-action@v2
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
publish:
name: Publish
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
needs: [test, test-build]
steps:
- name: Docker Meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/Karaoke-Manager/web
flavor: |
latest=false
tags: |
type=edge,enable={{is_default_branch}}
type=semver,pattern=v{{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{version}}
type=semver,pattern=latest
- name: Login To GitHub Container Registry
uses: docker/login-action@v2
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ node_modules
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
.idea
.idea
2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

14 changes: 14 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
bun.lockb
16 changes: 16 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"useTabs": true,
"singleQuote": false,
"trailingComma": "none",
"printWidth": 120,
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
"overrides": [
{
"files": "*.svelte",
"options": {
"parser": "svelte"
}
}
],
"tailwindConfig": "./tailwind.config.cjs"
}
21 changes: 11 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
FROM node:latest AS build
FROM oven/bun:latest AS build

WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile

COPY . .
RUN npm run build
RUN bun run build

FROM node:latest

FROM oven/bun:latest
WORKDIR /app
COPY --from=build app/package.json app/package-lock.json ./
RUN npm ci --omit dev

COPY --from=build /app/build .
COPY --from=build /app/build /app/package.json /app/bun.lockb ./
RUN bun install --production
# Required by svelte-adapter-bun (for whatever reason)
RUN bun install devalue cookie set-cookie-parser

EXPOSE 3000
ENTRYPOINT ["node", "."]
ENTRYPOINT ["bun", "index.js"]
Binary file added bun.lockb
Binary file not shown.
4 changes: 0 additions & 4 deletions tsconfig.json → jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,4 @@
"sourceMap": true,
"strict": true
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
}
Loading