Skip to content
Merged
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
54 changes: 54 additions & 0 deletions .github/workflows/sync_tpen_shared_openapi.yaml
Original file line number Diff line number Diff line change
@@ -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`
6 changes: 6 additions & 0 deletions __tests__/mount.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})
30 changes: 30 additions & 0 deletions __tests__/openapi_sync_artifacts.test.js
Original file line number Diff line number Diff line change
@@ -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: {}")
})
Comment thread
cubap marked this conversation as resolved.

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")
})
})
6 changes: 3 additions & 3 deletions classes/Tools/Tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
{
Expand Down
13 changes: 13 additions & 0 deletions openapi/components/tpen-services-shared-components.openapi.yaml
Original file line number Diff line number Diff line change
@@ -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: {}
Loading