Skip to content

Commit 4f910d5

Browse files
committed
revertを取り消し
1 parent 2a2b103 commit 4f910d5

File tree

15 files changed

+936
-63
lines changed

15 files changed

+936
-63
lines changed

.dependabot/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ update_configs:
33
- package_manager: "python"
44
directory: "/"
55
update_schedule: "live"
6+
target_branch: "develop"
67
allowed_updates:
78
- match:
89
update_type: "security"

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SLACKBOT_API_TOKEN=xoxb-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2+
DATABASE_URL=postgres://postgres:password@localhost:5432/
3+
YAHOO_API_TOKEN=xxxxxxxxx

.github/workflows/pr-test.yml

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
name: pr-test
2+
3+
# pull_requestで何かあった時に起動する
4+
on:
5+
pull_request:
6+
7+
jobs:
8+
# PRが来たらformatをかけてみて、差分があればPRを作って、エラーで落ちるjob
9+
pr-format:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
python-version: [3.8]
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 0
19+
- name: pipenv cache
20+
uses: actions/cache@v1
21+
with:
22+
key: ${{ runner.os }}-${{ matrix.python-version }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
23+
path: ~/.cache/pipenv
24+
restore-keys: |
25+
${{ runner.os }}-${{ matrix.python-version }}-pipenv-
26+
- name: pip cache
27+
uses: actions/cache@v1
28+
with:
29+
path: ~/.cache/pip
30+
key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile.lock') }}
31+
restore-keys: |
32+
${{ runner.os }}-pip-
33+
- name: Set up Python ${{ matrix.python-version }}
34+
uses: actions/setup-python@v1
35+
with:
36+
python-version: ${{ matrix.python-version }}
37+
- name: Install dependencies
38+
run: |
39+
python -m pip install --upgrade pip
40+
pip install pipenv
41+
pipenv install --dev
42+
# autopep8でformatする
43+
# --exit-codeをつけることで、autopep8内でエラーが起きれば1、差分があれば2のエラーステータスコードが返ってくる。正常時は0が返る
44+
- name: Format files
45+
id: format
46+
run: |
47+
pipenv run autopep8 --exit-code --in-place --recursive .
48+
continue-on-error: true
49+
# 差分があったときは、コミットを作りpushする
50+
- name: Push
51+
if: steps.format.outcome == 'failure'
52+
run: |
53+
git config user.name "hatohakaraage"
54+
git config user.email "hatohakaraage@example.com"
55+
git add -u
56+
git commit -m "鳩は唐揚げ!(自動で直してあげたよ!)"
57+
git push -f https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git HEAD:refs/heads/fix-format-${{github.event.pull_request.head.ref}}
58+
# pushしたブランチでPRを作る
59+
- name: Create PullRequest
60+
uses: actions/github-script@0.9.0
61+
if: steps.format.outcome == 'failure'
62+
with:
63+
github-token: ${{secrets.GITHUB_TOKEN}}
64+
script: |
65+
github.pulls.create({
66+
owner: context.repo.owner,
67+
repo: context.repo.repo,
68+
title: "formatが間違ってたので直してあげたよ!PRをマージしてね! #${{github.event.pull_request.number}}",
69+
body: "鳩の唐揚げおいしい!😋😋😋 #${{github.event.pull_request.number}}",
70+
head: "refs/heads/fix-format-${{github.event.pull_request.head.ref}}",
71+
base: "${{github.event.pull_request.head.ref}}"
72+
})
73+
- name: Exit
74+
if: steps.format.outcome == 'failure'
75+
run: return 1
76+
77+
# unittestを行う
78+
# testが落ちたらチェックが落ちる
79+
pr-test:
80+
runs-on: ubuntu-latest
81+
strategy:
82+
matrix:
83+
python-version: [3.8]
84+
85+
steps:
86+
- uses: actions/checkout@v2
87+
- name: pipenv cache
88+
uses: actions/cache@v1
89+
with:
90+
key: ${{ runner.os }}-${{ matrix.python-version }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
91+
path: ~/.cache/pipenv
92+
restore-keys: |
93+
${{ runner.os }}-${{ matrix.python-version }}-pipenv-
94+
- name: pip cache
95+
uses: actions/cache@v1
96+
with:
97+
path: ~/.cache/pip
98+
key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile.lock') }}
99+
restore-keys: |
100+
${{ runner.os }}-pip-
101+
- name: Set up Python ${{ matrix.python-version }}
102+
uses: actions/setup-python@v1
103+
with:
104+
python-version: ${{ matrix.python-version }}
105+
- name: Install dependencies
106+
run: |
107+
python -m pip install --upgrade pip
108+
pip install pipenv
109+
pipenv install --dev
110+
- name: Test
111+
run: |
112+
pipenv run python -m unittest
113+
114+
# lintを行い、結果をPRにコメントとして表示する。
115+
# ここではチェックは落ちない
116+
pr-lint:
117+
runs-on: ubuntu-latest
118+
strategy:
119+
matrix:
120+
python-version: [3.8]
121+
122+
steps:
123+
- uses: actions/checkout@v2
124+
with:
125+
fetch-depth: 0
126+
- name: pipenv cache
127+
uses: actions/cache@v1
128+
with:
129+
key: ${{ runner.os }}-${{ matrix.python-version }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
130+
path: ~/.cache/pipenv
131+
restore-keys: |
132+
${{ runner.os }}-${{ matrix.python-version }}-pipenv-
133+
- name: pip cache
134+
uses: actions/cache@v1
135+
with:
136+
path: ~/.cache/pip
137+
key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile.lock') }}
138+
restore-keys: |
139+
${{ runner.os }}-pip-
140+
- name: Set up Python ${{ matrix.python-version }}
141+
uses: actions/setup-python@v1
142+
with:
143+
python-version: ${{ matrix.python-version }}
144+
- name: Install dependencies
145+
run: |
146+
python -m pip install --upgrade pip
147+
pip install pipenv
148+
pipenv install --dev
149+
# 差分があるファイルのみlintする。
150+
# PRに関係のないところのlint結果を出されても困るだけなので。
151+
- name: Lint files
152+
id: lint
153+
run: |
154+
git fetch --no-tags --prune --depth=1 origin ${GITHUB_HEAD_REF}
155+
git fetch --no-tags --prune --depth=1 origin ${GITHUB_BASE_REF}
156+
result=$(pipenv run pylint --rcfile=./.pylintrc $(git diff origin/${GITHUB_BASE_REF}..origin/${GITHUB_HEAD_REF} --diff-filter=AM --name-only -- '*.py') 2>&1) || true
157+
result="${result//'%'/'%25'}"
158+
result="${result//$'\n'/'%0A'}"
159+
result="${result//$'\r'/'%0D'}"
160+
echo "::set-output name=result::$result"
161+
true
162+
continue-on-error: true
163+
# lint結果をコメントに残す
164+
- name: Lint Comment
165+
uses: actions/github-script@0.9.0
166+
with:
167+
github-token: ${{secrets.GITHUB_TOKEN}}
168+
script: |
169+
const result = `${{steps.lint.outputs.result}}`
170+
github.issues.createComment({
171+
issue_number: context.issue.number,
172+
owner: context.repo.owner,
173+
repo: context.repo.repo,
174+
body: "Lint結果だよ!🕊🕊🕊\n```\n"+result+"\n```"
175+
})

0 commit comments

Comments
 (0)