Skip to content

Commit

Permalink
PR docs buildbot: check free space/inodes, only build PR docs on request
Browse files Browse the repository at this point in the history
 * docs build for PRs can be requested by putting "+DOCS" somewhere in the
   github comments
 * current docs buildbot server has relatively low inode quota, avoid again
   using up all inodes

see obspy#1357
  • Loading branch information
megies authored and claudiodsf committed Jun 28, 2016
1 parent 52d2d91 commit 93f92bb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
22 changes: 22 additions & 0 deletions misc/scripts/docs_buildbot/update-docs-pr.sh
@@ -1,6 +1,28 @@
#!/bin/bash

cd $HOME
anaconda3/bin/python update_pull_request_metadata.py

# check free space and free inodes (current docs server has relatively low
# inode quota)
## `df` on docs server doesn't have "output" option
## FREE_INODES = `df . --output="iavail" | tail -1`
FREE_INODES = `df $HOME/htdocs -i | tail -1 | awk '{print $4}'`
INODE_CRITICAL = "300000" # 300k
if [ "$FREE_INODES" -lt "$INODE_CRITICAL" ]
then
echo "Aborting PR docs build, low inodes: $FREE_INODES"
exit 1
fi
FREE_SPACE = `df $HOME/htdocs/ | tail -1 | awk '{print $4}'`
SPACE_CRITICAL = "10000000" # 10G
if [ "$FREE_SPACE" -lt "$SPACE_CRITICAL" ]
then
echo "Aborting PR docs build, low disk space: $FREE_INODES"
exit 1
fi


for FILE in `ls pull_request_docs/*.todo 2> /dev/null`
do
PR=${FILE##*/}
Expand Down
17 changes: 17 additions & 0 deletions misc/scripts/docs_buildbot/update_pull_request_metadata.py
@@ -1,8 +1,23 @@
import os
import re
import requests
from obspy import UTCDateTime


def check_docs_build_requested(issue_number):
"""
Check if a docs build was requested for given issue number (by magic string
'+DOCS' anywhere in issue comments).
:rtype: bool
"""
url = "https://api.github.com/repos/obspy/obspy/issues/{:d}/comments"
data = requests.get(url.format(issue_number), params={"per_page": 100})
comments = [x["body"] for x in data.json()]
pattern = r'\+DOCS'
return any(re.search(pattern, comment) for comment in comments)


try:
# github API token with "repo.status" access right
token = os.environ["OBSPY_COMMIT_STATUS_TOKEN"]
Expand All @@ -27,6 +42,8 @@
for d in data:
# extract the pieces we need from the PR data
number = d['number']
if not check_docs_build_requested(number):
continue
fork = d['head']['user']['login']
branch = d['head']['ref']
commit = d['head']['sha']
Expand Down

0 comments on commit 93f92bb

Please sign in to comment.