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
14 changes: 12 additions & 2 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ on:
push:
branches:
- main
paths: &docs-paths
- 'docs/**'
- 'llms.txt'
- 'mkdocs.yml'
- 'schemas/module-schema.schema.json'
- 'scripts/gen_llms_full.py'
- 'scripts/mkdocs_schemas.py'
- '.github/workflows/deploy-docs.yml'
pull_request:
branches:
- main
paths: *docs-paths
workflow_dispatch:

permissions:
contents: read
Expand Down Expand Up @@ -37,12 +47,12 @@ jobs:
- run: mkdocs build --strict

- uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
if: github.event_name == 'push'
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
with:
path: site

deploy:
if: github.event_name == 'push'
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
needs: build
runs-on: ubuntu-latest
permissions:
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/package-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Core distribution verification (python)

on:
pull_request:
paths: &package-paths
- 'python/**'
- 'docs/getting-started.md'
- 'docs/features/streaming.md'
- 'docs/features/module-interface.md'
- 'docs/features/context-object.md'
- 'conformance/extract_doc_examples.py'
- '.github/workflows/package-python.yml'
push:
branches: [main]
paths: *package-paths
workflow_call:

permissions:
contents: read

jobs:
python:
runs-on: ubuntu-latest
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: '3.11'
- name: Build wheel and sdist
run: |
python -m pip install build
python -m build
- name: Verify installed wheel
shell: bash
run: |
wheel=( "$PWD"/dist/*.whl )
temporary=$(mktemp -d)
python -m venv "$temporary/venv"
cd "$temporary"
"$temporary/venv/bin/python" -m pip install "${wheel[0]}"
"$temporary/venv/bin/python" -m pip check
"$temporary/venv/bin/python" -c 'from apcore import APCore, Registry; from importlib.util import find_spec; assert all(find_spec(name) is None for name in ("yaml", "watchdog", "aiohttp", "opentelemetry"))'
"$temporary/venv/bin/python" -c 'from importlib.resources import files; assert files("apcore").joinpath("py.typed").is_file(), "installed wheel is missing apcore/py.typed"'
python3 "$GITHUB_WORKSPACE/conformance/extract_doc_examples.py" python "$temporary"
(cd quick-start && "$temporary/venv/bin/python" -I example.py)
(cd typed-module && "$temporary/venv/bin/python" -I example.py)
(cd invocation-budget && "$temporary/venv/bin/python" -I example.py)
python -m venv "$temporary/full"
"$temporary/full/bin/python" -m pip install "${wheel[0]}[all]"
"$temporary/full/bin/python" -m pip check
"$temporary/full/bin/python" -c 'from apcore.full import APCore, Config; from apcore.events import SubscriberRegistry; assert APCore(config=Config.from_defaults()).registry is not None'
(cd governed-stream && "$temporary/full/bin/python" -I example.py)
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: core-python-distributions
path: python/dist/
112 changes: 112 additions & 0 deletions .github/workflows/package-rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Core distribution verification (rust)

on:
pull_request:
paths: &package-paths
- 'rust/**'
- 'docs/getting-started.md'
- 'docs/features/streaming.md'
- 'docs/features/module-interface.md'
- 'docs/features/context-object.md'
- 'conformance/extract_doc_examples.py'
- '.github/workflows/package-rust.yml'
push:
branches: [main]
paths: *package-paths
workflow_call:

permissions:
contents: read

jobs:
rust:
runs-on: ubuntu-latest
defaults:
run:
working-directory: rust
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc
with:
toolchain: 1.86.0
- name: Package the macro and its SDK
shell: bash
run: |
# Package both workspace crates together to stage the macro in
# Cargo's temporary registry. Keep the published dependency and its
# checksum in the SDK archive's lockfile.
rustup toolchain install 1.100.0 --profile minimal
cargo +1.100.0 package --locked --all-features -p apcore -p apcore-macros
python3 - <<'PYTHON'
import hashlib
from pathlib import Path
import tarfile
import tomllib

sdk, = Path("target/package").glob("apcore-[0-9]*.crate")
macros, = Path("target/package").glob("apcore-macros-[0-9]*.crate")
with tarfile.open(sdk) as archive:
lockfile = archive.extractfile(f"{sdk.stem}/Cargo.lock")
assert lockfile is not None
lock = tomllib.loads(lockfile.read().decode("utf-8"))
macro, = (package for package in lock["package"] if package["name"] == "apcore-macros")
assert macro["source"] == "registry+https://github.com/rust-lang/crates.io-index"
assert macro["checksum"] == hashlib.sha256(macros.read_bytes()).hexdigest()
PYTHON
- name: Run downstream examples against the packaged crate
shell: bash
env:
CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS: fallback
run: |
sdk=( "$PWD"/target/package/apcore-[0-9]*.crate )
macro=( "$PWD"/target/package/apcore-macros-[0-9]*.crate )
temporary=$(mktemp -d)
cd "$temporary"
mkdir sdk macros
tar -xzf "${sdk[0]}" --strip-components=1 -C sdk
tar -xzf "${macro[0]}" --strip-components=1 -C macros
cp sdk/Cargo.lock Cargo.lock
python3 "$GITHUB_WORKSPACE/conformance/extract_doc_examples.py" rust "$temporary"
cat > Cargo.toml <<'EOF'
[package]
name = "apcore-doc-examples"
version = "0.0.0"
edition = "2021"
rust-version = "1.86"

[dependencies]
apcore = { path = "sdk", features = ["config", "events", "macros"] }
async-trait = "0.1.92"
futures-util = "0.3"
schemars = "0.8"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

[patch.crates-io]
apcore-macros = { path = "macros" }

[[bin]]
name = "quick-start"
path = "quick-start/example.rs"

[[bin]]
name = "governed-stream"
path = "governed-stream/example.rs"

[[bin]]
name = "typed-module"
path = "typed-module/example.rs"

[[bin]]
name = "invocation-budget"
path = "invocation-budget/example.rs"
EOF
(cd quick-start && cargo run --quiet --manifest-path ../Cargo.toml --bin quick-start)
(cd governed-stream && cargo run --locked --quiet --manifest-path ../Cargo.toml --bin governed-stream)
(cd typed-module && cargo run --locked --quiet --manifest-path ../Cargo.toml --bin typed-module)
(cd invocation-budget && cargo run --locked --quiet --manifest-path ../Cargo.toml --bin invocation-budget)
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: core-rust-distribution
path: rust/target/package/*.crate
73 changes: 73 additions & 0 deletions .github/workflows/package-typescript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Core distribution verification (typescript)

on:
pull_request:
paths: &package-paths
- 'typescript/**'
- 'docs/getting-started.md'
- 'docs/features/streaming.md'
- 'docs/features/module-interface.md'
- 'docs/features/context-object.md'
- 'conformance/extract_doc_examples.py'
- '.github/workflows/package-typescript.yml'
push:
branches: [main]
paths: *package-paths
workflow_call:

permissions:
contents: read

jobs:
typescript:
runs-on: ubuntu-latest
defaults:
run:
working-directory: typescript
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '22'
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
with:
version: '10.30.1'
- run: pnpm install --frozen-lockfile
- run: pnpm build
- name: Pack the distribution
run: |
mkdir -p "$GITHUB_WORKSPACE/dist-archives"
pnpm pack --pack-destination "$GITHUB_WORKSPACE/dist-archives"
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '20.0.0'
- name: Run installed package checks on the Node floor
shell: bash
run: |
temporary=$(mktemp -d)
archive=( "$GITHUB_WORKSPACE"/dist-archives/*.tgz )
cd "$temporary"
npm init -y
npm pkg set type=module
npm install --ignore-scripts "${archive[0]}" typescript@5.5.4 @types/node@20 zod@4
node --input-type=module -e 'import {APCore} from "apcore-js"; import "apcore-js/context-keys"; if (!APCore) throw new Error("APCore is missing");'
cat > verify-browser.mjs <<'EOF'
const url = await import.meta.resolve("apcore-js");
if (!url.endsWith("/dist/index.js")) throw new Error("browser entry did not resolve to the portable root");
const core = await import("apcore-js");
if (!core.APCore || "Config" in core) throw new Error("invalid Core Profile exports");
EOF
node --conditions=browser --experimental-import-meta-resolve verify-browser.mjs
node --input-type=module -e 'import {accessSync} from "node:fs"; for (const entry of ["index", "core", "full", "config-entry", "discovery", "events/entry", "context-keys"]) accessSync(`node_modules/apcore-js/dist/${entry}.d.ts`);'
node --input-type=module -e 'import {APCore} from "apcore-js/full"; import {Config} from "apcore-js/config"; import {createFilesystemDiscoveryPlugin} from "apcore-js/discovery"; if (!new APCore({config: new Config(), plugins: [createFilesystemDiscoveryPlugin()]}).registry) throw new Error("invalid full assembly");'
python3 "$GITHUB_WORKSPACE/conformance/extract_doc_examples.py" typescript "$temporary"
./node_modules/.bin/tsc --strict --module NodeNext --target ES2022 --rootDir . --outDir compiled \
quick-start/example.ts governed-stream/example.ts typed-module/example.ts invocation-budget/example.ts
(cd quick-start && node ../compiled/quick-start/example.js)
(cd governed-stream && node ../compiled/governed-stream/example.js)
(cd typed-module && node ../compiled/typed-module/example.js)
(cd invocation-budget && node ../compiled/invocation-budget/example.js)
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: core-npm-distribution
path: dist-archives/*.tgz
Loading
Loading