From 679b2ed61deec35921f6bac2babe2a3114597710 Mon Sep 17 00:00:00 2001 From: Ruth Fuchss Date: Wed, 24 Jul 2024 12:08:23 +0200 Subject: [PATCH] add test files Add some files that we can use to test the functionality. Signed-off-by: Ruth Fuchss --- .github/workflows/test-starter-pack.yml | 4 +++ sp-tests/add-files-and-build.sh | 34 +++++++++++++++++++++++++ sp-tests/testfiles/test-md.md | 6 +++++ sp-tests/testfiles/test-rst.rst | 5 ++++ 4 files changed, 49 insertions(+) create mode 100755 sp-tests/add-files-and-build.sh create mode 100644 sp-tests/testfiles/test-md.md create mode 100644 sp-tests/testfiles/test-rst.rst diff --git a/.github/workflows/test-starter-pack.yml b/.github/workflows/test-starter-pack.yml index ec826115..6109d8da 100644 --- a/.github/workflows/test-starter-pack.yml +++ b/.github/workflows/test-starter-pack.yml @@ -18,6 +18,8 @@ jobs: 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 @@ -45,6 +47,8 @@ jobs: 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 diff --git a/sp-tests/add-files-and-build.sh b/sp-tests/add-files-and-build.sh new file mode 100755 index 00000000..930ff40c --- /dev/null +++ b/sp-tests/add-files-and-build.sh @@ -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 diff --git a/sp-tests/testfiles/test-md.md b/sp-tests/testfiles/test-md.md new file mode 100644 index 00000000..e732a0f0 --- /dev/null +++ b/sp-tests/testfiles/test-md.md @@ -0,0 +1,6 @@ +--- +discourse: 42771 +relatedlinks: https://github.com/canonical/sphinx-docs-starter-pack +--- + +# Markdown test diff --git a/sp-tests/testfiles/test-rst.rst b/sp-tests/testfiles/test-rst.rst new file mode 100644 index 00000000..15efd01f --- /dev/null +++ b/sp-tests/testfiles/test-rst.rst @@ -0,0 +1,5 @@ +:discourse: 42771 +:relatedlinks: https://github.com/canonical/sphinx-docs-starter-pack + +reST test +=========