Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,49 @@ on:
- '*/docs/**'
- '*/mkdocs.yml'
- '.github/workflows/docs.yml'
- 'scripts/ci-components.py'
- 'scripts/test_ci_components.py'
- 'scripts/build-docs.sh'
- '*/scripts/gen_llms_full.py'
- '*/README.md'
- '*/CHANGELOG.md'
- '*/llms.txt'
- '*/apcore-*-logo.svg'
# Pages already builds the complete site on main when documentation changes.
push:
branches: [main]
paths:
- '*/docs/**'
- '*/mkdocs.yml'
- '.github/workflows/docs.yml'
- 'scripts/build-docs.sh'
- '*/scripts/gen_llms_full.py'
- '*/README.md'
- '*/CHANGELOG.md'
- '*/llms.txt'
- 'scripts/ci-components.py'
- 'scripts/test_ci_components.py'
workflow_dispatch:

permissions:
contents: read

jobs:
changes:
runs-on: ubuntu-latest
outputs:
components: ${{ steps.select.outputs.components }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
persist-credentials: false
- name: Test component selection
run: python3 -m unittest discover -s scripts -p test_ci_components.py
- id: select
run: python3 scripts/ci-components.py docs

docs:
needs: changes
if: needs.changes.outputs.components != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component: [toolkit, mcp, a2a, cli]
component: ${{ fromJSON(needs.changes.outputs.components) }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- '*/README.md'
- '*/CHANGELOG.md'
- '*/llms.txt'
- '*/apcore-*-logo.svg'
workflow_dispatch:

concurrency:
Expand Down
31 changes: 26 additions & 5 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- 'uv.lock'
- 'mcp/examples/management-reference/**'
- '.github/workflows/python.yml'
- 'scripts/ci-components.py'
pull_request:
paths: *python-paths
workflow_dispatch:
Expand All @@ -21,16 +22,34 @@ env:
CORE_REF: c89df2fcbe9224104151222006eeaa1b91f08d5e

jobs:
changes:
runs-on: ubuntu-latest
outputs:
components: ${{ steps.select.outputs.components }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
persist-credentials: false
- id: select
run: python3 scripts/ci-components.py python

test:
needs: changes
if: needs.changes.outputs.components != '[]'
name: Python ${{ matrix.version }} (${{ matrix.component }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component: [toolkit, mcp, a2a, cli]
version: ['3.12']
include:
- component: toolkit
component: ${{ fromJSON(needs.changes.outputs.components) }}
version: ['3.12', '3.11']
exclude:
- component: mcp
version: '3.11'
- component: a2a
version: '3.11'
- component: cli
version: '3.11'
defaults:
run:
Expand Down Expand Up @@ -93,12 +112,14 @@ jobs:
"$legacy/bin/python" "$example/legacy_smoke.py" "$reference/bin/python"

package:
needs: changes
if: needs.changes.outputs.components != '[]'
name: Python distribution (${{ matrix.component }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component: [toolkit, mcp, a2a, cli]
component: ${{ fromJSON(needs.changes.outputs.components) }}
defaults:
run:
working-directory: ${{ matrix.component }}/python
Expand Down
45 changes: 30 additions & 15 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@ name: Rust surfaces
on:
push:
branches: [main]
paths:
paths: &rust-paths
- '*/rust/**'
- '*/conformance/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/rust.yml'
- 'scripts/ci-components.py'
- 'scripts/verify-rust-surface.py'
pull_request:
paths:
- '*/rust/**'
- '*/conformance/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/rust.yml'
- 'scripts/verify-rust-surface.py'
paths: *rust-paths
workflow_dispatch:

permissions:
Expand All @@ -31,16 +26,34 @@ env:
CORE_CRATE_SHA256: 058a6b8bdece7890ecebbf9d988efc5186f806de838b230cb7c77549d1965228

jobs:
changes:
runs-on: ubuntu-latest
outputs:
components: ${{ steps.select.outputs.components }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
persist-credentials: false
- id: select
run: python3 scripts/ci-components.py rust

source:
name: Rust source tests (${{ matrix.component }})
needs: changes
if: needs.changes.outputs.components != '[]'
name: Rust source tests (${{ matrix.component }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
component: [toolkit, mcp, a2a, cli]
os: [ubuntu-latest]
include:
- component: mcp
component: ${{ fromJSON(needs.changes.outputs.components) }}
os: [ubuntu-latest, windows-latest]
exclude:
- component: toolkit
os: windows-latest
- component: a2a
os: windows-latest
- component: cli
os: windows-latest
defaults:
run:
Expand Down Expand Up @@ -68,7 +81,7 @@ jobs:
~/.cargo/git
${{ matrix.component }}/rust/target
key: ${{ runner.os }}-cargo-${{ matrix.component }}-${{ hashFiles('*/rust/Cargo.lock') }}
- run: cargo fmt --all -- --check
- run: cargo fmt --package apcore-${{ matrix.component }} -- --check
- name: Check and test against the pinned Core and checkout Toolkit
shell: bash
env:
Expand All @@ -79,12 +92,14 @@ jobs:
"$GITHUB_WORKSPACE/.ci-apcore-core/rust"

package:
needs: changes
if: needs.changes.outputs.components != '[]'
name: Rust crate verification (${{ matrix.component }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component: [toolkit, mcp, a2a, cli]
component: ${{ fromJSON(needs.changes.outputs.components) }}
defaults:
run:
working-directory: ${{ matrix.component }}/rust
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- '.github/workflows/typescript.yml'
- 'scripts/ci-components.py'
- 'scripts/verify-typescript-surface-package.sh'
pull_request:
paths: *typescript-paths
Expand All @@ -21,13 +22,27 @@ env:
CORE_REF: c89df2fcbe9224104151222006eeaa1b91f08d5e

jobs:
changes:
runs-on: ubuntu-latest
outputs:
components: ${{ steps.select.outputs.components }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
persist-credentials: false
- id: select
run: python3 scripts/ci-components.py typescript

test:
needs: changes
if: needs.changes.outputs.components != '[]'
name: TypeScript (${{ matrix.component }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component: [toolkit, mcp, a2a, cli]
component: ${{ fromJSON(needs.changes.outputs.components) }}
defaults:
run:
working-directory: ${{ matrix.component }}/typescript
Expand Down Expand Up @@ -111,12 +126,14 @@ jobs:
if: matrix.component == 'toolkit'

package:
needs: changes
if: needs.changes.outputs.components != '[]'
name: npm distribution (${{ matrix.component }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component: [toolkit, mcp, a2a, cli]
component: ${{ fromJSON(needs.changes.outputs.components) }}
defaults:
run:
working-directory: ${{ matrix.component }}/typescript
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ Rust and TypeScript component lockfiles pin the independent package graphs.
The distribution workflows verify component builds with these locks and the
published manifests' registry dependencies.

## Continuous integration

Source and distribution checks run for the affected language and component.
Changes to a component's `conformance/` directory run its Python, Rust, and
TypeScript checks. Toolkit implementation changes also run MCP, A2A, and CLI
for the same language. Changes to a language's workspace files run its full
component matrix. You can run each full matrix manually from GitHub Actions.

Pull requests build the affected documentation sites. On `main`, the Pages
workflow builds and publishes the combined site.

For Core candidate compatibility, manually run
[Core distribution verification](https://github.com/apstack/apcore/actions/workflows/packages.yml)
at the candidate commit. Supply its completed run ID to the
[Core candidate compatibility workflow](.github/workflows/core-candidate.yml).

## Coordinated release candidates

| Component | PyPI, npm, and crates.io |
Expand Down
84 changes: 84 additions & 0 deletions scripts/ci-components.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"""Select affected Surface components from the GitHub Actions event diff."""

from __future__ import annotations

import argparse
import json
import os
import subprocess
from pathlib import Path

COMPONENTS = ("toolkit", "mcp", "a2a", "cli")
SHARED_INPUTS = {
"python": {"pyproject.toml", "uv.lock"},
"rust": {"Cargo.toml", "Cargo.lock", "scripts/verify-rust-surface.py"},
"typescript": {"pnpm-lock.yaml", "pnpm-workspace.yaml", "scripts/verify-typescript-surface-package.sh"},
"docs": {"scripts/build-docs.sh"},
}
DOC_FILES = {"mkdocs.yml", "README.md", "CHANGELOG.md", "llms.txt", "scripts/gen_llms_full.py"}


def changed_paths() -> list[str] | None:
"""Return None when a complete diff is unavailable or the run is manual."""
event_name = os.environ["GITHUB_EVENT_NAME"]
if event_name == "workflow_dispatch":
return None

event = json.loads(Path(os.environ["GITHUB_EVENT_PATH"]).read_text(encoding="utf-8"))
if event_name == "pull_request":
pull_request = event["pull_request"]
revisions = pull_request["base"]["sha"] + "..." + pull_request["head"]["sha"]
elif event_name == "push":
revisions = event["before"] + ".." + event["after"]
else:
raise ValueError(f"Unsupported event: {event_name}")

# Disabling rename detection includes both paths when a file moves between components.
result = subprocess.run(
["git", "diff", "--name-only", "-z", "--no-renames", revisions, "--"],
capture_output=True,
check=False,
)
if result.returncode != 0:
print("::warning::Could not compare event commits, so all components will run.")
return None
return [os.fsdecode(path) for path in result.stdout.split(b"\0") if path]


def select_components(scope: str, paths: list[str] | None) -> list[str]:
shared = SHARED_INPUTS[scope] | {".github/workflows/" + scope + ".yml", "scripts/ci-components.py"}
if paths is None or shared.intersection(paths):
return list(COMPONENTS)

affected = set()
for path in paths:
component, _, relative = path.partition("/")
if component not in COMPONENTS:
continue
if scope == "docs":
if relative in DOC_FILES or relative == f"apcore-{component}-logo.svg" or relative.startswith("docs/"):
affected.add(component)
elif relative.startswith(scope + "/"):
# All release components use the checked-out Toolkit of their language.
if component == "toolkit":
return list(COMPONENTS)
affected.add(component)
elif relative.startswith("conformance/"):
affected.add(component)
elif scope == "python" and component == "mcp" and relative.startswith("examples/management-reference/"):
affected.add(component)
return [component for component in COMPONENTS if component in affected]


def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("scope", choices=SHARED_INPUTS)
args = parser.parse_args()
components = select_components(args.scope, changed_paths())
print("Components:", ", ".join(components) or "none")
with Path(os.environ["GITHUB_OUTPUT"]).open("a", encoding="utf-8") as output:
output.write(f"components={json.dumps(components)}\n")


if __name__ == "__main__":
main()
Loading
Loading