WarpEngine 0.7.0: a képtár és a CI is a hoszté, adapteren keresztül
Két dolog volt beépítve az engine-be, ami nem az övé. A **képtár** eddig `WarpEngine::Image` volt, pedig a modell teljesen általános: a teletypegames-ben a tagok arcképét is ez hordozza, nem csak a katalógus borítóit. Az `Image` modell, a feltöltött fájlok, az `/api/image/:id` végpont és az admin oldal ezért átkerült a hosztba, az engine pedig adapteren szól hozzá (`WarpEngine::Images`): `url_for` adja a katalógus JSON `imageUrl`-jét, `select_options` a software-form képválasztóját, `build_from_upload` a "tölts fel új képet" ágat. Az alapértelmezés az `Image` osztály, tehát a default útvonal bitre a régi. A `SoftwareImage` (a katalógus-kapcsolat) maradt az engine-ben, és **az `images` tábla nem mozdult**: az engine csak abbahagyta a létrehozását, a generátor írja meg hoszt-kódként. A **CI** eddig végig Woodpecker volt: kliens, aláírás-ellenőrzés, pipeline-receptek, repo-szinkron, secret-kiosztás. Mindez egy adapter mögé került (`WarpEngine.ci`), a Woodpecker-implementáció pedig az engine-ben maradt `WarpEngine::CI::Woodpecker` néven — kliens, adapter, httpsig-ellenőrző és a platformonkénti pipeline-receptek, mert a YAML-dialektus a szolgáltatóé. Az engine saját kódja már nem nevez szolgáltatót: `CI::Repo` és `CI::Run` értékeket kap, `CI::ConnectionError`/`ApiError`/`NotConfigured` hibákat dob, a `Pipeline` pedig `remote_repo_id`-t ad a történelmi `woodpecker_repo_id` kolumna fölött (a tábla itt sem mozdult). `c.ci_adapter = :none` azt jelenti, hogy ez a hoszt nem buildel: az `/api/ci/*` 503, a `/build/config` elutasít, az admin akciók elbújnak. Mindkét seam a hoszt initializerében van kimondva, nem alapértelmezésre hagyva — a hoszt megnevezi, mi a képtára és mi a CI-ja. Törés a 0.6-hoz képest: `image_container_path`, `image_owners`, `ci_platforms`, `ci_update_server`, `ci_extension_public_key(_url)`, `woodpecker_url`, `woodpecker_api_token`, `woodpecker_repo_owner` és a `WarpEngine.woodpecker_configured?` megszűnt; a helyük `c.image_class_name` / `c.image_adapter` és `c.ci_adapter`. Az `/api/ci/*` `latest_run`/`trigger` válasza a normalizált `CI::Run` alakot adja (number, status, branch, message, createdAt, url), a `pipelines` lista pedig `repo_id`-t is közöl a megtartott `woodpecker_repo_id` mellett. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe WarpEngine::PipelineSyncService do
|
||||
let(:client) { instance_double(WarpEngine::WoodpeckerClient) }
|
||||
let(:service) { described_class.new(client: client) }
|
||||
let(:ci) { instance_double(WarpEngine::CI::Woodpecker::Adapter) }
|
||||
let(:service) { described_class.new(ci: ci) }
|
||||
|
||||
def ci_repo(id:, name: "mygame", owner: "org", active: true)
|
||||
WarpEngine::CI::Repo.new(id: id, name: name, owner: owner, active: active)
|
||||
end
|
||||
|
||||
describe "#sync_all" do
|
||||
it "creates new Pipeline records from Woodpecker" do
|
||||
allow(client).to receive(:list_repos).and_return([
|
||||
{ "id" => 1, "name" => "mygame", "owner" => "org", "active" => true }
|
||||
])
|
||||
it "creates new Pipeline records from the CI provider" do
|
||||
allow(ci).to receive(:repos).and_return([ ci_repo(id: 1) ])
|
||||
|
||||
result = service.sync_all
|
||||
|
||||
@@ -21,9 +23,7 @@ RSpec.describe WarpEngine::PipelineSyncService do
|
||||
|
||||
it "updates existing records" do
|
||||
existing = create(:pipeline, woodpecker_repo_id: 1, repo_name: "old", platform: "tic80")
|
||||
allow(client).to receive(:list_repos).and_return([
|
||||
{ "id" => 1, "name" => "newname", "owner" => "org", "active" => true }
|
||||
])
|
||||
allow(ci).to receive(:repos).and_return([ ci_repo(id: 1, name: "newname") ])
|
||||
|
||||
result = service.sync_all
|
||||
|
||||
@@ -31,9 +31,9 @@ RSpec.describe WarpEngine::PipelineSyncService do
|
||||
expect(existing.reload.repo_name).to eq("newname")
|
||||
end
|
||||
|
||||
it "deactivates repos missing from Woodpecker" do
|
||||
it "deactivates repos the provider no longer has" do
|
||||
orphan = create(:pipeline, woodpecker_repo_id: 99, active: true)
|
||||
allow(client).to receive(:list_repos).and_return([])
|
||||
allow(ci).to receive(:repos).and_return([])
|
||||
|
||||
result = service.sync_all
|
||||
|
||||
@@ -43,9 +43,7 @@ RSpec.describe WarpEngine::PipelineSyncService do
|
||||
|
||||
it "auto-detects platform from matching Software" do
|
||||
create(:software, name: "mygame", platform: "godot")
|
||||
allow(client).to receive(:list_repos).and_return([
|
||||
{ "id" => 1, "name" => "mygame", "owner" => "org", "active" => true }
|
||||
])
|
||||
allow(ci).to receive(:repos).and_return([ ci_repo(id: 1) ])
|
||||
|
||||
result = service.sync_all
|
||||
|
||||
@@ -55,11 +53,9 @@ RSpec.describe WarpEngine::PipelineSyncService do
|
||||
end
|
||||
|
||||
describe "#activate" do
|
||||
it "calls client and syncs the repo" do
|
||||
allow(client).to receive(:activate_repo).with(42)
|
||||
allow(client).to receive(:get_repo).with(42).and_return(
|
||||
{ "id" => 42, "name" => "game", "owner" => "org", "active" => true }
|
||||
)
|
||||
it "calls the provider and syncs the repo" do
|
||||
allow(ci).to receive(:activate_repo).with(42)
|
||||
allow(ci).to receive(:repo).with(42).and_return(ci_repo(id: 42, name: "game"))
|
||||
|
||||
repo = service.activate(42)
|
||||
|
||||
@@ -69,9 +65,9 @@ RSpec.describe WarpEngine::PipelineSyncService do
|
||||
end
|
||||
|
||||
describe "#deactivate" do
|
||||
it "calls client and marks repo inactive" do
|
||||
it "calls the provider and marks the repo inactive" do
|
||||
repo = create(:pipeline, woodpecker_repo_id: 42, active: true)
|
||||
allow(client).to receive(:deactivate_repo).with(42)
|
||||
allow(ci).to receive(:deactivate_repo).with(42)
|
||||
|
||||
service.deactivate(42)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user