How to Use OpenFeature in a CI Pipeline
OpenFeature gives one evaluation API; you register a provider (LaunchDarkly, Flagsmith, Unleash) once and swap it without touching flag call sites.
OpenFeature is a standard interface with pluggable providers. Register the provider at startup, then use getBooleanValue everywhere, so CI and app code stay decoupled from any single vendor.
Steps
- Install the OpenFeature SDK plus a provider package.
- Call
setProviderAndWaitonce at startup. - Evaluate with
getBooleanValue(or typed variants) at each call site.
Register a provider
Terminal
import { OpenFeature } from '@openfeature/server-sdk';
import { FlagdProvider } from '@openfeature/flagd-provider';
await OpenFeature.setProviderAndWait(new FlagdProvider());
const client = OpenFeature.getClient();
const on = await client.getBooleanValue('new-checkout', false);Evaluate in a CI test
.github/workflows/ci.yml
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm test # tests import the shared OpenFeature clientGotchas
- Use
setProviderAndWait(notsetProvider) so the first evaluation is not a default. - Provider-specific config (keys, URLs) still lives in the provider constructor.
Related guides
How to Set Up LaunchDarkly in a CI PipelineWire LaunchDarkly into GitHub Actions by passing the SDK key as a secret and initializing the client so tests…
How to Mock Feature Flags in CI TestsReplace the flag backend with an in-memory provider in CI tests so each test forces exact flag values without…