Skip to content

Commit e696068

Browse files
authored
Add lint, type-check, and CI workflows for model-registry frontend and BFF (#7122)
Signed-off-by: ppadti <ppadti@redhat.com>
1 parent 58c5f8e commit e696068

91 files changed

Lines changed: 943 additions & 733 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Test / Model Registry BFF Tests
2+
on:
3+
push:
4+
paths:
5+
- 'packages/model-registry/**'
6+
- '!LICENSE*'
7+
- '!DOCKERFILE*'
8+
- '!**.gitignore'
9+
- '!**.md'
10+
11+
pull_request:
12+
paths:
13+
- 'packages/model-registry/**'
14+
- '.github/workflows/**'
15+
- '!LICENSE*'
16+
- '!DOCKERFILE*'
17+
- '!**.gitignore'
18+
- '!**.md'
19+
20+
jobs:
21+
test:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v6.0.1
25+
26+
- name: Setup Go
27+
uses: actions/setup-go@v6
28+
with:
29+
go-version: '1.25.0'
30+
31+
- name: Lint
32+
working-directory: packages/model-registry/upstream/bff
33+
run: make lint
34+
35+
- name: Build (BFF)
36+
working-directory: packages/model-registry/upstream/bff
37+
run: make build
38+
39+
- name: Check if there are uncommitted file changes
40+
working-directory: packages/model-registry
41+
run: |
42+
clean=$(git status --porcelain)
43+
if [[ -z "$clean" ]]; then
44+
echo "Empty git status --porcelain: $clean"
45+
else
46+
echo "Uncommitted file changes detected: $clean"
47+
git diff
48+
exit 1
49+
fi
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Test / Model Registry Frontend Tests
2+
on:
3+
push:
4+
paths:
5+
- 'packages/model-registry/**'
6+
- '!LICENSE*'
7+
- '!DOCKERFILE*'
8+
- '!**.gitignore'
9+
- '!**.md'
10+
11+
pull_request:
12+
paths:
13+
- 'packages/model-registry/**'
14+
- '!LICENSE*'
15+
- '!DOCKERFILE*'
16+
- '!**.gitignore'
17+
- '!**.md'
18+
19+
env:
20+
NODE_VERSION: 22
21+
22+
jobs:
23+
test:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Set up Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: ${{ env.NODE_VERSION }}
32+
33+
- name: Cache npm dependencies
34+
uses: actions/cache@v4
35+
with:
36+
path: |
37+
**/node_modules
38+
~/.npm
39+
~/.cache/Cypress
40+
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-npm-${{ hashFiles('package-lock.json', 'packages/model-registry/upstream/frontend/package-lock.json') }}
41+
restore-keys: |
42+
${{ runner.os }}-${{ env.NODE_VERSION }}-npm-
43+
44+
- name: Install root level dependencies
45+
run: npm install
46+
47+
- name: Install dependencies
48+
working-directory: packages/model-registry/upstream/frontend
49+
run: npm install
50+
51+
- name: Lint
52+
working-directory: packages/model-registry/upstream/frontend
53+
run: npm run test:lint
54+
55+
- name: Type check
56+
working-directory: packages/model-registry/upstream/frontend
57+
run: npm run test:type-check
58+
59+
- name: Check if there are uncommitted file changes
60+
working-directory: packages/model-registry/upstream/frontend
61+
run: |
62+
clean=$(git status --porcelain)
63+
if [[ -z "$clean" ]]; then
64+
echo "Empty git status --porcelain: $clean"
65+
else
66+
echo "Uncommitted file changes detected: $clean"
67+
git diff
68+
exit 1
69+
fi

package-lock.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/model-registry/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@
7474
},
7575
"devDependencies": {
7676
"@odh-dashboard/eslint-config": "*",
77+
"@odh-dashboard/plugin-core": "*",
7778
"@odh-dashboard/tsconfig": "*",
7879
"@odh-dashboard/contract-tests": "*",
80+
"@openshift/dynamic-plugin-sdk": "*",
81+
"@patternfly/react-code-editor": "*",
7982
"cross-env": "^10.1.0"
8083
}
8184
}

packages/model-registry/upstream/bff/internal/helpers/mcpserver_converter.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,15 @@ func ConvertToMCPServer(metadata *models.McpRuntimeMetadata, opts ConversionOpti
136136
}
137137

138138
// ExtractContainerImage finds the first OCI artifact URI and strips the oci:// prefix.
139+
// Falls back to the first artifact's URI if no OCI artifact is found.
139140
func ExtractContainerImage(artifacts []models.McpArtifact) string {
140141
for _, a := range artifacts {
141-
uri := a.URI
142-
if strings.HasPrefix(uri, "oci://") {
143-
return strings.TrimPrefix(uri, "oci://")
142+
if strings.HasPrefix(a.URI, "oci://") {
143+
return strings.TrimPrefix(a.URI, "oci://")
144144
}
145-
return uri
145+
}
146+
if len(artifacts) > 0 {
147+
return artifacts[0].URI
146148
}
147149
return ""
148150
}

packages/model-registry/upstream/frontend/.eslintrc.cjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
const path = require('path');
2+
13
module.exports = {
4+
"root": true,
25
"parser": "@typescript-eslint/parser",
36
"env": {
47
"browser": true,
@@ -180,7 +183,8 @@ module.exports = {
180183
"error",
181184
{
182185
"devDependencies": true,
183-
"optionalDependencies": true
186+
"optionalDependencies": true,
187+
"packageDir": [__dirname, path.resolve(__dirname, '../..')]
184188
}
185189
],
186190
"no-relative-import-paths/no-relative-import-paths": [

packages/model-registry/upstream/frontend/src/__mocks__/mockCatalogFilterOptionsList.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable camelcase */
2-
import { CatalogFilterOptionsList, NamedQuery, FilterOperator } from '../app/modelCatalogTypes';
2+
import { CatalogFilterOptionsList, NamedQuery, FilterOperator } from '~/app/modelCatalogTypes';
33
import {
44
ModelCatalogStringFilterKey,
55
ModelCatalogNumberFilterKey,
@@ -10,7 +10,7 @@ import {
1010
UseCaseOptionValue,
1111
DEFAULT_PERFORMANCE_FILTERS_QUERY_NAME,
1212
ModelCatalogTensorType,
13-
} from '../concepts/modelCatalog/const';
13+
} from '~/concepts/modelCatalog/const';
1414

1515
export const mockNamedQueries: Record<string, NamedQuery> = {
1616
// Default performance filters applied when performance toggle is turned on

packages/model-registry/upstream/frontend/src/__mocks__/mockCatalogModelArtifactList.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import {
88
MetricsType,
99
CatalogPerformanceMetricsArtifact,
1010
CatalogAccuracyMetricsArtifact,
11-
} from '../app/modelCatalogTypes';
12-
import { ModelRegistryMetadataType } from '../app/types';
13-
import { UseCaseOptionValue } from '../concepts/modelCatalog/const';
11+
} from '~/app/modelCatalogTypes';
12+
import { ModelRegistryMetadataType } from '~/app/types';
13+
import { UseCaseOptionValue } from '~/concepts/modelCatalog/const';
1414

1515
export const mockCatalogModelArtifact = (
1616
partial?: Partial<CatalogModelArtifact>,

packages/model-registry/upstream/frontend/src/__mocks__/mockCatalogModelList.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable camelcase */
2-
import { CatalogModel, CatalogModelList } from '../app/modelCatalogTypes';
3-
import { ModelRegistryMetadataType } from '../app/types';
2+
import { CatalogModel, CatalogModelList } from '~/app/modelCatalogTypes';
3+
import { ModelRegistryMetadataType } from '~/app/types';
44

55
export const mockCatalogModel = (partial?: Partial<CatalogModel>): CatalogModel => ({
66
source_id: 'sample-source',

packages/model-registry/upstream/frontend/src/__mocks__/mockCatalogSourceList.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CatalogSource, CatalogSourceList } from '../app/modelCatalogTypes';
1+
import { CatalogSource, CatalogSourceList } from '~/app/modelCatalogTypes';
22

33
export const mockCatalogSource = (partial?: Partial<CatalogSource>): CatalogSource => ({
44
id: 'sample-source',

0 commit comments

Comments
 (0)