Skip to content

Commit b82cc60

Browse files
authored
Add pubs testing script and CI workflow (#89)
* Add pubs testing script and CI workflow * Specify default branch of prl-website * Add read token for private repo
1 parent a7119ce commit b82cc60

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

.github/workflows/test.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Test pubs against website
2+
3+
on:
4+
# Pushes / merges to master
5+
push:
6+
branches:
7+
- master
8+
# On creation and updating of PR
9+
pull_request:
10+
types: [opened, reopened, synchronize]
11+
# Only those targeting master branch
12+
branches:
13+
- master
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout pubs
20+
uses: actions/checkout@v3
21+
with:
22+
path: pubs
23+
- name: Checkout prl-website
24+
uses: actions/checkout@v3
25+
with:
26+
token: ${{ secrets.READ_PAT }}
27+
ref: master
28+
repository: personalrobotics/prl-website
29+
path: prl-website
30+
- name: Setup Python
31+
uses: actions/setup-python@v4
32+
with:
33+
python-version: '3.x'
34+
cache: pip
35+
cache-dependency-path: prl-website/setup.py
36+
- name: Install PRL website
37+
run: pip install -e ./prl-website/
38+
- name: Run Test
39+
run: python pubs/test_pubs.py

test_pubs.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python
2+
### Test all bib files
3+
### Requires installation of github.com/personalrobotics/prl-website
4+
5+
from personalrobotics.main.publications import RenderableEntry
6+
import os
7+
import sys
8+
9+
import pybtex.database
10+
11+
if __name__ == "__main__":
12+
bibdir = os.path.dirname(os.path.realpath(__file__))
13+
for filename in os.listdir(bibdir):
14+
if not filename.endswith('.bib'):
15+
continue
16+
print("Checking Bib File: " + filename)
17+
18+
with open(os.path.join(bibdir, filename), 'r') as file:
19+
try:
20+
database = pybtex.database.parse_string(file.read(), "bibtex")
21+
entries = [RenderableEntry("Publication", e) for e in database.entries.values()]
22+
for entry in entries:
23+
entry.__str__()
24+
except Exception as e:
25+
print(type(e))
26+
print(e.args)
27+
print(e)
28+
sys.exit(-1)
29+

0 commit comments

Comments
 (0)