diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 484b382b6..caee88f37 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI on: push: - branches: [main] + branches: [main, "integration/*"] paths: - "apps/**" - "packages/**" @@ -20,7 +20,7 @@ on: - "install-cli.sh" - "website/install-cli.sh" pull_request: - branches: [main] + branches: [main, "integration/*"] paths: - "apps/**" - "packages/**" diff --git a/.github/workflows/gitleaks.yml b/.github/workflows/gitleaks.yml index 3c608c8fd..e4c41e21e 100644 --- a/.github/workflows/gitleaks.yml +++ b/.github/workflows/gitleaks.yml @@ -13,9 +13,9 @@ name: Secret Scan on: pull_request: - branches: [main] + branches: [main, "integration/*"] push: - branches: [main] + branches: [main, "integration/*"] schedule: # Weekly full-history sweep (Mondays 07:00 UTC): catches anything reachable # only from history and re-scans as gitleaks' default rules evolve. diff --git a/.github/workflows/pin-actions.yml b/.github/workflows/pin-actions.yml index c5c0ea2d6..4bd3a6a94 100644 --- a/.github/workflows/pin-actions.yml +++ b/.github/workflows/pin-actions.yml @@ -2,12 +2,12 @@ name: Pin GitHub Actions on: push: - branches: [main] + branches: [main, "integration/*"] paths: - ".github/workflows/**" - ".github/pinact.yaml" pull_request: - branches: [main] + branches: [main, "integration/*"] paths: - ".github/workflows/**" - ".github/pinact.yaml" diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 2e6332a34..d3f938a91 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -3,12 +3,12 @@ name: Deploy site to Pages on: push: - branches: ["main"] + branches: ["main", "integration/*"] paths: - "website/**" - ".github/workflows/static.yml" pull_request: - branches: ["main"] + branches: ["main", "integration/*"] paths: - "website/**" - ".github/workflows/static.yml" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3c89cebd2..3f1495777 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -361,6 +361,29 @@ MongoDB is CosmosDB-compatible — avoid MongoDB features that CosmosDB's MongoD See [Reviewing and merging community contributions](#reviewing-and-merging-community-contributions) for what to expect, including our acknowledgement target and follow-up on PRs waiting for a response. +### Integration branches + +Most PRs target `main`. When several PRs need to land together, a maintainer +can create `integration/` from current upstream `main`. Use a +single segment after `integration/`: `integration/taxonomy` matches the CI +filters; `integration/taxonomy/part-one` does not. + +Open each component PR against the initiative branch. Review and merge those +PRs there, keeping the initiative branch up to date with `main`. When the +combined change is ready, open one PR from `integration/` into +`main`. After it merges, delete the initiative branch. + +CI, secret scanning, action pinning, and the website build run on pushes to +and PRs targeting initiative branches, subject to their usual path filters. +Only `main` uploads and deploys Pages artifacts; CLI publishing still requires +a manual dispatch on upstream `main`. + +Workflow triggers do not protect branches. To enforce reviews or required +checks, a repository administrator must separately configure a GitHub branch +ruleset targeting `integration/*`. Keep the `main` ruleset intact and choose +required checks that report on every applicable PR: a path-filtered workflow +can leave a required check pending when it does not run. + ### Recording a demo For user-visible changes (Portal/CLI features or UX changes), attach a short recording in the PR's diff --git a/scripts/ci-workflow.test.ts b/scripts/ci-workflow.test.ts index c19bd6839..b721937e5 100644 --- a/scripts/ci-workflow.test.ts +++ b/scripts/ci-workflow.test.ts @@ -5,7 +5,7 @@ import { spawnSync } from "node:child_process"; import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; import { createRequire } from "node:module"; import { tmpdir } from "node:os"; -import { join, resolve } from "node:path"; +import { join, posix, resolve } from "node:path"; import { afterEach, describe, expect, it } from "vitest"; // Reuse shared's existing YAML dependency, as the worker Dockerfiles do. @@ -160,6 +160,34 @@ describe("GitHub Action pinning", () => { }); }); +describe("Integration branch CI", () => { + it.each(["ci", "gitleaks", "pin-actions", "static"])("%s checks pushes and PR bases for a single initiative", (name) => { + const { on } = parse(readFileSync(`.github/workflows/${name}.yml`, "utf8")) as { + on: Record<"push" | "pull_request", { branches: string[] }>; + }; + + // Both events filter the destination branch, not the contributor's topic branch. + for (const event of ["push", "pull_request"] as const) { + const matches = (branch: string) => on[event].branches.some((pattern) => posix.matchesGlob(branch, pattern)); + expect(matches("main"), event).toBe(true); + expect(matches("integration/taxonomy"), event).toBe(true); + expect(matches("integration/cli-refresh"), event).toBe(true); + expect(matches("feature/taxonomy"), event).toBe(false); + expect(matches("integration/taxonomy/part-one"), event).toBe(false); + } + }); + + it("builds the site on integration branches without uploading or deploying Pages", () => { + const { jobs } = parse(readFileSync(".github/workflows/static.yml", "utf8")) as { jobs: Record }; + expect(jobs.build.if).toBeUndefined(); + for (const action of ["actions/configure-pages", "actions/upload-pages-artifact"]) { + const step = jobs.build.steps.find(({ uses }) => uses?.startsWith(`${action}@`)); + expect(step?.if, action).toBe("github.ref == 'refs/heads/main'"); + } + expect(jobs.deploy.if).toBe("github.ref == 'refs/heads/main'"); + }); +}); + describe("CI execution prerequisites", () => { it("selects integration checks for workflow changes through a dedicated filter", () => { const filtersStep = jobs["detect-changes"].steps.find((candidate) => candidate.uses?.startsWith("dorny/paths-filter@")); diff --git a/website/src/content/docs/resources/contributing.md b/website/src/content/docs/resources/contributing.md index 4662aab1d..0a1f55aad 100644 --- a/website/src/content/docs/resources/contributing.md +++ b/website/src/content/docs/resources/contributing.md @@ -24,8 +24,10 @@ for coding conventions, testing requirements, and the pull request process. ## Pull requests -Open pull requests against `microsoft/scope` on `main`, including when working -from a fork. Keep changes focused, include appropriate tests, and update +Open pull requests against `microsoft/scope`, including when working from a +fork. Target `main` unless your change belongs to a maintainer's +[integration branch](https://github.com/microsoft/scope/blob/main/CONTRIBUTING.md#integration-branches). +Keep changes focused, include appropriate tests, and update affected documentation. See [Reviewing and merging community contributions](https://github.com/microsoft/scope/blob/main/CONTRIBUTING.md#reviewing-and-merging-community-contributions) for what to expect during review, including acknowledgement and follow-up