Files
CI-templates/README-web-formatting.md
Brian Bjarke Jensen 3104d9748a
Test CI Templates / test-python-code-quality (3.11) (pull_request) Successful in 5s
Test CI Templates / test-python-code-quality (3.12) (pull_request) Successful in 4s
Test CI Templates / test-python-code-quality (true, false, skip-mypy) (pull_request) Successful in 4s
Test CI Templates / test-python-pytest (false, 3.11) (pull_request) Successful in 4s
Test CI Templates / test-python-pytest (true, 3.11) (pull_request) Successful in 5s
Test CI Templates / test-python-pytest (true, 3.12) (pull_request) Successful in 5s
Test CI Templates / test-web-formatting (false, false, 18) (pull_request) Successful in 5s
Test CI Templates / test-web-formatting (false, false, 20) (pull_request) Successful in 5s
Test CI Templates / test-web-formatting (false, true, 20) (pull_request) Successful in 6s
Test CI Templates / test-web-formatting (true, false, 18) (pull_request) Successful in 5s
Test CI Templates / test-web-formatting (true, true, 20) (pull_request) Successful in 4s
Test CI Templates / test-monorepo (pull_request) Successful in 4s
Test CI Templates / validate-syntax (pull_request) Successful in 10s
Test CI Templates / test-python-code-quality (3.10) (pull_request) Successful in 5s
Test CI Templates / test-python-code-quality (false, false, basic) (pull_request) Successful in 4s
Test CI Templates / test-python-code-quality (false, true, skip-pyupgrade) (pull_request) Successful in 4s
Test CI Templates / test-python-pytest (false, 3.12) (pull_request) Successful in 5s
Test CI Templates / test-web-formatting (false, true, 18) (pull_request) Successful in 5s
Test CI Templates / test-web-formatting (true, false, 20) (pull_request) Successful in 4s
Test CI Templates / test-web-formatting (true, true, 18) (pull_request) Successful in 4s
Test CI Templates / test-edge-cases (pull_request) Successful in 4s
Test CI Templates / test-results (pull_request) Successful in 3s
updated readme to reference first release
2025-09-19 21:02:23 +02:00

3.3 KiB

Web/General Formatting Pipeline Template

This reusable Gitea Actions workflow provides formatting checks for web technologies and general file formats including JavaScript, TypeScript, JSON, YAML, Markdown, and more using Prettier and other tools.

Features

  • Prettier formatting: Check formatting for JS, TS, JSON, YAML, Markdown, HTML, CSS, and more
  • YAML validation: Optional yamllint checking for YAML files
  • JSON validation: Optional JSON syntax validation
  • Configurable: Skip specific checks, custom prettier config, and more

Usage

Basic Usage

Create a workflow file in your repository (e.g., .gitea/workflows/formatting.yml):

name: Formatting Check

on:
  push:
    branches: [main]
  pull_request:

jobs:
  formatting:
    uses: gitea.gt-proj.com/brian/CI-templates/.gitea/workflows/web/formatting.yml@v1.0.0

Advanced Usage with Custom Options

name: Formatting Check

on:
  push:
    branches: [main]
  pull_request:

jobs:
  formatting:
    uses: gitea.gt-proj.com/brian/CI-templates/.gitea/workflows/web/formatting.yml@v1.0.0
    with:
      working-directory: "./frontend"
      node-version: "18"
      prettier-config: ".prettierrc.json"
      check-yaml: true
      check-json: true

Combined with Python Code Quality

For repositories that contain both Python and web technologies:

name: Code Quality

on:
  push:
    branches: [main]
  pull_request:

jobs:
  python-quality:
    uses: gitea.gt-proj.com/brian/CI-templates/.gitea/workflows/python/code-quality.yml@v1.0.0
    with:
      python-version: "3.12"
      working-directory: "./backend"

  web-formatting:
    uses: gitea.gt-proj.com/brian/CI-templates/.gitea/workflows/web/formatting.yml@v1.0.0
    with:
      working-directory: "./frontend"
      check-yaml: true

Input Parameters

Parameter Description Required Default Type
working-directory Working directory for the project No "." string
node-version Node.js version to use for prettier No "20" string
skip-prettier Skip prettier formatting check No false boolean
prettier-config Path to prettier config file No "" string
check-yaml Check YAML files with yamllint No false boolean
check-json Check JSON files for validity No false boolean

Prettier Configuration

You can customize Prettier behavior by:

  1. Using a config file: Set the prettier-config input to point to your config file
  2. Using default prettier discovery: Prettier will automatically find .prettierrc, .prettierrc.json, .prettierrc.js, etc.
  3. Using package.json: Add prettier config to your package.json

Example .prettierrc.json:

{
  "semi": true,
  "trailingComma": "es5",
  "singleQuote": true,
  "printWidth": 100,
  "tabWidth": 2
}

What Files Are Checked

  • Prettier: JavaScript, TypeScript, JSON, YAML, Markdown, HTML, CSS, and more
  • yamllint: All .yml and .yaml files (when enabled)
  • JSON validation: All .json files (when enabled)

Requirements

  • Repository must be public or you must have access to the template repository
  • For YAML checking: Repository should contain YAML files
  • For JSON checking: Repository should contain JSON files