Skip to content

Commit

Permalink
tests: adds a test to ensure we don't break our folder structure for …
Browse files Browse the repository at this point in the history
…document snippets
  • Loading branch information
Justintime50 committed Dec 1, 2022
1 parent ccb3208 commit 75147dd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,10 @@ jobs:
run: make install-ruby
- name: Lint project
run: make lint-ruby
test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Check for current dirs in docs
run: ./test/ensure-current-dirs-exist.sh
33 changes: 33 additions & 0 deletions test/ensure-current-dirs-exist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# This script ensures that each of our languages `docs` directories has a `current` directory to ensure snippets populate on our website

LINT_FAILED=0
FAILED_LANG=""

main() {
# Iterate over each directory and run tests
for LANG_FULL_PATH in official/docs/*; do
if [ -d "$LANG_FULL_PATH" ]; then
if [ "$LANG_FULL_PATH" == "official/docs/responses" ]; then
# The responses dir won't have a `current` set since these aren't versioned
continue
elif [ ! -d "$LANG_FULL_PATH"/current ]; then
FAILED_LANG+="$LANG_FULL_PATH\n"
LINT_FAILED=1
fi
fi
done

# Set exit code based on if the tests passed or failed
if [ "$LINT_FAILED" == 0 ]; then
printf "Check for 'current' directories in docs passed!\n"
exit 0
else
printf "The following language directories do not have a 'current' directory:\n"
printf "%b" "$FAILED_LANG"
exit 1
fi
}

main

0 comments on commit 75147dd

Please sign in to comment.