Skip to content

Commit cd782ab

Browse files
committed
feat: Support Schemathesis hooks
Ref: #4
1 parent 64470e1 commit cd782ab

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

Diff for: .github/workflows/main.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,18 @@ jobs:
1717
# Start the API in the background
1818
- run: python apps/python/app.py &
1919

20-
- name: TEST
20+
- name: Default test
2121
uses: ./
22-
continue-on-error: true
2322
with:
2423
schema: 'http://127.0.0.1:5001/openapi.json'
2524
token: ${{ secrets.SCHEMATHESIS_TOKEN }}
2625
args: '-E success'
26+
27+
- name: Custom hooks
28+
uses: ./
29+
with:
30+
schema: 'http://127.0.0.1:5001/openapi.json'
31+
token: ${{ secrets.SCHEMATHESIS_TOKEN }}
32+
version: '3.18.5'
33+
hooks: 'apps.python.hooks'
34+
args: '-c custom_check -E success'

Diff for: README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Minimal:
1111
- uses: schemathesis/action@v1
1212
with:
1313
# API schema location
14-
schema: 'http://127.0.0.1:5001/openapi.json'
14+
schema: 'https://example.schemathesis.io/openapi.json'
1515
```
1616
1717
All options:
@@ -20,11 +20,11 @@ All options:
2020
- uses: schemathesis/action@v1
2121
with:
2222
# API schema location
23-
schema: 'http://127.0.0.1:5001/openapi.json'
23+
schema: 'https://example.schemathesis.io/openapi.json'
2424
# OPTIONAL. URL that will be used as a prefix for all API operations.
2525
# Required if the schema is provided as a file.
2626
# Otherwise, inferred from the schema.
27-
base-url: 'http://127.0.0.1:5001/v2/'
27+
base-url: 'https://example.schemathesis.io/v2/'
2828
# OPTIONAL. Your Schemathesis.io token
2929
token: ${{ secrets.SCHEMATHESIS_TOKEN }}
3030
# OPTIONAL. API name from Schemathesis.io
@@ -41,6 +41,8 @@ All options:
4141
# OPTIONAL. Specify which version of Schemathesis should be used.
4242
# Defaults to `latest`
4343
version: 'latest'
44+
# OPTIONAL. Schemathesis hooks module. Available for Schemathesis >= 3.18.5 only
45+
hooks: 'tests.hooks'
4446
# OPTIONAL. Extra arguments to pass to Schemathesis
4547
args: '-D negative'
4648
```

Diff for: action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ inputs:
3737
description: 'Specify which version of Schemathesis should be used. Defaults to `latest`'
3838
required: false
3939
default: "latest"
40+
hooks:
41+
description: 'Schemathesis hooks module'
42+
required: false
4043
args:
4144
description: 'Extra arguments to pass to Schemathesis'
4245
required: false
@@ -71,4 +74,5 @@ runs:
7174
SCHEMATHESIS_REPORT: ${{ inputs.report }}
7275
SCHEMATHESIS_WAIT_FOR_SCHEMA: ${{ inputs.wait-for-schema }}
7376
SCHEMATHESIS_TOKEN: ${{ inputs.token }}
77+
SCHEMATHESIS_HOOKS: ${{ inputs.hooks }}
7478
SCHEMATHESIS_ACTION_REF: ${{ github.action_ref }}

Diff for: apps/python/hooks.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import schemathesis
2+
3+
4+
@schemathesis.check
5+
def custom_check(response, case):
6+
# Always succeeds
7+
return None

0 commit comments

Comments
 (0)