Skip to content

Commit

Permalink
scheduler: bring config if missing
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoref committed Mar 26, 2020
1 parent 044323a commit c6c9e7c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ jq
json
perl
pne
rsync
spellchecker
SZ
timeframe
Expand Down
23 changes: 22 additions & 1 deletion check-pull-requests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ pulls=$temp/pulls.json
escaped=$temp/escaped.b64
pull=$temp/pull.json
fake_event=$temp/fake_event.json
tree_config="$bucket/$project/"
stored_config=$temp/config/
headers=$temp/headers

if [ -e "$pulls" ]; then
echo using cached $pulls
else
curl -s -s -H "Authorization: token $GITHUB_TOKEN" --header "Content-Type: application/json" -H "Accept: application/vnd.github.shadow-cat-preview+json" https://api.github.com/repos/$GITHUB_REPOSITORY/pulls > $pulls
fi

cat "$pulls" | jq -c '.[]'|jq -c -r '{
head_repo: .head.repo.full_name,
base_repo: .base.repo.full_name,
Expand All @@ -41,6 +44,12 @@ cat "$pulls" | jq -c '.[]'|jq -c -r '{
commits_url: .commits_url,
comments_url: .comments_url
} | @base64' > "$escaped"
if [ -s "$escaped" ]; then
if [ -d "$tree_config" ]; then
mkdir -p "$stored_config"
rsync -a "$tree_config" "$stored_config"
fi
fi
end_group

get_created_from_events() {
Expand Down Expand Up @@ -115,5 +124,17 @@ for a in $(cat "$escaped"); do
git checkout $head_sha
git remote rm pr 2>/dev/null || true
end_group
"$spellchecker/unknown-words.sh" || true
(
temp=$(mktemp -d)
if [ -d "$stored_config" ] && [ ! -d "$tree_config" ]; then
mkdir -p "$tree_config"
rsync -a "$stored_config" "$tree_config"
cleanup_tree_config=1
fi
"$spellchecker/unknown-words.sh" || true
rm -rf "$temp"
if [ -n "$cleanup_tree_config" ]; then
rm -rf "$tree_config"
fi
)
done
3 changes: 2 additions & 1 deletion common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ now() {
date +'%s%N'
}
start=$(now)
export temp='/tmp/spelling'
temp="${temp:-/tmp/spelling}"
export temp

0 comments on commit c6c9e7c

Please sign in to comment.