Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Sep 15, 2023
0 parents commit 3cd042d
Show file tree
Hide file tree
Showing 169 changed files with 15,192 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.vscode/
node_modules/
dist/
npm-debug.log

dist
apps/apps/core/dist
4 changes: 4 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
POSTGRES_PASSWORD=password
POSTGRES_USER=postgres

DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@127.0.0.1:5432/nest-drizzle?schema=public
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL=postgresql://postgres:password@127.0.0.1:5432/nest-drizzle-test?schema=public
27 changes: 27 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
extends: ['@innei/eslint-config-ts'],
root: true,
plugins: ['unused-imports', '@typescript-eslint'],
rules: {
'no-empty': 'warn',
'no-fallthrough': 'error',
'no-unused-vars': 'off', // or "@typescript-eslint/no-unused-vars": "off",
'@typescript-eslint/no-unused-vars': 'off',
'unused-imports/no-unused-imports': 'error',
'@typescript-eslint/consistent-type-imports': [
'warn',
{
prefer: 'no-type-imports',
},
],
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
},
}
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.paw filter=lfs diff=lfs merge=lfs -text

53 changes: 53 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js Build CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

services:
postgres:
image: postgres

env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres

options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2.4.0
with:
version: 8.x.x
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Install Dependencies
run: |
pnpm i --no-optional
- name: Build project
run: |
npm run build
57 changes: 57 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Docker Build

on:
push:
branches:
- main
tags:
- 'v*'

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
nest/nest-http
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and export to Docker
uses: docker/build-push-action@v4
with:
context: .
load: true
tags: ${{ steps.meta.outputs.tags }},nest/nest-http:latest
labels: ${{ steps.meta.outputs.labels }}
- name: Test
run: |
bash ./scripts/workflow/test-docker.sh
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
context: .
# push: ${{ startsWith(github.ref, 'refs/tags/v') }}
push: false
tags: ${{ steps.meta.outputs.tags }},nest/nest-http:latest
labels: ${{ steps.meta.outputs.labels }}
133 changes: 133 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
on:
push:
tags:
- 'v*'

name: Release

jobs:
build:
name: Upload Release Asset
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
outputs:
release_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Start MongoDB
uses: supercharge/mongodb-github-action@v1.10.0
with:
mongodb-version: 4.4
- name: Start Redis
uses: supercharge/redis-github-action@1.7.0
with:
redis-version: 6
- uses: pnpm/action-setup@v2.4.0
with:
version: 8.x.x
run_install: true
- name: Test
run: |
npm run lint
npm run test
npm run test:e2e
- name: Build project
run: |
pnpm run bundle
- name: Test Bundle Server
run: |
bash scripts/workflow/test-server.sh
# - name: Zip Assets
# run: |
# sh scripts/zip-asset.sh
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./release.zip
asset_name: release-${{ matrix.os }}.zip
asset_content_type: application/zip
# deploy:
# name: Deploy To Remote Server
# runs-on: ubuntu-latest
# needs: [build]
# steps:
# - name: Exec deploy script with SSH
# uses: appleboy/ssh-action@master
# env:
# JWTSECRET: ${{ secrets.JWTSECRET }}
# with:
# command_timeout: 10m
# host: ${{ secrets.HOST }}
# username: ${{ secrets.USER }}
# password: ${{ secrets.PASSWORD }}
# envs: JWTSECRET
# script_stop: true
# script: |
# whoami
# cd
# source ~/.zshrc
# cd mx
# ls -a
# node server-deploy.js --jwtSecret=$JWTSECRET

build_other_platform:
name: Build Other Platform
strategy:
matrix:
os: [macos-latest]
runs-on: ${{ matrix.os }}
needs: [build]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache pnpm modules
uses: actions/cache@v3
env:
cache-name: cache-pnpm-modules
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-
- uses: pnpm/action-setup@v2.4.0
with:
version: 8.x.x
run_install: true
- name: Build project
run: |
pnpm run bundle
- name: Zip Assets
run: |
sh scripts/zip-asset.sh
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.build.outputs.release_url }}
asset_path: ./release.zip
asset_name: release-${{ matrix.os }}.zip
asset_content_type: application/zip
62 changes: 62 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js Test CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres

env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres

options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v4
- name: Start Redis
uses: supercharge/redis-github-action@1.7.0
with:
redis-version: 6

- uses: pnpm/action-setup@v2.4.0
with:
version: 8.x.x
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm i
- name: Run Test
run: |
pnpm run lint
pnpm run pretest
pnpm run test
env:
CI: true
DATABASE_URL: 'postgres://postgres:postgres@localhost:5432/postgres?schema=public'
Loading

0 comments on commit 3cd042d

Please sign in to comment.