Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5284815
ci: Lint workflows with actionlint
nderjung Nov 3, 2026
d8e3056
ci: Check pull requests
nderjung Nov 3, 2026
752271f
ci: Publish the gem to RubyGems from the channel branches
nderjung Nov 3, 2026
633623d
ci: Promote prod-staging with the shared workflow
nderjung Nov 3, 2026
1750b92
ci: Regenerate the plumbing client from the OpenAPI spec
nderjung Nov 3, 2026
654235d
docs: Add contributing guide
nderjung Nov 3, 2026
1b23a81
chore: Scaffold the unikraft-cloud gem
nderjung Nov 3, 2026
cfc2456
feat(core): Add the error hierarchy
nderjung Nov 3, 2026
5fdba4d
feat(core): Add the HTTP transport
nderjung Nov 3, 2026
816fc9e
feat(core): Add the Model base class
nderjung Nov 3, 2026
1e809f5
feat(core): Add wait_until_ready polling
nderjung Nov 3, 2026
4b80d93
feat(api): Add the openapi-gen templates for Ruby
nderjung Nov 3, 2026
337ff78
feat(api): Generate the platform and control-plane plumbing
nderjung Nov 3, 2026
382a8db
docs: Name the core files and the stream contract
nderjung Nov 3, 2026
a40f6d2
test: Keep the fake server's connections alive
nderjung Nov 4, 2026
f95988f
feat(core): Reuse connections across requests
nderjung Nov 4, 2026
789919b
feat(core): Add metros, refs and envelope unwrapping
nderjung Nov 4, 2026
d46a31a
feat(core): Add metro fan-out and pagination
nderjung Nov 4, 2026
b92f654
feat(core): Add the session and metro discovery
nderjung Nov 4, 2026
ab431eb
feat(core): Add patch triples and the staged editor
nderjung Nov 4, 2026
48595d6
feat(core): Add handles, handle sets and the resource base
nderjung Nov 4, 2026
7218024
feat(core): Add the client and its metro scopes
nderjung Nov 4, 2026
8ef9ab7
feat(instances): Add the idiomatic instances client
nderjung Nov 4, 2026
59793e9
feat(volumes): Add the idiomatic volumes client
nderjung Nov 4, 2026
b3f794b
feat(services): Add the idiomatic service groups client
nderjung Nov 4, 2026
8e63083
feat(certificates): Add the idiomatic certificates client
nderjung Nov 4, 2026
4bfafbc
feat(users): Add quotas to the idiomatic client
nderjung Nov 4, 2026
fd0b994
test: Add live end-to-end tests for the porcelain
nderjung Nov 4, 2026
5f11953
docs: Add the quickstart, update and plumbing examples
nderjung Nov 4, 2026
7c9f496
docs: Add the README
nderjung Nov 4, 2026
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
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[Makefile]
indent_style = tab

[*.md]
trim_trailing_whitespace = false
24 changes: 24 additions & 0 deletions .github/workflows/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: actionlint

on:
pull_request:
branches:
- prod-staging
paths:
- '.github/workflows/**'

workflow_call:

# Automatically cancel in-progress actions on the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Run actionlint
uses: unikraft-cloud/x/.github/actions/actionlint@prod-staging
92 changes: 92 additions & 0 deletions .github/workflows/check-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: check/pr

on:
pull_request:
types:
- opened
- synchronize
- reopened
- edited
branches:
- prod-staging
- prod-stable

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Run check-pr
uses: unikraft-cloud/x/.github/actions/check-pr@prod-staging

# RuboCop's verdict does not depend on the interpreter running it, so lint
# runs on one Ruby only.
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: true

- name: Lint
run: bundle exec rake lint

# The test suite covers every supported Ruby.
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version:
- '3.3'
- '3.4'
- '4.0'
steps:
- uses: actions/checkout@v7

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- name: Test
run: bundle exec rake test

# The packaged gem is checked on the oldest and the newest supported Ruby.
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version:
- '3.3'
- '4.0'
steps:
- uses: actions/checkout@v7

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- name: Build
run: bundle exec rake build

- name: Check the packaged gem
run: bundle exec rake check_package
15 changes: 15 additions & 0 deletions .github/workflows/promote.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: promote

on:
push:
branches: [prod-staging]
workflow_dispatch:

permissions:
contents: read

jobs:
promote:
uses: unikraft-cloud/x/.github/workflows/promote.yaml@prod-staging
secrets:
gh_pat: ${{ secrets.GH_PAT }}
249 changes: 249 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
name: release

# Publishes the gem to RubyGems. The branch selects the channel:
# prod-stable -> stable versions (0.2.0)
# prod-staging -> prerelease versions (0.2.1.pre.next.3)
#
# The version is never committed. lib/unikraft/cloud/version.rb carries a 0.0.0
# placeholder, and svu derives the real version from the conventional-commit
# messages since the last release tag. The run stamps it into version.rb
# seconds before building the gem.
#
# svu speaks semver and prints 0.2.1-next.3. RubyGems has no dist-tags, so the
# version alone tells the channels apart: the run rewrites that to
# 0.2.1.pre.next.3, the canonical form Gem::Version itself gives the semver
# string. Any letter makes a RubyGems version a prerelease, which sorts below
# 0.2.1 and above 0.2.0, and the numeric counter segment sorts next.10 above
# next.9. `gem install unikraft-cloud` therefore never picks it up, and
# `gem install unikraft-cloud --pre` does.
#
# Only prod-stable pushes a tag, and both channels measure from that same tag,
# so a prerelease always sorts above the newest stable release. It needs no
# cross-branch coordination, because there is no committed version for the
# two branches to disagree about.
#
# Authentication uses RubyGems trusted publishing (OIDC): RubyGems exchanges
# the GitHub Actions ID token for a short-lived API key, so no long-lived
# RubyGems secret is involved. The trusted publisher registered on
# rubygems.org must name this repository and this workflow file
# (.github/workflows/release.yaml); renaming or moving this file breaks
# publishing until the RubyGems side is updated to match. Unlike npm,
# RubyGems accepts a *pending* trusted publisher for a gem that does not exist
# yet, so the first release needs no manual push: register this repository
# and this workflow file as a pending publisher of unikraft-cloud, then push.
on:
push:
branches:
- prod-stable
- prod-staging

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: write # required to push the release tag
id-token: write # required for trusted publishing

env:
GEM_NAME: unikraft-cloud
SVU_VERSION: '3.2.3'
# sha256 of svu_${SVU_VERSION}_linux_amd64.tar.gz, from the release's checksums.txt.
SVU_SHA256: '2509db2b9a5d97a212efb8e242e5782a1a62459ac516b3663c525db6b8474c02'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Fetch all tags
run: git fetch --force --tags

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: true

- name: Install svu
run: |
curl -fsSL -o svu.tar.gz \
"https://github.com/caarlos0/svu/releases/download/v${SVU_VERSION}/svu_${SVU_VERSION}_linux_amd64.tar.gz"
echo "${SVU_SHA256} svu.tar.gz" | sha256sum -c -
tar -xzf svu.tar.gz -C /usr/local/bin svu
rm svu.tar.gz

- name: Resolve the version
id: version
env:
CHANNEL: ${{ github.ref_name }}
run: |
api=https://rubygems.org/api
base=$(svu current)

# Tags are the only record of what has been released. If RubyGems
# holds a stable release that this repository has no tag for, svu
# starts again from zero and publishes below what is already out
# there, so stop instead. Prereleases alone carry no tag by design.
if ! git rev-parse -q --verify "refs/tags/$base" >/dev/null; then
status=$(curl -sSL -o "$RUNNER_TEMP/versions.json" -w '%{http_code}' \
"$api/v1/versions/$GEM_NAME.json") || status=000
case "$status" in
404) ;;
200)
if jq -e 'any(.[]; .prerelease | not)' "$RUNNER_TEMP/versions.json" >/dev/null; then
echo "::error::$GEM_NAME is published on RubyGems but this \
repository has no release tag. Tag the commit behind the current \
release, for example git tag v1.2.3 <sha> && git push origin v1.2.3, \
then re-run."
exit 1
fi
;;
*)
echo "::error::Could not list $GEM_NAME versions on RubyGems (HTTP $status)."
exit 1
;;
esac
fi

if [ "$CHANNEL" = prod-stable ]; then
channel=stable
# No --always here: a push carrying nothing bumpable (docs, CI, a
# refactor) must not burn a version number. svu then returns the
# current tag, the version is already on RubyGems, and the run
# skips.
tag=$(svu next --v0)
# An untagged repository with nothing bumpable resolves to the
# placeholder, which is no first version to release.
if [ "$tag" = v0.0.0 ]; then
echo "::error::No release tag and no feat or fix commit, so there \
is no first version to release. Land one, or tag it by hand."
exit 1
fi
else
channel=prerelease
# The prerelease counter is the commit distance from the last release
# tag. It rises on every staging push, and resets when a stable
# release moves the tag forward. An untagged repository has nothing
# to measure from, and the guard above has already proved it has
# published no stable release either.
if git rev-parse -q --verify "refs/tags/$base" >/dev/null; then
count=$(git rev-list --count "$base..HEAD")
else
count=$(git rev-list --count HEAD)
fi
# --always, unlike the stable path: staging must sit above the newest
# stable release even when only chores landed, or `--pre` would
# resolve below the stable release.
tag=$(svu next --always --v0 --prerelease "next.$count")
fi

# v0.2.1-next.3 -> 0.2.1.pre.next.3, see the header.
version=${tag#v}
version=${version/-/.pre.}
{
echo "tag=$tag"
echo "version=$version"
echo "channel=$channel"
} >> "$GITHUB_OUTPUT"
echo "Resolved $GEM_NAME $version ($channel)"

# Re-running a finished release, or a run whose tag push succeeded but
# whose publish did not, must not fail. Only a confirmed 404 means the
# version is absent; any other lookup failure stops the release rather
# than being read as "not published".
status=$(curl -sSL -o /dev/null -w '%{http_code}' \
"$api/v2/rubygems/$GEM_NAME/versions/$version.json") || status=000
case "$status" in
200)
echo "publish=false" >> "$GITHUB_OUTPUT"
echo "::notice::$GEM_NAME $version is already published; skipping release."
;;
404)
echo "publish=true" >> "$GITHUB_OUTPUT"
;;
*)
echo "::error::Could not look up $GEM_NAME $version on RubyGems (HTTP $status)."
exit 1
;;
esac

- name: Test
if: steps.version.outputs.publish == 'true'
run: bundle exec rake test

- name: Check the packaged gem
if: steps.version.outputs.publish == 'true'
run: bundle exec rake build check_package

# Tagged before the publish, and only after the build and the tests pass, so
# that a failed publish can be retried by re-running the job: the tag step
# below is a no-op once the tag exists, and the lookup above proves the
# version is still absent from RubyGems.
- name: Tag the release
if: steps.version.outputs.publish == 'true' && github.ref_name == 'prod-stable'
env:
TAG: ${{ steps.version.outputs.tag }}
run: |
if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
# Publishing HEAD under a tag on another commit would ship code the
# tag does not hold: re-run the original tagged run instead.
if [ "$(git rev-list -n 1 "$TAG")" != "$(git rev-parse HEAD)" ]; then
echo "::error::tag $TAG exists on another commit; re-run its release instead."
exit 1
fi
echo "::notice::tag $TAG already exists; not re-tagging."
exit 0
fi
git config user.name "Unikraft Bot"
git config user.email "monkey@unikraft.io"
git tag -a "$TAG" -m "$TAG"
git push origin "$TAG"

# Writes the resolved version into version.rb for the publish only. The
# commit keeps the 0.0.0 placeholder. The gem is built with plain
# `gem build` rather than through Bundler: the lockfile records the
# placeholder, and a frozen bundle refuses a path gem whose version moved.
- name: Build the release gem
if: steps.version.outputs.publish == 'true'
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
file=lib/unikraft/cloud/version.rb
sed -i "s/VERSION = \"0\.0\.0\"/VERSION = \"$VERSION\"/" "$file"
grep -q "VERSION = \"$VERSION\"" "$file" || {
echo "::error::Could not stamp $VERSION into $file."
exit 1
}
rm -rf pkg
mkdir pkg
gem build "$GEM_NAME.gemspec" --output "pkg/$GEM_NAME-$VERSION.gem"

# Exchanges the OIDC token for a short-lived API key in GEM_HOST_API_KEY.
# The action has no moving major tag, so the version is exact.
- name: Configure RubyGems credentials
if: steps.version.outputs.publish == 'true'
uses: rubygems/configure-rubygems-credentials@v2.1.0

- name: Publish to RubyGems
if: steps.version.outputs.publish == 'true'
run: gem push pkg/*.gem

# The version is no longer readable from the repository, so the run has to
# report what it shipped.
- name: Summary
env:
VERSION: ${{ steps.version.outputs.version }}
CHANNEL: ${{ steps.version.outputs.channel }}
PUBLISHED: ${{ steps.version.outputs.publish }}
run: |
{
if [ "$PUBLISHED" = true ]; then
echo "Published \`$GEM_NAME $VERSION\` ($CHANNEL) to RubyGems."
else
echo "\`$GEM_NAME $VERSION\` was already published; nothing to do."
fi
} >> "$GITHUB_STEP_SUMMARY"
Loading