Skip to content

Commit 1269ebf

Browse files
Copilotcubap
andauthored
Add provider-driven sync for shared RERUM OpenAPI artifacts (#272)
* Initial plan * chore: add shared openapi sync scaffolding Agent-Logs-Url: https://github.com/CenterForDigitalHumanities/rerum_server_nodejs/sessions/b8591b1e-5ffa-4f96-bdba-fc2d6341533a Co-authored-by: cubap <1119165+cubap@users.noreply.github.com> * test: tighten openapi sync scaffolding coverage Agent-Logs-Url: https://github.com/CenterForDigitalHumanities/rerum_server_nodejs/sessions/b8591b1e-5ffa-4f96-bdba-fc2d6341533a Co-authored-by: cubap <1119165+cubap@users.noreply.github.com> * test: simplify openapi artifact assertions Agent-Logs-Url: https://github.com/CenterForDigitalHumanities/rerum_server_nodejs/sessions/b8591b1e-5ffa-4f96-bdba-fc2d6341533a Co-authored-by: cubap <1119165+cubap@users.noreply.github.com> * docs: clarify synced openapi target artifact Agent-Logs-Url: https://github.com/CenterForDigitalHumanities/rerum_server_nodejs/sessions/b8591b1e-5ffa-4f96-bdba-fc2d6341533a Co-authored-by: cubap <1119165+cubap@users.noreply.github.com> * test: rename openapi sync checks for clarity Agent-Logs-Url: https://github.com/CenterForDigitalHumanities/rerum_server_nodejs/sessions/b8591b1e-5ffa-4f96-bdba-fc2d6341533a Co-authored-by: cubap <1119165+cubap@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
1 parent 777bff3 commit 1269ebf

4 files changed

Lines changed: 95 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Sync shared RERUM OpenAPI artifact
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- openapi/components/rerum-shared-components.openapi.yaml
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
dispatch-sync:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Dispatch sync-provider-artifact workflow
19+
uses: actions/github-script@v7
20+
with:
21+
github-token: ${{ secrets.BRY_PAT }}
22+
script: |
23+
await github.request('POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches', {
24+
owner: 'cubap',
25+
repo: 'rerum_openapi',
26+
workflow_id: 'sync-provider-artifact.yml',
27+
ref: 'main',
28+
inputs: {
29+
provider_repository: '${{ github.repository }}',
30+
provider_ref: '${{ github.sha }}',
31+
provider_artifact_path: 'openapi/components/rerum-shared-components.openapi.yaml',
32+
target_artifact_path: 'schemas/openapi/rerum-shared-components.openapi.yaml'
33+
}
34+
})
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import fs from "fs"
2+
import path from "path"
3+
import { fileURLToPath } from "url"
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = path.dirname(__filename)
7+
const repoRoot = path.resolve(__dirname, "..")
8+
9+
describe("Shared OpenAPI artifact sync scaffolding", () => {
10+
it("verifies provider and target artifact files contain valid OpenAPI structure", () => {
11+
const providerArtifactPath = path.join(repoRoot, "openapi/components/rerum-shared-components.openapi.yaml")
12+
const targetArtifactPath = path.join(repoRoot, "schemas/openapi/rerum-shared-components.openapi.yaml")
13+
const providerArtifact = fs.readFileSync(providerArtifactPath, "utf8")
14+
const targetArtifact = fs.readFileSync(targetArtifactPath, "utf8")
15+
16+
for (const artifact of [providerArtifact, targetArtifact]) {
17+
expect(artifact).toContain("openapi: 3.0.3")
18+
expect(artifact).toContain("title: RERUM Shared Components")
19+
expect(artifact).toContain("version: 0.1.0")
20+
expect(artifact).toContain("components:")
21+
expect(artifact).toContain("schemas: {}")
22+
}
23+
})
24+
25+
it("verifies the shared artifact sync workflow configuration", () => {
26+
const workflowPath = path.join(repoRoot, ".github/workflows/sync-rerum-shared-openapi.yml")
27+
const workflow = fs.readFileSync(workflowPath, "utf8")
28+
29+
expect(workflow).toContain("openapi/components/rerum-shared-components.openapi.yaml")
30+
expect(workflow).toContain("sync-provider-artifact.yml")
31+
expect(workflow).toContain("repo: 'rerum_openapi'")
32+
expect(workflow).toContain("target_artifact_path: 'schemas/openapi/rerum-shared-components.openapi.yaml'")
33+
})
34+
})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
openapi: 3.0.3
2+
info:
3+
title: RERUM Shared Components
4+
version: 0.1.0
5+
description: Shared reusable OpenAPI components for RERUM v1 contracts.
6+
externalDocs:
7+
description: RERUM API reference
8+
url: https://store.rerum.io/v1/API.html
9+
x-upstream-provider:
10+
name: rerum_server_nodejs
11+
baseUrl: https://store.rerum.io/v1
12+
components:
13+
schemas: {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file is automatically synced from openapi/components/rerum-shared-components.openapi.yaml. Do not edit manually.
2+
openapi: 3.0.3
3+
info:
4+
title: RERUM Shared Components
5+
version: 0.1.0
6+
description: Shared reusable OpenAPI components for RERUM v1 contracts.
7+
externalDocs:
8+
description: RERUM API reference
9+
url: https://store.rerum.io/v1/API.html
10+
x-upstream-provider:
11+
name: rerum_server_nodejs
12+
baseUrl: https://store.rerum.io/v1
13+
components:
14+
schemas: {}

0 commit comments

Comments
 (0)