Skip to content

Commit 918a5fa

Browse files
committed
pr: Introduce AI-Assisted requirements
AI-Assisted: no
1 parent 622b220 commit 918a5fa

3 files changed

Lines changed: 89 additions & 17 deletions

File tree

.config/ci/check_commits.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# SPDX-License-Identifier: GPL-2.0-only
4+
5+
# Check all commits in the PR have the "AI-Assisted" tag
6+
# We copy Wireshark's contributing guide, thanks to them for the idea !
7+
# This script is inspired by https://gitlab.com/wireshark/wireshark/-/blob/master/.gitlab-ci.yml
8+
9+
commits=$(git rev-list --no-merges --max-count=$((PR_FETCH_DEPTH - 1)) HEAD)
10+
if [ -z "$commits" ]; then
11+
echo "No commit to check in PR. OK."
12+
exit 0
13+
fi
14+
15+
missing=0
16+
for c in $commits; do
17+
if ! git log -1 --format=%B "$c" | grep -qi '^AI-Assisted:'; then
18+
echo -e "ERROR: Commit \033[0;33m$c\033[0m is missing the 'AI-Assisted: yes|no [tool(s)]' trailer."
19+
missing=1
20+
else
21+
echo -e "OK: Commit \033[0;32m$c\033[0m is properly tagged."
22+
fi
23+
done
24+
25+
if [ $missing -eq 1 ]; then
26+
echo
27+
echo -e "\033[0;31mPlease add the 'AI-Assisted' trailer to commit messages !\033[0m"
28+
echo "See the contribution guide at: https://github.com/secdev/scapy/blob/master/CONTRIBUTING.md"
29+
exit 1
30+
else
31+
echo "All checked commits include the AI-Assisted trailer."
32+
exit 0
33+
fi

.github/workflows/unittests.yml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,33 @@ permissions:
1616
contents: read
1717

1818
jobs:
19+
commit:
20+
name: Check the validity of the commits
21+
runs-on: ubuntu-latest
22+
if: github.event_name == 'pull_request'
23+
# We follow the same contributing patterns as Wireshark. Thanks to
24+
# https://gitlab.com/wireshark/wireshark/-/blob/master/.gitlab-ci.yml
25+
steps:
26+
- name: Get the number of commits in the PR
27+
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
28+
- name: Checkout Scapy
29+
uses: actions/checkout@v6
30+
with:
31+
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
32+
- name: AI trailer reminder
33+
run: bash ./.config/ci/check_commits.sh
34+
spdx:
35+
name: Check SPDX identifiers (Licensing)
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout Scapy
39+
uses: actions/checkout@v4
40+
- name: Launch script
41+
run: bash scapy/tools/check_spdx.sh
1942
health:
2043
name: Code health check
2144
runs-on: ubuntu-latest
45+
needs: [commit, spdx]
2246
steps:
2347
- name: Checkout Scapy
2448
uses: actions/checkout@v4
@@ -40,6 +64,7 @@ jobs:
4064
# 'runs-on' and 'python-version' should match the ones defined in .readthedocs.yml
4165
name: Build doc
4266
runs-on: ubuntu-22.04
67+
needs: [commit, spdx]
4368
steps:
4469
- name: Checkout Scapy
4570
uses: actions/checkout@v4
@@ -51,17 +76,10 @@ jobs:
5176
run: pip install tox
5277
- name: Build docs
5378
run: tox -e docs
54-
spdx:
55-
name: Check SPDX identifiers
56-
runs-on: ubuntu-latest
57-
steps:
58-
- name: Checkout Scapy
59-
uses: actions/checkout@v4
60-
- name: Launch script
61-
run: bash scapy/tools/check_spdx.sh
6279
mypy:
6380
name: Type hints check
6481
runs-on: ubuntu-latest
82+
needs: [commit, spdx]
6583
steps:
6684
- name: Checkout Scapy
6785
uses: actions/checkout@v4
@@ -77,6 +95,7 @@ jobs:
7795
utscapy:
7896
name: ${{ matrix.os }} ${{ matrix.installmode }} ${{ matrix.python }} ${{ matrix.mode }} ${{ matrix.flags }}
7997
runs-on: ${{ matrix.os }}
98+
needs: [commit, spdx]
8099
timeout-minutes: 20
81100
continue-on-error: ${{ matrix.allow-failure == 'true' }}
82101
strategy:
@@ -175,6 +194,7 @@ jobs:
175194
cryptography:
176195
name: pyca/cryptography test
177196
runs-on: ubuntu-latest
197+
needs: [commit, spdx]
178198
steps:
179199
- name: Checkout repository
180200
uses: actions/checkout@v4
@@ -195,6 +215,7 @@ jobs:
195215
analyze:
196216
name: CodeQL analysis
197217
runs-on: ubuntu-latest
218+
needs: [commit, spdx]
198219
permissions:
199220
security-events: write
200221
steps:

CONTRIBUTING.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ submitting an issue.
4040
If you're not sure whether a behavior is a bug or not, submit an issue
4141
and ask, don't be shy!
4242

43+
### AI-assisted reports
44+
45+
<!-- Wireshark has greate AI guidelines ! Let's not reinvent the wheel -->
46+
<!-- https://gitlab.com/wireshark/wireshark/-/blob/master/doc/wsug_src/wsug_introduction.adoc -->
47+
48+
If you use AI tools to help find or draft a bug report, please mention that and make sure you have personally verified the steps and details before submitting.
49+
Purely AI-generated reports are not supported and might be closed; a quick human check keeps triage efficient for everyone.
50+
4351
### Enhancements / feature requests
4452

4553
If you want a feature in Scapy, but cannot implement it yourself or
@@ -53,6 +61,18 @@ of function calls, packet creations, etc.).
5361

5462
### Coding style & conventions
5563

64+
- All commits should include the `AI-Assisted: (yes/no) [tool]` tag. This is used to disclose the AI tools that are used when authoring. You must check the commits you produce, or your PR might be closed. The tag may look like such:
65+
66+
```
67+
AI-Assisted: yes (Claude Opus 4.7)
68+
```
69+
or
70+
71+
```
72+
AI-Assisted: no
73+
```
74+
This guideline is adapted with thanks to [Wireshark's AI usage statement](https://www.wireshark.org/docs/wsdg_html_chunked/ChSrcContribute.html).
75+
5676
- The code should be PEP-8 compliant; you can check your code with
5777
[pep8](https://pypi.python.org/pypi/pep8) and the command `tox -e flake8`
5878
@@ -63,20 +83,18 @@ of function calls, packet creations, etc.).
6383
- [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)
6484
is a nice read!
6585
66-
- Avoid creating unnecessary `list` objects, particularly if they
67-
can be huge (e.g., when possible, use `for line in fdesc` instead of
68-
`for line in fdesc.readlines()`; more generally prefer generators over
69-
lists).
70-
7186
### Tests
7287
73-
Please consider adding tests for your new features or that trigger the
74-
bug you are fixing. This will prevent a regression from being
75-
unnoticed. Do not use the variable `_` in your tests, as it could break them.
88+
We require adding tests for all new features or bug fixes, or a justification as to why they are not relevant. We know it's annoying, but Scapy is all about parsing and dissecting weird protocols us maintainers will never encounter. Having good tests is the only way to keep the code maintainable.
89+
90+
- If you are fixing a bug, provide a one-liner that reproduced the bug you are fixing.
91+
- If you are introducing dissectors, provide at least a very simple "dissect" / "build" of real packets with simple assertions.
92+
- Tests can be very simple. It's much better to have dumb tests that break when one does changes than no tests.
93+
- Do not use the variable `_` in your tests, as it could break them.
7694
7795
If you find yourself in a situation where your tests locally succeed but
7896
fail if executed on the CI, try to enable the debugging option for the
79-
dissector by setting `conf.debug_dissector = 1`.
97+
dissector by setting `conf.debug_dissector = 1`. In doubt, feel free to ask maintainers for help.
8098
8199
### New protocols
82100

0 commit comments

Comments
 (0)