87 lines
2.3 KiB
YAML
87 lines
2.3 KiB
YAML
name: Web/General Formatting Pipeline
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
working-directory:
|
|
description: 'Working directory for the project'
|
|
required: false
|
|
type: string
|
|
default: "."
|
|
node-version:
|
|
description: 'Node.js version to use for prettier (e.g., "20")'
|
|
required: false
|
|
type: string
|
|
default: "20"
|
|
skip-prettier:
|
|
description: 'Skip prettier formatting check'
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
prettier-config:
|
|
description: 'Path to prettier config file (optional)'
|
|
required: false
|
|
type: string
|
|
default: ""
|
|
check-yaml:
|
|
description: 'Check YAML files with yamllint'
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
check-json:
|
|
description: 'Check JSON files for validity'
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
|
|
jobs:
|
|
formatting:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ${{ inputs.working-directory }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
if: ${{ !inputs.skip-prettier }}
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ inputs.node-version }}
|
|
|
|
- name: Install prettier
|
|
if: ${{ !inputs.skip-prettier }}
|
|
run: npm install --save-dev --save-exact prettier
|
|
|
|
- name: Run prettier check
|
|
if: ${{ !inputs.skip-prettier }}
|
|
run: |
|
|
if [ -n "${{ inputs.prettier-config }}" ]; then
|
|
npx prettier --check . --config ${{ inputs.prettier-config }}
|
|
else
|
|
npx prettier --check .
|
|
fi
|
|
|
|
- name: Set up Python for YAML linting
|
|
if: ${{ inputs.check-yaml }}
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install yamllint
|
|
if: ${{ inputs.check-yaml }}
|
|
run: pip install yamllint
|
|
|
|
- name: Check YAML files
|
|
if: ${{ inputs.check-yaml }}
|
|
run: yamllint .
|
|
|
|
- name: Check JSON files
|
|
if: ${{ inputs.check-json }}
|
|
run: |
|
|
find . -name "*.json" -type f | while read -r file; do
|
|
echo "Checking $file"
|
|
python -m json.tool "$file" > /dev/null
|
|
done |