Files
beekeeper-studio/.github/workflows/studio-test.yml
Matthew Rathbone a307e8d9ad ci: add runner.arch to test pipeline cache key
Future-proofs the cache key for multi-arch test runs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 13:15:42 -05:00

236 lines
6.8 KiB
YAML

name: Studio Tests
permissions:
contents: read
actions: write
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
- master
paths-ignore:
- apps/sqltools/**
pull_request:
paths-ignore:
- apps/sqltools/**
jobs:
prep:
runs-on: ubuntu-24.04
outputs:
test-chunks: ${{ steps.set-test-chunks.outputs.test-chunks }}
steps:
- name: 'Setup jq'
uses: dcarbone/install-jq-action@v2
with:
version: "1.7"
force: true
- uses: actions/checkout@v4
- id: set-test-chunks
name: Set Chunks
run: echo "test-chunks=$(./bin/get-db-files-as-json.sh)" >> $GITHUB_OUTPUT
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Cache node_modules
id: cache-nm
uses: actions/cache@v4
with:
path: |
node_modules
apps/studio/node_modules
apps/ui-kit/node_modules
apps/sqltools/node_modules
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.nvmrc') }}-${{ hashFiles('yarn.lock') }}
- name: Install dependencies
if: steps.cache-nm.outputs.cache-hit != 'true'
uses: nick-fields/retry@v2
with:
timeout_minutes: 20
max_attempts: 3
command: yarn install --frozen-lockfile --network-timeout 100000
env:
HUSKY: "0"
npm_config_node_gyp: ${{ github.workspace }}/node_modules/node-gyp/bin/node-gyp.js
unit:
name: Unit tests
runs-on: ubuntu-24.04
needs: [prep]
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Restore node_modules cache
uses: actions/cache/restore@v4
with:
path: |
node_modules
apps/studio/node_modules
apps/ui-kit/node_modules
apps/sqltools/node_modules
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.nvmrc') }}-${{ hashFiles('yarn.lock') }}
fail-on-cache-miss: true
- name: Lint
run: yarn workspace beekeeper-studio run lint
- name: Check for bad files
run: bin/check-for-only-tests.sh
- name: Check for license-breaking includes
run: bin/check-for-src-commercial.sh
- name: Check for bad log imports
run: bin/check-for-electron-log-imports.sh
- name: Check for missing lodash imports
run: bin/check-lodash.sh
- name: Unit Tests
run: yarn workspace beekeeper-studio run test:unit --ci --silent
- name: Non-DB Integration Tests
run: yarn workspace beekeeper-studio run test:ci --ci --silent
- name: Unit Tests (UI Kit)
run: yarn workspace @beekeeperstudio/ui-kit run test --silent
integration:
name: 🥞 ${{ matrix.chunk[0] }}
runs-on: ubuntu-24.04
needs:
- prep
strategy:
fail-fast: false
matrix:
chunk: ${{ fromJson(needs.prep.outputs['test-chunks']) }}
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Restore node_modules cache
uses: actions/cache/restore@v4
with:
path: |
node_modules
apps/studio/node_modules
apps/ui-kit/node_modules
apps/sqltools/node_modules
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.nvmrc') }}-${{ hashFiles('yarn.lock') }}
fail-on-cache-miss: true
- name: Install libaio (for oracle)
run: sudo apt install libaio-dev
- name: Symlink libaio v1 (for oracle)
run: sudo ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64 /usr/lib/x86_64-linux-gnu/libaio.so.1
- name: Test
uses: nick-fields/retry@v2
with:
timeout_minutes: 20
max_attempts: 2
on_retry_command: "docker ps -aq | xargs docker stop | xargs docker rm"
command: yarn workspace beekeeper-studio run test:integration --runInBand --ci ${{ matrix.chunk[1] }}
env:
TESTCONTAINERS_RYUK_DISABLED: true
# codemirror:
# name: CodeMirror tests
# runs-on: ubuntu-latest
# steps:
# - name: Check out Git repository
# uses: actions/checkout@v2
# - name: Install Node.js, NPM and Yarn
# uses: actions/setup-node@v3
# with:
# node-version-file: '.nvmrc'
# cache: yarn
# - name: Install dependencies
# run: yarn install --frozen-lockfile
# env:
# npm_config_node_gyp: ${{ github.workspace }}${{ runner.os == 'Windows' && '\node_modules\node-gyp\bin\node-gyp.js' || '/node_modules/node-gyp/bin/node-gyp.js' }}
# - name: Test
# uses: nick-fields/retry@v2
# with:
# timeout_minutes: 20
# max_attempts: 2
# on_retry_command: "docker ps -aq | xargs docker stop | xargs docker rm"
# command: yarn workspace beekeeper-studio run test:codemirror --runInBand --ci
e2e:
name: E2E tests
runs-on: ubuntu-24.04
needs: [prep]
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Restore node_modules cache
uses: actions/cache/restore@v4
with:
path: |
node_modules
apps/studio/node_modules
apps/ui-kit/node_modules
apps/sqltools/node_modules
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.nvmrc') }}-${{ hashFiles('yarn.lock') }}
fail-on-cache-miss: true
- name: Start postgres container
run: docker compose up psql15 -d
- name: Serve + Run Tests
run: |
xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" bash -c '
yarn run electron:serve > server.log 2>&1 &
sleep 15
cat server.log # (Optional: see if it launched correctly)
yarn workspace beekeeper-studio test:e2e:ci
'
env:
ELECTRON_ENABLE_LOGGING: 1
ELECTRON_DISABLE_SANDBOX: 1
ELECTRON_EXTRA_LAUNCH_ARGS: "--disable-gpu"
# - name: Run E2E Tests
# run: yarn test:e2e:ci
# continue-on-error: true
- name: Upload test results
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: test-results
path: apps/studio/test-results
retention-days: 30