Skip to content

Commit

Permalink
workflow to push html?
Browse files Browse the repository at this point in the history
  • Loading branch information
mscroggs committed Jan 16, 2024
1 parent 0fadf6e commit b99128e
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 31 deletions.
44 changes: 44 additions & 0 deletions .github/scripts/make_and_upload_html.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import github
import json
import os
import sys

key = sys.argv[-1]
git = github.Github(key)

root_dir = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
os.path.join(os.path.pardir, os.path.pardir))
with open(os.path.join(root_dir, "data.json")) as f:
data = json.load(f)

benches = list(data.keys())
benches.sort()

html = ""
# html += "<h2>All benchmarks</h2>\n"
html += "<div id='benchall'></div>\n"
# for i, b in enumerate(benches):
# html += f"<h2>{b}</h2>\n"
# html += f"<div id='bench{i}'></div>\n"

html += "<script type='text/javascript'>\n"
for i, b in enumerate(benches):
html += f"var line{i} = {{\n"
html += " x: [" + ", ".join([f"\"{j['date']}\"" for j in data[b]]) + "],\n"
html += " y: [" + ", ".join([f"{j['mean']['estimate']}" for j in data[b]]) + "],\n"
html += " type: 'scatter',\n"
html += " mode: 'lines+markers',\n"
html += f" name: \"{b}\"\n"
html += "};\n"
html += "Plotly.newPlot('benchall', [" + ", ".join([f"line{i}" for i, _ in enumerate(benches)]) + "]);\n"
# for i, _ in enumerate(benches):
# html += f"Plotly.newPlot('bench{i}', [line{i}]);\n"
html += "</script>\n"


r = git.get_repo("bempp/bempp-website")
current = r.get_contents("_includes/_rs_benches.html")


r.update_file("_includes/_rs_benches.html", "Update benchmark plots", html, sha=current.sha)
31 changes: 0 additions & 31 deletions .github/scripts/make_html.py

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/push-html.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Update plots on website

on:
push:
branches:
- "main"

jobs:
push-html:
runs-on: ubunut-latest
permissions:
contents: write
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- uses: actions/checkout@v4
- run: python3 -m pip install PyGithub
- name: Build and push HTML
uses: python3 .github/scripts/make_and_upload_html.py ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash

python3 -m pip install PyGithub
git clone https://github.com/bempp/bempp-rs
cargo install cargo-criterion

0 comments on commit b99128e

Please sign in to comment.