diff --git a/.github/workflows/api-fix-docs-artefacts.yml b/.github/workflows/api-fix-docs-artefacts.yml new file mode 100644 index 000000000000..65ffc30208f4 --- /dev/null +++ b/.github/workflows/api-fix-docs-artefacts.yml @@ -0,0 +1,71 @@ +name: API Documentation Artefacts Auto-Update + +permissions: + contents: read # For actions/checkout + id-token: write # For CodeArtifact OIDC + +on: + pull_request: + paths: + - api/** + types: [opened, synchronize, reopened, ready_for_review] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +defaults: + run: + working-directory: api + +env: + DOTENV_OVERRIDE_FILE: .env-ci + +jobs: + fix-docs-artefacts: + runs-on: depot-ubuntu-latest + name: Fix Documentation Artefacts + + steps: + - name: Generate GitHub App token with push access + id: app-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ vars.FLAGSMITH_ENGINEERING_GH_APP_ID }} + private-key: ${{ secrets.FLAGSMITH_ENGINEERING_GH_APP_PRIVATE_KEY }} + + - name: Cloning repo + uses: actions/checkout@v7 + with: + ref: ${{ github.event.pull_request.head.ref }} + token: ${{ steps.app-token.outputs.token }} + + - uses: ./.github/actions/install-uv + with: + working-directory: api + + - name: Install SAML Dependencies + run: sudo apt-get install -y xmlsec1 + + - name: Generate public documentation artefacts + run: | + make install-packages opts='--extra dev' + make generate-docs + + - name: Authenticate with CodeArtifact + uses: ./.github/actions/codeartifact-login + + - name: Generate private documentation artefacts + run: make generate-docs-private + + - name: Commit and push fixes + run: | + git add --all + if git diff --cached --quiet; then + echo "Documentation artefacts are up to date." + exit 0 + fi + git config user.name '${{ steps.app-token.outputs.app-slug }}[bot]' + git config user.email '${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com' + git commit --message 'chore: Update documentation artefacts' + git push || { git pull --rebase && git push; } diff --git a/.github/workflows/api-pull-request.yml b/.github/workflows/api-pull-request.yml index d6dc9740f05b..21f446c9bb04 100644 --- a/.github/workflows/api-pull-request.yml +++ b/.github/workflows/api-pull-request.yml @@ -68,11 +68,6 @@ jobs: action: remove linters: mypy - - name: Check autogenerated documentation - uses: nickcharlton/diff-check@v1.0.0 - with: - command: make -C api generate-docs - - name: Run Tests run: make test diff --git a/.github/workflows/api-tests-with-private-packages.yml b/.github/workflows/api-tests-with-private-packages.yml index 6111de9584ee..5b851e06db00 100644 --- a/.github/workflows/api-tests-with-private-packages.yml +++ b/.github/workflows/api-tests-with-private-packages.yml @@ -60,22 +60,6 @@ jobs: make integrate-private-tests rm -rf ${HOME}/.git-credentials - - name: Check MCP enterprise tool catalogue is up to date - env: - DOTENV_OVERRIDE_FILE: .env-ci - run: | - uv run python manage.py generate_mcp_tool_catalogue \ - --exclude ../docs/docs/integrating-with-flagsmith/_mcp-tool-catalogue.md \ - > ../docs/docs/integrating-with-flagsmith/_mcp-tool-catalogue-enterprise.md - git diff --exit-code ../docs/docs/integrating-with-flagsmith/_mcp-tool-catalogue-enterprise.md - - - name: Check full OpenAPI schema is up to date - env: - DOTENV_OVERRIDE_FILE: .env-ci - run: | - make generate-full-openapi - git diff --exit-code ../openapi.yaml - - name: Run Tests env: DOTENV_OVERRIDE_FILE: .env-ci diff --git a/api/Makefile b/api/Makefile index 0f40fa25692f..df2e94e21905 100644 --- a/api/Makefile +++ b/api/Makefile @@ -27,6 +27,10 @@ codeartifact-login: install-packages: uv sync --frozen $(opts) +.PHONY: install-private-packages +install-private-packages: opts=--extra private +install-private-packages: install-packages + .PHONY: install install: install-packages @@ -193,6 +197,12 @@ generate-docs: generate-flagsmith-sdk-openapi generate-mcp-openapi uv run flagsmith docgen events > ../docs/docs/deployment-self-hosting/observability/_events-catalogue.md uv run python manage.py generate_mcp_tool_catalogue > ../docs/docs/integrating-with-flagsmith/_mcp-tool-catalogue.md +.PHONY: generate-docs-private +generate-docs-private: install-private-packages generate-full-openapi generate-mcp-openapi + uv run python manage.py generate_mcp_tool_catalogue \ + --exclude ../docs/docs/integrating-with-flagsmith/_mcp-tool-catalogue.md \ + > ../docs/docs/integrating-with-flagsmith/_mcp-tool-catalogue-enterprise.md + .PHONY: add-known-sdk-version add-known-sdk-version: uv run python scripts/add-known-sdk-version.py $(opts) diff --git a/api/experimentation/tasks.py b/api/experimentation/tasks.py index d035330a8e74..1446db7f31b2 100644 --- a/api/experimentation/tasks.py +++ b/api/experimentation/tasks.py @@ -101,6 +101,7 @@ def compute_experiment_exposures(experiment_id: int) -> None: "exposures.compute_failed", exc_info=exc, experiment__id=experiment.id, + feature__id=experiment.feature_id, environment__id=experiment.environment_id, organisation__id=experiment.environment.project.organisation_id, ) diff --git a/api/experimentation/views.py b/api/experimentation/views.py index 2a4af7fdf4a6..897b3d0546e0 100644 --- a/api/experimentation/views.py +++ b/api/experimentation/views.py @@ -210,7 +210,7 @@ def _get_user(request: Request) -> FFAdminUser: decorator=extend_schema( tags=["mcp"], operation_id="update_experiment", - description="(Beta) Updates an experiment's name or hypothesis.", + description="(Beta) Updates an experiment's name or its hypothesis.", ), ) class ExperimentViewSet( diff --git a/api/features/views.py b/api/features/views.py index e4d25e761a59..462053151125 100644 --- a/api/features/views.py +++ b/api/features/views.py @@ -996,7 +996,7 @@ class SDKFeatureStates(GenericAPIView): # type: ignore[type-arg] ) def get(self, request, identifier=None, *args, **kwargs): # type: ignore[no-untyped-def] """ - Retrieve the flags for an environment. + Retrieve the feature flags for an environment. --- *Note*: when providing the `feature` query argument, this endpoint will diff --git a/api/segment_membership/metrics.py b/api/segment_membership/metrics.py index 7ced432a4485..c18561aea9a7 100644 --- a/api/segment_membership/metrics.py +++ b/api/segment_membership/metrics.py @@ -25,5 +25,5 @@ flagsmith_segment_membership_read_duration_seconds = prometheus_client.Histogram( "flagsmith_segment_membership_read_duration_seconds", - "Duration of a single segment membership page read.", + "Duration of one segment membership page read.", )