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

[ Docs ] Lint, Build, Assign Reviewer Workflow 생성 #13

Merged
merged 26 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
28 changes: 28 additions & 0 deletions .github/auto_assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Set to true to add reviewers to pull requests
addReviewers: true

# Set to true to add assignees to pull requests
addAssignees: author

# A list of reviewers to be added to pull requests (GitHub user name)
reviewers:
- HwangDo
- Lee jin
- ptyoiy
- wuzoo

# A number of reviewers added to the pull request
# Set 0 to add all the reviewers (default: 0)
numberOfReviewers: 0
# A list of assignees, overrides reviewers if set
# assignees:
# - assigneeA

# A number of assignees to add to the pull request
# Set to 0 to add all of the assignees.
# Uses numberOfReviewers if unset.
# numberOfAssignees: 2

# A list of keywords to be skipped the process that add reviewers if pull requests include it
# skipKeywords:
# - wip
11 changes: 11 additions & 0 deletions .github/workflows/assign-reviewer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Assign Reviewer

on:
pull_request:
types: [opened, reopened, ready_for_review]

jobs:
assign_reviewer:
runs-on: ubuntu-latest
steps:
- uses: kentaro-m/[email protected]
47 changes: 47 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build Next JS

on:
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Setup Pnpm
uses: pnpm/action-setup@v4
with:
version: 9

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

- name: Lint Check
run: pnpm biome ci --formatter-enabled=false

- name: Restore cache
uses: actions/cache@v4
with:
path: |
.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/pnpm-lock.yaml') }}-

- name: Build with Next.js
run: pnpm build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
name: build-app
path: .next
Copy link
Contributor

@hwangjokim hwangjokim Sep 9, 2024

Choose a reason for hiding this comment

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

[P4]
저는 CI에서 실제 Production 빌드 및 아티팩트 업로드까지 이루어지면 안된다고 생각합니다.
책임의 분리 관점인데요, CI 레벨에서 정말 필요한 체크는 네 가지라고 생각합니다.

  • tsc를 통한 타입스크립트 컴파일 (==컴파일타임 에러 검사)
  • lint 검사
  • 코드 포매팅 검사
  • 테스트코드 존재시 테스트 코드 Run

위 네가지는 Production 빌드를 하지 않아도 검사가 가능한 부분이고, 통합테스트가 필요한 부분이 아닙니다.

또한 CI 파이프라인의 메인 사용처는 이런 PR입니다. 아티팩트는 업로드하면 버저닝으로 기록이 계속해서 남습니다. 업로드된 아티팩트를 시간순으로 볼 수 있고, 별도로 다운로드도 가능한데요, 이렇게 CI마다 모두 빌드 및 아티팩트 업로드를 반복하면 배포 단위, feature단위로 아티팩트가 나오지 않고 각종 PR의 trivial한 커밋에 대해서도 모두 히스토리가 생겨버려 아티팩트 관리가 어려워집니다.

결론은 컴파일 검사는 tsc로 하고, restore 캐시와 빌드 및 업로드는 CD 파이프라인의 책임이 맞다고 생각합니다.

Copy link
Member Author

Choose a reason for hiding this comment

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

상세한 피드백 감사드립니다 황조님 !

말씀 정말 이해완료했습니다. CI CD 파이프라인을 구축하는데 있어서도 이런 사소한 부분들이 정말 중요하다는 걸 다시금 깨닫고 가네요 ! 지금까지 워크플로우를 작성할 때, 항상 ci cd를 같은 부분에서 작성하곤 했는데, 황조님이 말씀하신 것처럼 불필요한 pr에서까지 빌드가 되고 아티팩트가 생성된다는 점, 그리고 특정 파일이 해당 파일의 순수한 책임을 다하지 못한다는 점에서 리뷰해주신 점이 와닿은 것 같습니다.

수정해서 반영하도록 하겠습니다 ~

Copy link
Member Author

Choose a reason for hiding this comment

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

추가적으로 그렇다면 cd 파이프라인에 해당하는 부분은 deploy 브랜치에 pr 이 트리거되었을 때로 yml 파일을 따로 작성해서 생성해두면 될까요 ??

Copy link
Contributor

Choose a reason for hiding this comment

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

배포하려면 제가 갖고있는 AWS에 접근해야하고, secrets들도 설정해야 하는 부분이라 CD yml은 제가 작성하겠습니다 :D
캐시쪽부터 아티팩트까지 잘 작성해주셔서 그대로 가져다 써도 될 것 같아요

24 changes: 10 additions & 14 deletions biome.json
wuzoo marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@
"enabled": true
},
"javascript": {
"globals": [
"React"
]
"globals": ["React"]
},
"linter": {
"enabled": true,
"ignore": [
"node_modules",
"static",
".next"
],
"ignore": ["node_modules", "static", ".next"],
"rules": {
"all": true,
"complexity": {
"noUselessFragments": "off",
"noExcessiveCognitiveComplexity": "off",
"useArrowFunction": "error"
},
"a11y": {
"useButtonType": "off"
},
"style": {
"useSingleVarDeclarator": "off",
"noParameterAssign": "off",
Expand All @@ -45,7 +42,9 @@
"noUnusedImports": "warn"
},
"performance": {
"noAccumulatingSpread": "off"
"noAccumulatingSpread": "off",
"noBarrelFile": "off",
"noReExportAll": "off"
},
"nursery": {
"all": false
Expand All @@ -61,9 +60,6 @@
"indentWidth": 2
},
"files": {
"include": [
"**/*.ts",
"**/*.tsx"
]
"include": ["**/*.ts", "**/*.tsx"]
}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"react-dom": "^18"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
Expand Down
Loading