Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds testable examples for redis.io docs #2558

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/doctests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Documentation Tests

on:
push:
pull_request:

workflow_dispatch:

permissions:
contents: read

jobs:
doctests:
runs-on: ubuntu-latest
services:
redis-stack:
image: redis/redis-stack-server:latest
options: >-
--health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2.3.0
with:
node-version: 18
- name: Install Packages
run: npm ci
- name: Build
run: npm run build-all
- run: |
sudo apt update
sudo apt install -y redis-tools
- name: install doctest deps
run: |
npm install
working-directory: doctests
- name: run tests
run: |
sh run_examples.sh
working-directory: doctests
32 changes: 32 additions & 0 deletions doctests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Command examples for redis.io

## Setup

To set up the examples folder so that you can run an example / develop one of your own:

```
$ git clone https://github.com/redis/node-redis.git
$ cd node-redis
$ npm install -ws && npm run build-all
$ cd doctests
$ npm install
```

## How to add examples

Create regular node file in the current folder with meaningful name. It makes sense prefix example files with
command category (e.g. string, set, list, hash, etc) to make navigation in the folder easier.

### Special markup

See https://github.com/redis-stack/redis-stack-website#readme for more details.

## How to test the examples

Just include necessary assertions in the example file and run
```bash
sh doctests/run_examples.sh
```
to test all examples in the current folder.

See `tests.js` for more details.
Loading
Loading