Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Add Travis script to verify that docs were updated for PRs which modify services #262

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ script:
- "[ $(make fmt | wc -l) == 0 ]"
- make all
- make test
- bash ./scripts/travis-doc-check.sh
before_deploy:
- make docs
- make container TAG=$TRAVIS_TAG
Expand Down
32 changes: 32 additions & 0 deletions scripts/travis-doc-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#! /bin/bash

services=( auth checkin decision event mail notifications registration rsvp stat upload user )

if [ "$TRAVIS_PULL_REQUEST" != "false" ] ; then
# get all changed files in PR
changed_files=`git diff --name-only $TRAVIS_BRANCH...HEAD`

# figure out which services might be a problem
n_changed_services=0
changed_services_list=""
for service in ${services[*]} ; do
service_upper=${service^}

# check if any file in the service has been changed and if the doc page has not been changed
if [[ $changed_files =~ "services/${service}" ]] \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we simplify this logic into separate variables which make it clear what each expression signifies?
This is currently hard to read.

&& ! [[ $changed_files =~ "documentation/docs/reference/services/${service_upper}.md" ]]; then
n_changed_services=$(($n_changed_services + 1))
changed_services_list="${changed_services_list}- [${service_upper}](https://github.com/HackIllinois/api/blob/master/documentation/docs/reference/services/${service_upper}.md)\n"
fi
done

pr_message="It looks like your PR makes changes to the following services, but does not include changes \
to the corresponding documentation:\n${changed_services_list}\nIf your changes do not require documentation \
updates, feel free to ignore this message."

if (( $n_changed_services > 0 )); then
echo "a service has changed"
curl -H "Authorization: token $GITHUB_ACCESS_TOKEN" -X POST -d "{\"body\": \"${pr_message}\"}" "https://api.github.com/repos/\
${TRAVIS_REPO_SLUG}/issues/${TRAVIS_PULL_REQUEST}/comments"
fi
fi