From 1a8df47e022b994c9aad4c25a57cb385e2b2aa74 Mon Sep 17 00:00:00 2001 From: icefed Date: Fri, 2 Aug 2024 09:52:37 +0800 Subject: [PATCH] feat(registry-lint): use jv instead of ajv for clear error output --- registry-lint/action.yaml | 3 +++ registry-lint/validate-schema.sh | 4 +--- setup-jv/action.yaml | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 setup-jv/action.yaml diff --git a/registry-lint/action.yaml b/registry-lint/action.yaml index 9d87569..9ba364e 100644 --- a/registry-lint/action.yaml +++ b/registry-lint/action.yaml @@ -43,6 +43,9 @@ runs: echo "packages=${{ steps.changed-packages.outputs.all_changed_files }}" >> "$GITHUB_OUTPUT" fi + - name: Install jv + uses: mason-org/actions/setup-jv@v1 + - name: Validate schema conformance if: ${{ steps.package-targets.outputs.packages != '' }} shell: bash diff --git a/registry-lint/validate-schema.sh b/registry-lint/validate-schema.sh index e233f68..a7956ba 100755 --- a/registry-lint/validate-schema.sh +++ b/registry-lint/validate-schema.sh @@ -6,11 +6,9 @@ fi set -euo pipefail -npm install -g ajv ajv-cli ajv-formats - SCHEMA_FILE=$(mktemp -t XXXX.json) curl -fsSL https://github.com/mason-org/registry-schema/releases/latest/download/package.schema.json > "$SCHEMA_FILE" -<<< "$PACKAGES" tr ' ' '\n' | xargs -P10 -I{} ajv validate -d {} -c ajv-formats -s "$SCHEMA_FILE" +<<< "$PACKAGES" tr ' ' '\n' | xargs -P10 -I{} jv -d 7 "$SCHEMA_FILE" {} for pkg in $PACKAGES; do # Check if CRLF characters exist in the file diff --git a/setup-jv/action.yaml b/setup-jv/action.yaml new file mode 100644 index 0000000..7cbca85 --- /dev/null +++ b/setup-jv/action.yaml @@ -0,0 +1,18 @@ +--- +name: Setup jv +description: Action for setting up jv(JSONSchema Validator). Only supports Linux x64. + +inputs: + version: + description: jv version. + required: false + default: v6.0.1 + +runs: + using: composite + steps: + - name: Install jv + shell: bash + run: | + sudo curl -fL "https://github.com/santhosh-tekuri/jsonschema/releases/download/${{ inputs.version }}/jv-${{ inputs.version }}-linux-amd64.tar.gz" | sudo tar -C /usr/local/bin -xzf - + sudo chmod +x /usr/local/bin/jv