From 47479af210329fc4bc6b2ce80814d19160fd3bba Mon Sep 17 00:00:00 2001 From: Ivan Date: Thu, 2 Apr 2026 13:04:19 -0500 Subject: [PATCH] feat(ci): add GitHub Actions workflow for building and testing on Windows and macOS, including scripts for dependency installation, testing, and artifact uploads --- .github/workflows/build.yml | 156 ++++++++++++++++++++++++++++ scripts/ci/github-build-macos.sh | 10 ++ scripts/ci/github-build-windows.sh | 10 ++ scripts/ci/github-install-deps.sh | 11 ++ scripts/ci/github-install-poetry.sh | 10 ++ scripts/ci/github-run-tests.sh | 14 +++ 6 files changed, 211 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100755 scripts/ci/github-build-macos.sh create mode 100755 scripts/ci/github-build-windows.sh create mode 100755 scripts/ci/github-install-deps.sh create mode 100755 scripts/ci/github-install-poetry.sh create mode 100755 scripts/ci/github-run-tests.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5e8ae1d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,156 @@ +# Windows and macOS distributables on GitHub-hosted runners; Linux stays on Gitea. +# +# - dev branch: lint, tests, then native builds + artifact upload (similar to .gitea/workflows/build-test.yml). +# - Any tag push (release, -rc, -dev, etc.): same tests, then builds + artifact upload only (no GitHub Release; Gitea can fetch artifacts later). +# +# Pinned first-party actions (bump tag and SHA together when upgrading): +# actions/checkout@v4.2.2 11bd71901bbe5b1630ceea73d27597364c9af683 +# actions/setup-python@v5.6.0 a26af69be951a213d495a4c3e4e4022e16d87065 +# actions/setup-node@v4.4.0 49933ea5288caeca8642d1e84afbd3f7d6820020 +# actions/upload-artifact@v4.6.2 ea165f8d65b6e75b540449e92b4886f43607fa02 + +name: Build + +on: + push: + branches: + - dev + tags: + - "*" + pull_request: + branches: + - dev + workflow_dispatch: + +permissions: + contents: read + actions: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + NODE_OPTIONS: --max-old-space-size=8192 + PYTHON_VERSION: "3.13" + NODE_VERSION: "24" + POETRY_VERSION: "2.1.1" + PNPM_VERSION: "10.32.1" + +jobs: + test: + name: Lint and test + runs-on: ubuntu-latest + timeout-minutes: 45 + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + + - name: Set up Python + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install Poetry (PyPI pin) + env: + POETRY_VERSION: ${{ env.POETRY_VERSION }} + run: bash scripts/ci/github-install-poetry.sh + + - name: Set up Node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Enable pnpm (corepack) + run: corepack enable && corepack prepare "pnpm@${PNPM_VERSION}" --activate + + - name: Install dependencies + run: bash scripts/ci/github-install-deps.sh + + - name: Lint and test + run: bash scripts/ci/github-run-tests.sh + + windows: + name: Windows (portable + NSIS) + needs: test + if: github.event_name != 'pull_request' + runs-on: windows-latest + timeout-minutes: 120 + defaults: + run: + shell: bash + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + + - name: Set up Python + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install Poetry (PyPI pin) + env: + POETRY_VERSION: ${{ env.POETRY_VERSION }} + run: bash scripts/ci/github-install-poetry.sh + + - name: Set up Node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Enable pnpm (corepack) + run: corepack enable && corepack prepare "pnpm@${PNPM_VERSION}" --activate + + - name: Install dependencies + run: bash scripts/ci/github-install-deps.sh + + - name: Build distributables + run: bash scripts/ci/github-build-windows.sh + + - name: Upload dist artifacts + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + with: + name: meshchatx-windows-${{ github.ref_name }}-${{ github.run_id }} + path: dist/ + if-no-files-found: warn + + macos: + name: macOS (universal DMG) + needs: test + if: github.event_name != 'pull_request' + runs-on: macos-latest + timeout-minutes: 180 + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + + - name: Set up Python + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install Poetry (PyPI pin) + env: + POETRY_VERSION: ${{ env.POETRY_VERSION }} + run: bash scripts/ci/github-install-poetry.sh + + - name: Set up Node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Enable pnpm (corepack) + run: corepack enable && corepack prepare "pnpm@${PNPM_VERSION}" --activate + + - name: Install dependencies + run: bash scripts/ci/github-install-deps.sh + + - name: Build distributables + run: bash scripts/ci/github-build-macos.sh + + - name: Upload dist artifacts + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + with: + name: meshchatx-macos-${{ github.ref_name }}-${{ github.run_id }} + path: dist/ + if-no-files-found: warn diff --git a/scripts/ci/github-build-macos.sh b/scripts/ci/github-build-macos.sh new file mode 100755 index 0000000..59608de --- /dev/null +++ b/scripts/ci/github-build-macos.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# Build macOS universal (x64 + arm64) DMG via electron-builder. Unsigned CI build; signing is disabled. +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/../.." && pwd)" +cd "$ROOT" + +export CSC_IDENTITY_AUTO_DISCOVERY=false + +pnpm run dist:mac-universal diff --git a/scripts/ci/github-build-windows.sh b/scripts/ci/github-build-windows.sh new file mode 100755 index 0000000..7317e32 --- /dev/null +++ b/scripts/ci/github-build-windows.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# Build Windows portable + NSIS installers (electron-builder). See package.json dist:windows. +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/../.." && pwd)" +cd "$ROOT" + +git config --global core.longpaths true 2>/dev/null || true + +pnpm run dist:windows diff --git a/scripts/ci/github-install-deps.sh b/scripts/ci/github-install-deps.sh new file mode 100755 index 0000000..8a2ccc4 --- /dev/null +++ b/scripts/ci/github-install-deps.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# Install Python (Poetry) and Node (pnpm) dependencies for native Electron builds. +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/../.." && pwd)" +cd "$ROOT" + +export GIT_TERMINAL_PROMPT=0 + +python -m poetry install --no-interaction --no-ansi +pnpm install --frozen-lockfile diff --git a/scripts/ci/github-install-poetry.sh b/scripts/ci/github-install-poetry.sh new file mode 100755 index 0000000..32ad08a --- /dev/null +++ b/scripts/ci/github-install-poetry.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# Install Poetry from PyPI with an explicit version (no third-party installers). +# Set POETRY_VERSION to override the default. +set -euo pipefail + +POETRY_VERSION="${POETRY_VERSION:-2.1.1}" + +python -m pip install --disable-pip-version-check --upgrade pip +python -m pip install --disable-pip-version-check "poetry==${POETRY_VERSION}" +python -m poetry --version diff --git a/scripts/ci/github-run-tests.sh b/scripts/ci/github-run-tests.sh new file mode 100755 index 0000000..939e479 --- /dev/null +++ b/scripts/ci/github-run-tests.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# Lint and test (parity with: task lint && task test:all). Used by GitHub Actions. +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/../.." && pwd)" +cd "$ROOT" + +poetry run ruff check . +poetry run ruff format --check . +pnpm run lint +poetry run pytest tests/backend --cov=meshchatx/src/backend -q --tb=short +pnpm run test -- --exclude tests/frontend/i18n.test.js +pnpm run test tests/frontend/i18n.test.js +poetry run pytest tests/backend/test_translator_handler.py