Skip to content

Commit 92f0137

Browse files
committed
feat: Support config-file
Signed-off-by: Dmitry Dygalo <[email protected]>
1 parent 71f06c5 commit 92f0137

File tree

3 files changed

+47
-6
lines changed

3 files changed

+47
-6
lines changed

.github/workflows/main.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,20 @@ jobs:
3636
version: 'latest'
3737
hooks: 'apps.python.hooks'
3838
args: '-c custom_check --include-name-regex success -H "Authorization: Bearer ${{ env.ACCESS_TOKEN }}"'
39+
40+
- name: Write a Schemathesis config file
41+
run: |
42+
mkdir -p .github/schemathesis
43+
cat <<EOF > .github/schemathesis/schemathesis.toml
44+
[[operations]]
45+
# Disable everything except `GET /success`
46+
exclude-name = "GET /success"
47+
enabled = false
48+
EOF
49+
50+
- name: With config file
51+
uses: ./
52+
with:
53+
schema: 'http://127.0.0.1:5001/openapi.json'
54+
version: 'latest'
55+
config-file: '.github/schemathesis/schemathesis.toml'

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ GitHub Action for running [Schemathesis](https://github.com/schemathesis/schemat
2828
version: 'latest'
2929
# Python module path for hooks
3030
hooks: 'tests.hooks'
31+
# Path to a `schemathesis.toml` configuration file
32+
config-file: 'tests/schemathesis-config.yaml'
3133
# Additional CLI arguments
3234
args: '--report-junit-path=/tmp/junit.xml'
3335
```

action.yml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ inputs:
3030
hooks:
3131
description: 'Python module path for hooks'
3232
required: false
33+
config-file:
34+
description: 'Path to a `schemathesis.toml` configuration file'
35+
required: false
3336
args:
3437
description: 'Additional CLI arguments'
3538
required: false
@@ -50,12 +53,31 @@ runs:
5053
fi
5154
shell: bash
5255
- run: |
53-
schemathesis run \
54-
${{ inputs.schema }} \
55-
--generation-database=:memory: \
56-
--max-examples=${{ inputs.max-examples }} \
57-
--checks=${{ inputs.checks }} \
58-
${{ inputs.args }} \
56+
set -euo pipefail
57+
58+
SCHEMA='${{ inputs.schema }}'
59+
CHECKS='${{ inputs.checks }}'
60+
MAX_EXAMPLES='${{ inputs.max-examples }}'
61+
CONFIG_FILE='${{ inputs.config-file }}'
62+
ARGS='${{ inputs.args }}'
63+
64+
eval "ARGS_ARRAY=($ARGS)"
65+
66+
CMD=(schemathesis)
67+
if [[ -n "$CONFIG_FILE" ]]; then
68+
CMD+=(--config-file="$CONFIG_FILE")
69+
fi
70+
71+
CMD+=(run
72+
"$SCHEMA"
73+
--generation-database=":memory:"
74+
--max-examples="$MAX_EXAMPLES"
75+
--checks="$CHECKS"
76+
)
77+
78+
CMD+=("${ARGS_ARRAY[@]}")
79+
80+
"${CMD[@]}"
5981
shell: bash
6082
env:
6183
SCHEMATHESIS_BASE_URL: ${{ inputs.base-url }}

0 commit comments

Comments
 (0)