|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file provides guidance to AI assistents when working with code in this repository. |
| 4 | + |
| 5 | +## Repository Overview |
| 6 | + |
| 7 | +This is kubernetes/test-infra, which contains tools and configuration files for testing and automation needs of the Kubernetes project. The main components are: |
| 8 | + |
| 9 | +- **Prow Jobs**: CI/CD job configurations at prow.k8s.io (config/jobs/) |
| 10 | +- **TestGrid**: Test result visualization at testgrid.k8s.io (testgrid/) |
| 11 | +- **Kettle**: Extracts test results from GCS to BigQuery (kettle/) |
| 12 | +- **Label Sync**: Manages GitHub labels across repos (label_sync/) |
| 13 | +- **Gopherage**: Go coverage file manipulation (gopherage/) |
| 14 | +- **Experiment**: One-off tools and scripts (experiment/) |
| 15 | + |
| 16 | +Note: Prow source code moved to kubernetes-sigs/prow in April 2024. This repo now contains prow job configurations and test-infra specific tooling. |
| 17 | + |
| 18 | +## Building and Testing |
| 19 | + |
| 20 | +### Running Tests |
| 21 | + |
| 22 | +```bash |
| 23 | +# Run all tests (Go + Python unit tests) |
| 24 | +make test |
| 25 | + |
| 26 | +# Run only Go unit tests |
| 27 | +make go-unit |
| 28 | + |
| 29 | +# Run only Python unit tests |
| 30 | +make py-unit |
| 31 | + |
| 32 | +# Test a specific Go package or folder |
| 33 | +hack/make-rules/go-test/unit.sh <folder> |
| 34 | +# Examples: |
| 35 | +hack/make-rules/go-test/unit.sh kettle/... |
| 36 | +hack/make-rules/go-test/unit.sh pkg/benchmarkjunit/... |
| 37 | +``` |
| 38 | + |
| 39 | +### Verification and Linting |
| 40 | + |
| 41 | +```bash |
| 42 | +# Run all verification checks |
| 43 | +make verify |
| 44 | + |
| 45 | +# Run specific verifications |
| 46 | +make go-lint # golangci-lint checks |
| 47 | +make verify-gofmt # Go formatting |
| 48 | +make verify-eslint # TypeScript/JavaScript linting |
| 49 | +make py-lint # Python linting |
| 50 | +make verify-boilerplate # License header checks |
| 51 | +make verify-yamllint # YAML linting |
| 52 | +make verify-spelling # Spell checking |
| 53 | +make verify-labels # GitHub label validation |
| 54 | +make verify-file-perms # File permission checks |
| 55 | +make verify-generated-jobs # Verify generated jobs are up to date |
| 56 | +``` |
| 57 | + |
| 58 | +### Auto-fixing Issues |
| 59 | + |
| 60 | +```bash |
| 61 | +# Auto-format Go code |
| 62 | +make update-gofmt |
| 63 | + |
| 64 | +# Update Go dependencies (after changing go.mod) |
| 65 | +make update-go-deps |
| 66 | + |
| 67 | +# Auto-fix spelling mistakes |
| 68 | +make update-spelling |
| 69 | + |
| 70 | +# Update file permissions |
| 71 | +make update-file-perms |
| 72 | + |
| 73 | +# Regenerate generated job configs |
| 74 | +make generate-jobs |
| 75 | +``` |
| 76 | + |
| 77 | +## Dependency Management |
| 78 | + |
| 79 | +This repo uses Go modules. Key rules: |
| 80 | + |
| 81 | +- **NEVER add `replace` directives to go.mod** - this breaks published packages |
| 82 | +- Run `make update-go-deps` after modifying go.mod |
| 83 | +- Use `hack/make-rules/go-run/arbitrary.sh go <command>` instead of `go <command>` to ensure correct Go version (1.25.3) |
| 84 | +- See docs/dep.md for complete details |
| 85 | + |
| 86 | +## Working with Prow Jobs |
| 87 | + |
| 88 | +Job configurations live in `config/jobs/`. The directory structure is: |
| 89 | +- `org/repo/filename.yaml` for most repos |
| 90 | +- `kubernetes/sig-foo/filename.yaml` for kubernetes/kubernetes jobs |
| 91 | + |
| 92 | +### Job Types |
| 93 | + |
| 94 | +- **Presubmits**: Run on PRs before merge |
| 95 | +- **Postsubmits**: Run after code is merged |
| 96 | +- **Periodics**: Run on a schedule |
| 97 | + |
| 98 | +### Adding or Updating Jobs |
| 99 | + |
| 100 | +1. Create/edit YAML in config/jobs/ following the org/repo structure |
| 101 | +2. Ensure an OWNERS file exists in the directory |
| 102 | +3. Add testgrid annotations to display results: |
| 103 | + ```yaml |
| 104 | + annotations: |
| 105 | + testgrid-dashboards: sig-foo-bar |
| 106 | + testgrid-tab-name: pull-verify |
| 107 | + ``` |
| 108 | +4. Open PR - changes auto-deploy when merged |
| 109 | +5. Optionally test locally: `config/mkpj.sh` or `config/pj-on-kind.sh` |
| 110 | + |
| 111 | +See config/jobs/README.md for comprehensive job configuration guide. |
| 112 | + |
| 113 | +### Generated Jobs |
| 114 | + |
| 115 | +Some jobs are auto-generated and should NOT be edited directly: |
| 116 | + |
| 117 | +- **Image validation jobs**: Edit releng/test_config.yaml then run `./hack/update-generated-tests.sh` |
| 118 | +- **Release branch jobs**: Use releng/config-forker to fork master jobs for new release branches |
| 119 | + |
| 120 | +Always run `make verify-generated-jobs` before submitting PRs. |
| 121 | + |
| 122 | +## TestGrid Configuration |
| 123 | + |
| 124 | +TestGrid displays test results at testgrid.k8s.io. Two ways to configure: |
| 125 | + |
| 126 | +1. **Simple (recommended)**: Add annotations to prow job YAML: |
| 127 | + ```yaml |
| 128 | + annotations: |
| 129 | + testgrid-dashboards: sig-testing-misc |
| 130 | + testgrid-tab-name: pull-verify |
| 131 | + ``` |
| 132 | + |
| 133 | +2. **Advanced**: Edit testgrid/config.yaml directly |
| 134 | + |
| 135 | +See testgrid/README.md and testgrid/config.md for details. |
| 136 | + |
| 137 | +## Image Building |
| 138 | + |
| 139 | +```bash |
| 140 | +# Build all misc images (local) |
| 141 | +make build-misc-images |
| 142 | +
|
| 143 | +# Build single image (local) |
| 144 | +make build-single-image PROW_IMAGE=<image-name> |
| 145 | +
|
| 146 | +# Push all misc images to registry |
| 147 | +make push-misc-images REGISTRY=gcr.io/k8s-staging-test-infra |
| 148 | +
|
| 149 | +# Push single image to registry |
| 150 | +make push-single-image PROW_IMAGE=<image-name> REGISTRY=gcr.io/k8s-staging-test-infra |
| 151 | +``` |
| 152 | + |
| 153 | +Images are configured in .test-infra-misc-images.yaml |
| 154 | + |
| 155 | +## Repository Structure |
| 156 | + |
| 157 | +Key directories: |
| 158 | + |
| 159 | +- **config/**: Prow configuration and job definitions |
| 160 | + - **config/jobs/**: All prow job configs (org/repo structure) |
| 161 | + - **config/prow/**: Prow cluster configuration |
| 162 | + - **config/testgrids/**: TestGrid dashboard configs |
| 163 | +- **hack/**: Build and test scripts |
| 164 | + - **hack/make-rules/**: Make targets for testing/verification |
| 165 | + - **hack/tools/**: Tool dependencies (gotestsum, etc.) |
| 166 | +- **releng/**: Release engineering tools |
| 167 | + - **releng/config-forker**: Fork jobs for new release branches |
| 168 | + - **releng/test_config.yaml**: Image validation job config |
| 169 | +- **pkg/**: Shared Go packages (minimal, most moved to prow repo) |
| 170 | +- **testgrid/**: TestGrid-specific configs and docs |
| 171 | +- **kettle/**: BigQuery data pipeline |
| 172 | +- **label_sync/**: GitHub label management |
| 173 | +- **experiment/**: Ad-hoc scripts and tools |
| 174 | + |
| 175 | +## Architecture Notes |
| 176 | + |
| 177 | +- Prow jobs run in Kubernetes pods on the prow.k8s.io cluster |
| 178 | +- Test results stored in GCS buckets (kubernetes-ci-logs) |
| 179 | +- Kettle extracts GCS results → BigQuery for metrics/analysis |
| 180 | +- TestGrid reads from GCS to display historical results |
| 181 | +- GitHub webhooks trigger presubmit jobs on PRs |
| 182 | +- Jobs use presets (defined in config/prow/config.yaml) for common credentials/config |
| 183 | + |
| 184 | +## Common Workflows |
| 185 | + |
| 186 | +### Updating Job Configs |
| 187 | +1. Edit YAML in config/jobs/org/repo/ |
| 188 | +2. Run `make verify` to check for issues |
| 189 | +3. Commit and open PR |
| 190 | +4. Changes auto-deploy on merge |
| 191 | + |
| 192 | +### Adding New Release Branch Jobs |
| 193 | +```bash |
| 194 | +go run ./releng/config-forker \ |
| 195 | + --job-config $(pwd)/config/jobs \ |
| 196 | + --version 1.27 \ |
| 197 | + --go-version 1.20.2 \ |
| 198 | + --output $(pwd)/config/jobs/kubernetes/sig-release/release-branch-jobs/1.27.yaml |
| 199 | +``` |
| 200 | + |
| 201 | +### Testing Locally |
| 202 | +```bash |
| 203 | +# Test prow job config locally |
| 204 | +config/pj-on-kind.sh |
| 205 | +
|
| 206 | +# Create prowjob CR from local config |
| 207 | +config/mkpj.sh |
| 208 | +``` |
| 209 | + |
| 210 | +## CI and PR Workflow |
| 211 | + |
| 212 | +- All PRs checked by presubmit jobs configured in config/jobs/ |
| 213 | +- Use `/test <job-name>` to trigger specific jobs |
| 214 | +- Use `/retest` to re-run failed jobs |
| 215 | +- Jobs automatically deployed when PRs merge to master |
| 216 | +- Use `/hold` to prevent auto-merge, `/hold cancel` to release |
| 217 | +- Use `/cc @person` or `/assign @person` to notify reviewers |
| 218 | +- See https://prow.k8s.io/command-help for all bot commands |
| 219 | + |
| 220 | +## Contact |
| 221 | + |
| 222 | +- SIG Testing owns this repo |
| 223 | +- Slack: #sig-testing, #testing-ops, #prow, #testgrid |
| 224 | + |
0 commit comments