|
1 | 1 | name: "Lint OpenAPI spec with vacuum" |
2 | 2 |
|
3 | 3 | on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - 'QuantConnect-Platform-2.0.0.yaml' |
4 | 7 | pull_request: |
5 | 8 | paths: |
6 | 9 | - 'QuantConnect-Platform-2.0.0.yaml' |
|
17 | 20 | - name: Checkout repository |
18 | 21 | uses: actions/checkout@v3 |
19 | 22 |
|
20 | | - - name: Run OpenAPI lint with vacuum |
21 | | - uses: pb33f/vacuum-action@v2 |
22 | | - with: |
23 | | - openapi_path: "QuantConnect-Platform-2.0.0.yaml" |
24 | | - github_token: ${{ secrets.GH_ACCESS_TOKEN }} |
| 23 | + - name: Lint OpenAPI specification using vacuum |
| 24 | + id: lint |
| 25 | + shell: bash |
| 26 | + env: |
| 27 | + DOCKER_BUILDKIT: 1 |
| 28 | + OPENAPI_PATH: "QuantConnect-Platform-2.0.0.yaml" |
| 29 | + SHOW_RULES: "false" |
| 30 | + MINIMUM_SCORE: "70" |
| 31 | + FAIL_ON_ERROR: "true" |
| 32 | + RULESET: "" |
| 33 | + PRINT_LOGS: "true" |
| 34 | + GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} |
| 35 | + run: | |
| 36 | + args=( lint --pipeline-output "$OPENAPI_PATH" ) |
| 37 | + |
| 38 | + # --min-score <value> |
| 39 | + args+=( --min-score "$MINIMUM_SCORE" ) |
| 40 | + |
| 41 | + # --fail-severity none|error |
| 42 | + if [ "$FAIL_ON_ERROR" = "true" ]; then |
| 43 | + args+=( --fail-severity error ) |
| 44 | + else |
| 45 | + args+=( --fail-severity none ) |
| 46 | + fi |
| 47 | + |
| 48 | + # --show-rules only if show_rules == "true" |
| 49 | + if [ "$SHOW_RULES" = "true" ]; then |
| 50 | + args+=( --show-rules ) |
| 51 | + fi |
| 52 | + |
| 53 | + # optional ruleset |
| 54 | + if [ -n "$RULESET" ]; then |
| 55 | + args+=( --ruleset "$RULESET" ) |
| 56 | + 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 | + |
| 65 | + REPORT_FILE="$GITHUB_WORKSPACE/vacuum-lint-report.md" |
| 66 | + { |
| 67 | + echo "<!-- vacuum-lint-report -->" |
| 68 | + echo |
| 69 | + echo "$report" |
| 70 | + } > "$REPORT_FILE" |
| 71 | + |
| 72 | + # print logs to console if enabled |
| 73 | + if [ "$PRINT_LOGS" = "true" ]; then |
| 74 | + cat "$REPORT_FILE" |
| 75 | + fi |
| 76 | + |
| 77 | + echo "report_path=vacuum-lint-report.md" >> "$GITHUB_OUTPUT" |
0 commit comments