Skip to content

Commit

Permalink
Use GITHUB_REPOSITORY environment variable
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
  • Loading branch information
miurahr committed Feb 18, 2021
1 parent 4367706 commit 4e60d5b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/run-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ jobs:
matrix:
python-version: [3.9, pypy3]
name: Benchmark on Python ${{ matrix.python-version }}
env:
ISSUE_NUMBER: 297
JSONFILE: ${{ github.workspace }}/results_${{ matrix.python_version }}.json
steps:
- uses: actions/checkout@v2
- name: Setup python
Expand All @@ -22,15 +25,13 @@ jobs:
pip install -U pip
pip install tox tox-gh-actions
pip install -r utils/requirements.txt
- name: Benchmark project with tox
- name: Run benchmark with tox
run: |
tox
env:
PYTEST_ADDOPTS: '--benchmark-only --no-cov --benchmark-json=${{ github.workspace }}/results_${{ matrix.python_version }}.json'
PYTEST_ADDOPTS: '--benchmark-only --no-cov --benchmark-json=${JSONFILE}'
- name: post result to issue
run: |
python utils/bench_commit_issue.py ${{ github.workspace }}/results_${{ matrix.python_version }}.json
python utils/bench_comment_issue.py ${JSONFILE} ${GITHUB_REPOSITORY} ${ISSUE_NUMBER}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: miurahr/py7zr
ISSUE: 297
19 changes: 13 additions & 6 deletions utils/bench_commit_issue.py → utils/bench_comment_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,27 @@
import bench_result as bench


def post_comment(jsonfile, token: str, repository: str, issue_number:int):
def post_comment(jsonfile: pathlib.Path, repository: str, issue_number:int):
body = bench.generate_comment(bench.read_results_json(jsonfile))
token = os.getenv("GITHUB_TOKEN")
g = github.Github(token)
repo = g.get_repo(repository)
issue = repo.get_issue(number=issue_number)
issue.create_comment(body)


if __name__ == "__main__":
def parse():
parser = argparse.ArgumentParser(prog='bench_comment_issue')
parser.add_argument('jsonfile', type=pathlib.Path, nargs=1, help='pytest-benchmark saved result.')
parser.add_argument('repository', type=str, nargs=1, help='Repository to post comment')
parser.add_argument('issue_number', type=int, nargs=1, help='Issue number to post comment')
args = parser.parse_args()
jsonfile = args.jsonfile
token = os.getenv("GITHUB_TOKEN")
repository = os.getenv("REPOSITORY")
issue_number = int(os.getenv("ISSUE"))
post_comment(jsonfile, token, repository, issue_number)
repository = args.repository
issue_number = args.issue_number
return jsonfile, repository, issue_number


if __name__ == "__main__":
jsonfile, repository, issue_number = parse()
post_comment(jsonfile, repository, issue_number)

0 comments on commit 4e60d5b

Please sign in to comment.