Skip to content

Commit 40a066f

Browse files
improvement(FF): CI check to prevent hardcoding of FFs (#2790)
* improvement(FF): CI check to prevent hardcoding of FFs * revert test change * add FF lint checks
1 parent c9068d0 commit 40a066f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

.github/workflows/test-build.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,41 @@ jobs:
3838
- name: Install dependencies
3939
run: bun install --frozen-lockfile
4040

41+
- name: Validate feature flags
42+
run: |
43+
FILE="apps/sim/lib/core/config/feature-flags.ts"
44+
ERRORS=""
45+
46+
echo "Checking for hardcoded boolean feature flags..."
47+
48+
# Use perl for multiline matching to catch both:
49+
# export const isHosted = true
50+
# export const isHosted =
51+
# true
52+
HARDCODED=$(perl -0777 -ne 'while (/export const (is[A-Za-z]+)\s*=\s*\n?\s*(true|false)\b/g) { print " $1 = $2\n" }' "$FILE")
53+
54+
if [ -n "$HARDCODED" ]; then
55+
ERRORS="${ERRORS}\n❌ Feature flags must not be hardcoded to boolean literals!\n\nFound hardcoded flags:\n${HARDCODED}\n\nFeature flags should derive their values from environment variables.\n"
56+
fi
57+
58+
echo "Checking feature flag naming conventions..."
59+
60+
# Check that all export const (except functions) start with 'is'
61+
# This finds exports like "export const someFlag" that don't start with "is" or "get"
62+
BAD_NAMES=$(grep -E "^export const [a-z]" "$FILE" | grep -vE "^export const (is|get)" | sed 's/export const \([a-zA-Z]*\).*/ \1/')
63+
64+
if [ -n "$BAD_NAMES" ]; then
65+
ERRORS="${ERRORS}\n❌ Feature flags must use 'is' prefix for boolean flags!\n\nFound incorrectly named flags:\n${BAD_NAMES}\n\nExample: 'hostedMode' should be 'isHostedMode'\n"
66+
fi
67+
68+
if [ -n "$ERRORS" ]; then
69+
echo ""
70+
echo -e "$ERRORS"
71+
exit 1
72+
fi
73+
74+
echo "✅ All feature flags are properly configured"
75+
4176
- name: Lint code
4277
run: bun run lint:check
4378

0 commit comments

Comments
 (0)