xref: /curl/.github/workflows/checksrc.yml (revision 38c57bdf)
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 apt-get install -y --no-install-suggests --no-install-recommends
55          codespell python3-pip python3-networkx python3-pydot python3-yaml
56          python3-toml python3-markupsafe python3-jinja2 python3-tabulate
57          python3-typing-extensions python3-libcst python3-impacket
58          python3-websockets python3-pytest &&
59          python3 -m pip install --break-system-packages cmakelint==1.4.3 pytype==2024.9.13 ruff==0.6.8
60
61      - name: spellcheck
62        run: |
63          codespell \
64            --skip scripts/mk-ca-bundle.pl \
65            --skip src/tool_hugehelp.c \
66            -I .github/scripts/codespell-ignore.txt \
67            CMake include m4 scripts src lib
68
69      - name: cmakelint
70        run: scripts/cmakelint.sh
71
72      - name: pytype
73        run: find . -name '*.py' -exec pytype -j auto -k {} +
74
75      - name: ruff
76        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
77
78  reuse:
79    runs-on: ubuntu-latest
80    steps:
81      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
82        name: checkout
83
84      - name: REUSE Compliance Check
85        uses: fsfe/reuse-action@3ae3c6bdf1257ab19397fab11fd3312144692083 # v4
86
87  miscchecks:
88    runs-on: ubuntu-24.04
89    timeout-minutes: 5
90    steps:
91      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
92        name: checkout
93
94      - name: shellcheck
95        run: .github/scripts/shellcheck.sh
96
97      - name: spacecheck
98        run: .github/scripts/spacecheck.pl
99
100      - name: yamlcheck
101        run: .github/scripts/yamlcheck.sh
102
103      - name: binarycheck
104        run: .github/scripts/binarycheck.pl
105
106      # we allow some extra in source code
107      - name: badwords
108        run: |
109          grep -Ev '(\\bwill| url | dir )' .github/scripts/badwords.txt | \
110          .github/scripts/badwords.pl $(git ls-files -- src lib include)
111