-
Notifications
You must be signed in to change notification settings - Fork 537
feat: use lifecycles API #7793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kyle-ssg
wants to merge
12
commits into
main
Choose a base branch
from
feat/lifecycle-stats-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+398
−650
Open
feat: use lifecycles API #7793
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a369ed5
feat(lifecycle): use lifecycle stats API instead of client-side class…
kyle-ssg e5fd8b8
feat(lifecycle): align frontend with backend lifecycle API contract
kyle-ssg de0667c
Merge remote-tracking branch 'origin/main' into feat/lifecycle-stats-api
kyle-ssg 216352d
fix(lifecycle): improve UI consistency and loading states
kyle-ssg c890063
fix(lifecycle): rename "Needs Monitoring" to "To Monitor"
kyle-ssg 8923106
fix(lifecycle): use correct cache tags for lifecycle counts
kyle-ssg bf57a38
fix(lifecycle): use dedicated LifecycleCounts tag type
kyle-ssg 06ac488
revert: remove unrelated FeatureImport type fix
kyle-ssg ac8d1a3
chore: remove testing doc (moved to separate PR)
kyle-ssg 5cf7e38
chore: revert CLAUDE.md change (moved to separate PR)
kyle-ssg 0fe0f62
feat(lifecycle): add feature click modal with usage and settings tabs
kyle-ssg 34e3478
fix(lifecycle): use create-feature-modal class for consistent tab sty…
kyle-ssg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # Testing the Frontend Against an Unmerged Backend PR | ||
|
|
||
| When a backend PR adds or changes API behaviour, you can run that exact backend | ||
| locally — without checking out or building the API — and point your local | ||
| frontend dev server at it. CI publishes a Docker image for every PR. | ||
|
|
||
| ## Where the images live | ||
|
|
||
| Every PR's CI builds and **pushes** multi-arch (amd64 + arm64) images to GHCR, | ||
| tagged `pr-<number>`. They are **public** — no `docker login` needed. | ||
|
|
||
| | Image | Tag | Contents | | ||
| | --- | --- | --- | | ||
| | `ghcr.io/flagsmith/flagsmith` | `pr-<number>` | Unified image — API + bundled frontend, serves on `:8000` | | ||
| | `ghcr.io/flagsmith/flagsmith-api` | `pr-<number>` | API only | | ||
|
|
||
| Use the **unified** image with the repo's root `docker-compose.yml`, which is | ||
| already wired for it (Postgres, migrations, API, task processor). | ||
|
|
||
| Confirm an image exists before relying on it: | ||
|
|
||
| ```bash | ||
| docker manifest inspect ghcr.io/flagsmith/flagsmith:pr-<number> >/dev/null && echo pullable | ||
| ``` | ||
|
|
||
| ## Run a PR backend + local frontend | ||
|
|
||
| From the repo root, create a one-off compose override that swaps the three | ||
| `flagsmith` services onto the PR image (the root compose hardcodes the image, so | ||
| an override file is the clean way to repoint it): | ||
|
|
||
| ```bash | ||
| cat > docker-compose.pr.yml <<'EOF' | ||
| services: | ||
| migrate-db: | ||
| image: ghcr.io/flagsmith/flagsmith:pr-<number> | ||
| flagsmith: | ||
| image: ghcr.io/flagsmith/flagsmith:pr-<number> | ||
| flagsmith-task-processor: | ||
| image: ghcr.io/flagsmith/flagsmith:pr-<number> | ||
| EOF | ||
|
|
||
| docker compose -f docker-compose.yml -f docker-compose.pr.yml pull | ||
| docker compose -f docker-compose.yml -f docker-compose.pr.yml up | ||
| ``` | ||
|
|
||
| The API comes up on `localhost:8000`. Then run the frontend against it: | ||
|
|
||
| ```bash | ||
| cd frontend | ||
| ENV=local npm run dev # dev server on :3000, talks to the API on :8000 | ||
| ``` | ||
|
|
||
| `docker-compose.pr.yml` is throwaway — delete it (or keep it git-ignored) when | ||
| done. To switch PRs, change the tag and re-run `pull` + `up`. | ||
|
|
||
| ## Notes / gotchas | ||
|
|
||
| - **Flagsmith-on-Flagsmith gates.** Backend features are often gated by an | ||
| OpenFeature flag (e.g. `feature_lifecycle`). The flag's default for a | ||
| self-hosted/local run comes from the baked-in | ||
| `api/integrations/flagsmith/data/environment.json`. Check it's enabled there; | ||
| if not, the gated endpoints/fields won't appear. | ||
| - **Data, not just code.** Endpoints may need seeded data to return anything | ||
| meaningful (e.g. code references, stale tags, usage). The image gives you the | ||
| behaviour; you still have to create the data through the UI/API. | ||
| - **Inspect what the PR actually built.** Job logs show the pushed tag: | ||
| `gh run view --job <id> --log | grep -i 'tags:'`. The `pr-<number>` convention | ||
| is stable, but the logs are the source of truth. | ||
| - **Contract-checking without running.** To verify the frontend matches a | ||
| backend PR's contract, read its diff directly instead of (or before) running: | ||
| `gh api repos/Flagsmith/flagsmith/contents/<path>?ref=<pr-head-branch> --jq .content | base64 -d`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { createSlice, PayloadAction } from '@reduxjs/toolkit' | ||
|
|
||
| type LifecycleEnvironmentState = { | ||
| // Maps a project id to the environment id selected for lifecycle analysis. | ||
| byProject: Record<number, number> | ||
| } | ||
|
|
||
| const initialState: LifecycleEnvironmentState = { | ||
| byProject: {}, | ||
| } | ||
|
|
||
| const lifecycleEnvironmentSlice = createSlice({ | ||
| initialState, | ||
| name: 'lifecycleEnvironment', | ||
| reducers: { | ||
| setLifecycleEnvironment( | ||
| state, | ||
| action: PayloadAction<{ projectId: number; environmentId: number }>, | ||
| ) { | ||
| state.byProject[action.payload.projectId] = action.payload.environmentId | ||
| }, | ||
| }, | ||
| }) | ||
|
|
||
| export const { setLifecycleEnvironment } = lifecycleEnvironmentSlice.actions | ||
| export default lifecycleEnvironmentSlice.reducer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.