Skip to content
Open
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
13 changes: 10 additions & 3 deletions .github/workflows/openshell-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ jobs:
echo "before=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
echo "pin=$("$TOOLS/openshell-tags.sh" pinned)" >> "$GITHUB_OUTPUT"

- name: Install Rust
run: rustup toolchain install 1.94 --profile minimal --component rustfmt,clippy && rustup default 1.94

- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
Expand All @@ -118,6 +115,16 @@ jobs:
-m "Automated by .github/workflows/openshell-next.yml. Upstream changes: $UPSTREAM/compare/$prev...$tag"
fi

# After the merge and the bump: the toolchain is the highest rust-version of openshell-annotate and the pinned
# OpenShell crates, so a prerelease that raises its rust-version (v0.1.11-pre.2 needs 1.95) does not fail on a
# hard-coded toolchain. The merge and bump steps run `cargo update`/`cargo metadata` with the runner's
# preinstalled stable cargo.
- name: Install Rust (the version the branch needs)
run: |
tc=$("$TOOLS/openshell-next.sh" toolchain)
echo "Rust $tc (highest rust-version of openshell-annotate and the pinned OpenShell crates)" | tee -a "$GITHUB_STEP_SUMMARY"
rustup toolchain install "$tc" --profile minimal --component rustfmt,clippy && rustup default "$tc"

- name: Test (fmt, clippy, test, docs)
id: test
continue-on-error: true
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version section and adds the squash-merged PR titles since the previous tag. Ver

## [Unreleased]

- ci(openshell-next): the tracking job installs the Rust version the branch needs, the highest `rust-version` of openshell-annotate and the pinned OpenShell crates (new `scripts/openshell-next.sh toolchain`), instead of a hard-coded 1.94, so OpenShell v0.1.11-pre.2 (Rust 1.95) builds; `sync` keeps the branch's higher `rust-version` when it resolves a pin conflict from main's `Cargo.toml` (#118)
- chore(deps): build against OpenShell v0.1.10 (`openshell-policy-schema`, `openshell-policy`, commit 152c59d); docs, generated policy headers and the `diff-logs`/`--image` notes now name v0.1.10. v0.1.10 still declares `rust-version = "1.94"`, so main stays on Rust 1.94 (#113)
- feat(validate): `lint --policy`, `drift` and `generate` run the offline checks of `openshell policy lint` (OpenShell v0.1.10, ai-openshell/openshell#5358): `find_endpoint_ambiguities` and `validate_and_canonicalize_authored_policy` (reserved `_provider_` keys, credential bindings, size limit) next to the gateway validator. Endpoints that match the same requests with different protocols are now an error, since a request is authorized only by endpoints using the selected route's protocol (ai-openshell/openshell#5274) (#113)
- feat(validate): a YAML policy file with `endpoint_settings` (a Cedar-only section, ai-openshell/openshell#5006) is rejected by `lint --policy` and `drift` with OpenShell's message (#113)
Expand Down
10 changes: 7 additions & 3 deletions docs/DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,15 @@ false`), so a delayed early run is not cancelled when the later one starts; the
comment) if the pin is unchanged and everything already passed. Dispatch it by hand when you need a bump now. It:

1. checks out `openshell-next` (recreating it from `main` if it was deleted) and merges `origin/main` into it with a
signed-off merge commit. If both sides changed the pin it keeps the newer tag; any other conflict stops the run
without pushing and is reported on the issue for a human to resolve;
signed-off merge commit. If both sides changed the pin it keeps the newer tag (and the branch's `rust-version` when
it is higher than main's); any other conflict stops the run without pushing and is reported on the issue for a
human to resolve;
2. moves the pin when upstream has a newer tag (`scripts/openshell-next.sh update`) and commits it as
`github-actions[bot]` with a `Signed-off-by` line;
3. runs `cargo fmt --check`, clippy, `cargo test --locked` and `scripts/gen-docs.sh --check` in the same job;
3. installs the Rust version the branch needs, the highest `rust-version` of openshell-annotate and the pinned
OpenShell crates (`scripts/openshell-next.sh toolchain`; v0.1.11-pre.2 needs 1.95), and runs `cargo fmt --check`,
clippy, `cargo test --locked` and `scripts/gen-docs.sh --check` in the same job. The dispatched `ci.yml` uses the
toolchain the branch's own `ci.yml` pins;
4. pushes the branch, even when the tests fail (the branch mirrors upstream; the fix is made on top), then dispatches
`ci.yml` on it, because a push with `GITHUB_TOKEN` starts no `push` workflow. The dispatched run publishes its result
as the commit statuses `CI (dispatched) / check` and `CI (dispatched) / audit`, which is what the tracking PR shows.
Expand Down
37 changes: 34 additions & 3 deletions scripts/openshell-next.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
# scripts/openshell-next.sh bump <tag> # pin both OpenShell crates to <tag> in Cargo.toml and re-resolve Cargo.lock
# scripts/openshell-next.sh update [<tag>] # bump to <tag> (default: newest upstream tag) only if it is newer than the pin
# scripts/openshell-next.sh sync [<ref>] # merge <ref> (default origin/main) into the current branch
# scripts/openshell-next.sh toolchain # print the Rust version the checkout needs (highest rust-version of
# # openshell-annotate and the locked ai-openshell/openshell crates)
#
# `bump` and `update` edit files only; they never commit. `sync` creates a signed-off merge commit. When main and the
# branch both changed the pin, `sync` keeps the newer of the two tags and re-resolves Cargo.lock; any other conflict
# aborts the merge (exit 3) so a human can resolve it.
# aborts the merge (exit 3) so a human can resolve it. The pin conflict is resolved from main's Cargo.toml, but a higher
# `rust-version` on the branch is kept (the branch may need a newer toolchain than main).
# `update` prints `previous=`, `tag=`, `changed=` and `stable=` lines (also appended to $GITHUB_OUTPUT when set).
# Env: OPENSHELL_ANNOTATE_ROOT, the checkout to work on (default: the one this script lives in). The workflow runs
# main's copy of these scripts from a temp dir against the openshell-next checkout, so the branch needs no copy.
Expand Down Expand Up @@ -51,9 +54,30 @@ update() {
if "$TAGS" is-stable "$want"; then out "stable=true"; else out "stable=false"; fi
}

# rust-version of the root package in Cargo.toml (empty when unset).
own_rust_version() { sed -nE 's/^rust-version[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/p' Cargo.toml | head -n 1; }

# Highest of two dotted versions (either may be empty).
max_version() { printf '%s\n%s\n' "$1" "$2" | grep . | sort -V | tail -n 1; }

# The Rust toolchain this checkout needs: the highest `rust-version` declared by openshell-annotate itself or by any
# package Cargo.lock resolves from ai-openshell/openshell. A prerelease pin can need a newer Rust than the branch
# declares yet; the tests then run on what upstream needs. Falls back to Cargo.toml when `cargo metadata` fails.
toolchain() {
local own upstream
own=$(own_rust_version)
upstream=$(cargo metadata --locked --format-version 1 2>/dev/null |
jq -r '.packages[] | select((.source // "") | startswith("git+https://github.com/ai-openshell/openshell")) | .rust_version // empty' |
sort -V | tail -n 1) || upstream=""
own=$(max_version "$own" "$upstream")
[ -n "$own" ] || { echo "no rust-version in Cargo.toml or the OpenShell crates" >&2; exit 2; }
echo "$own"
}

sync() {
local ref="${1:-origin/main}" before after bad msg
local ref="${1:-origin/main}" before after bad msg rv tmp
before=$("$TAGS" pinned)
rv=$(own_rust_version)
msg="Merge $ref into $(git rev-parse --abbrev-ref HEAD)"
if git merge --no-ff --no-edit --signoff -m "$msg" "$ref"; then
echo "merged $ref cleanly"
Expand All @@ -66,6 +90,12 @@ sync() {
# Both sides moved the pin: start from main's files and re-apply the newer tag.
git checkout --theirs -- Cargo.toml Cargo.lock 2>/dev/null || git checkout "$ref" -- Cargo.toml Cargo.lock
after=$("$TAGS" pinned)
if [ -n "$rv" ] && [ "$rv" != "$(own_rust_version)" ] && [ "$(max_version "$rv" "$(own_rust_version)")" = "$rv" ]; then
tmp=$(mktemp)
sed -E "s/^rust-version[[:space:]]*=[[:space:]]*\"[^\"]+\"/rust-version = \"$rv\"/" Cargo.toml > "$tmp"
cat "$tmp" > Cargo.toml; rm -f "$tmp"
echo "kept the branch's rust-version $rv"
fi
if "$TAGS" newer "$before" "$after"; then bump "$before"; fi
git add Cargo.toml Cargo.lock
git commit --signoff -m "$msg" -m "Both sides changed the OpenShell pin; kept the newer tag."
Expand All @@ -84,5 +114,6 @@ case "$cmd" in
bump) [ $# -eq 1 ] || { echo "usage: $0 bump <tag>" >&2; exit 2; }; bump "$1" ;;
update) update "${1:-}" ;;
sync) sync "${1:-}" ;;
*) sed -n '2,13p' "$0" | sed 's/^# \{0,1\}//' >&2; exit 2 ;;
toolchain) toolchain ;;
*) sed -n '2,17p' "$0" | sed 's/^# \{0,1\}//' >&2; exit 2 ;;
esac
Loading