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

日本語のリンター (textlint) 追加 #352

Merged
merged 50 commits into from
Sep 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
df91483
textlint追加
massongit Sep 10, 2020
983a9f7
対象外のコメントが消されないようにする
massongit Sep 10, 2020
187c5f3
コメントするジョブとPRを出すジョブを分離
massongit Sep 10, 2020
e33441a
Yahoo!は文法的に間違っていない
massongit Sep 10, 2020
b4b9bf1
Add exit
massongit Sep 10, 2020
e367ba7
Fix
massongit Sep 10, 2020
2651221
Add dependabot
massongit Sep 10, 2020
29034e2
Add roles
massongit Sep 10, 2020
1f7825e
pg8000とIssue番号は文法的に正しい
massongit Sep 10, 2020
a257ce9
段落の先頭に許可する文字はチェックしない
massongit Sep 10, 2020
398717a
remove period-in-list-item
massongit Sep 10, 2020
bc6ec62
1.1.3.箇条書き除外
massongit Sep 10, 2020
4492f8d
4.3.1.丸かっこ()除外
massongit Sep 10, 2020
a7ed09a
Merge 4492f8d8afe305ac96087760cee2c6cb89076bcd into a0f3d1e5ae138e081…
massongit Sep 10, 2020
20afa0f
鳩は唐揚げ!(自動で直してあげたよ!)
Sep 10, 2020
ffaf11f
Merge pull request #353 from dev-hato/fix-text-add_textlint_3
massongit Sep 10, 2020
a4f7e92
日本語修正
massongit Sep 10, 2020
5b45ec2
Revert
massongit Sep 11, 2020
ab9d238
リンクに「閉じ括弧の手前に句読点(。、)を置かない」が適用されないようにする
massongit Sep 11, 2020
cfd1f87
修正結果を一旦Revert
massongit Sep 11, 2020
af4f797
修正結果を一旦Revert
massongit Sep 11, 2020
3f0cdbf
Merge af4f7973d746a8d40c5505ba99411ff0060612e7 into a0f3d1e5ae138e081…
massongit Sep 11, 2020
9d47132
鳩は唐揚げ!(自動で直してあげたよ!)
Sep 11, 2020
9964365
Merge pull request #355 from dev-hato/fix-text-add_textlint_3
massongit Sep 12, 2020
ecc0744
fix japanese
nakkaa Sep 12, 2020
04d27c3
Merge branch 'add_textlint_3' into fix_japanese
nakkaa Sep 12, 2020
d70af4d
コピペ
nakkaa Sep 12, 2020
d913c96
Merge pull request #356 from dev-hato/fix_japanese
nakkaa Sep 12, 2020
c040243
Fix cache key
massongit Sep 12, 2020
857ad24
Update textlint-rule-preset-jtf-style
massongit Sep 12, 2020
2d8f44d
rm textlint-filter-rule-comments
massongit Sep 13, 2020
f29050c
リンク切れを修正できるようにする
massongit Sep 13, 2020
3d709eb
deploy to herokuのURLを除外
massongit Sep 13, 2020
240c041
textlint-rule-general-novel-style-jaをforkしたリポジトリに差し替え
massongit Sep 13, 2020
c8d9ea6
リポジトリ名修正
massongit Sep 13, 2020
6c8e753
一定桁数以上の算用数字を漢数字に置き換えるルールは適用しない
massongit Sep 13, 2020
681ae6d
no-dead-linkの例外設定をno-dead-linkの設定に移動
massongit Sep 13, 2020
1bdbcad
Update textlint-rule-no-exclamation-question-mark
massongit Sep 14, 2020
0ec730f
pr-textlintを別ファイルに分離
massongit Sep 14, 2020
afb9328
向き先をmasterに変更
massongit Sep 19, 2020
b13ef74
pacage.json, yarn.lock更新用CI追加
massongit Sep 19, 2020
df267a9
textlint関連のファイルもsudden_deathと共通化する
massongit Sep 19, 2020
e3048a7
textlint関連のファイルもsudden_deathと共通化する
massongit Sep 19, 2020
7eb321e
Revert "textlint関連のファイルもsudden_deathと共通化する"
massongit Sep 19, 2020
8ce324f
Fix
massongit Sep 19, 2020
1916ede
Change branch name
massongit Sep 19, 2020
32ada47
Add checkout
massongit Sep 19, 2020
aee9f5f
Revert "Add checkout"
massongit Sep 19, 2020
78179f1
delete cache
massongit Sep 19, 2020
0842ce3
Merge branch 'develop' into add_textlint_3
massongit Sep 19, 2020
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
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ updates:
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: npm
directory: "/"
schedule:
interval: "monthly"
132 changes: 132 additions & 0 deletions .github/workflows/pr-check-yarn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: pr-check-yarn

# package.jsonかyarn.lockに差分があるPRに反応して起動する
on:
pull_request:
paths:
- "package.json"
- "yarn.lock"

jobs:
# package.jsonかyarn.lockに差分があれば、package.jsonからyarn.lockを作り出す
pr-check-yarn:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
fail-fast: false

steps:
- uses: actions/checkout@v2
with:
# ここでsubmodule持ってくるとdetached headにcommitして死ぬ
# submodule: 'recursive'
fetch-depth: 0
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
yarn install -D
# 差分があったときは差分を出力する
- name: Show diff
id: diff
run: |
result=`git diff`
echo "::set-output name=result::$result"
# 差分があったときは、コミットを作りpushする
- name: Push
if: github.event.pull_request.head.repo.full_name == github.repository && steps.diff.outputs.result != ''
run: |
git config user.name "hatohakaraage"
git config user.email "[email protected]"
git add -u
git commit -m "鳩は唐揚げ!(自動で直してあげたよ!)"
git push -f https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git HEAD:refs/heads/yarn-${{github.event.pull_request.head.ref}}
# pushしたブランチでPRを作る
- name: Create PullRequest
uses: actions/github-script@v3
if: github.event.pull_request.head.repo.full_name == github.repository && steps.diff.outputs.result != ''
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const common_params = {
owner: context.repo.owner,
repo: context.repo.repo
}
const pull_params = {
head: "${{github.event.pull_request.head.repo.owner.login}}:yarn-${{github.event.pull_request.head.ref}}",
base: "${{github.event.pull_request.head.ref}}",
...common_params
}
const pulls_list_params = {
state: "open",
...pull_params
}
console.log("call pulls.list:")
console.log(pulls_list_params)
github.pulls.list(pulls_list_params).then(list_res => {
if (list_res.data.length === 0) {
const pulls_create_params = {
title: "package.jsonやyarn.lockが更新されたので直してあげたよ!PRをマージしてね! #${{github.event.pull_request.number}}",
body: "鳩の唐揚げおいしい!😋😋😋 #${{github.event.pull_request.number}}",
...pull_params
}
console.log("call pulls.create:")
console.log(pulls_create_params)
github.pulls.create(pulls_create_params).then(create_res => {
const issues_add_assignees_params = {
issue_number: create_res.data.number,
assignees: ["${{github.event.pull_request.user.login}}"],
...common_params
}
console.log("call issues.addAssignees:")
console.log(issues_add_assignees_params)
github.issues.addAssignees(issues_add_assignees_params)
})
}
})
# 既にpackage.json, yarn.lock修正のPRがある状態で、手動でpackage.json, yarn.lockを修正した場合、修正のPRを閉じる
- name: Close PullRequest
uses: actions/github-script@v3
if: github.event.pull_request.head.repo.full_name == github.repository && steps.diff.outputs.result == ''
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const head_name = "yarn-${{github.event.pull_request.head.ref}}"
const common_params = {
owner: context.repo.owner,
repo: context.repo.repo
}
const pulls_list_params = {
head: "${{github.event.pull_request.head.repo.owner.login}}:" + head_name,
base: "${{github.event.pull_request.head.ref}}",
state: "open",
...common_params
}
console.log("call pulls.list:")
console.log(pulls_list_params)
github.pulls.list(pulls_list_params).then(res => {
for(const data of res.data){
const pulls_update_params = {
pull_number: data.number,
state: "closed",
...common_params
}
console.log("call pulls.update:")
console.log(pulls_update_params)
github.pulls.update(pulls_update_params).then(res2 => {
const git_deleteRef_params = {
ref: "heads/" + head_name,
...common_params
}
console.log("call git.deleteRef:")
console.log(git_deleteRef_params)
github.git.deleteRef(git_deleteRef_params)
})
}
})
- name: Exit
if: steps.diff.outputs.result != ''
run: exit 1
4 changes: 4 additions & 0 deletions .github/workflows/pr-copy-ci-hato-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
do
cp hato-bot/${worklows_path}/${f} sudden-death/${worklows_path}/
done
for f in .textlintrc package.json yarn.lock
do
cp hato-bot/${f} sudden-death/
done
- name: Show diff
id: show_diff
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ jobs:
console.log(issues_listComments_params)
github.issues.listComments(issues_listComments_params).then(response =>
response.data.filter(
comment=>comment.user.id==41898282
comment=>comment.user.id==41898282 && comment.body.startsWith('Lint結果')
).map(
comment=>comment.id
).forEach(
Expand Down
235 changes: 235 additions & 0 deletions .github/workflows/pr-textlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
name: pr-textlint

# pull_requestで何かあった時に起動する
on:
pull_request:

jobs:
# textlintをかけ、結果をPRにコメントとして表示する。
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]

steps:
- uses: actions/checkout@v2
with:
# ここでsubmodule持ってくるとdetached headにcommitして死ぬ
# submodule: 'recursive'
fetch-depth: 0
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: yarn cache
uses: actions/cache@v2
with:
key: ${{ hashFiles('./.github/workflows/pr-textlint.yml') }}-${{ runner.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
restore-keys: |
${{ hashFiles('./.github/workflows/pr-textlint.yml') }}-${{ runner.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
${{ hashFiles('./.github/workflows/pr-textlint.yml') }}-${{ runner.os }}-${{ matrix.node-version }}-yarn-
- name: Install dependencies
run: |
yarn install -D
# lintする
- name: Lint files
id: lint
run: |
result=$(yarn textlint $(find . -type f -name "*.md" -not -path "./node_modules/*") 2>&1) || true
echo "$result"
result="${result//'%'/'%25'}"
result="${result//$'\n'/'%0A'}"
result="${result//$'\r'/'%0D'}"
echo "::set-output name=result::$result"
true
continue-on-error: true
# lint結果をコメントに残す
- name: Lint Comment
if: github.event.pull_request.head.repo.full_name == github.repository && steps.lint.outputs.result != ''
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const issues_listComments_params = {
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
}
console.log("call issues.listComments:")
console.log(issues_listComments_params)
github.issues.listComments(issues_listComments_params).then(response =>
response.data.filter(
comment=>comment.user.id==41898282 && comment.body.startsWith('日本語の')
).map(
comment=>comment.id
).forEach(
comment_id => {
const issues_deleteComment_params = {
comment_id: comment_id,
owner: context.repo.owner,
repo: context.repo.repo
}
console.log("call issues.deleteComment:")
console.log(issues_deleteComment_params)
github.issues.deleteComment(issues_deleteComment_params)
}
)
)

const result = `${{steps.lint.outputs.result}}`
const issues_createComment_params = {
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "日本語のLint結果だよ!🕊🕊🕊\n```\n"+result+"\n```"
}
console.log("call issues.createComment:")
console.log(issues_createComment_params)
github.issues.createComment(issues_createComment_params)
- name: Exit
if: github.event.pull_request.head.repo.full_name != github.repository && steps.lint.outcome == 'failure'
run: exit 1

# PRが来たらtextlintをかけてみて、差分があればPRを作って、エラーで落ちるjob
format:
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository
strategy:
matrix:
node-version: [12.x]

steps:
- uses: actions/checkout@v2
with:
# ここでsubmodule持ってくるとdetached headにcommitして死ぬ
# submodule: 'recursive'
fetch-depth: 0
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: yarn cache
uses: actions/cache@v2
with:
key: ${{ hashFiles('./.github/workflows/pr-textlint.yml') }}-${{ runner.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
restore-keys: |
${{ hashFiles('./.github/workflows/pr-textlint.yml') }}-${{ runner.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
${{ hashFiles('./.github/workflows/pr-textlint.yml') }}-${{ runner.os }}-${{ matrix.node-version }}-yarn-
- name: Install dependencies
run: |
yarn install -D
# textlintでformatする
- name: Format files
id: format
run: |
yarn textlint --fix $(find . -type f -name "*.md" -not -path "./node_modules/*")
continue-on-error: true
# 差分があったときは差分を出力する
- name: Show diff
id: show_diff
run: |
echo "::set-output name=diff::$(git diff)"
# 差分があったときは、コミットを作りpushする
- name: Push
if: steps.show_diff.outputs.diff != ''
run: |
git config user.name "hatohakaraage"
git config user.email "[email protected]"
git add -u
git commit -m "鳩は唐揚げ!(自動で直してあげたよ!)"
git push -f https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git HEAD:refs/heads/fix-text-${{github.event.pull_request.head.ref}}
# pushしたブランチでPRを作る
- name: Create PullRequest
uses: actions/github-script@v3
if: steps.show_diff.outputs.diff != ''
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const common_params = {
owner: context.repo.owner,
repo: context.repo.repo
}
const pull_params = {
head: "dev-hato:fix-text-${{github.event.pull_request.head.ref}}",
base: "${{github.event.pull_request.head.ref}}",
...common_params
}
const pulls_list_params = {
state: "open",
...pull_params
}
console.log("call pulls.list:")
console.log(pulls_list_params)
github.pulls.list(pulls_list_params).then(list_res => {
if (list_res.data.length === 0) {
const pulls_create_params = {
title: "日本語が間違ってたので直してあげたよ!PRをマージしてね! #${{github.event.pull_request.number}}",
body: "鳩の唐揚げおいしい!😋😋😋 #${{github.event.pull_request.number}}",
...pull_params
}
console.log("call pulls.create:")
console.log(pulls_create_params)
github.pulls.create(pulls_create_params).then(create_res => {
const issues_add_assignees_params = {
issue_number: create_res.data.number,
assignees: ["${{github.event.pull_request.user.login}}"],
...common_params
}
console.log("call issues.addAssignees:")
console.log(issues_add_assignees_params)
github.issues.addAssignees(issues_add_assignees_params)
})
}
})
# 既にformat修正のPRがある状態で、手動でformatを修正した場合、format修正のPRを閉じる
- name: Close PullRequest
uses: actions/github-script@v3
if: steps.show_diff.outputs.diff == ''
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const head_name = "fix-text-${{github.event.pull_request.head.ref}}"
const common_params = {
owner: context.repo.owner,
repo: context.repo.repo
}
const pulls_list_params = {
head: "dev-hato:" + head_name,
base: "${{github.event.pull_request.head.ref}}",
state: "open",
...common_params
}
console.log("call pulls.list:")
console.log(pulls_list_params)
github.pulls.list(pulls_list_params).then(res => {
for(const data of res.data){
const pulls_update_params = {
pull_number: data.number,
state: "closed",
...common_params
}
console.log("call pulls.update:")
console.log(pulls_update_params)
github.pulls.update(pulls_update_params).then(res2 => {
const git_deleteRef_params = {
ref: "heads/" + head_name,
...common_params
}
console.log("call git.deleteRef:")
console.log(git_deleteRef_params)
github.git.deleteRef(git_deleteRef_params)
})
}
})
- name: Exit
if: steps.show_diff.outputs.diff != ''
run: exit 1
Loading