Skip to content

Commit 2113cf5

Browse files
authored
Update lint workflow to exclude new usages of SafeAttributePersistenceProvider (project-chip#40776)
* Update files to match the style from the ember exclusion script * Update lint workflow to use the script * Remove search for AttributePersistenceProvider * Restyled - script * Update lint workflow to skip `scripts/`
1 parent 6f5acc8 commit 2113cf5

File tree

3 files changed

+107
-1
lines changed

3 files changed

+107
-1
lines changed

.github/workflows/lint.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ jobs:
253253
# to avoid our grep regexp matching itself.
254254
#
255255
# Known client-side clusters are allowed to use this only.
256-
- name: emberAfClusterInit/Shutdown callbacks are for client side use, not server side. Use ClusterServerInit/Shutdown for server clusters
256+
- name:
257+
emberAfClusterInit/Shutdown callbacks are for client side use,
258+
not server side. Use ClusterServerInit/Shutdown for server
259+
clusters
257260
if: always()
258261
run: |
259262
git grep -I -n "void emberAf.*Cluster\(Init\|Shutdown\)Callback(" -- \
@@ -330,6 +333,18 @@ jobs:
330333
--skip-subtree src/controller/tests \
331334
--skip-from-file scripts/ember_exclusions.txt
332335
336+
# This check ensures that `SafeAttributePersistenceProvider` nor `AttributePersistenceProvider`
337+
# are being used. Exclusions should be removed as soon as a refactor of the file affected is done.
338+
- name:
339+
Check for use of 'SafeAttributePersistenceProvider' and
340+
'AttributePersistenceProvider' symbols
341+
if: always()
342+
run: |
343+
scripts/find_attribute_persistence_provider_usage.sh \
344+
--skip-subtree .github/ \
345+
--skip-subtree scripts/ \
346+
--skip-from-file scripts/attribute_persistence_provider_exclusions.txt
347+
333348
# git grep exits with 0 if it finds a match, but we want
334349
# to fail (exit nonzero) on match. And we want to exclude this file,
335350
# to avoid our grep regexp matching itself, as well as excluding the files
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Exclusion list for SafeAttributePersistenceProvider usage checker
2+
# This file contains paths to files that currently use SafeAttributePersistenceProvider and are allowed to continue using it
3+
# Files listed here will be skipped when checking for new usage of SafeAttributePersistenceProvider
4+
5+
# Documentation files
6+
docs/cluster_and_device_type_dev/cluster_and_device_type_dev.md
7+
8+
# Example applications
9+
examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseDelegateImpl.cpp
10+
examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseManager.cpp
11+
12+
# Build files
13+
src/app/BUILD.gn
14+
src/app/chip_data_model.cmake
15+
16+
# Core SafeAttributePersistenceProvider implementation files
17+
src/app/SafeAttributePersistenceProvider.h
18+
src/app/SafeAttributePersistenceProvider.cpp
19+
src/app/DefaultSafeAttributePersistenceProvider.h
20+
src/app/persistence/AttributePersistenceProvider.h
21+
22+
# Server implementation
23+
src/app/server/Server.cpp
24+
25+
# Cluster server implementations that currently use SafeAttributePersistenceProvider
26+
src/app/clusters/boolean-state-configuration-server/boolean-state-configuration-server.cpp
27+
src/app/clusters/camera-av-settings-user-level-management-server/camera-av-settings-user-level-management-server.h
28+
src/app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.h
29+
src/app/clusters/chime-server/chime-server.cpp
30+
src/app/clusters/mode-base-server/mode-base-server.cpp
31+
src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp
32+
src/app/clusters/thread-network-directory-server/thread-network-directory-server.cpp
33+
src/app/clusters/tls-certificate-management-server/tls-certificate-management-server.cpp
34+
src/app/clusters/tls-client-management-server/tls-client-management-server.cpp
35+
src/app/clusters/unit-localization-server/unit-localization-server.cpp
36+
src/app/clusters/zone-management-server/zone-management-server.h
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
# This script checks for the use of 'SafeAttributePersistenceProvider'
4+
# symbols in the codebase. It takes exclusion folders as arguments and can also read exclusions from a file.
5+
6+
# Function to check for SafeAttributePersistenceProvider symbols
7+
check_symbols() {
8+
local exclusions=()
9+
while [[ $# -gt 0 ]]; do
10+
case $1 in
11+
--skip-subtree)
12+
exclusions+=(":(exclude)$2")
13+
shift 2
14+
;;
15+
--skip-from-file)
16+
if [[ -f "$2" ]]; then
17+
while IFS= read -r line || [[ -n "$line" ]]; do
18+
[[ -z "$line" || "$line" =~ ^[[:space:]]*# ]] && continue
19+
exclusions+=(":(exclude)$line")
20+
done <"$2"
21+
else
22+
echo "Warning: File '$2' not found, continuing without these exclusions"
23+
fi
24+
shift 2
25+
;;
26+
--help)
27+
echo "Usage: $0 [--skip-subtree <dir>] [--skip-from-file <file>]"
28+
echo " --skip-subtree <dir> Skip the specified subtree or file from the search (can be used multiple times)"
29+
echo " --skip-from-file <file> Read paths to exclude from the specified file (one path per line)"
30+
echo " --help Display this help message"
31+
exit 0
32+
;;
33+
*)
34+
echo "Unknown option: $1"
35+
exit 1
36+
;;
37+
esac
38+
done
39+
40+
# Search for SafeAttributePersistenceProvider usage (class usage, not just includes)
41+
safe_provider_matches=$(git grep -I -n '\<SafeAttributePersistenceProvider\>' -- './*' "${exclusions[@]}" | grep -v '#include')
42+
43+
if [[ -n "$safe_provider_matches" ]]; then
44+
echo "Error: Found 'SafeAttributePersistenceProvider' usage in the following files and lines:"
45+
echo ""
46+
echo "SafeAttributePersistenceProvider usage:"
47+
echo "$safe_provider_matches"
48+
exit 1
49+
else
50+
echo "SUCCESS: No unauthorized usage of SafeAttributePersistenceProvider found."
51+
fi
52+
}
53+
54+
# Main script execution here
55+
check_symbols "$@"

0 commit comments

Comments
 (0)