Skip to content

Commit

Permalink
fix: spectral linter (#340)
Browse files Browse the repository at this point in the history
* fix: remove minify json

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix: replace tab with space

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix: update spectral linter

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix: update spectral linter

Signed-off-by: bkioshn <bkioshn@gmail.com>

* fix: move openapi linter

Signed-off-by: bkioshn <bkioshn@gmail.com>

---------

Signed-off-by: bkioshn <bkioshn@gmail.com>
Co-authored-by: Steven Johnson <stevenj@users.noreply.github.com>
  • Loading branch information
bkioshn and stevenj authored Oct 29, 2024
1 parent 16fd122 commit 97361e9
Show file tree
Hide file tree
Showing 6 changed files with 333 additions and 364 deletions.
6 changes: 1 addition & 5 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,4 @@ edit-docs:
LOCALLY

RUN ./earthly/docs/dev/local.py cat-ci-docs:latest

# check-lint-openapi - OpenAPI linting from a given directory
check-lint-openapi:
FROM spectral-ci+spectral-base
DO spectral-ci+BUILD_SPECTRAL --dir="./examples/openapi" --file_type="json"

27 changes: 9 additions & 18 deletions earthly/spectral/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,20 @@ VERSION 0.8
# cspell: words ruleset

spectral-base:
FROM stoplight/spectral
FROM stoplight/spectral:6.13.1
WORKDIR /work
COPY . .
RUN chmod +x ./minify-json.sh
SAVE ARTIFACT minify-json.sh

BUILD_SPECTRAL:
LINT:
FUNCTION

# Specify what file type to lint
ARG file_type = "json"

# FIle type to be linted, default linting only JSON files
ARG file_type = json
# Directory to lint
ARG dir = .
ARG src = .
# Rule set for spectral
ARG rule_set=.spectral.yml

COPY $src .

COPY +spectral-base/minify-json.sh minify-json.sh
# If file type is json, minify the JSON
RUN ./minify-json.sh
ARG rule_set = .spectral.yml

RUN spectral \
lint \
$dir/"**/*.{yml,json}" \
--ruleset $rule_set
$dir/"**/*.$file_type" \
--ruleset $rule_set
22 changes: 0 additions & 22 deletions earthly/spectral/minify-json.sh

This file was deleted.

File renamed without changes.
8 changes: 8 additions & 0 deletions examples/openapi/Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
VERSION 0.8
IMPORT ../../earthly/spectral AS spectral-ci

# check-lint-openapi - OpenAPI linting from a given directory
check-lint-openapi:
FROM spectral-ci+spectral-base
COPY . .
DO spectral-ci+LINT --dir=. --rule_set=.spectral.yml
Loading

0 comments on commit 97361e9

Please sign in to comment.