-
Notifications
You must be signed in to change notification settings - Fork 242
125 lines (107 loc) · 6.32 KB
/
Copy pathpython_lint.yml
File metadata and controls
125 lines (107 loc) · 6.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Python Lint Check
on:
pull_request:
paths:
- '**.py' # only trigger on python files
permissions:
contents: read
jobs:
lint-changed-files:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Required to fetch the base branch for comparison
fetch-depth: 0
- name: Get changed Python files
id: changed-files-py
uses: tj-actions/changed-files@v46 # This action finds changed files
with:
files: |
**.py
- name: Set up Python
if: steps.changed-files-py.outputs.any_changed == 'true'
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Pylint
if: steps.changed-files-py.outputs.any_changed == 'true'
run: python -m pip install pylint
- name: Install dependencies
if: steps.changed-files-py.outputs.any_changed == 'true'
run: python -m pip install -r requirements.txt
# Artifact name and description fields reach the HTML report and the LAVA manifest
# and get quoted in casework, so they must not claim more than the data shows.
# Runs over the whole artifact tree, not just changed files, so an allowlist entry
# removed elsewhere still gets caught. See the script's docstring.
- name: Check artifact claim language
if: steps.changed-files-py.outputs.any_changed == 'true'
run: python admin/scripts/check_claim_language.py
# A conversation artifact's columns are ordered from the roles it declares in
# data_views: timestamp, other dates, direction, sender, conversation label,
# message text, media, then the rest. See admin/docs/conversation_column_order.md.
- name: Check conversation artifact column order
if: steps.changed-files-py.outputs.any_changed == 'true'
run: python admin/scripts/check_conversation_column_order.py
# html_columns cells are written to the report without html.escape, so evidence
# placed there can inject markup, and any remote href/src makes opening a report
# beacon to a third party. Pre-existing findings are carried in the script's
# BASELINE and do not fail; new ones do. See the script's docstring.
- name: Guard report output against injection and remote destinations
if: steps.changed-files-py.outputs.any_changed == 'true'
run: python admin/scripts/check_html_safety.py
# The seeker stages evidence under <report folder>/data, so every files_found entry
# is an absolute path on the examiner's machine. artifact_processor normalizes only
# the third element of the return tuple; a path put in a data row or handed to
# write_artifact_data_table is published verbatim. The column is never empty and the
# row count is always right, so nothing else catches it. See the script's docstring.
- name: Guard report output against local filesystem paths
if: steps.changed-files-py.outputs.any_changed == 'true'
run: python admin/scripts/check_report_local_paths.py
# aleapp.py searches `paths` one pattern at a time and extends files_found with
# each result, and fnmatch's `*` crosses `/`, so a broad pattern usually covers a
# narrower sibling and every file it names is read twice. The rows are real and the
# count is double, which is silent in a report and rides into sample_data.
- name: Guard against a path pattern a sibling already covers
if: steps.changed-files-py.outputs.any_changed == 'true'
run: python admin/scripts/check_artifact_paths.py
# The third element of an artifact's return tuple becomes the report's
# "located at" line and the LAVA manifest source_path, so it has to be real
# paths. Prose standing in for one points the examiner at a column that often
# holds a basename, and the location ends up nowhere in the report.
- name: Guard against prose returned as a source path
if: steps.changed-files-py.outputs.any_changed == 'true'
run: python admin/scripts/check_source_path.py
# scripts/mmkv_parser.py is copied verbatim from its own repository, so it drifts
# in two directions and both are silent: an edit here looks like a fix until the
# next re-vendor reverts it, and an upstream release leaves this copy quietly old.
# The file's banner names the upstream commit; this fetches that file and fails
# when anything below the banner differs. Unconditional rather than gated on
# changed Python files, because the banner and the body can go stale together.
- name: Check vendored files match the pinned upstream commit
run: python admin/scripts/check_vendored.py
- name: Guard against artifact functions returning None
if: steps.changed-files-py.outputs.any_changed == 'true'
run: python admin/scripts/check_artifact_returns.py
- name: Guard against run-together implicit string concatenation
if: steps.changed-files-py.outputs.any_changed == 'true'
run: python admin/scripts/check_implicit_concat.py
# An artifact's description is the one line the report, the LAVA manifest and
# casework quote for it. One that is missing, runs to several lines, only repeats
# the name, or duplicates a sibling's in the same module says nothing about the
# rows it fronts. Whether a description claims past its own notes is a judgement
# the script cannot make; its --review mode lays the pair out for that pass.
- name: Guard against an artifact description that says nothing
if: steps.changed-files-py.outputs.any_changed == 'true'
run: python admin/scripts/check_artifact_descriptions.py
# Fails only on warnings this pull request introduces. Long-lived modules carry
# deliberate pre-existing warnings, and failing on those pushed contributors toward
# unrelated refactors or blanket file-level disables. See the script's docstring.
- name: Run on changed files
if: steps.changed-files-py.outputs.any_changed == 'true'
run: |
BASE=$(git merge-base "origin/${{ github.base_ref }}" HEAD)
echo "Comparing against merge base $BASE"
python admin/scripts/lint_changed.py --base-ref "$BASE" \
${{ steps.changed-files-py.outputs.all_changed_files }}