GitHubActions์ reviewdog ๐ถ์ ๋์ ํ์ฌ ์๋์ผ๋ก PR ์ฝ๋ฉํธ ํ์์ผ๋ก Typescript ์ค๋ฅ๋ฅผ ์ฃผ์ ์ํค์
13966 ๋จ์ด reviewdogGitHubActionsTypeScriptGitHub
ํ๊ณ ์ถ์ ๊ฒ, ํ๋ ๊ฒ
Typescript
ํ์ ์ค๋ฅ๊ฐ ํฌํจ ๋ ์ฝ๋๋ฅผ GitHub
์ ๋ณดํธ ์ง์ ์ ๋ณํฉํ์ง ์๋๋ก GitHub Actions
๊ฒ๋ค๊ฐ tsc
๊ฐ ๊ฒ์งํ ๊ฐ์์ PR ์ฝ๋ฉํธ๋ก ์ฃผ์ํด ์ฃผ์์ผ๋ฉด ํ๋ ๋ ์ด ์๋ค. ์ด๋ฒ์ reviewdog ์ ์ฌ์ฉํด ์๋์ผ๋ก ์ฃผ์ํ๊ฒ ํ๋ค.
tsc
๊ฐ ์ฌ์ฉ๋๊ณ ์๋ ๊ธฐ์ฑํ reviewdog
์, GitHub Action
์ ์๋ฌ๋ฅผ ์๋์ผ๋ก ์ฃผ์ํด ์ค๋ค ๊ทธ๋ ๊ฒ ํ์ง ์์๊น ํ๋ ์๊ฐ.
์ฃผ์์ด ๋ฌ๋ฆฐ ๋ชจ์ต
Run eslint with reviewdog
๊ตฌํํ workflow
์ ์
ํ๋ก์ ํธ์ eslint
์ TypeScript
๊ฐ ๋์
๋์์ต๋๋ค.
yarn add -D typescript
๊ตฌํํ Workflow
๊ตฌํํ Workflow์ ํฌ์ธํธ๋ ์ดํ 2์ .
์ ์
ํ๋ก์ ํธ์
eslint
์ TypeScript
๊ฐ ๋์
๋์์ต๋๋ค.yarn add -D typescript
๊ตฌํํ Workflow
๊ตฌํํ Workflow์ ํฌ์ธํธ๋ ์ดํ 2์ .
npmใใใฑใผใธ
์ ์ ์ฌ์ฉํ๋ ๊ฒ์ผ๋ก, typescript
์์์ GithubใAction
GithubใActions
๋จ๊ณ. .github/workflows/main.yml
name: Test
on: [pull_request]
jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# ref: https://github.com/actions/setup-node#v2
- uses: actions/setup-node@v2
with:
node-version: "14"
# ref: https://github.com/reviewdog/reviewdog#github-action-reviewdogaction-setup
- uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest
# ref: https://github.com/actions/cache/blob/main/examples.md#node---yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Dependencies
run: yarn --frozen-lockfile
# ref: https://github.com/reviewdog/reviewdog#available-pre-defined-errorformat
- name: Typecheck
run: tsc --pretty false --noEmit | reviewdog -f=tsc -reporter=github-pr-review -fail-on-error=true
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.github_token }}
๊ฐ ํฌ์ธํธ์ ๋ํด
reviewdog/action-setup@v1
reviewdog/action-setup@v1 ์์
reviewdog
์์ Typecheck
๋ฅผ ์ค์นํ์ต๋๋ค. GitHub Actions
๋ ๋ค์ํ ์ฒดํฌ ํด์ ์ถ๋ ฅ์ ๋์ํ๊ณ reviewdog
์ต์
์ ๋ถ์ฌ ์คํํ๋ฉด ๊ทธ ์ผ๋์ ๋ณผ ์ ์๋ค. ์ด ๊ฒ์ฌ ๋๊ตฌ์ ์ถ๋ ฅ์ ๋ฐ์ ๊ฒฐ๊ณผ๋ฅผ reviewdog
์ PR์ ์ฃผ์์ ๋ฌ ์ ์์ต๋๋ค.-list
๊ฒฐ๊ณผterminal
โฏโฏโฏ reviewdog -list
rdjson Reviewdog Diagnostic JSON Format (JSON of DiagnosticResult message) - https://github.com/reviewdog/reviewdog
rdjsonl Reviewdog Diagnostic JSONL Format (JSONL of Diagnostic message) - https://github.com/reviewdog/reviewdog
diff Unified Diff Format - https://en.wikipedia.org/wiki/Diff#Unified_format
checkstyle checkstyle XML format - http://checkstyle.sourceforge.net/
ansible-lint (ansible-lint -p playbook.yml) Checks playbooks for practices and behaviour that could potentially be improved - https://github.com/ansible/ansible-lint
brakeman (brakeman --quiet --format tabs) A static analysis security vulnerability scanner for Ruby on Rails applications- https://github.com/presidentbeef/brakeman
cargo-check (cargo check -q --message-format=short) Check a local package and all of its dependencies for errors - https://github.com/rust-lang/cargo
clippy (cargo clippy -q --message-format=short) A bunch of lints to catch common mistakes and improve your Rust code - https://github.com/rust-lang/rust-clippy
dotenv-linter Lightning-fast linter for .env files. Written in Rust - https://github.com/dotenv-linter/dotenv-linter
dotnet (dotnet build -clp:NoSummary -p:GenerateFullPaths=true --no-incremental --nologo -v q) .NET Core CLI - https://docs.microsoft.com/en-us/dotnet/core/tools/
eslint (eslint [-f stylish]) A fully pluggable tool for identifying and reporting on patterns in JavaScript - https://github.com/eslint/eslint
eslint-compact (eslint -f compact) A fully pluggable tool for identifying and reporting on patterns in JavaScript - https://github.com/eslint/eslint
fasterer Speed improvements suggester - https://github.com/DamirSvrtan/fasterer
go-consistent Source code analyzer that helps you to make your Go programs more consistent - https://github.com/quasilyte/go-consistent
golangci-lint (golangci-lint run --out-format=line-number) GolangCI-Lint is a linters aggregator. - https://github.com/golangci/golangci-lint
golint linter for Go source code - https://github.com/golang/lint
gosec (gosec -fmt=golint) Golang Security Checker - https://github.com/securego/gosec
govet Vet examines Go source code and reports suspicious problems - https://golang.org/cmd/vet/
haml-lint Tool for writing clean and consistent HAML - https://github.com/sds/haml-lint
hlint Linter for Haskell source code - https://github.com/ndmitchell/hlint
msbuild (msbuild /property:GenerateFullPaths=true /nologo /v:q) Microsoft Build Engine - https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild
pep8 Python style guide checker - https://pypi.python.org/pypi/pep8
phpstan (phpstan --error-format=raw) PHP Static Analysis Tool - discover bugs in your code without running it! - https://github.com/phpstan/phpstan
psalm (psalm --output-format=text) Psalm is a static analysis tool for finding errors in PHP - https://github.com/vimeo/psalm
puppet-lint Check that your Puppet manifests conform to the style guide - https://github.com/rodjek/puppet-lint
reek (reek --single-line) Code smell detector for Ruby - https://github.com/troessner/reek
rubocop A Ruby static code analyzer, based on the community Ruby style guide - https://github.com/rubocop-hq/rubocop
sbt the interactive build tool - http://www.scala-sbt.org/
sbt-scalastyle Scalastyle - SBT plugin - http://www.scalastyle.org/sbt.html
scalac Scala compiler - http://www.scala-lang.org/
scalastyle Scalastyle - Command line - http://www.scalastyle.org/command-line.html
slim-lint Tool to help keep your Slim files clean and readable - https://github.com/sds/slim-lint
sorbet A fast, powerful type checker designed for Ruby - https://github.com/sorbet/sorbet
standardjs (standard) JavaScript style guide, linter, and formatter - https://github.com/standard/standard
standardrb (standard) Ruby style guide, linter, and formatter - https://github.com/testdouble/standard
stylelint A mighty modern CSS linter - https://github.com/stylelint/stylelint
tsc TypeScript compiler - https://www.typescriptlang.org/
tslint An extensible linter for the TypeScript language - https://github.com/palantir/tslint
TypeCheck ๋จ๊ณ
.github/workflows/main.yml ๋ถ๋ถ
- name: Typecheck
run: tsc --pretty false --noEmit | reviewdog -f=tsc -reporter=github-pr-review -fail-on-error=true
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.github_token }}
GitHub
์ ์ปดํ์ผ๋ฌ์ธ reviewdog -list
๋ TypeScript
์ต์
์ ๋ถ์ด๋ฉด ์๋ฌ ์ถ๋ ฅ์ด ๋จ์ํ๋๋ค. tsc
๊ฐ ๋ฐ์๋ค์ธ๋ค --pretty false
์ ์ถ๋ ฅ์ ๋จ์ํ๋ (๋ถ)ํธ์ด๋ฏ๋ก, ์ด ์ต์
์ ๋ถ์ฌํ ๊ฒ์ ํ์ดํ( reviewdog
)๋ก tsc
์ ๋ณด๋ธ๋ค.|
์ ์ ๋ฌด์ ๋ฐ๋ฅธ ์ฐจ์ดterminal
โฏโฏโฏ tsc
src/components/IndexPage.tsx:3:7 - error TS2322: Type 'string' is not assignable to type 'number'.
3 const a: number = "hoge";
~
Found 1 error.
โฏโฏโฏ tsc --pretty false
src/components/IndexPage.tsx(3,7): error TS2322: Type 'string' is not assignable to type 'number'.
reviewdog
์๋ tsc --pretty
์ต์
์ผ๋ก ์ด๋ ์ฒดํฌ ํด์ ์ถ๋ ฅ์ด ์
๋ ฅ๋๊ณ ์๋์ง ์ ํ๊ณ ์๋ค. ์ฌ๊ธฐ์ reviewdog
์ต์
๊ณผ ํ์ํ ํ๊ฒฝ ๋ณ์๋ฅผ ๋ถ์ด๋ ๊ฒ์ผ๋ก, ์๋์ผ๋ก PR์ ์ฝ๋ฉํธ๊ฐ ๋๋ค. ํ์ํ ํ๊ฒฝ ๋ณ์๋ -f
์ด๋ฉฐ, -reporter=github-pr-review
์ $REVIEWDOG_GITHUB_API_TOKEN
์์๋ ์์ ๊ฐ์ ์ค์ ์ ํ๋ฉด ๋๋ค.๋
GitHub Actions
์ Workflow
์ต์
์ ๋ถ์ด๋ ๊ฒ์ผ๋ก, ์๋ฌ๊ฐ ์
๋ ฅ๋๋ฉด reviewdog
์ PR ์ ์ฒดํฌ๋ฅผ ์คํจ์ํค๋๋ก ํ๊ณ ์๋ค.๋์
์ต๊ทผ ์ ๋ ๋น๋ก ํผ์ ๋ง๋๋ ๊ฒ๋ -fail-on-error=true
๋ฑ์ ์ ๋ํ๋ ๊ฒ์ ์ฆ๊ฒจ ํ๊ณ ์์ต๋๋ค. ์ฐ๋ฆฌ๊ฐ ๋ด๋ PR์ ์ฝ๋ฉํธ๋ฅผ ๋ฌป์ง ์๋ ๊ณณ, bot์๋ผ๋ ์ฝ๋ฉํธ๋๋ฉด ํ๊ธฐ์ฐจ๊ณ ์ข์ ๊ฒ์ด๊ตฐ์. ํผ์ ๋ง๋๋ ํ๋ก์ ํธ์ผ๋ง๋ก ๊ทธ ์ ์ ํ์ธํ ํ์๊ฐ ์๋๋ฐ, ๊ฑฐ๊ธฐ์, ๋ก๋ด์ด ๋๊ณ ๊ณ ์์ด๊ฐ ๋์ง ๋๋ฆ๋๋ก ์์ ์ ๋ถ์ฃผ์๋ฅผ ์ง์ ํด ์ฃผ์์ผ๋ฉด ํ๋ ๊ฒ์, ๋ญ๊ฐ ๋ง๋ค๊ธฐ์ ์์ด์ ๋ฌถ์ด ํ๋ ์ด์ ์ฌ๋ฏธ๋ฅผ ๋๋ผ๋ ์์์ด๊ธฐ ๋๋ฌธ์ด๋ค ๋ผ๊ณ ์๊ฐํฉ๋๋ค.
Reference
์ด ๋ฌธ์ ์ ๊ดํ์ฌ(GitHubActions์ reviewdog ๐ถ์ ๋์
ํ์ฌ ์๋์ผ๋ก PR ์ฝ๋ฉํธ ํ์์ผ๋ก Typescript ์ค๋ฅ๋ฅผ ์ฃผ์ ์ํค์), ์ฐ๋ฆฌ๋ ์ด๊ณณ์์ ๋ ๋ง์ ์๋ฃ๋ฅผ ๋ฐ๊ฒฌํ๊ณ ๋งํฌ๋ฅผ ํด๋ฆญํ์ฌ ๋ณด์๋ค
https://qiita.com/NanimonoDaemon/items/2be5ad35aa2eb100ef50
ํ
์คํธ๋ฅผ ์์ ๋กญ๊ฒ ๊ณต์ ํ๊ฑฐ๋ ๋ณต์ฌํ ์ ์์ต๋๋ค.ํ์ง๋ง ์ด ๋ฌธ์์ URL์ ์ฐธ์กฐ URL๋ก ๋จ๊ฒจ ๋์ญ์์ค.
์ฐ์ํ ๊ฐ๋ฐ์ ์ฝํ
์ธ ๋ฐ๊ฒฌ์ ์ ๋
(Collection and Share based on the CC Protocol.)
Reference
์ด ๋ฌธ์ ์ ๊ดํ์ฌ(GitHubActions์ reviewdog ๐ถ์ ๋์ ํ์ฌ ์๋์ผ๋ก PR ์ฝ๋ฉํธ ํ์์ผ๋ก Typescript ์ค๋ฅ๋ฅผ ์ฃผ์ ์ํค์), ์ฐ๋ฆฌ๋ ์ด๊ณณ์์ ๋ ๋ง์ ์๋ฃ๋ฅผ ๋ฐ๊ฒฌํ๊ณ ๋งํฌ๋ฅผ ํด๋ฆญํ์ฌ ๋ณด์๋ค https://qiita.com/NanimonoDaemon/items/2be5ad35aa2eb100ef50ํ ์คํธ๋ฅผ ์์ ๋กญ๊ฒ ๊ณต์ ํ๊ฑฐ๋ ๋ณต์ฌํ ์ ์์ต๋๋ค.ํ์ง๋ง ์ด ๋ฌธ์์ URL์ ์ฐธ์กฐ URL๋ก ๋จ๊ฒจ ๋์ญ์์ค.
์ฐ์ํ ๊ฐ๋ฐ์ ์ฝํ ์ธ ๋ฐ๊ฒฌ์ ์ ๋ (Collection and Share based on the CC Protocol.)
์ข์ ์นํ์ด์ง ์ฆ๊ฒจ์ฐพ๊ธฐ
๊ฐ๋ฐ์ ์ฐ์ ์ฌ์ดํธ ์์ง
๊ฐ๋ฐ์๊ฐ ์์์ผ ํ ํ์ ์ฌ์ดํธ 100์ ์ถ์ฒ ์ฐ๋ฆฌ๋ ๋น์ ์ ์ํด 100๊ฐ์ ์์ฃผ ์ฌ์ฉํ๋ ๊ฐ๋ฐ์ ํ์ต ์ฌ์ดํธ๋ฅผ ์ ๋ฆฌํ์ต๋๋ค