Skip to content

Commit e99bb46

Browse files
committed
NO-ISSUE: Sync UI types with monorepo protobufs
Regenerate the committed TypeScript protobuf bindings from the monorepo's local proto sources and update affected UI code for the new API shapes. Add CI validation that regenerates the bindings when proto/** changes and fails if the generated UI types are out of sync. Assisted-by: Codex <codex@openai.com> Signed-off-by: Rastislav Wagner <rawagner@redhat.com>
1 parent 1d8aa81 commit e99bb46

222 files changed

Lines changed: 2696 additions & 2115 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: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Check UI types
2+
3+
on:
4+
# Keep the check reporting on every PR so it can be made a required status
5+
# without leaving non-proto PRs pending. The job itself runs only when the
6+
# shared proto module changes.
7+
pull_request:
8+
branches:
9+
- main
10+
merge_group:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
changes:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
pull-requests: read
21+
outputs:
22+
proto: ${{ steps.filter.outputs.proto }}
23+
steps:
24+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
25+
if: github.event_name == 'merge_group'
26+
with:
27+
fetch-depth: 0
28+
persist-credentials: false
29+
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
30+
id: filter
31+
with:
32+
filters: |
33+
proto:
34+
- 'proto/**'
35+
36+
check-ui-types:
37+
name: Check UI types (proto)
38+
needs: changes
39+
# A skipped job reports success, which is intentional for PRs without a
40+
# proto change; failures in the filter job must still fail this check.
41+
if: ${{ always() }}
42+
runs-on: ubuntu-latest
43+
permissions:
44+
contents: read
45+
steps:
46+
- name: Fail if path filter failed
47+
if: needs.changes.result != 'success'
48+
run: exit 1
49+
- id: should-run
50+
if: needs.changes.outputs.proto == 'true'
51+
run: echo "run=true" >> "$GITHUB_OUTPUT"
52+
- if: steps.should-run.outputs.run
53+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
54+
with:
55+
persist-credentials: false
56+
- if: steps.should-run.outputs.run
57+
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
58+
with:
59+
run_install: false
60+
package_json_file: osac-ui/package.json
61+
- if: steps.should-run.outputs.run
62+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
63+
with:
64+
node-version-file: osac-ui/package.json
65+
cache: pnpm
66+
cache-dependency-path: osac-ui/pnpm-lock.yaml
67+
- if: steps.should-run.outputs.run
68+
name: Install UI dependencies
69+
working-directory: osac-ui
70+
run: pnpm install --frozen-lockfile
71+
- if: steps.should-run.outputs.run
72+
name: Regenerate UI types from local proto
73+
working-directory: osac-ui
74+
run: pnpm gen-types
75+
- if: steps.should-run.outputs.run
76+
name: Check for uncommitted UI type changes
77+
run: |
78+
if ! git diff --exit-code -- osac-ui/libs/types/src/ || \
79+
[ -n "$(git ls-files --others --exclude-standard -- osac-ui/libs/types/src/)" ]; then
80+
echo "::error::UI types are out of date. Run 'pnpm gen-types' in osac-ui and commit the generated files."
81+
git status --short -- osac-ui/libs/types/src/
82+
exit 1
83+
fi

‎osac-ui/libs/i18n/locales/en/translation.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,6 @@
610610
"Projects": "Projects",
611611
"Protocol": "Protocol",
612612
"Protocol is required": "Protocol is required",
613-
"Provide either an SSH public key or user data containing access credentials.": "Provide either an SSH public key or user data containing access credentials.",
614613
"Provider": "Provider",
615614
"Provider is required": "Provider is required",
616615
"Provides outbound internet access for workloads in this virtual network.": "Provides outbound internet access for workloads in this virtual network.",
@@ -822,6 +821,7 @@
822821
"Value": "Value",
823822
"Value type": "Value type",
824823
"VAST": "VAST",
824+
"vCPUs": "vCPUs",
825825
"Vendor": "Vendor",
826826
"Version": "Version",
827827
"Version is required": "Version is required",
@@ -831,6 +831,7 @@
831831
"View password": "View password",
832832
"View the virtual network configuration and related resources.": "View the virtual network configuration and related resources.",
833833
"Viewer": "Viewer",
834+
"Virtual CPUs": "Virtual CPUs",
834835
"Virtual Machine": "Virtual Machine",
835836
"Virtual machine conditions": "Virtual machine conditions",
836837
"Virtual machine summary": "Virtual machine summary",

‎osac-ui/libs/types/buf.gen.yaml‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,5 @@ plugins:
77
include_imports: true
88
include_wkt: true
99
inputs:
10-
- git_repo: https://github.com/osac-project/osac.git
11-
branch: main
12-
subdir: fulfillment-service/proto/public
13-
- git_repo: https://github.com/osac-project/osac.git
14-
branch: main
15-
subdir: fulfillment-service/proto/private
10+
- directory: ../../../proto/public
11+
- directory: ../../../proto/private
Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,11 @@
11
import { spawnSync } from 'node:child_process';
2-
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
3-
import { tmpdir } from 'node:os';
4-
import { dirname, join } from 'node:path';
2+
import { dirname } from 'node:path';
53
import { fileURLToPath } from 'node:url';
64

75
const typesDirectory = dirname(dirname(fileURLToPath(import.meta.url)));
8-
const templatePath = join(typesDirectory, 'buf.gen.yaml');
9-
const args = process.argv.slice(2);
10-
11-
const getCommit = (providedArgs) => {
12-
if (providedArgs.length === 0) {
13-
return undefined;
14-
}
15-
16-
if (providedArgs.length === 1 && !providedArgs[0].startsWith('--')) {
17-
return providedArgs[0];
18-
}
19-
20-
if (providedArgs.length === 2 && providedArgs[0] === '--commit') {
21-
return providedArgs[1];
22-
}
23-
24-
if (providedArgs.length === 1 && providedArgs[0].startsWith('--commit=')) {
25-
return providedArgs[0].slice('--commit='.length);
26-
}
27-
28-
throw new Error('Usage: pnpm gen-types [commit] or pnpm gen-types --commit <commit>');
29-
};
30-
31-
let temporaryDirectory;
326

337
try {
34-
const commit = getCommit(args);
35-
let bufArgs = ['generate'];
36-
37-
if (commit !== undefined) {
38-
if (commit.length === 0 || /\s/.test(commit)) {
39-
throw new Error('The commit must not contain whitespace.');
40-
}
41-
42-
const template = readFileSync(templatePath, 'utf8');
43-
const branchPattern = /^(\s*)branch: main$/gm;
44-
const branchMatches = template.match(branchPattern);
45-
46-
if (branchMatches?.length !== 2) {
47-
throw new Error('Expected both protobuf inputs to use branch: main.');
48-
}
49-
50-
const customTemplate = template.replace(
51-
branchPattern,
52-
(_, indentation) => `${indentation}ref: ${JSON.stringify(commit)}`,
53-
);
54-
55-
temporaryDirectory = mkdtempSync(join(tmpdir(), 'osac-gen-types-'));
56-
const temporaryTemplatePath = join(temporaryDirectory, 'buf.gen.yaml');
57-
writeFileSync(temporaryTemplatePath, customTemplate);
58-
bufArgs = ['generate', '--template', temporaryTemplatePath];
59-
}
60-
61-
const result = spawnSync('buf', bufArgs, {
8+
const result = spawnSync('buf', ['generate'], {
629
cwd: typesDirectory,
6310
stdio: 'inherit',
6411
});
@@ -71,8 +18,4 @@ try {
7118
} catch (error) {
7219
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
7320
process.exitCode = 1;
74-
} finally {
75-
if (temporaryDirectory) {
76-
rmSync(temporaryDirectory, { force: true, recursive: true });
77-
}
7821
}

‎osac-ui/libs/types/src/buf/validate/validate_pb.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5037,3 +5037,4 @@ export const field: GenExtension<FieldOptions, FieldRules> = /*@__PURE__*/
50375037
*/
50385038
export const predefined: GenExtension<FieldOptions, PredefinedRules> = /*@__PURE__*/
50395039
extDesc(file_buf_validate_validate, 3);
5040+

‎osac-ui/libs/types/src/cleanapi/cleanapi_pb.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,4 @@ export const service: GenExtension<ServiceOptions$1, ServiceOptions> = /*@__PURE
223223
*/
224224
export const method: GenExtension<MethodOptions$1, MethodOptions> = /*@__PURE__*/
225225
extDesc(file_cleanapi_cleanapi, 6);
226+

‎osac-ui/libs/types/src/google/api/annotations_pb.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ export const file_google_api_annotations: GenFile = /*@__PURE__*/
3636
*/
3737
export const http: GenExtension<MethodOptions, HttpRule> = /*@__PURE__*/
3838
extDesc(file_google_api_annotations, 0);
39+

‎osac-ui/libs/types/src/google/api/field_behavior_pb.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,4 @@ export const FieldBehaviorSchema: GenEnum<FieldBehavior> = /*@__PURE__*/
154154
*/
155155
export const field_behavior: GenExtension<FieldOptions, FieldBehavior[]> = /*@__PURE__*/
156156
extDesc(file_google_api_field_behavior, 0);
157+

‎osac-ui/libs/types/src/google/api/http_pb.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,3 +471,4 @@ export type CustomHttpPattern = Message<"google.api.CustomHttpPattern"> & {
471471
*/
472472
export const CustomHttpPatternSchema: GenMessage<CustomHttpPattern> = /*@__PURE__*/
473473
messageDesc(file_google_api_http, 2);
474+

‎osac-ui/libs/types/src/google/api/httpbody_pb.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,4 @@ export type HttpBody = Message<"google.api.HttpBody"> & {
105105
*/
106106
export const HttpBodySchema: GenMessage<HttpBody> = /*@__PURE__*/
107107
messageDesc(file_google_api_httpbody, 0);
108+

0 commit comments

Comments
 (0)