Node Bundle #18
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Validate YAML with Spectral | |
| on: | |
| push: | |
| pull_request: | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Check out the repository | |
| - name: Checkout Code | |
| uses: actions/checkout@v3 | |
| # Step 2: Install Node.js (required for Spectral) | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '16' | |
| # Step 3: Install Spectral | |
| - name: Install Spectral | |
| run: | | |
| npm install -g @stoplight/spectral-cli | |
| whereis spectral | |
| - name: Install json-ref-resolver | |
| run: | | |
| npm install -g --save @apidevtools/json-schema-ref-parse | |
| # Step 4: Fetch the JSON Schema from the external GitHub repository | |
| - name: Download Schema | |
| run: | | |
| # curl -o ./schemas/metadata.json https://raw.githubusercontent.com/OpenXcom/vscode-ruleset/master/schemas/metadata.json | |
| git clone https://github.com/OpenXcom/vscode-ruleset | |
| # copy WeightedOptions.json etc. so it exists locally in the same folder | |
| cp -n --verbose ./vscode-ruleset/schemas/oxc/* ./vscode-ruleset/schemas/oxce-merge/ | |
| # cp -n --verbose ./vscode-ruleset/schemas/oxc/* ./ | |
| # Step 5: Generate the Ruleset JSON | |
| - name: Generate Ruleset JSON | |
| run: | | |
| echo '{ "rules": {' > ruleset.json | |
| first=true | |
| for schema in $(find ./vscode-ruleset/schemas -name '*.json' | grep -v "/oxc/"); do | |
| name=$(basename "$schema" .json) | |
| if [ "$first" = true ]; then | |
| first=false | |
| else | |
| echo ',' >> ruleset.json | |
| fi | |
| echo " \"${name}-validation\": {" >> ruleset.json | |
| echo " \"description\": \"Validate against $name\"," >> ruleset.json | |
| echo " \"given\": \"$\"," >> ruleset.json | |
| echo " \"then\": {" >> ruleset.json | |
| echo " \"function\": \"schema\"," >> ruleset.json | |
| echo " \"functionOptions\": {" >> ruleset.json | |
| echo " \"schema\": {" >> ruleset.json | |
| echo " \"\$ref\": \"$schema\"" >> ruleset.json | |
| echo " }" >> ruleset.json | |
| echo " }" >> ruleset.json | |
| echo " }" >> ruleset.json | |
| echo " }" >> ruleset.json | |
| done | |
| echo '}}' >> ruleset.json | |
| cat ruleset.json | |
| - name: Bundle Test | |
| run: | | |
| # npx json-schema-ref-parser bundle ruleset.json > bundled-ruleset.json | |
| node bundle-schemas.js | |
| cat bundled-ruleset.json | |
| # Step 6: Validate YAML Files with each Schema | |
| - name: Lint YAML Files | |
| run: | | |
| spectral lint --verbose --ruleset ./bundled-ruleset.json **/*.rul | |