diff --git a/.github/workflows/sync_tpen_shared_openapi.yaml b/.github/workflows/sync_tpen_shared_openapi.yaml new file mode 100644 index 00000000..79d0e3b8 --- /dev/null +++ b/.github/workflows/sync_tpen_shared_openapi.yaml @@ -0,0 +1,54 @@ +name: Sync TPEN-services shared OpenAPI artifact + +on: + push: + branches: + - development + paths: + - openapi/components/tpen-services-shared-components.openapi.yaml + workflow_dispatch: + +permissions: + contents: read + +jobs: + sync: + name: Sync TPEN-services shared OpenAPI artifact + runs-on: ubuntu-latest + steps: + - name: Checkout TPEN-services + uses: actions/checkout@v4 + + - name: Checkout receiver repository + uses: actions/checkout@v4 + with: + repository: cubap/rerum_openapi + ref: main + token: ${{ secrets.OPENAPI }} + path: receiver + + # No `test -f` guard: the receiver target may not exist on the first + # sync; cp creates it. Once the receiver registry references this file, + # add `test -f receiver/schemas/openapi/tpen-services-shared-components.openapi.yaml` + # to catch retargeted copies. + + - name: Copy canonical shared artifact + run: cp openapi/components/tpen-services-shared-components.openapi.yaml receiver/schemas/openapi/tpen-services-shared-components.openapi.yaml + + - name: Create or update sync pull request + uses: peter-evans/create-pull-request@v8 + with: + token: ${{ secrets.OPENAPI }} + path: receiver + add-paths: schemas/openapi/tpen-services-shared-components.openapi.yaml + commit-message: "chore: sync TPEN-services shared OpenAPI artifact" + branch: sync/tpen-services-shared-openapi + base: main + delete-branch: true + title: "chore: sync TPEN-services shared OpenAPI artifact" + body: | + Syncs the canonical TPEN-services shared OpenAPI artifact from CenterForDigitalHumanities/TPEN-services. + + - Source commit: ${{ github.sha }} + - Source artifact: `openapi/components/tpen-services-shared-components.openapi.yaml` + - Target artifact: `schemas/openapi/tpen-services-shared-components.openapi.yaml` diff --git a/__tests__/mount.test.js b/__tests__/mount.test.js index 38dde54d..eb5b6051 100644 --- a/__tests__/mount.test.js +++ b/__tests__/mount.test.js @@ -343,4 +343,10 @@ describe('Check to see that critical repo files are present #exists_unit', () => expect(fs.existsSync(filePath+".gitignore")).toBeTruthy() expect(fs.existsSync(filePath+"package.json")).toBeTruthy() }) + + it('shared OpenAPI sync files', () => { + const filePath = './' + expect(fs.existsSync(filePath+"openapi/components/tpen-services-shared-components.openapi.yaml")).toBeTruthy() + expect(fs.existsSync(filePath+".github/workflows/sync_tpen_shared_openapi.yaml")).toBeTruthy() + }) }) diff --git a/__tests__/openapi_sync_artifacts.test.js b/__tests__/openapi_sync_artifacts.test.js new file mode 100644 index 00000000..777aaf94 --- /dev/null +++ b/__tests__/openapi_sync_artifacts.test.js @@ -0,0 +1,30 @@ +import fs from "fs" +import path from "path" +import { fileURLToPath } from "url" + +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) +const repoRoot = path.resolve(__dirname, "..") + +describe("Shared OpenAPI artifact sync scaffolding #exists_unit", () => { + it("verifies provider artifact has expected OpenAPI baseline fields", () => { + const providerArtifactPath = path.join(repoRoot, "openapi/components/tpen-services-shared-components.openapi.yaml") + const providerArtifact = fs.readFileSync(providerArtifactPath, "utf8") + + expect(providerArtifact).toContain("openapi: 3.0.3") + expect(providerArtifact).toContain("title: TPEN Services Shared OpenAPI Components") + expect(providerArtifact).toContain("version: 0.1.0") + expect(providerArtifact).toContain("components:") + expect(providerArtifact).toContain("schemas: {}") + }) + + it("verifies the shared artifact sync workflow configuration", () => { + const workflowPath = path.join(repoRoot, ".github/workflows/sync_tpen_shared_openapi.yaml") + const workflow = fs.readFileSync(workflowPath, "utf8") + + expect(workflow).toContain("openapi/components/tpen-services-shared-components.openapi.yaml") + expect(workflow).toContain("repository: cubap/rerum_openapi") + expect(workflow).toContain("schemas/openapi/tpen-services-shared-components.openapi.yaml") + expect(workflow).toContain("secrets.OPENAPI") + }) +}) diff --git a/classes/Tools/Tools.js b/classes/Tools/Tools.js index a1d935bc..199b583c 100644 --- a/classes/Tools/Tools.js +++ b/classes/Tools/Tools.js @@ -214,11 +214,11 @@ export default class Tools { { "label": "History Tool", "toolName": "history", - "custom": { - "enabled": true, + "custom": { + "enabled": true, "tagName": "tpen-line-history" }, - "url": "https://app.t-pen.org/components/line-history/index.js", + "url": "https://centerfordigitalhumanities.github.io/tpen-line-history/tpen-line-history.js", "location": "pane" }, { diff --git a/openapi/components/tpen-services-shared-components.openapi.yaml b/openapi/components/tpen-services-shared-components.openapi.yaml new file mode 100644 index 00000000..c11dea10 --- /dev/null +++ b/openapi/components/tpen-services-shared-components.openapi.yaml @@ -0,0 +1,13 @@ +openapi: 3.0.3 +info: + title: TPEN Services Shared OpenAPI Components + version: 0.1.0 + description: Shared reusable OpenAPI components for TPEN services contracts. +externalDocs: + description: TPEN-services API reference + url: https://api.t-pen.org/API.html +x-upstream-provider: + name: TPEN-services + baseUrl: https://api.t-pen.org +components: + schemas: {}