👷 Update proto build system
This commit is contained in:
@@ -36,6 +36,11 @@ jobs:
|
|||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
cache-dependency-path: "./app/pnpm-lock.yaml"
|
cache-dependency-path: "./app/pnpm-lock.yaml"
|
||||||
|
|
||||||
|
- name: Install Protoc
|
||||||
|
uses: arduino/setup-protoc@v3
|
||||||
|
with:
|
||||||
|
version: "27.x"
|
||||||
|
|
||||||
- run: pnpm install
|
- run: pnpm install
|
||||||
- run: pnpm run build
|
- run: pnpm run build
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ name: Frontend Tests
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [master]
|
||||||
paths:
|
paths:
|
||||||
- 'app/**'
|
- "app/**"
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [master]
|
||||||
paths:
|
paths:
|
||||||
- 'app/**'
|
- "app/**"
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -20,22 +20,31 @@ jobs:
|
|||||||
run:
|
run:
|
||||||
working-directory: ./app
|
working-directory: ./app
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v2
|
||||||
with:
|
with:
|
||||||
version: 9
|
version: 9
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 'latest'
|
node-version: "latest"
|
||||||
cache: 'pnpm'
|
cache: "pnpm"
|
||||||
cache-dependency-path: './app/pnpm-lock.yaml'
|
cache-dependency-path: "./app/pnpm-lock.yaml"
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install Protoc
|
||||||
run: pnpm install
|
uses: arduino/setup-protoc@v3
|
||||||
- name: Install Playwright Browsers
|
with:
|
||||||
run: npx playwright install --with-deps
|
version: "27.x"
|
||||||
|
|
||||||
- name: Run tests
|
- name: Install dependencies
|
||||||
run: pnpm test
|
run: pnpm install
|
||||||
|
|
||||||
|
- name: Generate Proto
|
||||||
|
run: pnpm proto
|
||||||
|
|
||||||
|
- name: Install Playwright Browsers
|
||||||
|
run: npx playwright install --with-deps
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: pnpm test
|
||||||
|
|||||||
@@ -56,4 +56,5 @@ jobs:
|
|||||||
working-directory: ./app
|
working-directory: ./app
|
||||||
|
|
||||||
- name: Build Protocol Buffers (Typescript)
|
- name: Build Protocol Buffers (Typescript)
|
||||||
run: protoc --plugin="protoc-gen-ts_proto=./app/node_modules/.bin/protoc-gen-ts_proto" --ts_proto_out="./app/src/lib/platform_shared" --ts_proto_opt=outputSchema=true --proto_path "./platform_shared" ./platform_shared/websocket_message.proto ./platform_shared/rest_message.proto
|
run: pnpm proto
|
||||||
|
working-directory: ./app
|
||||||
+4
-2
@@ -6,5 +6,7 @@ __pycache__/
|
|||||||
*.py[cod]
|
*.py[cod]
|
||||||
*$py.class
|
*$py.class
|
||||||
.pio
|
.pio
|
||||||
esp32/src/platform_shared
|
esp32/src/platform_shared/*
|
||||||
app/src/lib/platform_shared
|
!esp32/src/platform_shared/.gitkeep
|
||||||
|
app/src/lib/platform_shared/*
|
||||||
|
!app/src/lib/platform_shared/.gitkeep
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@
|
|||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"test:integration": "playwright test",
|
"test:integration": "playwright test",
|
||||||
"test:unit": "vitest",
|
"test:unit": "vitest",
|
||||||
"proto": "protoc --plugin=protoc-gen-ts_proto=.\\node_modules\\.bin\\protoc-gen-ts_proto.cmd --ts_proto_out=./src/lib/platform_shared --ts_proto_opt=outputTypeAnnotations=true,useExactTypes=false,outputExtensions=true,outputTypeRegistry=true,outputSchema=true -I ../platform_shared ../platform_shared/websocket_message.proto ../platform_shared/rest_message.proto"
|
"proto": "node scripts/compile_protos.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.39.2",
|
"@eslint/js": "^9.39.2",
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
import { execSync } from 'child_process';
|
||||||
|
import path from 'path';
|
||||||
|
import os from 'os';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
const isWindows = os.platform() === 'win32';
|
||||||
|
const projectRoot = path.resolve(__dirname, '..');
|
||||||
|
const platformSharedDir = path.resolve(projectRoot, '..', 'platform_shared');
|
||||||
|
const outputDir = path.resolve(projectRoot, 'src', 'lib', 'platform_shared');
|
||||||
|
|
||||||
|
const pluginPath = isWindows
|
||||||
|
? path.join(projectRoot, 'node_modules', '.bin', 'protoc-gen-ts_proto.cmd')
|
||||||
|
: path.join(projectRoot, 'node_modules', '.bin', 'protoc-gen-ts_proto');
|
||||||
|
|
||||||
|
const protoFiles = ['websocket_message.proto', 'rest_message.proto'];
|
||||||
|
|
||||||
|
const tsProtoOpts = [
|
||||||
|
'outputTypeAnnotations=true',
|
||||||
|
'useExactTypes=false',
|
||||||
|
'outputExtensions=true',
|
||||||
|
'outputTypeRegistry=true',
|
||||||
|
'outputSchema=true'
|
||||||
|
].join(',');
|
||||||
|
|
||||||
|
const cmd = [
|
||||||
|
'protoc',
|
||||||
|
`--plugin=protoc-gen-ts_proto=${pluginPath}`,
|
||||||
|
`--ts_proto_out=${outputDir}`,
|
||||||
|
`--ts_proto_opt=${tsProtoOpts}`,
|
||||||
|
`-I${platformSharedDir}`,
|
||||||
|
...protoFiles.map(f => path.join(platformSharedDir, f))
|
||||||
|
].join(' ');
|
||||||
|
|
||||||
|
console.log('Compiling protos...');
|
||||||
|
console.log(` Platform: ${os.platform()}`);
|
||||||
|
console.log(` Output: ${outputDir}`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
execSync(cmd, { stdio: 'inherit', cwd: projectRoot });
|
||||||
|
console.log('Proto compilation complete!');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Proto compilation failed!');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user