xref: /curl/.github/workflows/checksrc.yml (revision cb092c0a)
1# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
2#
3# SPDX-License-Identifier: curl
4
5# This workflow contains checks at the source code level only.
6
7name: Source
8
9'on':
10  push:
11    branches:
12      - master
13      - '*/ci'
14    paths-ignore:
15      - '**/*.md'
16      - '.circleci/**'
17      - 'appveyor.*'
18      - 'plan9/**'
19      - 'tests/data/**'
20      - 'winbuild/**'
21  pull_request:
22    branches:
23      - master
24    paths-ignore:
25      - '**/*.md'
26      - '.circleci/**'
27      - 'appveyor.*'
28      - 'plan9/**'
29      - 'tests/data/**'
30      - 'winbuild/**'
31
32permissions: {}
33
34jobs:
35  checksrc:
36    runs-on: ubuntu-latest
37    steps:
38      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
39        name: checkout
40
41      - name: check
42        run: git ls-files -z "*.[ch]" | xargs -0 -n1 ./scripts/checksrc.pl
43
44  codespell-cmakelint-pytype-ruff:
45    runs-on: ubuntu-24.04
46    steps:
47      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
48        name: checkout
49
50      - name: install
51        env:
52          DEBIAN_FRONTEND: noninteractive
53        run: |
54          sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
55          sudo apt-get update -y
56          sudo apt-get install -y --no-install-suggests --no-install-recommends \
57            codespell python3-pip python3-networkx python3-pydot python3-yaml \
58            python3-toml python3-markupsafe python3-jinja2 python3-tabulate \
59            python3-typing-extensions python3-libcst python3-impacket \
60            python3-websockets python3-pytest
61          python3 -m pip install --break-system-packages cmakelint==1.4.3 pytype==2024.9.13 ruff==0.6.8
62
63      - name: spellcheck
64        run: |
65          codespell \
66            --skip scripts/mk-ca-bundle.pl \
67            --skip src/tool_hugehelp.c \
68            -I .github/scripts/codespell-ignore.txt \
69            CMake include m4 scripts src lib
70
71      - name: cmakelint
72        run: scripts/cmakelint.sh
73
74      - name: pytype
75        run: find . -name '*.py' -exec pytype -j auto -k {} +
76
77      - name: ruff
78        run: ruff check --extend-select=B007,B016,C405,C416,COM818,D200,D213,D204,D401,D415,FURB129,N818,PERF401,PERF403,PIE790,PIE808,PLW0127,Q004,RUF010,SIM101,SIM117,SIM118,TRY400,TRY401
79
80  reuse:
81    runs-on: ubuntu-latest
82    steps:
83      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
84        name: checkout
85
86      - name: REUSE Compliance Check
87        uses: fsfe/reuse-action@3ae3c6bdf1257ab19397fab11fd3312144692083 # v4
88
89  miscchecks:
90    runs-on: ubuntu-24.04
91    timeout-minutes: 5
92    steps:
93      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
94        name: checkout
95
96      - name: shellcheck
97        run: .github/scripts/shellcheck.sh
98
99      - name: spacecheck
100        run: .github/scripts/spacecheck.pl
101
102      - name: yamlcheck
103        run: .github/scripts/yamlcheck.sh
104
105      - name: binarycheck
106        run: .github/scripts/binarycheck.pl
107
108      # we allow some extra in source code
109      - name: badwords
110        run: |
111          grep -Ev '(\\bwill| url | dir )' .github/scripts/badwords.txt | \
112          .github/scripts/badwords.pl $(git ls-files -- src lib include)
113