Skip to content

Commit 56b4835

Browse files
authored
Added CI for testing the Sphinx Needs JS libs (#819)
* 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
1 parent dd3a7e8 commit 56b4835

File tree

8 files changed

+73
-10
lines changed

8 files changed

+73
-10
lines changed

.github/workflows/js_test.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Cypress E2E tests for Sphinx Needs
2+
on: [pull_request]
3+
jobs:
4+
js_tests:
5+
runs-on: ubuntu-latest
6+
env:
7+
ON_CI: true
8+
FAST_BUILD: true
9+
steps:
10+
- name: Set Up Python 3.10.8
11+
uses: actions/setup-python@v3
12+
with:
13+
python-version: 3.10.8
14+
- name: Use Node.js
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: 18
18+
- uses: actions/[email protected]
19+
- name: Update pip
20+
run: |
21+
pip install -U wheel
22+
pip install -U setuptools
23+
python -m pip install -U pip
24+
- name: Get pip cache dir
25+
id: pip-cache
26+
run: |
27+
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
28+
- name: Pip cache
29+
uses: actions/cache@v2
30+
with:
31+
path: ${{ steps.pip-cache.outputs.dir }}
32+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
33+
restore-keys: |
34+
${{ runner.os }}-pip-
35+
- name: Install Python dependencies
36+
run: |
37+
pip install -r docs/requirements.txt
38+
- name: Install Sphinx-Needs from master
39+
run: |
40+
pip install -e .
41+
- name: Install Node dependencies
42+
run: npm install cypress
43+
- name: Build Docs
44+
id: sphinx-build-docs
45+
run: sphinx-build -a -T -E -j 4 -b html -d /tmp/sphinx_build/doctrees ./docs /tmp/sphinx_build/html
46+
- name: E2E Cypress Test on Chrome
47+
uses: cypress-io/github-action@v4
48+
with:
49+
browser: chrome
50+
config-file: tests/js_test/cypress.config.js
51+
start: npm start
52+
# quote the url to be safe against YML parsing surprises
53+
wait-on: 'http://localhost:8080'
54+
55+
56+

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,3 @@ mem_out.*
3636

3737
pyinstrument*
3838
*.prof
39-
40-
package-lock.json
41-
package.json

docs/changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Released: 22.09.2022
110110
* Improvement: Renamed jinja function `need` to `flow` for :ref:`needuml`.
111111
* Improvement: Added directive :ref:`needarch`.
112112
* Improvement: Added configuration option :ref:`needs_ide_snippets_id` to support custom need ID for :ref:`ide` snippets.
113-
* Improvement: Provides jinja function :ref:`needarch_jinja_import` for :ref:`needarch` to execute :ref:`jinja_uml`
113+
* Improvement: Provides jinja function :ref:`needarch_jinja_import` for :ref:`needarch` to execute :ref:`needuml_jinja_uml`
114114
automatically for all the links defined in the need :ref:`need_links` options.
115115
* Improvement: Added configuration :ref:`needs_ide_directive_snippets` to support custom directive snippets for IDE features.
116116
(`#640 <https://github.com/useblocks/sphinx-needs/issues/640>`_)

docs/directives/needuml.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,10 @@ Finds a list of Sphinx-Need objects that pass the given filter string.
345345
{% endfor %}
346346

347347

348-
.. _needuml_jinja_ref
348+
.. _needuml_jinja_ref:
349349

350350
ref(id, option, text)
351-
~~~~~~~~~~~~~~~~~~~~~~
351+
~~~~~~~~~~~~~~~~~~~~~
352352

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

369369
.. needuml::
370370

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

374374
.. _needuml_jinja_uml:
375375

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def tests(session, sphinx, docutils):
5959
def linkcheck(session):
6060
session.install(".")
6161
# LinkCheck can handle rate limits since Sphinx 3.4, which is needed as
62-
# our doc has to many links to GitHub.
62+
# our doc has too many links to GitHub.
6363
session.run("pip", "install", "sphinx==3.5.4", silent=True)
6464

6565
session.run("pip", "install", "-r", "docs/requirements.txt", silent=True)

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "test-sphinx-needs",
3+
"description": "E2E tests for Sphinx Needs",
4+
"scripts": {
5+
"start": "python3 -m http.server --directory='/tmp/sphinx_build/html' 8080"
6+
}
7+
}

tests/js_test/cypress.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ module.exports = {
33
setupNodeEvents(on, config) {
44
// implement node event listeners here
55
},
6-
baseUrl: 'http://localhost:8000'
6+
baseUrl: 'http://localhost:8080',
7+
specPattern: 'tests/js_test/cypress/e2e/test-*.js',
8+
fixturesFolder: false,
9+
supportFile: 'tests/js_test/cypress/support/e2e.js',
710
},
811
};

0 commit comments

Comments
 (0)