Skip to content

Commit 1aa49d4

Browse files
authored
Nix shell for testing (#97)
* Test build using nix-shell --pure * Update node packages and nix dependencies * Add geckodriver and tests pass in nix-shell * Update conda and pip test requirements * Ensure curl and libcurl for testing * Use new setup-micromamba action * Relax python and curl version pins to get latest patch versions * Use latest micromamba * Exact setup-micromamba versions * Exact setup-micromamba version v1.4.4 * Use the last version of old micromamba action * Let conda install pycurl * Relax pycurl version * Limit to selenium v3 and urllib v1 for tests * Comment out pycurl * Upg actions/checkout and setup-node
1 parent d92ef0f commit 1aa49d4

File tree

9 files changed

+76
-42
lines changed

9 files changed

+76
-42
lines changed

.github/workflows/nodejs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ jobs:
3030
shell: bash -l {0}
3131

3232
steps:
33-
- uses: actions/checkout@v2
33+
- uses: actions/checkout@v4
3434

3535
- name: Use Node.js ${{ matrix.node-version }}
36-
uses: actions/setup-node@v2
36+
uses: actions/setup-node@v3
3737
with:
3838
node-version: ${{ matrix.node-version }}
3939

@@ -58,11 +58,11 @@ jobs:
5858
CI: true
5959

6060
- name: Install mamba
61-
uses: mamba-org/provision-with-micromamba@v12
61+
uses: mamba-org/provision-with-micromamba@v16
6262
with:
6363
environment-file: tests/environment.yml
6464

6565
- name: Fine grained tests
6666
run: |
6767
micromamba activate instant-markdown
68-
python -m pytest --log-cli-level=info
68+
python -m pytest

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ Ensure that prefix points to somewhere you have access to (such as the home dire
66

77
Read more on [how to configure `npm`'s paths](https://stackoverflow.com/a/13021677).
88

9-
npm install -g .
109
npm install
10+
npm link .
1111

1212
## Testing
1313

1414
Simple integration test
1515

1616
npm run test
1717

18-
Fine grained tests with checks for output requires Python, Firefox and geckodriver.
18+
Fine grained tests with checks for output requires Python, Firefox and geckodriver.
1919

2020
python -m venv venv && source venv/bin/activate && pip install -r tests/requirements.txt
2121
pytest --log-cli-level=info

default.nix

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
pkgs ? import <nixpkgs> {}
3+
}:
4+
5+
pkgs.mkShell {
6+
name = "instant-markdown-d";
7+
# nativeBuildInputs is usually what you want -- tools you need to run
8+
nativeBuildInputs = with pkgs.buildPackages; [
9+
nodePackages.npm
10+
git
11+
geckodriver
12+
];
13+
# libs
14+
buildInputs = with pkgs; [
15+
nodejs-slim-12_x
16+
];
17+
shellHook = ''
18+
npm install .
19+
ln -rsf ./src/cli.js node_modules/.bin/instant-markdown-d
20+
export PATH="$PWD/node_modules/.bin:$PATH"
21+
'';
22+
}
23+

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
},
2626
"dependencies": {
2727
"highlight.js": "^10.4.1",
28-
"markdown-it": "^8.4.2",
28+
"markdown-it": "^13.0.1",
2929
"markdown-it-mathjax": "^2.0.0",
3030
"markdown-it-task-lists": "^2.1.1",
3131
"markdown-it-front-matter": "^0.2.3",
3232
"markdown-it-textual-uml": "^0.1.3",
3333
"mathjax": "^2.7.5",
34-
"mathjax-node-page": "^3.0.2",
35-
"mermaid": "^8.9.0",
34+
"mathjax-node-page": "^1.4.0",
35+
"mermaid": "^9.1.1",
3636
"minimist": "^1.2.5",
3737
"send": "~0.17.1",
3838
"socket.io": "^3.0.4"

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[pytest]
2+
log_cli_level=info
23
log_format = %(asctime)s %(levelname)s %(filename)s:%(lineno)03d::%(funcName)-20s %(message)s
34
log_date_format = %H:%M:%S
45
addopts = --reruns 3 --reruns-delay 2

tests/conftest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
from selenium.webdriver.support.ui import WebDriverWait
1414

1515
logger = logging.getLogger("instant-markdown-d_tests")
16+
logger.setLevel(logging.INFO)
17+
# logger = logging
18+
# logging.basicConfig(level=logging.INFO)
1619

1720

1821
def port_in_use(port):
@@ -93,7 +96,11 @@ def __init__(self, options, port=8090):
9396

9497
def __enter__(self):
9598
node = which("node")
99+
if not node:
100+
raise OSError("Node.js is not installed.")
101+
96102
cmd = [node, "./src/cli.js", *self.options]
103+
assert all(isinstance(c, str) for c in cmd)
97104
logger.info(f"Running {' '.join(cmd)}")
98105
self.process = subprocess.Popen(
99106
cmd,
@@ -165,3 +172,14 @@ def browser():
165172
@pytest.fixture(scope="function")
166173
def Server():
167174
return InstantMarkdownD
175+
176+
177+
if __name__ == "__main__":
178+
# Run
179+
# python tests/conftest.py
180+
# to ensure all fixtures work
181+
with BrowserEngine():
182+
pass
183+
184+
with InstantMarkdownD(""):
185+
pass

tests/environment.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ channels:
33
- conda-forge
44
- defaults
55
dependencies:
6-
- firefox=89.0
7-
- geckodriver=0.29.0
8-
- pycurl=7.43.0.6
9-
- pytest=6.2.4
10-
- pytest-rerunfailures=10.0
11-
- python=3.9.4
12-
- selenium=3.141.0
13-
- wheel=0.36.2
6+
- firefox=115.2.1esr
7+
- geckodriver=0.33.0
8+
- python=3.9
9+
- curl=8.3
10+
- pycurl=7
11+
- pip:
12+
- -r requirements.txt

tests/requirements.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
wheel
2-
selenium
1+
selenium<4
2+
urllib3<2
33
pytest
44
pytest-rerunfailures
5-
pycurl
5+
# pycurl

tests/requirements.txt

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,30 @@
11
#
2-
# This file is autogenerated by pip-compile
2+
# This file is autogenerated by pip-compile with python 3.9
33
# To update, run:
44
#
55
# pip-compile
66
#
7-
attrs==21.2.0
7+
exceptiongroup==1.1.3
88
# via pytest
9-
iniconfig==1.1.1
9+
iniconfig==2.0.0
1010
# via pytest
11-
packaging==20.9
12-
# via pytest
13-
pluggy==0.13.1
14-
# via pytest
15-
py==1.10.0
11+
packaging==23.1
12+
# via
13+
# pytest
14+
# pytest-rerunfailures
15+
pluggy==1.3.0
1616
# via pytest
17-
pycurl==7.43.0.6
18-
# via -r requirements.in
19-
pyparsing==2.4.7
20-
# via packaging
21-
pytest==6.2.4
17+
pytest==7.4.2
2218
# via
2319
# -r requirements.in
2420
# pytest-rerunfailures
25-
pytest-rerunfailures==10.0
21+
pytest-rerunfailures==12.0
2622
# via -r requirements.in
2723
selenium==3.141.0
2824
# via -r requirements.in
29-
toml==0.10.2
25+
tomli==2.0.1
3026
# via pytest
31-
urllib3==1.26.5
32-
# via selenium
33-
wheel==0.38.1
34-
# via -r requirements.in
35-
36-
# The following packages are considered to be unsafe in a requirements file:
37-
# setuptools
27+
urllib3==1.26.16
28+
# via
29+
# -r requirements.in
30+
# selenium

0 commit comments

Comments
 (0)