Skip to content

Latest commit

 

History

History
173 lines (121 loc) · 17.9 KB

guidelines.md

File metadata and controls

173 lines (121 loc) · 17.9 KB

Contributing Guidelines

FleetMDM (flamingo-stack/fleetmdm) is Flamingo's fork of the open-source Fleet device management platform, extended for the OpenFrame unified MSP ecosystem. It ships a Go backend service (cmd/fleet), the fleetctl CLI, the orbit/fleetd agent, a React/TypeScript web console (frontend/), and an Enterprise Chrome-extension agent (ee/fleetd-chrome). This document explains how to propose and land a change: code style, branching, commit messages, the pull request process, and what the review checklist expects.

This repository does not use GitHub Issues or GitHub Discussions. Day-to-day coordination happens on the OpenMSP Slack community (https://www.openmsp.ai/, invite: https://join.slack.com/t/openmsp/shared_invite/zt-36bl7mx0h-3~U2nFH6nqHqoTPXMaHEHA). Open a pull request directly against https://github.com/flamingo-stack/fleetmdm/pulls rather than filing an issue first.

Before You Start

Read the broader development context first:

  • ../../getting-started/introduction.md and ../../getting-started/prerequisites.md for what you need installed.
  • ../../getting-started/quick-start.md and ../../getting-started/first-steps.md to get a working environment.
  • ../setup/environment.md and ../setup/local-development.md for the day-to-day dev loop.
  • ../architecture/README.md and ../../reference/architecture/overview.md for how the server, agents, MDM stacks, and OpenFrame integration fit together.
  • ../testing/README.md before you write tests for a change.
  • ../security/README.md if your change touches authentication, certificates, MDM enrollment, or secrets handling.

This Is a Tracked Fork

FleetMDM is synced weekly from upstream fleetdm/fleet (see the scheduled Sync from upstream fleet workflow, which merges upstream/main into a sync/upstream-main branch and opens a pull request). Because of this, any edit to a file that originated upstream must be wrapped in sentinel comments so the next upstream sync can locate and re-apply Flamingo-specific logic:

// >>> OPENFRAME(<slug>): <why> — openframe/docs/<doc>.md
... your fork-specific change ...
// <<< OPENFRAME(<slug>)

This is an enforced, active review rule (FLEETMDM-001) covering **/*.go, **/*.yaml, and **/*.tpl. Real examples of the pattern live in cmd/fleet/cron_registration.go, cmd/fleet/openframe_windows_wstep.go, and client/orbit_client.go. Net-new, fork-only code under paths like server/service/openframe/ is exempt — it never existed upstream, so there is nothing to reconcile.

A pull request that edits a shared upstream file without these sentinels will be rejected by the automated reviewer.

Code Style and Conventions

Go

  • Formatting and linting are enforced by .golangci.yml (golangci-lint v2 config) at the repository root, covering gofmt, govet, errcheck, staticcheck, revive, gosec, gocritic, ineffassign, unconvert, unused, rowserrcheck, sqlclosecheck, nilnesserr, and depguard.
  • depguard forbids importing github.com/pkg/errors (use ctxerr where a context.Context is available, or stdlib errors.New / fmt.Errorf with %w) and forbids github.com/valyala/fastjson / fasttemplate.
  • forbidigo forbids bare print/println, and forbids the context-less slog.Debug/Info/Warn/Error package-level calls — use a specific *slog.Logger instance with the *Context variants instead.
  • Several active, enforced rules govern server-layer Go code specifically:
    • FLEETMDM-002: inside cmd/, server/, and ee/server/, create errors with ctxerr.New(ctx, ...) / ctxerr.Wrap(...) rather than fmt.Errorf or errors.New; plain stdlib errors are acceptable only in leaf utility packages with no context available.
    • FLEETMDM-002-2: every error returned from a called function must be wrapped at the call boundary, e.g. fmt.Errorf("<short lowercase context>: %w", err) — never a bare return err.
    • FLEETMDM-004: server-side logging must use log/slog via InfoContext/ErrorContext/DebugContext with structured key-value pairs (never interpolated into the message string), and the logger should be threaded through function signatures, not accessed globally.
    • FLEETMDM-006-2: in cron/schedule code (cmd/fleet/cron.go and sibling files), non-fatal errors go through the local errHandler(ctx, logger, msg, err) helper; fatal errors are returned directly with fmt.Errorf wrapping. Never log.Fatal, panic, or bare fmt.Println for error reporting in a cron job.
    • FLEETMDM-007-2: each distinct phase of a long-running cron function should open its own OpenTelemetry span (tracer.Start(ctx, "<subsystem>.<phase>"), defer span.End()), record errors on the span with span.RecordError(err), and log phase timing.
  • .golangci.yml carries a long list of path-scoped gosec exclusions for legacy files (for example cmd/osquery-perf/agent.go, orbit/pkg/update/update.go, server/mail/mail.go) — new code should not rely on these exclusions; they exist for pre-existing files only.
  • Generated code is excluded from formatting checks (server/fleet/agent_options_generated.go).
  • errcheck has an explicit allow-list of close/flush/logging calls whose errors may be ignored (see the exclude-functions block in .golangci.yml); anything not on that list must have its error checked.

JavaScript / TypeScript (frontend)

  • The root .eslintrc.js extends airbnb, plugin:jest/recommended, plugin:react-hooks/recommended, plugin:@typescript-eslint/recommended, plugin:prettier/recommended, and plugin:storybook/recommended, parsed with @typescript-eslint/parser.
  • Formatting is delegated to Prettier (.prettierrc.json at the root, currently using Prettier's defaults) via eslint-plugin-prettier.
  • Notable project-specific rule overrides in .eslintrc.js: @typescript-eslint/no-shadow replaces the base no-shadow; @typescript-eslint/no-use-before-define replaces the base rule; camelcase is off; react/jsx-filename-extension is a warning limited to .jsx/.tsx; import/no-unresolved is case-insensitive via the webpack resolver configured in webpack.config.js.
  • Run npm run lint (eslint frontend --ext .js,.jsx,.ts,.tsx) and npm run prettier:check before opening a pull request that touches frontend/.
  • TypeScript compiles against tsconfig.json, targeting ES2019 with "jsx": "react" and a node-sql-parser path alias pointed at the vendored @sgress454/node-sql-parser fork.

Sails sub-applications (website/, ee/fleet-agent-downloader/, ee/vulnerability-dashboard/)

These Sails apps each carry their own .eslintrc (and an assets/.eslintrc / views/.eslintrc override inside website/) with a stricter, non-airbnb rule set: 2-space indentation, single quotes, mandatory semicolons, eqeqeq, and no-undef against an explicit globals list of Sails models. If you touch one of these apps, lint with its own config, not the root one — the globals and quote/semicolon rules differ intentionally between backend Sails code and browser-facing assets/ code.

Android (android/)

Kotlin code is formatted with Spotless + ktlint (see the spotless block in android/app/build.gradle.kts) and linted with Detekt (android/app/detekt.yml, run via ./gradlew check in CI, not in local builds by default). android/.editorconfig sets 4-space indentation, a 140-character line length, Android Studio's ktlint_code_style, and disables the function-naming/property-naming ktlint rules that would otherwise flag @Composable function names and uppercase TAG constants.

General formatting

  • .editorconfig files (root-level ones live under website/, ee/fleet-agent-downloader/, ee/vulnerability-dashboard/, and android/) set LF line endings, UTF-8, and trailing-newline/trailing-whitespace trimming — configure your editor to respect them.
  • .pre-commit-config.yaml wires gitleaks (secret scanning), golangci-lint, shellcheck, cpplint, eslint, pylint, RuboCop, and php-lint-all, plus end-of-file-fixer/trailing-whitespace from pre-commit-hooks. Installing pre-commit locally catches most style and secret issues before they reach CI.

Branch Naming and PR Process

Branches

There is no single enforced branch-naming scheme documented in this repository, but the workflows reveal the conventions already in use — follow them for consistency:

  • Automated upstream sync uses sync/upstream-main (see .github/workflows/sync-upstream.yml).
  • The documentation pipeline uses a code-documentation/ branch prefix for its own generated pull requests — do not hand-author branches under this prefix.
  • Branches whose head repository is a fork (not flamingo-stack/fleetmdm itself) are excluded from several automated workflows (code graph, code review), so contributions from forks should still target main through a normal pull request from your fork.

A descriptive, slash-namespaced branch name that states the area and intent (for example, a fix under the MDM stack, or a change to the vulnerability pipeline) is the most useful convention given the size of this codebase (cmd/, server/, ee/, orbit/, frontend/, android/).

Opening a Pull Request

  1. Fork or branch from main and make your change.
  2. Keep upstream-originated files wrapped in OPENFRAME(...) sentinels as described above; net-new OpenFrame-only code does not need them.
  3. Run the relevant local checks before pushing (see Review Checklist below) — Go lint/tests, frontend lint/tests, or Helm lint, depending on what you touched.
  4. Push and open a pull request against main at https://github.com/flamingo-stack/fleetmdm/pulls.
  5. CI runs automatically:
    • .github/workflows/test.yml (Fleet Test) detects which parts of the tree changed via .github/workflows/changes.yaml and conditionally runs test_client (Go tests + cross-compiles orbit for macOS/Windows), test (server-side Go tests, a GoReleaser snapshot build, and a Trivy image scan), and test_helm (helm template fleet charts/fleet). The all-checks job aggregates these and fails the pull request if any of them fail or are cancelled.
    • .github/workflows/flamingo-code-review.yml (Flamingo Code Review) provides an AI-assisted review. On opened/ready_for_review/reopened it posts an invitation comment rather than reviewing automatically; a maintainer (or you, if you have write access) starts the first pass by checking its checkbox, commenting @flamingo-review, or applying the flamingo-review label. Commenting @flamingo-review full re-reviews the whole cumulative diff instead of only the incremental delta since the last reviewed commit.
  6. Address review feedback by pushing additional commits to the same branch; CODEOWNERS-required reviewers (see below) are requested automatically.
  7. Once all-checks is green and required reviewers have approved, the PR can be merged. A push to main triggers .github/workflows/release.yml, which builds and publishes the fleet binary image and the charts/fleet Helm chart — so changes to server/, cmd/, ee/, tools/, the root Dockerfile, or .goreleaser.yml ship automatically on merge.

Required Reviewers (CODEOWNERS)

The root CODEOWNERS file and .github/CODEOWNERS define required reviewers by path, on a last-match-wins basis. Notable entries:

Path Required reviewer(s)
*.go, go.mod, go.sum, /cmd/, /server/, /ee/server/, /orbit/ @fleetdm/go
/frontend/ @fleetdm/frontend
/infrastructure/, /charts/, /terraform/ @rfairburn @ksatter @georgekarrv @BCTBB @ddribeiro
/.github/workflows/ @georgekarrv @sharon-fdm @lukeheath @lucasmrod @getvictor
/.github/CODEOWNERS @flamingo-stack/devops-engineers
/docs/Contributing/architecture/mdm, /docs/Contributing/product-groups/mdm @georgekarrv @JordanMontgomery
/docs/Contributing/architecture/orchestration @sharon-fdm @sgress454
/docs/Contributing/architecture/software @georgekarrv @cdcme
/docs/Contributing/architecture/security-compliance @sharon-fdm @getvictor @mostlikelee

If your change touches one of these paths, expect GitHub to request the matching reviewer(s) automatically — do not bypass this by routing the change through an unrelated path.

Commit Message Format

No commit-template or commit-lint tooling is enforced in this repository's CI. Write commits that:

  • Use a short, present-tense summary line describing the change (for example, "fix MDM profile reconciliation retry loop", not "fixed bug").
  • Reference the relevant subsystem when it helps reviewers scope the diff (server/mdm/apple, orbit, frontend, ee/maintained-apps, etc.).
  • Explain why in the body for anything non-obvious — particularly for OPENFRAME(...)-wrapped changes, where the sentinel's own <why> clause should be echoed or expanded on in the commit body so a future upstream-sync author understands the deviation from upstream Fleet.
  • Are scoped to one logical change; prefer several focused commits over one sprawling commit when a change spans both a fork-only file and an upstream-originated file.
  • Avoid committing secrets — gitleaks runs as a pre-commit hook (.pre-commit-config.yaml) and will also be caught by CI if bypassed locally.

Squashing is a repository/maintainer decision at merge time; keep individual commits reviewable regardless of the final merge strategy.

Review Checklist

Before requesting review, verify the following. These map directly to what CI and the active review rules check:

All changes

  • Every edit to an upstream-originated file is wrapped in // >>> OPENFRAME(<slug>): <why> / // <<< OPENFRAME(<slug>) sentinels (FLEETMDM-001). Net-new fork-only files under server/service/openframe/ or similar are exempt.
  • No secrets, tokens, or credentials are committed (checked by gitleaks in .pre-commit-config.yaml and again in CI).
  • The change is scoped to the area it claims to touch; unrelated formatting churn is avoided so CODEOWNERS routing and diff review stay meaningful.

Go changes (cmd/, server/, ee/, orbit/, client/, tools/)

  • golangci-lint passes locally against .golangci.yml (gofmt, govet, errcheck, staticcheck, revive, gosec, gocritic, unused, ineffassign, unconvert, rowserrcheck, sqlclosecheck, nilnesserr, depguard).
  • No new import of github.com/pkg/errors, github.com/valyala/fastjson, or github.com/valyala/fasttemplate (depguard).
  • No bare print/println, and no package-level slog.Debug/Info/Warn/Error calls (forbidigo) — use a *slog.Logger instance with *Context methods.
  • Inside cmd/, server/, ee/server/: new errors use ctxerr.New/ctxerr.Wrap, not fmt.Errorf/errors.New (FLEETMDM-002), except in context-less leaf utility packages.
  • Every error returned across a call boundary is wrapped with a short lowercase context string via %w (FLEETMDM-002-2) — no bare return err.
  • Server-side logging uses log/slog with InfoContext/ErrorContext/DebugContext and structured key-value pairs, not string interpolation (FLEETMDM-004).
  • New cron/schedule jobs route non-fatal errors through errHandler(ctx, logger, msg, err) and fatal errors through wrapped fmt.Errorf returns — no log.Fatal, panic, or bare fmt.Println (FLEETMDM-006-2).
  • Multi-phase cron jobs wrap each phase in its own OpenTelemetry span and record phase timing and errors (FLEETMDM-007-2).
  • go test -race ./orbit/... (client) and the server-focused Go tests referenced by .github/workflows/test.yml (for example go test -race ./server/config ./server/service ./cmd/fleet -run 'Test(OpenframeConfig|OpenframeOsquerySchemaRoute)') pass locally for the packages you touched.
  • A goreleaser release --snapshot --clean --skip=publish build succeeds if you changed anything under cmd/, server/, ee/, pkg/, tools/, the root Dockerfile, or .goreleaser.yml — this mirrors the test job in .github/workflows/test.yml.

Frontend changes (frontend/)

  • npm run lint (eslint frontend --ext .js,.jsx,.ts,.tsx) passes.
  • npm run prettier:check passes.
  • npm run test / npm run test:ci (Jest, configured via ./frontend/test/jest.config.js) passes for affected components.
  • TypeScript compiles cleanly against tsconfig.json.
  • New Storybook stories, if applicable, build via npm run build-storybook.

Sails app changes (website/, ee/fleet-agent-downloader/, ee/vulnerability-dashboard/)

  • Linted against that app's own .eslintrc (and assets/.eslintrc/views/.eslintrc where applicable), not the root config — quote style, semicolons, and the Sails model globals list differ per app.

Infrastructure / Helm changes (charts/, infrastructure/, terraform/)

  • helm template fleet charts/fleet succeeds (the same check test_helm runs in .github/workflows/test.yml).
  • Chart dependency and image pins in charts/fleet/Chart.yaml / charts/fleet/values.yaml are deliberate version bumps, not accidental — these feed the published OCI chart (oci://ghcr.io/flamingo-stack/fleetmdm/helm-charts/fleet) and image (ghcr.io/flamingo-stack/fleetmdm/fleet) on every merge to main.

Android changes (android/)

  • Spotless/ktlint formatting is applied (spotless block in android/app/build.gradle.kts).
  • Detekt findings are addressed per android/app/detekt.yml if running ./gradlew check.

Before merge

  • all-checks in .github/workflows/test.yml is green.
  • Required CODEOWNERS reviewers for every path you touched have approved.
  • If the change affects published artifacts (the fleet Go module, fleetctl, fleetd-for-chrome, the Helm chart, or the container image), confirm the change is intentional for that artifact's consumers — this repository currently shows no downstream consumers recorded in the code graph, but the graph's coverage is partial, so an empty consumer list does not prove nothing depends on it.