From 0385f1dfe9af0730e9594e2f7a9d5e05e5a31084 Mon Sep 17 00:00:00 2001 From: Ilja Rotar Date: Fri, 14 Aug 2026 15:20:52 +0200 Subject: [PATCH 1/4] Fix js generate --- js/Makefile | 2 +- bun.lock => js/bun.lock | 0 js/client-test.js | 10 ++--- js/client-test.ts | 11 ++--- package.json => js/package.json | 6 +-- js/tsconfig.json | 76 +++++---------------------------- 6 files changed, 25 insertions(+), 80 deletions(-) rename bun.lock => js/bun.lock (100%) rename package.json => js/package.json (89%) diff --git a/js/Makefile b/js/Makefile index 7c5059fb..f9d4335b 100644 --- a/js/Makefile +++ b/js/Makefile @@ -16,7 +16,7 @@ ifeq ($(CI),true) yq e -i -o=json ".version=\"$(VERSION_STRIPPED)\"" package.json &&\ yq e -o=json ".version" package.json endif - cd .. && bun run build + bun run build .PHONY: test test: diff --git a/bun.lock b/js/bun.lock similarity index 100% rename from bun.lock rename to js/bun.lock diff --git a/js/client-test.js b/js/client-test.js index 05b9a1f6..52e4b60d 100644 --- a/js/client-test.js +++ b/js/client-test.js @@ -9,10 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; import { describe, it, expect } from "bun:test"; import { create } from "@bufbuild/protobuf"; -import { VersionServiceGetRequestSchema, } from "./metalstack/api/v2/version_pb"; +import { VersionSchema, VersionServiceGetRequestSchema, VersionServiceGetResponseSchema, } from "./metalstack/api/v2/version_pb"; import { newClient } from "./client"; import { newTestInterceptor } from "./test-interceptor"; -function unaryResponse(schema, message) { +function unaryResponse(message) { return { stream: false, message: message, @@ -32,9 +32,9 @@ describe("client", () => { { wantRequest: create(VersionServiceGetRequestSchema, {}), wantRequestSchema: VersionServiceGetRequestSchema, - wantResponse: () => unaryResponse(VersionServiceGetRequestSchema, { - version: { version: "1.0", revision: "", gitSha1: "", buildDate: "" }, - }), + wantResponse: () => unaryResponse(create(VersionServiceGetResponseSchema, { + version: create(VersionSchema, { version: "1.0" }), + })), }, ]), ], diff --git a/js/client-test.ts b/js/client-test.ts index bf8fa251..751cc01f 100644 --- a/js/client-test.ts +++ b/js/client-test.ts @@ -2,16 +2,15 @@ import { describe, it, expect } from "bun:test"; import { create } from "@bufbuild/protobuf"; import type { DescMessage, MessageShape } from "@bufbuild/protobuf"; import { + VersionSchema, VersionServiceGetRequestSchema, VersionServiceGetResponseSchema, - VersionService, } from "./metalstack/api/v2/version_pb"; import type { UnaryResponse } from "@connectrpc/connect"; import { newClient } from "./client"; import { newTestInterceptor } from "./test-interceptor"; function unaryResponse( - schema: Req, message: MessageShape, ): UnaryResponse { return { @@ -34,9 +33,11 @@ describe("client", () => { wantRequest: create(VersionServiceGetRequestSchema, {}), wantRequestSchema: VersionServiceGetRequestSchema, wantResponse: () => - unaryResponse(VersionServiceGetRequestSchema, { - version: { version: "1.0", revision: "", gitSha1: "", buildDate: "" }, - }), + unaryResponse( + create(VersionServiceGetResponseSchema, { + version: create(VersionSchema, { version: "1.0" }), + }), + ), }, ]), ], diff --git a/package.json b/js/package.json similarity index 89% rename from package.json rename to js/package.json index 82d871d0..54091740 100644 --- a/package.json +++ b/js/package.json @@ -3,7 +3,7 @@ "description": "metal-stack api typescript client", "repository": "https://github.com/metal-stack/api.git", "scripts": { - "build": "tsc --project js/tsconfig.json", + "build": "tsc --project tsconfig.json", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "metal-stack.io", @@ -18,7 +18,7 @@ "typescript": "^7.0.2" }, "files": [ - "js/*" + "./*" ], "version": "0.0.0" -} +} \ No newline at end of file diff --git a/js/tsconfig.json b/js/tsconfig.json index 701fd34b..685f2bd7 100644 --- a/js/tsconfig.json +++ b/js/tsconfig.json @@ -1,70 +1,14 @@ { "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - - /* Basic Options */ - // "incremental": true, /* Enable incremental compilation */ - "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ - "module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ - // "lib": [], /* Specify library files to be included in the compilation. */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "composite": true, /* Enable project compilation */ - // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - - /* Strict Type-Checking Options */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "strictFunctionTypes": true, /* Enable strict checking of function types. */ - // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ - // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - - /* Source Map Options */ - // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - - /* Advanced Options */ - "skipLibCheck": true, /* Skip type checking of declaration files. */ - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ + "target": "es6", + "module": "esnext", + "declaration": true, + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "types": [ + "bun" + ] } } \ No newline at end of file From 035a06510c32d9c70400012ef819f100c83851d8 Mon Sep 17 00:00:00 2001 From: Ilja Rotar Date: Fri, 14 Aug 2026 15:50:45 +0200 Subject: [PATCH 2/4] add tests and build to regular pipeline --- .github/workflows/main.yml | 22 ++++++++++ .../workflows/{python-tests.yml => tests.yml} | 42 ++++++++++++++++++- 2 files changed, 62 insertions(+), 2 deletions(-) rename .github/workflows/{python-tests.yml => tests.yml} (50%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5a8f666a..b9f830d1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,6 +34,28 @@ jobs: run: | git diff --exit-code --compact-summary + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v7 + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: 24 + registry-url: https://registry.npmjs.org/ + + - name: Setup bun + uses: oven-sh/setup-bun@v2 + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: build + run: make build + go: name: Go runs-on: ubuntu-latest diff --git a/.github/workflows/python-tests.yml b/.github/workflows/tests.yml similarity index 50% rename from .github/workflows/python-tests.yml rename to .github/workflows/tests.yml index 18b5e9c2..45cfe50a 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: python-tests +name: tests on: pull_request: @@ -12,7 +12,23 @@ permissions: contents: read jobs: - test: + go: + name: Go + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v7 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version-file: "go.mod" + cache: false + + - name: Run tests + run: make -C go test + + python: name: Python (${{ matrix.python-version }}) runs-on: ubuntu-latest timeout-minutes: 10 @@ -40,3 +56,25 @@ jobs: - name: Run Python client tests run: | python -m pytest python/metalstack/client/tests/ -v + + js: + name: JavaScript + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v7 + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: 24 + registry-url: https://registry.npmjs.org/ + + - name: Setup bun + uses: oven-sh/setup-bun@v2 + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Run tests + run: make -C js test From 19ef66293b57470c30e7a488968dd7d0e4eea6e3 Mon Sep 17 00:00:00 2001 From: Ilja Rotar Date: Fri, 14 Aug 2026 15:53:56 +0200 Subject: [PATCH 3/4] try to fix bun install --- .github/workflows/main.yml | 2 +- .github/workflows/npm-publish.yaml | 2 +- .github/workflows/tests.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b9f830d1..d7d86eb3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,7 +51,7 @@ jobs: uses: oven-sh/setup-bun@v2 - name: Install dependencies - run: bun install --frozen-lockfile + run: cd js && bun install --frozen-lockfile - name: build run: make build diff --git a/.github/workflows/npm-publish.yaml b/.github/workflows/npm-publish.yaml index a547242a..86c56ea8 100644 --- a/.github/workflows/npm-publish.yaml +++ b/.github/workflows/npm-publish.yaml @@ -31,7 +31,7 @@ jobs: uses: oven-sh/setup-bun@v2 - name: Install dependencies - run: bun install --frozen-lockfile + run: cd js && bun install --frozen-lockfile - name: build run: make build diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 45cfe50a..3896deda 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -74,7 +74,7 @@ jobs: uses: oven-sh/setup-bun@v2 - name: Install dependencies - run: bun install --frozen-lockfile + run: cd js && bun install --frozen-lockfile - name: Run tests run: make -C js test From cd8db67199b9575dfa2cc3bb3a48e3812d4c3569 Mon Sep 17 00:00:00 2001 From: Ilja Rotar Date: Fri, 14 Aug 2026 15:55:43 +0200 Subject: [PATCH 4/4] fix build target --- js/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/js/Makefile b/js/Makefile index f9d4335b..c631affe 100644 --- a/js/Makefile +++ b/js/Makefile @@ -12,7 +12,6 @@ clean: .PHONY: build build: install ifeq ($(CI),true) - cd .. &&\ yq e -i -o=json ".version=\"$(VERSION_STRIPPED)\"" package.json &&\ yq e -o=json ".version" package.json endif