-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for the starter pack #261
Merged
ru-fu
merged 6 commits into
canonical:use-canonical-sphinx-extension
from
ru-fu:DOCPR-649-init-tests
Aug 12, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
322f299
add a set of scripts for testing starter pack functionality
ru-fu 592bac0
add a GitHub workflow for testing the starter pack
ru-fu dae99ac
make sure aspell is installed for the spelling check
ru-fu 4dd8c93
Update get_vale_conf.py
evilnick a27d57f
workaround for Discourse links
ru-fu 679b2ed
add test files
ru-fu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# This workflow runs the init.sh script to test setting up | ||
# the starter pack. | ||
# You shouldn't run this workflow on any repos that use the | ||
# starter pack. | ||
|
||
name: Test starter pack | ||
|
||
on: | ||
- pull_request | ||
- push | ||
|
||
jobs: | ||
test-root: | ||
name: Test in root folder | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v4 | ||
- name: Run init and build | ||
run: sp-tests/run-init-and-build.sh | ||
- name: Add some files, build, and test | ||
run: sp-tests/add-files-and-build.sh | ||
- name: Run inclusive language check | ||
if: success() || failure() | ||
run: sp-tests/check-inclusive-language.sh | ||
- name: Run link check | ||
if: success() || failure() | ||
run: sp-tests/check-links.sh | ||
- name: Run spelling check | ||
if: success() || failure() | ||
run: sp-tests/check-spelling.sh | ||
- name: Run styleguide check (expected to fail) | ||
continue-on-error: true | ||
if: success() || failure() | ||
run: sp-tests/check-styleguide.sh | ||
- name: Run accessibility check | ||
if: success() || failure() | ||
run: sp-tests/check-accessibility.sh | ||
- name: Clean up | ||
if: success() || failure() | ||
run: sp-tests/clean-up.sh | ||
test-docs: | ||
name: Test on docs folder | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v4 | ||
- name: Run init and build | ||
run: sp-tests/run-init-and-build.sh docs | ||
- name: Add some files, build, and test | ||
run: sp-tests/add-files-and-build.sh docs | ||
- name: Run inclusive language check | ||
if: success() || failure() | ||
run: sp-tests/check-inclusive-language.sh docs | ||
- name: Run link check | ||
if: success() || failure() | ||
run: sp-tests/check-links.sh docs | ||
- name: Run spelling check | ||
if: success() || failure() | ||
run: sp-tests/check-spelling.sh docs | ||
- name: Run styleguide check (expected to fail) | ||
continue-on-error: true | ||
run: sp-tests/check-styleguide.sh docs | ||
- name: Run accessibility check | ||
if: success() || failure() | ||
run: sp-tests/check-accessibility.sh docs | ||
- name: Clean up | ||
if: success() || failure() | ||
run: sp-tests/clean-up.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
testdir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
source sp-tests/get-installation-directory.sh | ||
|
||
# Copy the test files | ||
cp sp-tests/testfiles/test-md.md testdir/$install_directory/ | ||
cp sp-tests/testfiles/test-rst.rst testdir/$install_directory/ | ||
|
||
# Include the files in the toctree | ||
if ! grep -Fxq " test-md" testdir/$install_directory/index.rst | ||
then | ||
echo " test-md" >> testdir/$install_directory/index.rst | ||
echo " test-rst" >> testdir/$install_directory/index.rst | ||
fi | ||
|
||
# Build the documentation | ||
cd testdir/$install_directory | ||
make html | ||
|
||
# Test the output | ||
if ! grep -Fq "A documentation starter-pack" _build/test-md/index.html || \ | ||
! grep -Fq "A documentation starter-pack" _build/test-rst/index.html | ||
then | ||
echo "Related links don't work (in RST or Markdown)" | ||
exit 1 | ||
fi | ||
|
||
if ! grep -Fq "Open Documentation Hour" _build/test-md/index.html || \ | ||
! grep -Fq "Open Documentation Hour" _build/test-rst/index.html | ||
then | ||
echo "Discourse links don't work (in RST or Markdown)" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
source sp-tests/get-installation-directory.sh | ||
|
||
# Test the documentation | ||
cd testdir/$install_directory | ||
make pa11y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
source sp-tests/get-installation-directory.sh | ||
|
||
# Test the documentation | ||
cd testdir/$install_directory | ||
make woke |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
source sp-tests/get-installation-directory.sh | ||
|
||
# Test the documentation | ||
cd testdir/$install_directory | ||
make linkcheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
source sp-tests/get-installation-directory.sh | ||
|
||
# Copy the custom wordlist | ||
cp sp-tests/testfiles/.custom_wordlist.txt testdir/$install_directory/ | ||
|
||
# Test the documentation | ||
cd testdir/$install_directory | ||
make spelling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
source sp-tests/get-installation-directory.sh | ||
|
||
# Test the documentation | ||
cd testdir/$install_directory | ||
make vale |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
# clean up | ||
rm -rf testdir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Determine installation directory | ||
while getopts d: flag | ||
do | ||
case "${flag}" in | ||
d) install_directory=${OPTARG};; | ||
esac | ||
done | ||
|
||
if [ ! -n "$install_directory" ]; then | ||
install_directory="." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
source sp-tests/get-installation-directory.sh | ||
|
||
# Save current directory | ||
cwd=$(pwd) | ||
|
||
# Check if the testdir folder must be deleted first | ||
if test -d "testdir"; then | ||
read -p "The \"testdir\" folder already exists. Delete the folder? (y/n) " deletefolder | ||
if [ $deletefolder = "y" ]; then | ||
rm -rf testdir | ||
fi | ||
fi | ||
|
||
# Create a folder for testing | ||
mkdir testdir | ||
cd testdir | ||
git init | ||
|
||
# Copy the init script | ||
cp ../init.sh . | ||
chmod u+x init.sh | ||
|
||
# Run the init script | ||
./init.sh $install_directory | ||
|
||
# Make a first commit | ||
git add . | ||
git config user.email "[email protected]" | ||
git config user.name "Dummy user" | ||
git commit -m 'adding all files' | ||
|
||
# Build the documentation | ||
cd $install_directory | ||
make html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
adipiscing | ||
aliqua | ||
amet | ||
arcu | ||
augue | ||
blandit | ||
congue | ||
consectetur | ||
Consectetur | ||
consequat | ||
cursus | ||
dolor | ||
dolore | ||
dui | ||
Dui | ||
eget | ||
eiusmod | ||
elit | ||
enim | ||
et | ||
eu | ||
faucibus | ||
habitant | ||
iaculis | ||
incididunt | ||
Ipsum | ||
labore | ||
lacus | ||
lectus | ||
leo | ||
libero | ||
lorem | ||
magna | ||
massa | ||
mattis | ||
mauris | ||
molestie | ||
nec | ||
Nibh | ||
nisl | ||
nulla | ||
nullam | ||
nunc | ||
Nunc | ||
odio | ||
ornare | ||
Ornare | ||
pellentesque | ||
pharetra | ||
phasellus | ||
porttitor | ||
rhoncus | ||
scelerisque | ||
sed | ||
sem | ||
sollicitudin | ||
tempor | ||
tincidunt | ||
Urna | ||
ut | ||
vestibulum | ||
viverra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
discourse: 42771 | ||
relatedlinks: https://github.com/canonical/sphinx-docs-starter-pack | ||
--- | ||
|
||
# Markdown test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
:discourse: 42771 | ||
:relatedlinks: https://github.com/canonical/sphinx-docs-starter-pack | ||
|
||
reST test | ||
========= |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Add a comment to indicate this is intended just for testing the starter pack itself.
I believe a lot of teams clone the starter pack instead of using the init script, so this might help to prevent them from running these checks unnecessarily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense - but if teams keep cloning the starter pack in the future, they will be in a lot of trouble, so we should REALLY tell them not to do this.