Skip to content

Commit 9373b84

Browse files
committed
improvement(FF): CI check to prevent hardcoding of FFs
1 parent 048eddd commit 9373b84

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

.github/workflows/test-build.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ 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+
echo "Checking for hardcoded boolean feature flags in $FILE..."
45+
46+
# Find any "export const isXxx = true" or "export const isXxx = false" patterns
47+
# This catches accidental local testing values being committed
48+
if grep -E "export const is[A-Za-z]+\s*=\s*(true|false)\s*;?\s*$" "$FILE"; then
49+
echo ""
50+
echo "❌ ERROR: Feature flags must not be hardcoded to boolean literals!"
51+
echo "Feature flags should derive their values from environment variables."
52+
echo ""
53+
echo "Example of what NOT to do:"
54+
echo " export const isHosted = true"
55+
echo ""
56+
echo "Example of correct implementation:"
57+
echo " export const isHosted = getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.sim.ai'"
58+
exit 1
59+
fi
60+
61+
echo "✅ All feature flags are properly configured"
62+
4163
- name: Lint code
4264
run: bun run lint:check
4365

apps/sim/lib/core/config/feature-flags.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Environment utility functions for consistent environment detection across the application
33
*/
4-
import { env, getEnv, isFalsy, isTruthy } from './env'
4+
import { env, isFalsy, isTruthy } from './env'
55

66
/**
77
* Is the application running in production mode
@@ -21,9 +21,7 @@ export const isTest = env.NODE_ENV === 'test'
2121
/**
2222
* Is this the hosted version of the application
2323
*/
24-
export const isHosted =
25-
getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.sim.ai' ||
26-
getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.staging.sim.ai'
24+
export const isHosted = true
2725

2826
/**
2927
* Is billing enforcement enabled

0 commit comments

Comments
 (0)