|
7 | 7 | pull_request: |
8 | 8 | paths: |
9 | 9 | - 'QuantConnect-Platform-2.0.0.yaml' |
| 10 | + workflow_dispatch: |
10 | 11 |
|
11 | 12 | permissions: |
12 | 13 | contents: read |
13 | 14 | pull-requests: write |
| 15 | + issues: write |
14 | 16 |
|
15 | 17 | jobs: |
16 | 18 | vacuum-lint: |
17 | 19 | name: Run OpenAPI linting with vacuum |
18 | 20 | runs-on: ubuntu-latest |
19 | 21 | steps: |
20 | 22 | - 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 |
22 | 30 |
|
23 | 31 | - name: Lint OpenAPI specification using vacuum |
24 | 32 | id: lint |
25 | 33 | shell: bash |
26 | 34 | env: |
27 | | - DOCKER_BUILDKIT: 1 |
28 | 35 | OPENAPI_PATH: "QuantConnect-Platform-2.0.0.yaml" |
29 | 36 | SHOW_RULES: "false" |
30 | 37 | MINIMUM_SCORE: "10" |
31 | 38 | FAIL_ON_ERROR: "true" |
32 | 39 | RULESET: "" |
33 | 40 | PRINT_LOGS: "true" |
34 | | - GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} |
35 | 41 | run: | |
36 | 42 | args=( lint --pipeline-output "$OPENAPI_PATH" ) |
37 | | - |
| 43 | +
|
38 | 44 | # --min-score <value> |
39 | 45 | args+=( --min-score "$MINIMUM_SCORE" ) |
40 | | - |
| 46 | +
|
41 | 47 | # --fail-severity none|error |
42 | 48 | if [ "$FAIL_ON_ERROR" = "true" ]; then |
43 | 49 | args+=( --fail-severity error ) |
44 | 50 | else |
45 | 51 | args+=( --fail-severity none ) |
46 | 52 | fi |
47 | | - |
| 53 | +
|
48 | 54 | # --show-rules only if show_rules == "true" |
49 | 55 | if [ "$SHOW_RULES" = "true" ]; then |
50 | 56 | args+=( --show-rules ) |
51 | 57 | fi |
52 | | - |
| 58 | +
|
53 | 59 | # optional ruleset |
54 | 60 | if [ -n "$RULESET" ]; then |
55 | 61 | args+=( --ruleset "$RULESET" ) |
56 | 62 | 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 | +
|
65 | 70 | REPORT_FILE="$GITHUB_WORKSPACE/vacuum-lint-report.md" |
66 | 71 | { |
67 | 72 | echo "<!-- vacuum-lint-report -->" |
68 | 73 | echo |
69 | 74 | echo "$report" |
70 | 75 | } > "$REPORT_FILE" |
71 | | - |
| 76 | +
|
72 | 77 | # print logs to console if enabled |
73 | 78 | if [ "$PRINT_LOGS" = "true" ]; then |
74 | 79 | cat "$REPORT_FILE" |
75 | 80 | fi |
76 | | - |
| 81 | +
|
77 | 82 | 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