Skip to content

Commit 534dfb2

Browse files
committed
Use bash script to test doc tests
1 parent 490f962 commit 534dfb2

File tree

5 files changed

+50
-26
lines changed

5 files changed

+50
-26
lines changed

.github/workflows/doctests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Documentation Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
doctests:
14+
runs-on: ubuntu-latest
15+
services:
16+
redis-stack:
17+
image: redis/redis-stack-server:latest
18+
options: >-
19+
--health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
20+
ports:
21+
- 6379:6379
22+
steps:
23+
- uses: actions/checkout@v3
24+
- uses: actions/setup-node@v2.3.0
25+
with:
26+
node-version: 18
27+
- name: Install Packages
28+
run: npm ci
29+
- run: |
30+
sudo apt update
31+
sudo apt install -y redis-tools
32+
- name: run tests
33+
run: |
34+
sh doctests/run_examples.sh

examples/docs/README.md renamed to doctests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ See https://github.com/redis-stack/redis-stack-website#readme for more details.
1313

1414
Just include necessary assertions in the example file and run
1515
```bash
16-
node tests.js
16+
sh doctests/run_examples.sh
1717
```
1818
to test all examples in the current folder.
1919

doctests/run_examples.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
4+
basepath=`readlink -f $1`
5+
if [ $? -ne 0 ]; then
6+
basepath=`readlink -f $(dirname $0)`
7+
fi
8+
echo "No path specified, using ${basepath}"
9+
10+
set -e
11+
cd ${basepath}
12+
for i in `ls ${basepath}/*.mjs`; do
13+
redis-cli flushdb
14+
node $i
15+
done
File renamed without changes.

examples/docs/tests.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)