Skip to content

Commit

Permalink
Added CI for testing the Sphinx Needs JS libs (#819)
Browse files Browse the repository at this point in the history
* Added CI for testing the Sphinx Needs JS libs

* Updated CI for JS Test

* Minor bug fixes

* CI fixes

* Updated js_test CI workflow and .gitignore
  • Loading branch information
iSOLveIT committed Nov 29, 2022
1 parent dd3a7e8 commit 56b4835
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 10 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/js_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Cypress E2E tests for Sphinx Needs
on: [pull_request]
jobs:
js_tests:
runs-on: ubuntu-latest
env:
ON_CI: true
FAST_BUILD: true
steps:
- name: Set Up Python 3.10.8
uses: actions/setup-python@v3
with:
python-version: 3.10.8
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/checkout@v3.1.0
- name: Update pip
run: |
pip install -U wheel
pip install -U setuptools
python -m pip install -U pip
- name: Get pip cache dir
id: pip-cache
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Pip cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python dependencies
run: |
pip install -r docs/requirements.txt
- name: Install Sphinx-Needs from master
run: |
pip install -e .
- name: Install Node dependencies
run: npm install cypress
- name: Build Docs
id: sphinx-build-docs
run: sphinx-build -a -T -E -j 4 -b html -d /tmp/sphinx_build/doctrees ./docs /tmp/sphinx_build/html
- name: E2E Cypress Test on Chrome
uses: cypress-io/github-action@v4
with:
browser: chrome
config-file: tests/js_test/cypress.config.js
start: npm start
# quote the url to be safe against YML parsing surprises
wait-on: 'http://localhost:8080'



3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,3 @@ mem_out.*

pyinstrument*
*.prof

package-lock.json
package.json
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Released: 22.09.2022
* Improvement: Renamed jinja function `need` to `flow` for :ref:`needuml`.
* Improvement: Added directive :ref:`needarch`.
* Improvement: Added configuration option :ref:`needs_ide_snippets_id` to support custom need ID for :ref:`ide` snippets.
* Improvement: Provides jinja function :ref:`needarch_jinja_import` for :ref:`needarch` to execute :ref:`jinja_uml`
* Improvement: Provides jinja function :ref:`needarch_jinja_import` for :ref:`needarch` to execute :ref:`needuml_jinja_uml`
automatically for all the links defined in the need :ref:`need_links` options.
* Improvement: Added configuration :ref:`needs_ide_directive_snippets` to support custom directive snippets for IDE features.
(`#640 <https://github.com/useblocks/sphinx-needs/issues/640>`_)
Expand Down
8 changes: 4 additions & 4 deletions docs/directives/needuml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,10 @@ Finds a list of Sphinx-Need objects that pass the given filter string.
{% endfor %}


.. _needuml_jinja_ref
.. _needuml_jinja_ref:

ref(id, option, text)
~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~

Allows to create an hyperlink to a Sphinx-Need object in a PlantUML schema. The
text associated to the hyperlink is either defined by `option` (in this case,
Expand All @@ -368,8 +368,8 @@ Sphinx-Need picks the text of the field specified by `option`), or by the free t

.. needuml::

Alice -> Bob: {{ref("FEATURE_1", option="title")}}
Bob -> Alice: {{ref("FEATURE_2", text="A completely free text")}}
Alice -> Bob: {{ref("FEATURE_1", option="title")}}
Bob -> Alice: {{ref("FEATURE_2", text="A completely free text")}}

.. _needuml_jinja_uml:

Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def tests(session, sphinx, docutils):
def linkcheck(session):
session.install(".")
# LinkCheck can handle rate limits since Sphinx 3.4, which is needed as
# our doc has to many links to GitHub.
# our doc has too many links to GitHub.
session.run("pip", "install", "sphinx==3.5.4", silent=True)

session.run("pip", "install", "-r", "docs/requirements.txt", silent=True)
Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "test-sphinx-needs",
"description": "E2E tests for Sphinx Needs",
"scripts": {
"start": "python3 -m http.server --directory='/tmp/sphinx_build/html' 8080"
}
}
5 changes: 4 additions & 1 deletion tests/js_test/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module.exports = {
setupNodeEvents(on, config) {
// implement node event listeners here
},
baseUrl: 'http://localhost:8000'
baseUrl: 'http://localhost:8080',
specPattern: 'tests/js_test/cypress/e2e/test-*.js',
fixturesFolder: false,
supportFile: 'tests/js_test/cypress/support/e2e.js',
},
};

0 comments on commit 56b4835

Please sign in to comment.