From 91357aca3be1aa0c1ca05e45343a52adf11207e8 Mon Sep 17 00:00:00 2001 From: openhands Date: Thu, 30 Jul 2026 17:51:24 +0200 Subject: [PATCH] ci: fix Gitea Actions workflow --- .gitea/workflows/ci.yml | 40 ++-------------------------------- .husky/pre-commit | 1 + .husky/pre-push | 2 ++ scripts/merge-config.cjs | 47 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 38 deletions(-) create mode 100755 .husky/pre-commit create mode 100755 .husky/pre-push create mode 100644 scripts/merge-config.cjs diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index cfb1721a..806b7f91 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -1,50 +1,14 @@ name: CI -on: - push: - branches: [main] - pull_request: - branches: [main] - -env: - NEXT_TELEMETRY_DISABLED: "1" +on: [push, pull_request] jobs: - lint: + ci: runs-on: ubuntu-latest - container: - image: node:22-slim steps: - uses: actions/checkout@v4 - run: corepack enable && corepack prepare pnpm@10.33.4 --activate - run: pnpm install --frozen-lockfile - run: pnpm biome:lint - - typecheck: - runs-on: ubuntu-latest - container: - image: node:22-slim - steps: - - uses: actions/checkout@v4 - - run: corepack enable && corepack prepare pnpm@10.33.4 --activate - - run: pnpm install --frozen-lockfile - run: pnpm typecheck - - test: - runs-on: ubuntu-latest - container: - image: node:22-slim - steps: - - uses: actions/checkout@v4 - - run: corepack enable && corepack prepare pnpm@10.33.4 --activate - - run: pnpm install --frozen-lockfile - run: pnpm test - - build: - runs-on: ubuntu-latest - container: - image: node:22-slim - steps: - - uses: actions/checkout@v4 - - run: corepack enable && corepack prepare pnpm@10.33.4 --activate - - run: pnpm install --frozen-lockfile - run: pnpm build diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000..5ee7abd8 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +pnpm exec lint-staged diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100755 index 00000000..42267220 --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,2 @@ +pnpm typecheck +pnpm test diff --git a/scripts/merge-config.cjs b/scripts/merge-config.cjs new file mode 100644 index 00000000..6c88a2d9 --- /dev/null +++ b/scripts/merge-config.cjs @@ -0,0 +1,47 @@ +const fs = require('fs'); +const JSON5 = require('json5'); + +const exampleFile = process.argv[2]; +const targetFile = process.argv[3]; + +if (!exampleFile || !targetFile) { + process.exit(1); +} + +function deepMerge(target, source) { + const result = { ...target }; + for (const key of Object.keys(source)) { + if (source[key] !== null && typeof source[key] === 'object' && !Array.isArray(source[key])) { + result[key] = deepMerge(target[key] || {}, source[key]); + } else { + if (!(key in result)) { + result[key] = source[key]; + } + } + } + return result; +} + +let example; +try { + const content = fs.readFileSync(exampleFile, 'utf-8'); + example = JSON5.parse(content); +} catch { + process.exit(1); +} + +let current = {}; +try { + if (fs.existsSync(targetFile)) { + const content = fs.readFileSync(targetFile, 'utf-8'); + current = JSON5.parse(content); + } +} catch { + current = {}; +} + +const merged = deepMerge(current, example); + +const isJson5 = targetFile.endsWith('.json5'); +const output = isJson5 ? JSON5.stringify(merged, null, 4) : JSON.stringify(merged, null, 4); +fs.writeFileSync(targetFile, output + '\n');