Skip to content

validate-rules: use base-branch local staging checks#537

Merged
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
dims:dsri/validate-rules-base-branch-local
Feb 28, 2026
Merged

validate-rules: use base-branch local staging checks#537
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
dims:dsri/validate-rules-base-branch-local

Conversation

@dims
Copy link
Member

@dims dims commented Feb 27, 2026

Summary:

  • validate only the PR base branch in validate-rules staging directory checks
  • for that base branch, prefer local checkout (staging/src/k8s.io/...) and fall back to GitHub API otherwise
  • keep non-base branches skipped as before

Why:

  • pull-publishing-bot-validate can false-fail when a new staging repo exists in PR checkout but not yet in upstream branch refs

Validation:

  • go test ./cmd/validate-rules/... -count=1
  • PULL_BASE_REF=master go run ./cmd/validate-rules /Users/dsrinivas/go/src/k8s.io/kubernetes/staging/publishing/rules.yaml

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 27, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dims

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 27, 2026
@dims
Copy link
Member Author

dims commented Feb 27, 2026

we always run into this when we want to iterate on creation of a new staging repo!

xref: kubernetes/kubernetes#137298

@dims
Copy link
Member Author

dims commented Feb 27, 2026

/assign @akhilerm

@dims dims added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2026
@k8s-ci-robot k8s-ci-robot merged commit 0f38856 into kubernetes:master Feb 28, 2026
7 checks passed
Copy link
Member

@akhilerm akhilerm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got a few questions on the change. cc: @dims

// EnsureStagingDirectoriesExist walks through the repository rules and checks
// if the specified directories are present in the specific kubernetes branch.
func EnsureStagingDirectoriesExist(rules *config.RepositoryRules, baseBranch string) []error {
func EnsureStagingDirectoriesExist(rules *config.RepositoryRules, baseBranch, rulesFile string) []error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the rulesFile here? only for getting the kuberoot?

func checkDirectoryExists(directory, branch, baseBranch, kubeRoot string) error {
if branch == baseBranch {
localPath := filepath.Join(kubeRoot, "staging", "src", "k8s.io", directory)
if info, err := os.Stat(localPath); err == nil && info.IsDir() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a directory does not exist in the local checkout, but exists when fetching via an API, doesnt it mean the content in the PR is wrong and it should fail the job?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants