Skip to content
Open
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
49 changes: 49 additions & 0 deletions .github/workflows/sync_tpen_shared_openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Sync shared TPEN OpenAPI artifact

on:
push:
branches:
- development
paths:
- openapi/components/tpen-services-shared-components.openapi.yaml
workflow_dispatch:

permissions:
contents: read

jobs:
sync-shared-openapi-artifact:
runs-on: ubuntu-latest
steps:
- name: Checkout TPEN-services
uses: actions/checkout@v4

- name: Checkout cubap/rerum_openapi
uses: actions/checkout@v4
with:
repository: cubap/rerum_openapi
token: ${{ secrets.OPENAPI }}
path: rerum_openapi

- name: Copy shared OpenAPI artifact into receiver repository
run: |
cp openapi/components/tpen-services-shared-components.openapi.yaml \
rerum_openapi/schemas/openapi/tpen-services-shared-components.openapi.yaml

- name: Create or update sync pull request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.OPENAPI }}
path: rerum_openapi
branch: automation/sync-tpen-shared-openapi-artifact
delete-branch: true
commit-message: Sync shared TPEN OpenAPI artifact from TPEN-services
title: Sync shared TPEN OpenAPI artifact from TPEN-services
body: |
Automated sync from `${{ github.repository }}` at `${{ github.sha }}`.

Source:
- `openapi/components/tpen-services-shared-components.openapi.yaml`

Target:
- `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")
})
})
10 changes: 10 additions & 0 deletions openapi/components/tpen-services-shared-components.openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
openapi: 3.0.3
info:
title: TPEN Services Shared OpenAPI Components
version: 0.1.0
description: Shared reusable OpenAPI components for TPEN services contracts.
x-upstream-provider:
name: TPEN-services
baseUrl: https://api.t-pen.org
components:
schemas: {}
Loading