1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-07-25 12:05:19 +02:00
Files
misskey/.github/workflows/test-backend.yml
kakkokari-gtyih e60e965c3c perf
2026-07-08 16:36:58 +09:00

209 lines
6.0 KiB
YAML

name: Test (backend)
on:
push:
branches:
- master
- develop
paths:
- packages/backend/**
# for permissions
- packages/misskey-js/**
- .github/workflows/test-backend.yml
- .github/misskey/test.yml
pull_request:
paths:
- packages/backend/**
# for permissions
- packages/misskey-js/**
- .github/workflows/test-backend.yml
- .github/misskey/test.yml
workflow_dispatch:
jobs:
build:
name: Build (${{ matrix.node-version-file }})
runs-on: ubuntu-latest
strategy:
matrix:
include:
- node-version-file: .node-version
artifact-name: backend-test-repo-node-version
- node-version-file: .github/min.node-version
artifact-name: backend-test-repo-min-node-version
steps:
- uses: actions/checkout@v6.0.3
with:
submodules: true
- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
- name: Use Node.js
uses: actions/setup-node@v6.4.0
with:
node-version-file: ${{ matrix.node-version-file }}
cache: 'pnpm'
- run: pnpm i --frozen-lockfile
- name: Check pnpm-lock.yaml
run: git diff --exit-code pnpm-lock.yaml
- name: Copy Configure
run: cp .github/misskey/test.yml .config
- name: Build
run: pnpm build
- name: Archive built repository
run: tar -C "$GITHUB_WORKSPACE" -czf "$RUNNER_TEMP/${{ matrix.artifact-name }}.tar.gz" .
- name: Upload built repository
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact-name }}
path: ${{ runner.temp }}/${{ matrix.artifact-name }}.tar.gz
unit:
name: Unit tests (backend)
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
include:
- node-version-file: .node-version
artifact-name: backend-test-repo-node-version
- node-version-file: .github/min.node-version
artifact-name: backend-test-repo-min-node-version
services:
postgres:
image: postgres:18
ports:
- 54312:5432
env:
POSTGRES_DB: test-misskey
POSTGRES_HOST_AUTH_METHOD: trust
redis:
image: redis:8
ports:
- 56312:6379
meilisearch:
image: getmeili/meilisearch:v1.48.1
ports:
- 57712:7700
env:
MEILI_NO_ANALYTICS: true
MEILI_ENV: development
steps:
- name: Download built repository
uses: actions/download-artifact@v8
with:
name: ${{ matrix.artifact-name }}
path: ${{ runner.temp }}
- name: Extract built repository
run: tar -C "$GITHUB_WORKSPACE" -xzf "$RUNNER_TEMP/${{ matrix.artifact-name }}.tar.gz"
- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
- name: Install FFmpeg
run: |
sudo apt install -y ffmpeg
- name: Use Node.js
uses: actions/setup-node@v6.4.0
with:
node-version-file: ${{ matrix.node-version-file }}
cache: 'pnpm'
- name: Test
run: pnpm --filter backend test-and-coverage
- name: Upload to Codecov
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./packages/backend/coverage/coverage-final.json
e2e:
name: E2E tests (backend)
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
include:
- node-version-file: .node-version
artifact-name: backend-test-repo-node-version
- node-version-file: .github/min.node-version
artifact-name: backend-test-repo-min-node-version
services:
postgres:
image: postgres:18
ports:
- 54312:5432
env:
POSTGRES_DB: test-misskey
POSTGRES_HOST_AUTH_METHOD: trust
redis:
image: redis:8
ports:
- 56312:6379
steps:
- name: Download built repository
uses: actions/download-artifact@v8
with:
name: ${{ matrix.artifact-name }}
path: ${{ runner.temp }}
- name: Extract built repository
run: tar -C "$GITHUB_WORKSPACE" -xzf "$RUNNER_TEMP/${{ matrix.artifact-name }}.tar.gz"
- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
- name: Use Node.js
uses: actions/setup-node@v6.4.0
with:
node-version-file: ${{ matrix.node-version-file }}
cache: 'pnpm'
- name: Test
run: pnpm --filter backend test-and-coverage:e2e
- name: Upload to Codecov
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./packages/backend/coverage/coverage-final.json
migration:
name: Migration tests (backend)
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
include:
- node-version-file: .node-version
artifact-name: backend-test-repo-node-version
services:
postgres:
image: postgres:18
ports:
- 54312:5432
env:
POSTGRES_DB: test-misskey
POSTGRES_HOST_AUTH_METHOD: trust
steps:
- name: Download built repository
uses: actions/download-artifact@v8
with:
name: ${{ matrix.artifact-name }}
path: ${{ runner.temp }}
- name: Extract built repository
run: tar -C "$GITHUB_WORKSPACE" -xzf "$RUNNER_TEMP/${{ matrix.artifact-name }}.tar.gz"
- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
- name: Get current date
id: current-date
run: echo "today=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Use Node.js
uses: actions/setup-node@v6.4.0
with:
node-version-file: ${{ matrix.node-version-file }}
cache: 'pnpm'
- name: Run migrations
run: MISSKEY_CONFIG_YML=test.yml pnpm --filter backend migrate
- name: Check no migrations are remaining
run: MISSKEY_CONFIG_YML=test.yml pnpm --filter backend check-migrations