Skip to content

Commit 8432ce6

Browse files
jonkoopsdavidfestal
authored andcommitted
feat: add validate-metadata action for catalog metadata validation
Add new GitHub Action to validate catalog metadata files against plugin package.json files to ensure consistency during the dynamic plugin export workflow. Features: - Validates `packageName` corresponds to a plugin in `plugins-list.yaml` - Validates `version` matches the plugin's `package.json` version - Validates OCI reference format in `dynamicArtifact` (tag and repository) - Validates `backstage.supportedVersions` matches `dist-dynamic/package.json` - Reports detailed errors to GitHub workflow summary - Provides JSON output for downstream workflow consumption Also updates: - Integrate `validate-metadata` into `export-dynamic` workflow - Add metadata validation outputs to `export-dynamic` and `export-workspaces` - Update `actions/checkout` and `actions/setup-node` to latest versions - Add comprehensive test suite with 8 test scenarios Signed-off-by: Jon Koops <jonkoops@gmail.com>
1 parent 2c8e068 commit 8432ce6

32 files changed

Lines changed: 1347 additions & 13 deletions

.github/workflows/check-backstage-compatibility.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ jobs:
8181
echo "OVERLAY_REPO=${{ github.repository }}" >> $GITHUB_OUTPUT
8282
fi
8383
84-
- uses: actions/checkout@v4.2.2
84+
name: Checkout overlay repository
85+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
8586
with:
8687
ref: ${{ steps.set-overlay-repo-ref.outputs.OVERLAY_REPO_REF }}
8788
repository: ${{ steps.set-overlay-repo.outputs.OVERLAY_REPO }}

.github/workflows/export-dynamic.yaml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ on:
7777
default: false
7878
required: false
7979

80+
target-backstage-version:
81+
description: Target Backstage version for validating OCI tag format in metadata (e.g., "1.42.5")
82+
type: string
83+
required: true
84+
8085
image-repository-prefix:
8186
description: Repository prefix of the dynamic plugin container images
8287
type: string
@@ -119,6 +124,15 @@ on:
119124
value: '${{ jobs.export.outputs.published-exports }}'
120125
failed-exports:
121126
value: '${{ jobs.export.outputs.failed-exports }}'
127+
metadata-validation-passed:
128+
description: Whether the metadata validation passed (true/false)
129+
value: '${{ jobs.export.outputs.metadata-validation-passed }}'
130+
metadata-validation-errors:
131+
description: JSON array of metadata validation errors, empty array if validation passed
132+
value: '${{ jobs.export.outputs.metadata-validation-errors }}'
133+
metadata-validation-error-count:
134+
description: Number of metadata validation errors found
135+
value: '${{ jobs.export.outputs.metadata-validation-error-count }}'
122136

123137
jobs:
124138
export:
@@ -136,6 +150,9 @@ jobs:
136150
outputs:
137151
published-exports: '${{ steps.export-dynamic.outputs.published-exports }}'
138152
failed-exports: '${{ steps.export-dynamic.outputs.failed-exports }}'
153+
metadata-validation-passed: '${{ steps.validate-metadata.outputs.validation-passed }}'
154+
metadata-validation-errors: '${{ steps.validate-metadata.outputs.validation-errors }}'
155+
metadata-validation-error-count: '${{ steps.validate-metadata.outputs.validation-error-count }}'
139156

140157
steps:
141158
- name: Validate Inputs
@@ -155,15 +172,15 @@ jobs:
155172
}
156173
157174
- name: Checkout plugins repository ${{ inputs.plugins-repo }}
158-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
175+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
159176
if: ${{ inputs.plugins-root == '.' }}
160177
with:
161178
repository: ${{ inputs.plugins-repo }}
162179
ref: ${{ inputs.plugins-repo-ref }}
163180
path: source-repo
164181

165182
- name: Checkout plugins repository ${{ inputs.plugins-repo }} at ${{ inputs.plugins-root }}
166-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
183+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
167184
if: ${{ inputs.plugins-root != '.' }}
168185
with:
169186
repository: ${{ inputs.plugins-repo }}
@@ -177,7 +194,7 @@ jobs:
177194
path: source-repo
178195

179196
- name: Checkout overlay repository ${{ inputs.overlay-repo }} in the 'overlay-repo' sub-folder
180-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
197+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
181198
with:
182199
repository: ${{ inputs.overlay-repo }}
183200
ref: ${{ inputs.overlay-repo-ref }}
@@ -220,8 +237,8 @@ jobs:
220237
sudo apt-get update
221238
sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
222239
223-
- name: Use node.js ${{ inputs.node-version }}
224-
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
240+
- name: Setup Node.js ${{ inputs.node-version }}
241+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
225242
with:
226243
node-version: ${{ inputs.node-version }}
227244
registry-url: https://registry.npmjs.org/ # Needed for auth
@@ -287,6 +304,16 @@ jobs:
287304
image-tag-prefix: ${{ inputs.image-tag-prefix }}
288305
last-publish-commit: ${{ inputs.last-publish-commit }}
289306

307+
- name: Validate Catalog Metadata
308+
if: ${{ success() && steps.export-dynamic.outputs.workspace-skipped-unchanged-since == 'false' }}
309+
id: validate-metadata
310+
uses: redhat-developer/rhdh-plugin-export-utils/validate-metadata@main
311+
with:
312+
overlay-root: ${{ github.workspace }}/overlay-repo/${{inputs.overlay-root}}
313+
plugins-root: ${{ github.workspace }}/source-repo/${{inputs.plugins-root}}
314+
target-backstage-version: ${{ inputs.target-backstage-version }}
315+
image-repository-prefix: ${{ steps.set-image-tag-name.outputs.IMAGE_REPOSITORY_PREFIX }}
316+
290317
- name: Set artifacts name suffix
291318
id: set-artifacts-name-suffix
292319
shell: bash

.github/workflows/export-workspaces-as-dynamic.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ on:
8080

8181
failed-exports:
8282
value: '${{ jobs.export.outputs.failed-exports }}'
83+
84+
metadata-validation-passed:
85+
description: Whether the metadata validation passed (true/false)
86+
value: '${{ jobs.export.outputs.metadata-validation-passed }}'
87+
88+
metadata-validation-errors:
89+
description: JSON array of metadata validation errors
90+
value: '${{ jobs.export.outputs.metadata-validation-errors }}'
91+
92+
metadata-validation-error-count:
93+
description: Number of metadata validation errors found
94+
value: '${{ jobs.export.outputs.metadata-validation-error-count }}'
8395

8496
jobs:
8597
prepare:
@@ -131,7 +143,8 @@ jobs:
131143
echo "OVERLAY_REPO=${{ github.repository }}" >> $GITHUB_OUTPUT
132144
fi
133145
134-
- uses: actions/checkout@v4.2.2
146+
- name: Checkout overlay repository
147+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
135148
with:
136149
ref: ${{ steps.set-overlay-repo-ref.outputs.OVERLAY_REPO_REF }}
137150
repository: ${{ steps.set-overlay-repo.outputs.OVERLAY_REPO }}
@@ -226,6 +239,7 @@ jobs:
226239
publish-container: ${{ inputs.publish-container }}
227240
image-repository-prefix: ${{ inputs.image-repository-prefix }}
228241
image-tag-prefix: ${{ inputs.image-tag-prefix != '' && inputs.image-tag-prefix || format('bs_{0}__', needs.prepare.outputs.backstage-version) }}
242+
target-backstage-version: ${{ needs.prepare.outputs.backstage-version }}
229243
last-publish-commit: ${{ inputs.last-publish-commit }}
230244
image-registry-user: ${{ inputs.image-registry-user }}
231245

0 commit comments

Comments
 (0)