mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-10 02:15:07 +00:00
Merge pull request #53837 from ruthra-kumar/semgrep_to_prevent_test_regression
ci: semgrep to prevent test regression
This commit is contained in:
3
.github/workflows/linters.yml
vendored
3
.github/workflows/linters.yml
vendored
@@ -43,3 +43,6 @@ jobs:
|
||||
|
||||
- name: Run Semgrep rules
|
||||
run: semgrep ci --config ./frappe-semgrep-rules/rules --config r/python.lang.correctness
|
||||
|
||||
- name: Semgrep for Test Correctness
|
||||
run: semgrep ci --include=**/test_*.py --config ./semgrep/test-correctness.yml
|
||||
|
||||
18
semgrep/test-correctness.yml
Normal file
18
semgrep/test-correctness.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
rules:
|
||||
- id: Dont-commit
|
||||
pattern: frappe.db.commit()
|
||||
message: Commiting inside test breaks idempotency.
|
||||
languages: [python]
|
||||
severity: ERROR
|
||||
- id: Implicit-commit
|
||||
pattern: frappe.db.truncate()
|
||||
message: DB truncation does implict commit which breaks test idempotency.
|
||||
languages: [python]
|
||||
severity: ERROR
|
||||
- id: Dont-override-teardown
|
||||
pattern: |
|
||||
def tearDown(...):
|
||||
...
|
||||
message: ERPNextTestSuite forces rollback on each tearDown, which ensures idempotency. Don't override tearDown.
|
||||
languages: [python]
|
||||
severity: ERROR
|
||||
Reference in New Issue
Block a user