-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 207c672
Showing
27 changed files
with
4,159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": 1, | ||
"project": "pyglotaran", | ||
"project_url": "https://github.com/glotaran/pyglotaran", | ||
"repo": "https://github.com/glotaran/pyglotaran", | ||
"branches": ["HEAD"], // for git | ||
"dvcs": "git", | ||
"environment_type": "virtualenv", | ||
"show_commit_url": "http://github.com/glotaran/pyglotaran/commit/", | ||
"results_dir": "../results", | ||
"html_dir": "../html" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
from __future__ import annotations | ||
|
||
import subprocess | ||
from pathlib import Path | ||
import requests | ||
from bs4 import BeautifulSoup | ||
|
||
SCRIPT_DIR = Path(__file__).parent | ||
INDEX_TEMPLATE = SCRIPT_DIR / "pr_index_template.html" | ||
PR_INDEX_FILE = (SCRIPT_DIR / "../html/prs/index.html").resolve() | ||
|
||
|
||
def pr_branches() -> list[str]: | ||
"""List of branches that start with 'pr-'""" | ||
out = subprocess.run( | ||
[ | ||
"git", | ||
"for-each-ref", | ||
"--shell", | ||
'--format="%(refname:strip=3)"', | ||
"refs/remotes/origin/pr-*", | ||
], | ||
capture_output=True, | ||
) | ||
branches = out.stdout.decode().splitlines() | ||
return [branch.replace('"', "").replace("'", "") for branch in branches] | ||
|
||
|
||
def create_worktrees(branches: list[str]): | ||
"""Create folders for pr-* branches inside of html/prs/""" | ||
for branch in branches: | ||
subprocess.run( | ||
["git", "worktree", "add", str(PR_INDEX_FILE.parent / branch), branch] | ||
) | ||
|
||
|
||
def clean_pr_benchmark_branches(branch: str): | ||
"""Remove benchmark branches odf closed PRs""" | ||
subprocess.run(["git", "push", "origin", "--delete", branch]) | ||
|
||
|
||
def pr_info(branch: str): | ||
"""Get PR title and link from github api""" | ||
_, _, pr_nr = branch.partition("-") | ||
try: | ||
response = requests.get( | ||
f"https://api.github.com/repos/glotaran/pyglotaran/pulls/{pr_nr}", | ||
).json() | ||
return response["title"], response["html_url"], response["state"] | ||
except Exception: | ||
return pr_nr, f"https://github.com/glotaran/pyglotaran/pull/{pr_nr}", "unknown" | ||
|
||
|
||
def create_pr_index_page(branches: list[str]): | ||
"""Writes index page for prs folder.""" | ||
template = BeautifulSoup(INDEX_TEMPLATE.read_text(encoding="utf8"), features="lxml") | ||
for branch in branches: | ||
title, link, state = pr_info(branch) | ||
if state == "closed": | ||
clean_pr_benchmark_branches(branch) | ||
continue | ||
li = template.new_tag("li") | ||
pr_link = template.new_tag("a", href=link) | ||
pr_link.append(title) | ||
li.append(pr_link) | ||
li.append(" ( ") | ||
benchmark_link = template.new_tag( | ||
"a", href=f"https://glotaran.github.io/pyglotaran-benchmarks/prs/{branch}" | ||
) | ||
benchmark_link.append("benchmark") | ||
li.append(benchmark_link) | ||
li.append(" )") | ||
template.ul.append(li) | ||
PR_INDEX_FILE.write_text(str(template), encoding="utf8") | ||
|
||
|
||
if __name__ == "__main__": | ||
branches = pr_branches() | ||
create_worktrees(branches) | ||
if PR_INDEX_FILE.parent.exists(): | ||
create_pr_index_page(branches) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>pyglotaran PR benchmarks</title> | ||
<style> | ||
main { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
li { | ||
display: block; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<main> | ||
<h1>PR Benchmarks</h1> | ||
<ul></ul> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: Build gh-pages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout main branch | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: main | ||
fetch-depth: 0 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install -r requirements.txt | ||
- name: Build Github-Pages | ||
run: | | ||
asv --config=.github/asv.conf.json publish --no-pull | ||
- name: Build PR index page | ||
run: | | ||
python .github/create_pr_pages.py | ||
- name: Show file tree | ||
run: tree html | ||
|
||
- name: Upload bundled page | ||
if: success() | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: html | ||
path: html | ||
|
||
deploy-page: | ||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | ||
name: Deploy gh-pages | ||
needs: [build] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download bundled page | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: html | ||
path: html | ||
|
||
- name: Deploy to GitHub Pages | ||
if: success() | ||
uses: crazy-max/ghaction-github-pages@v2 | ||
with: | ||
target_branch: gh-pages | ||
build_dir: html | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
/* Basic navigation */ | ||
|
||
.asv-navigation { | ||
padding: 2px; | ||
} | ||
|
||
nav ul li.active a { | ||
height: 52px; | ||
} | ||
|
||
nav li.active span.navbar-brand { | ||
background-color: #e7e7e7; | ||
height: 52px; | ||
} | ||
|
||
nav li.active span.navbar-brand:hover { | ||
background-color: #e7e7e7; | ||
} | ||
|
||
.navbar-default .navbar-link { | ||
color: #2458D9; | ||
} | ||
|
||
.panel-body { | ||
padding: 0; | ||
} | ||
|
||
.panel { | ||
margin-bottom: 4px; | ||
-webkit-box-shadow: none; | ||
box-shadow: none; | ||
border-radius: 0; | ||
border-top-left-radius: 3px; | ||
border-top-right-radius: 3px; | ||
} | ||
|
||
.panel-default>.panel-heading, | ||
.panel-heading { | ||
font-size: 12px; | ||
font-weight:bold; | ||
padding: 2px; | ||
text-align: center; | ||
border-top-left-radius: 3px; | ||
border-top-right-radius: 3px; | ||
background-color: #eee; | ||
} | ||
|
||
.btn, | ||
.btn-group, | ||
.btn-group-vertical>.btn:first-child, | ||
.btn-group-vertical>.btn:last-child:not(:first-child), | ||
.btn-group-vertical>.btn:last-child { | ||
border: none; | ||
border-radius: 0px; | ||
overflow: hidden; | ||
} | ||
|
||
.btn-default:focus, .btn-default:active, .btn-default.active { | ||
border: none; | ||
color: #fff; | ||
background-color: #99bfcd; | ||
} | ||
|
||
#range { | ||
font-family: monospace; | ||
text-align: center; | ||
background: #ffffff; | ||
} | ||
|
||
.form-control { | ||
border: none; | ||
border-radius: 0px; | ||
font-size: 12px; | ||
padding: 0px; | ||
} | ||
|
||
.tooltip-inner { | ||
min-width: 100px; | ||
max-width: 800px; | ||
text-align: left; | ||
white-space: pre-wrap; | ||
font-family: monospace; | ||
} | ||
|
||
/* Benchmark tree */ | ||
|
||
.nav-list { | ||
font-size: 12px; | ||
padding: 0; | ||
padding-left: 15px; | ||
} | ||
|
||
.nav-list>li { | ||
overflow-x: hidden; | ||
} | ||
|
||
.nav-list>li>a { | ||
padding: 0; | ||
padding-left: 5px; | ||
color: #000; | ||
} | ||
|
||
.nav-list>li>a:focus { | ||
color: #fff; | ||
background-color: #99bfcd; | ||
box-shadow: inset 0 3px 5px rgba(0,0,0,.125); | ||
} | ||
|
||
.nav-list>li>.nav-header { | ||
white-space: nowrap; | ||
font-weight: 500; | ||
margin-bottom: 2px; | ||
} | ||
|
||
.caret-right { | ||
display: inline-block; | ||
width: 0; | ||
height: 0; | ||
margin-left: 2px; | ||
vertical-align: middle; | ||
border-left: 4px solid; | ||
border-bottom: 4px solid transparent; | ||
border-top: 4px solid transparent; | ||
} | ||
|
||
/* Summary page */ | ||
|
||
.benchmark-group > h1 { | ||
text-align: center; | ||
} | ||
|
||
.benchmark-container { | ||
width: 300px; | ||
height: 116px; | ||
padding: 4px; | ||
border-radius: 3px; | ||
} | ||
|
||
.benchmark-container:hover { | ||
background-color: #eee; | ||
} | ||
|
||
.benchmark-plot { | ||
width: 292px; | ||
height: 88px; | ||
} | ||
|
||
.benchmark-text { | ||
font-size: 12px; | ||
color: #000; | ||
width: 292px; | ||
overflow: hidden; | ||
} | ||
|
||
#extra-buttons { | ||
margin: 1em; | ||
} | ||
|
||
#extra-buttons a { | ||
border: solid 1px #ccc; | ||
} |
Oops, something went wrong.