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

[Feat] PR lint, tsc, prettier 검사 workflow 구현 #120

Merged
merged 13 commits into from
Nov 10, 2024
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
41 changes: 41 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Check PR

on:
pull_request:
branches:
- main
- develop

jobs:
check:
runs-on: ubuntu-latest

steps:
- name: Checkout Branch
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: latest

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'pnpm'

- name: Install Packages
run: pnpm install --frozen-lockfile

- name: Run Check Scripts
run: |
set -o pipefail
pnpm run check | tee check.log

- name: Print Summary
run: |
echo "## Check Result" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "$(cat check.log)" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
Comment on lines +37 to +41
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 부분은 어떤 동작을 하나요?

Copy link
Collaborator Author

@simeunseo simeunseo Nov 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 workflow의 동작 내용과 결과를 출력하는 코드입니다! PR의 Checks 탭 > Check PR > Summary 에서 볼 수 있습니다

4 changes: 2 additions & 2 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## .github/workflows/labeler.yml
name: labeler
name: PR Size Labeler

on: [pull_request]

Expand All @@ -13,7 +13,7 @@ jobs:
name: Label the PR size
steps:
- uses: codelytv/pr-size-labeler@v1

with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
xs_label: 'size/xs'
Expand Down
6 changes: 4 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
"scripts": {
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"",
"typecheck": "tsc --noEmit",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
Expand All @@ -26,7 +28,7 @@
"@nestjs/platform-express": "^10.0.0",
"@nestjs/swagger": "^8.0.1",
"@nestjs/typeorm": "^10.0.2",
"@repo/shards": "workspace:*",
"@repo/shared": "workspace:*",
"@repo/types": "workspace:*",
"mysql2": "^3.11.3",
"reflect-metadata": "^0.2.0",
Expand Down
8 changes: 5 additions & 3 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
"typecheck": "tsc --noEmit",
"preview": "vite preview",
"format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx,json,md}\""
},
"dependencies": {
"@repo/shards": "workspace:*",
"@repo/shared": "workspace:*",
"@repo/types": "workspace:*",
"@tanstack/react-router": "^1.79.0",
"@tanstack/router-vite-plugin": "^1.79.0",
"prettier-plugin-tailwindcss": "^0.6.8",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
Expand All @@ -34,6 +35,7 @@
"eslint-plugin-react-refresh": "^0.4.14",
"globals": "^15.11.0",
"postcss": "^8.4.47",
"prettier-plugin-tailwindcss": "^0.6.8",
"tailwindcss": "^3.4.14",
"typescript": "~5.6.2",
"vite": "^5.4.10",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createRouter, RouterProvider } from '@tanstack/react-router';

import { routeTree } from './routeTree.gen';

const router = createRouter({ routeTree });
declare module '@tanstack/react-router' {
interface Register {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/common/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Link } from '@tanstack/react-router';
/**@desc router 테스트를 위해 임시 구현한 Header입니다. */
function Header() {
return (
<nav className="p-5 flex gap-2 border border-main">
<nav className="flex gap-2 border border-main p-5">
<Link to="/" className="[&.active]:font-bold">
티클
</Link>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Link } from '@tanstack/react-router';
/**@desc router 테스트를 위해 임시 구현한 DashboardTab입니다. */
function DashboardTab() {
return (
<nav className="p-5 flex gap-2">
<nav className="flex gap-2 p-5">
<Link to="/dashboard/apply" className="[&.active]:font-bold">
신청한 티클 관리
</Link>
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ function IndexPage() {
return (
<>
<Link to="/ticle/open">티클 개설하기</Link>
<div className="flex m-5 gap-2">
<Link to="/ticle/$ticleId" params={{ ticleId: '1' }} className="p-4 border border-main">
<div className="m-5 flex gap-2">
<Link to="/ticle/$ticleId" params={{ ticleId: '1' }} className="border border-main p-4">
Ticle 1
</Link>
<Link to="/ticle/$ticleId" params={{ ticleId: '2' }} className="p-4 border border-main">
<Link to="/ticle/$ticleId" params={{ ticleId: '2' }} className="border border-main p-4">
Ticle 2
</Link>
<Link to="/ticle/$ticleId" params={{ ticleId: '3' }} className="p-4 border border-main">
<Link to="/ticle/$ticleId" params={{ ticleId: '3' }} className="border border-main p-4">
Ticle 3
</Link>
</div>
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
"scripts": {
"dev": "turbo dev",
"lint": "turbo lint",
"typecheck": "turbo typecheck",
"build": "turbo run build",
"build:apps": "turbo run build --filter=./apps/*",
"build:packages": "turbo run build --filter=./packages/*",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,md}\"",
"prepare": "husky"
"prepare": "husky",
"check": "turbo run lint typecheck format:check --parallel"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turpo.json 을 통해 script에 대한 명령를 정의할 수 있지않나요?

lint와 typecheck를 같이 진행하는 이유가 있을까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turpo.json 을 통해 script에 대한 명령를 정의할 수 있지않나요?

이 말씀은 아래처럼 check script를 turbo.json으로 옮겼으면 좋겠다는 말씀이실까요?!

// turbo.json
{
  "tasks": {
    "check": {
      "dependsOn": ["lint", "typecheck", "format:check"],
      "cache": true
    }
  }
}

// package.json
{
  "scripts": {
    "check": "turbo run check"
  }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lint와 typecheck를 같이 진행하는 이유가 있을까요?

이 workflow의 목적이 PR에 대해 lint, tsc, prettier 검사를 하는것이기 때문에 같이 진행하는것인데
같이 진행하지 않는다면 어떤 방법을 생각하시는 건지 궁금합니다!!

},
"devDependencies": {
"husky": "^9.1.6",
Expand Down
4 changes: 0 additions & 4 deletions packages/eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ module.exports = {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-non-null-assertion': 'warn',
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: 'import', next: '*' },
],

// 분리된 규칙들 병합
...namingConfig.rules,
Expand Down
1 change: 1 addition & 0 deletions packages/eslint/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ module.exports = {
},
},
],
'import/newline-after-import': 'error',
},
};
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/shards/index.ts → packages/shared/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const shards = {
export const shared = {
asdasd: 1,
asdww: 1,
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@repo/shards",
"name": "@repo/shared",
"version": "0.0.0",
"private": true,
"main": "./dist/index.js",
Expand Down
File renamed without changes.
Loading
Loading