branch: master
checksrc.yml
5104 bytesRaw
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# SPDX-License-Identifier: curl

# This workflow contains checks at the source code level only.

name: 'Source'

'on':
  push:
    branches:
      - master
      - '*/ci'
    paths-ignore:
      - '.circleci/**'
      - 'appveyor.*'
      - 'Dockerfile'
  pull_request:
    branches:
      - master
    paths-ignore:
      - '.circleci/**'
      - 'appveyor.*'
      - 'Dockerfile'

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
  cancel-in-progress: true

permissions: {}

jobs:
  checksrc:
    name: 'checksrc'
    runs-on: ubuntu-slim
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - name: 'check'
        run: scripts/checksrc-all.pl

  linters:
    name: 'spellcheck, linters, REUSE'
    runs-on: ubuntu-24.04-arm
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - name: 'install prereqs'
        run: |
          python3 -m venv ~/venv
          ~/venv/bin/pip --disable-pip-version-check --no-input --no-cache-dir install --progress-bar off --prefer-binary \
            -r .github/scripts/requirements.txt \
            -r tests/http/requirements.txt \
            -r tests/requirements.txt

      - name: 'REUSE check'
        run: |
          source ~/venv/bin/activate
          reuse lint

      - name: 'codespell'
        run: |
          source ~/venv/bin/activate
          codespell --version
          .github/scripts/codespell.sh

      - name: 'typos'
        timeout-minutes: 2
        run: |
          HOMEBREW_NO_AUTO_UPDATE=1 /home/linuxbrew/.linuxbrew/bin/brew install typos-cli
          eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
          typos --version
          .github/scripts/typos.sh

      - name: 'cmakelint'
        run: |
          source ~/venv/bin/activate
          scripts/cmakelint.sh

      - name: 'perlcheck'
        run: |
          scripts/perlcheck.sh

      - name: 'pytype'
        run: |
          source ~/venv/bin/activate
          find . -name '*.py' -exec pytype -j auto -k -- {} +

      - name: 'ruff'
        run: |
          source ~/venv/bin/activate
          scripts/pythonlint.sh

  complexity:
    name: 'complexity'
    runs-on: ubuntu-slim
    timeout-minutes: 3
    steps:
      - name: 'install pmccabe'
        run: |
          sudo rm -f /etc/apt/sources.list.d/{azure-cli.sources,microsoft-prod.list,ondrej-ubuntu-php-noble.sources}
          sudo apt-get -o Dpkg::Use-Pty=0 update
          sudo apt-get -o Dpkg::Use-Pty=0 install \
            pmccabe

      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - name: 'check scores'
        run: ./scripts/top-complexity

  xmllint:
    name: 'xmllint'
    runs-on: ubuntu-slim
    timeout-minutes: 3
    steps:
      - name: 'install prereqs'
        run: |
          sudo rm -f /etc/apt/sources.list.d/{azure-cli.sources,microsoft-prod.list,ondrej-ubuntu-php-noble.sources}
          sudo apt-get -o Dpkg::Use-Pty=0 update
          sudo apt-get -o Dpkg::Use-Pty=0 install \
            libxml2-utils

      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - name: 'check'
        run: git grep -z -i -l -E '^<\?xml' | xargs -0 -r xmllint --output /dev/null

  miscchecks:
    name: 'misc checks'
    runs-on: ubuntu-24.04-arm
    timeout-minutes: 5
    steps:
      - name: 'install prereqs'
        timeout-minutes: 2
        run: HOMEBREW_NO_AUTO_UPDATE=1 /home/linuxbrew/.linuxbrew/bin/brew install actionlint shellcheck zizmor

      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - name: 'zizmor GHA'
        env:
          GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
        run: |
          eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
          zizmor --pedantic .github/workflows/*.yml .github/dependabot.yml

      - name: 'actionlint'
        run: |
          eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
          export SHELLCHECK_OPTS='--exclude=1090,1091,2086,2153 --enable=avoid-nullary-conditions,deprecate-which'
          actionlint --version
          actionlint --ignore matrix .github/workflows/*.yml

      - name: 'shellcheck CI'
        run: |
          eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
          shellcheck --version
          .github/scripts/shellcheck-ci.sh

      - name: 'shellcheck'
        run: |
          eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
          shellcheck --version
          .github/scripts/shellcheck.sh

      - name: 'spacecheck'
        run: scripts/spacecheck.pl

      - name: 'yamlcheck'
        run: .github/scripts/yamlcheck.sh

      - name: 'badwords'
        run: scripts/badwords-all