-
Notifications
You must be signed in to change notification settings - Fork 63
chore(SREP-4482, SREP-4486, SREP-4800: Boilerplate Update for Agentic SDLC Rollout) #430
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| build_root_image: | ||
| name: boilerplate | ||
| namespace: openshift | ||
| tag: image-v8.3.4 | ||
| tag: image-v8.3.6 |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these rules also enforced server-side during CI or just as part of local pre-commit hooks? |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,134 @@ | ||||||||||
| # ============================================================================= | ||||||||||
| # Tier 1 — Common Pre-Commit Hooks for OSD Operators | ||||||||||
| # SREP-4485 | Golden rules: SREP-4450 | ||||||||||
| # ============================================================================= | ||||||||||
| # | ||||||||||
| # INSTALL | ||||||||||
| # pip install pre-commit | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Golden Rule 15 requires version pinning of dependencies and this needs to apply here as well. The change should be made in Boilerplate and pulled into the projects that consume it. Also see this comment for more general suggestions regarding Python dependencies. |
||||||||||
| # pre-commit install | ||||||||||
| # | ||||||||||
| # USAGE | ||||||||||
| # pre-commit run # staged files only (developer / agent workflow) | ||||||||||
| # pre-commit run --all-files # full repo (CI / first-time setup) | ||||||||||
| # | ||||||||||
| # BYPASS (golden rule 16) | ||||||||||
| # Skip one hook: SKIP=hook-id git commit | ||||||||||
| # Never use: git commit --no-verify | ||||||||||
| # Agents: never bypass any hook | ||||||||||
| # Security hooks: never bypassable under any circumstances | ||||||||||
| # | ||||||||||
| # CI RELATIONSHIP (golden rule 17) | ||||||||||
| # These hooks mirror ci/prow/lint. CI remains the authoritative gate. | ||||||||||
| # Every check here also runs in CI. Pre-commit is developer convenience. | ||||||||||
| # | ||||||||||
| # AGENT USAGE (golden rule 1, 7, 19) | ||||||||||
| # Agents run: pre-commit run | ||||||||||
| # Output: PRE_COMMIT=1 is set automatically — hooks emit structured output | ||||||||||
| # Retry: max 2 fix-and-retry iterations before escalating to human | ||||||||||
| # | ||||||||||
| # TIMING TARGETS (golden rule 2, 3) | ||||||||||
| # Total run: <= 10s target / <= 60s hard limit on a 10-file changeset | ||||||||||
| # Hooks run fastest-first (golden rule 13). Each hook has a timeout guard. | ||||||||||
| # | ||||||||||
| # FIRST RUN NOTE | ||||||||||
| # Auto-fix hooks (trailing-whitespace, end-of-file-fixer) will correct | ||||||||||
| # pre-existing violations on the first run. Stage and commit those fixes | ||||||||||
| # separately before day-to-day use. | ||||||||||
| # | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
It would be a good idea to add these instructions to the Boilerplate file as well. |
||||||||||
| # ============================================================================= | ||||||||||
|
|
||||||||||
| repos: | ||||||||||
|
|
||||||||||
| # --------------------------------------------------------------------------- | ||||||||||
| # 1. FILE HYGIENE + YAML SYNTAX | target < 2s | auto-fix + error | ||||||||||
| # - check-merge-conflict: detects unresolved merge markers | ||||||||||
| # - trailing-whitespace: removes trailing spaces (auto-fix) | ||||||||||
| # - end-of-file-fixer: ensures single EOF newline (auto-fix) | ||||||||||
| # - check-yaml: validates YAML syntax in deploy/ manifests; | ||||||||||
| # mirrors ci/prow/lint: olm-deploy-yaml-validate | ||||||||||
| # --------------------------------------------------------------------------- | ||||||||||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||||||||||
| rev: v5.0.0 # pinned immutable tag | ||||||||||
| hooks: | ||||||||||
| - id: check-merge-conflict | ||||||||||
| - id: trailing-whitespace | ||||||||||
| args: [--markdown-linebreak-ext=md] | ||||||||||
| - id: end-of-file-fixer | ||||||||||
| - id: check-yaml | ||||||||||
| name: YAML syntax (deploy/) | ||||||||||
| files: ^deploy/.*\.ya?ml$ | ||||||||||
| args: [--allow-multiple-documents] | ||||||||||
|
|
||||||||||
| # --------------------------------------------------------------------------- | ||||||||||
| # 2. SECRETS DETECTION | target < 5s | always blocking | ||||||||||
| # Scans all file types (YAML, shell, config) — gosec covers Go only. | ||||||||||
| # High-confidence findings block; configure .gitleaks.toml for allowlist. | ||||||||||
| # --------------------------------------------------------------------------- | ||||||||||
| - repo: https://github.com/gitleaks/gitleaks | ||||||||||
| rev: v8.18.0 # pinned immutable tag (golden rule 15) | ||||||||||
| hooks: | ||||||||||
| - id: gitleaks | ||||||||||
|
|
||||||||||
| # --------------------------------------------------------------------------- | ||||||||||
| # 3. STATIC ANALYSIS | target < 15s cached | error | ||||||||||
| # Mirrors ci/prow/lint: go-check exactly (same version + config as CI). | ||||||||||
| # Linter config: boilerplate/openshift/golang-osd-operator/golangci.yml | ||||||||||
| # --------------------------------------------------------------------------- | ||||||||||
| - repo: https://github.com/golangci/golangci-lint | ||||||||||
| rev: v2.0.2 # pinned immutable tag — must match CI (golden rule 15) | ||||||||||
| hooks: | ||||||||||
| - id: golangci-lint | ||||||||||
| args: | ||||||||||
| - --config=boilerplate/openshift/golang-osd-operator/golangci.yml | ||||||||||
| - --timeout=120s # graceful timeout (golden rule 3) | ||||||||||
|
|
||||||||||
| # --------------------------------------------------------------------------- | ||||||||||
| # Local hooks — compile, dependency, security | ||||||||||
| # | ||||||||||
| # TIMEOUT NOTE (golden rule 3) | ||||||||||
| # Uses portable timeout detection: 'timeout' on Linux, 'gtimeout' on macOS. | ||||||||||
| # macOS: brew install coreutils | ||||||||||
| # Linux: timeout is available by default (GNU coreutils) | ||||||||||
| # --------------------------------------------------------------------------- | ||||||||||
| - repo: local | ||||||||||
| hooks: | ||||||||||
|
|
||||||||||
| # ----------------------------------------------------------------------- | ||||||||||
| # 4. COMPILE CHECK | target < 10s cached | error | ||||||||||
| # Catches import cycles and type errors before golangci-lint runs. | ||||||||||
| # Note: go build ./... writes no binary to the repo (compile check only). | ||||||||||
| # Fix: resolve compilation errors reported by go build. | ||||||||||
| # ----------------------------------------------------------------------- | ||||||||||
| - id: go-build | ||||||||||
| name: go build | ||||||||||
| language: system | ||||||||||
| entry: bash -c 'T=$(command -v timeout || command -v gtimeout || echo); ${T:+$T 30s} go build ./...' | ||||||||||
| types: [go] | ||||||||||
| pass_filenames: false | ||||||||||
|
|
||||||||||
| # ----------------------------------------------------------------------- | ||||||||||
| # 5. DEPENDENCY DRIFT | target < 10s | error | ||||||||||
| # Detects uncommitted go.mod/go.sum changes after go mod tidy. | ||||||||||
| # Fix: run 'go mod tidy' and stage go.mod and go.sum. | ||||||||||
| # ----------------------------------------------------------------------- | ||||||||||
| - id: go-mod-tidy | ||||||||||
| name: go mod tidy | ||||||||||
| language: system | ||||||||||
| entry: bash -c 'T=$(command -v timeout || command -v gtimeout || echo); ${T:+$T 60s} go mod tidy && git diff --exit-code go.mod go.sum' | ||||||||||
| files: '(\.go$|go\.(mod|sum)$)' | ||||||||||
| exclude: '^vendor/' | ||||||||||
| pass_filenames: false | ||||||||||
|
|
||||||||||
| # ----------------------------------------------------------------------- | ||||||||||
| # 6. RBAC WILDCARD CHECK | target < 5s | warn-only (blocking after cleanup) | ||||||||||
| # Rejects wildcard RBAC in deploy/ manifests (verbs/resources: ["*"] | ||||||||||
| # or multi-line - '*' format). Logic lives in standard.mk target | ||||||||||
| # 'rbac-wildcard-check' for readability and reuse. | ||||||||||
| # Fix: replace wildcards with explicit verbs and resource names. | ||||||||||
| # ----------------------------------------------------------------------- | ||||||||||
| - id: rbac-wildcard-check | ||||||||||
| name: RBAC wildcard permissions | ||||||||||
| language: system | ||||||||||
| entry: bash -c 'make rbac-wildcard-check' | ||||||||||
| files: ^deploy/.*\.ya?ml$ | ||||||||||
| pass_filenames: false | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| image-v8.3.4 | ||
| image-v8.3.6 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 28f0d527a87f963961e218687f8e481acf62e47d | ||
| 0d8c4f5b1d0cc0be7f35fa2d84430c112eb3a5f0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,76 @@ | ||
| version: "2" | ||
| run: | ||
| concurrency: 10 | ||
|
|
||
| linters: | ||
| default: none | ||
| enable: | ||
| # Error Handling & Security | ||
| - errcheck | ||
| - gosec | ||
| - govet | ||
| - ineffassign | ||
| - misspell | ||
| - staticcheck | ||
| - gosec | ||
| - bodyclose | ||
| - sqlclosecheck | ||
| - contextcheck | ||
| - noctx | ||
|
|
||
| # Error Prevention | ||
| - errorlint | ||
| - nilerr | ||
| - nilnil | ||
| - revive | ||
|
|
||
| # Code Quality | ||
| - ineffassign | ||
| - unconvert | ||
| - unparam | ||
| - unused | ||
| - misspell | ||
|
|
||
| # Maintainability | ||
| - prealloc | ||
| - nolintlint | ||
| - gocyclo | ||
| - exhaustive | ||
| - makezero | ||
| - containedctx | ||
|
|
||
| settings: | ||
| revive: | ||
| rules: | ||
| - name: package-comments | ||
| disabled: true | ||
|
|
||
| errcheck: | ||
| check-type-assertions: true | ||
| check-blank: false | ||
|
|
||
| exclusions: | ||
| presets: | ||
| - std-error-handling | ||
|
|
||
| gocyclo: | ||
| min-complexity: 15 | ||
|
|
||
| errorlint: | ||
| errorf: true | ||
| asserts: true | ||
| comparison: true | ||
|
|
||
| misspell: | ||
| extra-words: | ||
| - typo: openshit | ||
| correction: OpenShift | ||
| exclusions: | ||
| generated: lax | ||
| presets: | ||
| - comments | ||
| - common-false-positives | ||
| - legacy | ||
| - std-error-handling | ||
| paths: | ||
| - third_party/ | ||
| - builtin/ | ||
| - examples/ | ||
|
|
||
| run: | ||
| timeout: 5m | ||
| # Incremental linting (new-from-rev) is passed via the Makefile's | ||
| # go-check target. In CI it uses PULL_BASE_SHA (guaranteed to exist | ||
| # even in shallow clones); locally it falls back to origin/HEAD. | ||
|
|
||
| formatters: | ||
| enable: | ||
| - gofmt | ||
| - goimports | ||
|
|
||
| issues: | ||
| max-issues-per-linter: 0 | ||
| max-same-issues: 0 | ||
| formatters: | ||
| exclusions: | ||
| generated: lax | ||
| paths: | ||
| - third_party/ | ||
| - builtin/ | ||
| - examples/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What effect will this have on other PRs for this repo? Will it prevent them from passing until there is sufficient coverage or is it only for new code?