---
name: Linting jobs

on:
  - push
  - pull_request
  - workflow_dispatch

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
  # The concurrency group contains the workflow name and the branch name.
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  validate-composer:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
          persist-credentials: false
      - name: Validate composer.json and composer.lock
        uses: "docker://composer"
        with:
          args: "composer validate --no-check-lock"

  lint-json:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
          persist-credentials: false
      - name: Lint json
        uses: "docker://pipelinecomponents/jsonlint:latest"
        with:
          args: "find . -not -path './.git/*' -name '*.json' -type f -exec jsonlint --quiet {} ;"

  yamllint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
          persist-credentials: false
      - name: Check yaml for issues
        uses: pipeline-components/yamllint@master

  php-codesniffer:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
          persist-credentials: false
      - name: Check php for code style and php cross-version compatibility issues
        uses: pipeline-components/php-codesniffer@master

  lint-remark:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
          persist-credentials: false
      - name: Check markdown
        uses: pipeline-components/remark-lint@master
