Skip to content

Commit 6e9b4e4

Browse files
committed
Improves OpenAPI Lint
1 parent 9f46a9a commit 6e9b4e4

1 file changed

Lines changed: 69 additions & 17 deletions

File tree

.github/workflows/lint_openapi_spec.yml

Lines changed: 69 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,71 +7,123 @@ on:
77
pull_request:
88
paths:
99
- 'QuantConnect-Platform-2.0.0.yaml'
10+
workflow_dispatch:
1011

1112
permissions:
1213
contents: read
1314
pull-requests: write
15+
issues: write
1416

1517
jobs:
1618
vacuum-lint:
1719
name: Run OpenAPI linting with vacuum
1820
runs-on: ubuntu-latest
1921
steps:
2022
- name: Checkout repository
21-
uses: actions/checkout@v3
23+
uses: actions/checkout@v6
24+
25+
- name: Install vacuum
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
run: |
29+
curl -fsSL https://quobix.com/scripts/install_vacuum.sh | sh
2230
2331
- name: Lint OpenAPI specification using vacuum
2432
id: lint
2533
shell: bash
2634
env:
27-
DOCKER_BUILDKIT: 1
2835
OPENAPI_PATH: "QuantConnect-Platform-2.0.0.yaml"
2936
SHOW_RULES: "false"
3037
MINIMUM_SCORE: "10"
3138
FAIL_ON_ERROR: "true"
3239
RULESET: ""
3340
PRINT_LOGS: "true"
34-
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
3541
run: |
3642
args=( lint --pipeline-output "$OPENAPI_PATH" )
37-
43+
3844
# --min-score <value>
3945
args+=( --min-score "$MINIMUM_SCORE" )
40-
46+
4147
# --fail-severity none|error
4248
if [ "$FAIL_ON_ERROR" = "true" ]; then
4349
args+=( --fail-severity error )
4450
else
4551
args+=( --fail-severity none )
4652
fi
47-
53+
4854
# --show-rules only if show_rules == "true"
4955
if [ "$SHOW_RULES" = "true" ]; then
5056
args+=( --show-rules )
5157
fi
52-
58+
5359
# optional ruleset
5460
if [ -n "$RULESET" ]; then
5561
args+=( --ruleset "$RULESET" )
5662
fi
57-
58-
CMD=( docker run --rm \
59-
-v "$GITHUB_WORKSPACE":/work:ro \
60-
dshanley/vacuum "${args[@]}" )
61-
62-
echo "Running: ${CMD[*]}"
63-
report=$("${CMD[@]}")
64-
63+
64+
echo "Running: vacuum ${args[*]}"
65+
set +e
66+
report=$(vacuum "${args[@]}")
67+
exit_code=$?
68+
set -e
69+
6570
REPORT_FILE="$GITHUB_WORKSPACE/vacuum-lint-report.md"
6671
{
6772
echo "<!-- vacuum-lint-report -->"
6873
echo
6974
echo "$report"
7075
} > "$REPORT_FILE"
71-
76+
7277
# print logs to console if enabled
7378
if [ "$PRINT_LOGS" = "true" ]; then
7479
cat "$REPORT_FILE"
7580
fi
76-
81+
7782
echo "report_path=vacuum-lint-report.md" >> "$GITHUB_OUTPUT"
83+
echo "exit_code=$exit_code" >> "$GITHUB_OUTPUT"
84+
exit $exit_code
85+
86+
- name: Create GitHub issue on failure
87+
if: failure() && github.event_name == 'workflow_dispatch'
88+
env:
89+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
run: |
91+
REPORT_FILE="$GITHUB_WORKSPACE/vacuum-lint-report.md"
92+
SUMMARY=$(sed -n '/| Category/,/^$/p' "$REPORT_FILE")
93+
94+
BODY=$(cat <<EOF
95+
## OpenAPI Lint Errors
96+
97+
The \`vacuum\` linter found errors in \`QuantConnect-Platform-2.0.0.yaml\`.
98+
99+
$SUMMARY
100+
101+
**Run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
102+
103+
## Steps to fix
104+
105+
1. Install vacuum locally:
106+
- **Linux/macOS:** \`curl -fsSL https://quobix.com/scripts/install_vacuum.sh | sh\`
107+
- **Windows:** download the latest release from https://github.com/daveshanley/vacuum/releases (e.g. \`vacuum_*_windows_x86_64.tar.gz\`), extract, and add to PATH.
108+
2. Run vacuum to get the detailed error report:
109+
\`\`\`
110+
vacuum lint QuantConnect-Platform-2.0.0.yaml --fail-severity error
111+
\`\`\`
112+
3. Fix each error in \`QuantConnect-Platform-2.0.0.yaml\`. Common issues:
113+
- \`oas3-schema\`: Using \`nullable: true\` (OpenAPI 3.0 style) instead of \`type: [string, "null"]\` (OpenAPI 3.1 style).
114+
- \`oas-schema-check\`: Fields listed in \`required\` that don't exist in \`properties\`, or invalid type values (e.g. \`type: int\` instead of \`type: integer\`).
115+
4. Re-run vacuum to confirm no errors remain:
116+
\`\`\`
117+
vacuum lint QuantConnect-Platform-2.0.0.yaml --fail-severity error
118+
\`\`\`
119+
5. Regenerate the API reference pages:
120+
\`\`\`
121+
python code-generators/API-Reference-Code-Generator.py
122+
\`\`\`
123+
EOF
124+
)
125+
126+
gh issue create \
127+
--title "OpenAPI spec lint errors detected" \
128+
--body "$BODY" \
129+
--label "bug"

0 commit comments

Comments
 (0)