2023-06-09 09:23:04 +08:00
|
|
|
name: NocoBase Backend Test
|
2022-01-08 17:16:11 +08:00
|
|
|
|
2022-09-19 09:23:01 +08:00
|
|
|
on:
|
2022-09-27 22:50:10 +08:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
- develop
|
2022-10-28 11:41:48 +08:00
|
|
|
paths:
|
2023-12-18 22:41:14 +08:00
|
|
|
- 'package.json'
|
2023-03-30 18:27:38 +08:00
|
|
|
- 'packages/core/acl/**'
|
|
|
|
- 'packages/core/actions/**'
|
|
|
|
- 'packages/core/database/**'
|
|
|
|
- 'packages/core/server/**'
|
2023-12-28 13:40:11 +08:00
|
|
|
- 'packages/core/utils/**'
|
2023-03-30 18:27:38 +08:00
|
|
|
- 'packages/plugins/**/src/server/**'
|
2023-06-09 09:23:04 +08:00
|
|
|
- '.github/workflows/nocobase-test-backend.yml'
|
2022-09-19 09:23:01 +08:00
|
|
|
pull_request:
|
2022-10-28 11:41:48 +08:00
|
|
|
paths:
|
2023-12-18 22:41:14 +08:00
|
|
|
- 'package.json'
|
2023-03-30 18:27:38 +08:00
|
|
|
- 'packages/core/acl/**'
|
|
|
|
- 'packages/core/actions/**'
|
|
|
|
- 'packages/core/database/**'
|
|
|
|
- 'packages/core/server/**'
|
2023-12-28 13:40:11 +08:00
|
|
|
- 'packages/core/utils/**'
|
2023-03-30 18:27:38 +08:00
|
|
|
- 'packages/plugins/**/src/server/**'
|
2023-06-09 09:23:04 +08:00
|
|
|
- '.github/workflows/nocobase-test-backend.yml'
|
2022-01-08 17:16:11 +08:00
|
|
|
|
|
|
|
jobs:
|
2023-02-22 12:05:59 +08:00
|
|
|
sqlite-test:
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-07-14 14:49:12 +08:00
|
|
|
node_version: ['18']
|
|
|
|
underscored: [true, false]
|
2023-02-22 12:05:59 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container: node:${{ matrix.node_version }}
|
|
|
|
steps:
|
2023-10-18 07:40:39 +08:00
|
|
|
- uses: actions/checkout@v4
|
2023-02-22 12:05:59 +08:00
|
|
|
- name: Use Node.js ${{ matrix.node_version }}
|
2023-10-18 07:40:39 +08:00
|
|
|
uses: actions/setup-node@v3
|
2023-02-22 12:05:59 +08:00
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node_version }}
|
2023-10-18 07:40:39 +08:00
|
|
|
- name: Get yarn cache directory path
|
|
|
|
id: yarn-cache-dir-path
|
|
|
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
|
|
|
|
|
|
- uses: actions/cache@v3
|
|
|
|
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
|
|
|
with:
|
|
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-yarn-
|
|
|
|
|
|
|
|
- name: Install project dependencies
|
|
|
|
run: yarn --prefer-offline
|
2022-10-28 11:41:48 +08:00
|
|
|
- name: Test with Sqlite
|
2023-12-21 20:39:11 +08:00
|
|
|
run: yarn test --server --single-thread=false
|
2022-10-28 11:41:48 +08:00
|
|
|
env:
|
2023-07-27 21:57:13 +08:00
|
|
|
LOGGER_LEVEL: error
|
2022-10-28 11:41:48 +08:00
|
|
|
DB_DIALECT: sqlite
|
|
|
|
DB_STORAGE: /tmp/db.sqlite
|
2023-10-17 22:22:45 +08:00
|
|
|
DB_TEST_PREFIX: test_
|
2023-02-16 10:53:04 +08:00
|
|
|
DB_UNDERSCORED: ${{ matrix.underscored }}
|
2023-08-24 17:47:45 +08:00
|
|
|
timeout-minutes: 40
|
2022-10-28 11:41:48 +08:00
|
|
|
|
|
|
|
postgres-test:
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-07-14 14:49:12 +08:00
|
|
|
node_version: ['18']
|
|
|
|
underscored: [true, false]
|
|
|
|
schema: [public, nocobase]
|
|
|
|
collection_schema: [public, user_schema]
|
2022-01-08 17:16:11 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container: node:${{ matrix.node_version }}
|
|
|
|
services:
|
|
|
|
# Label used to access the service container
|
|
|
|
postgres:
|
|
|
|
# Docker Hub image
|
2023-07-14 14:49:12 +08:00
|
|
|
image: postgres:11
|
2022-01-08 17:16:11 +08:00
|
|
|
# Provide the password for postgres
|
|
|
|
env:
|
|
|
|
POSTGRES_USER: nocobase
|
|
|
|
POSTGRES_PASSWORD: password
|
|
|
|
# Set health checks to wait until postgres has started
|
|
|
|
options: >-
|
|
|
|
--health-cmd pg_isready
|
|
|
|
--health-interval 10s
|
|
|
|
--health-timeout 5s
|
|
|
|
--health-retries 5
|
|
|
|
steps:
|
2023-10-18 07:40:39 +08:00
|
|
|
- uses: actions/checkout@v4
|
2022-01-08 17:16:11 +08:00
|
|
|
- name: Use Node.js ${{ matrix.node_version }}
|
2023-10-18 07:40:39 +08:00
|
|
|
uses: actions/setup-node@v3
|
2022-01-08 17:16:11 +08:00
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node_version }}
|
2023-10-18 07:40:39 +08:00
|
|
|
- name: Get yarn cache directory path
|
|
|
|
id: yarn-cache-dir-path
|
|
|
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
|
|
|
|
|
|
- uses: actions/cache@v3
|
|
|
|
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
|
|
|
with:
|
|
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-yarn-
|
|
|
|
|
|
|
|
- name: Install project dependencies
|
|
|
|
run: yarn --prefer-offline
|
2022-01-08 17:16:11 +08:00
|
|
|
- name: Test with postgres
|
2023-10-17 22:22:45 +08:00
|
|
|
run: |
|
|
|
|
./node_modules/.bin/tsx packages/core/test/src/scripts/test-db-creator.ts &
|
|
|
|
sleep 1
|
2023-12-21 20:39:11 +08:00
|
|
|
yarn test --server --single-thread=false
|
2022-01-08 17:16:11 +08:00
|
|
|
env:
|
2023-07-27 21:57:13 +08:00
|
|
|
LOGGER_LEVEL: error
|
2022-01-08 17:16:11 +08:00
|
|
|
DB_DIALECT: postgres
|
|
|
|
DB_HOST: postgres
|
|
|
|
DB_PORT: 5432
|
|
|
|
DB_USER: nocobase
|
|
|
|
DB_PASSWORD: password
|
|
|
|
DB_DATABASE: nocobase
|
2023-02-16 10:53:04 +08:00
|
|
|
DB_UNDERSCORED: ${{ matrix.underscored }}
|
|
|
|
DB_SCHEMA: ${{ matrix.schema }}
|
2023-03-05 14:45:56 +08:00
|
|
|
COLLECTION_MANAGER_SCHEMA: ${{ matrix.collection_schema }}
|
2023-10-17 22:22:45 +08:00
|
|
|
DB_TEST_DISTRIBUTOR_PORT: 23450
|
|
|
|
DB_TEST_PREFIX: test_
|
2023-08-24 17:47:45 +08:00
|
|
|
timeout-minutes: 40
|
2022-10-28 11:41:48 +08:00
|
|
|
|
|
|
|
mysql-test:
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-07-14 14:49:12 +08:00
|
|
|
node_version: ['18']
|
|
|
|
underscored: [true, false]
|
2022-10-28 11:41:48 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container: node:${{ matrix.node_version }}
|
|
|
|
services:
|
|
|
|
mysql:
|
2024-01-20 20:59:49 +08:00
|
|
|
image: mysql:8.2 # >= 8.3 will meet unsolved error: https://github.com/nocobase/nocobase/actions/runs/7581141593/job/20653828990?pr=3383
|
2022-01-08 17:16:11 +08:00
|
|
|
env:
|
2022-10-28 11:41:48 +08:00
|
|
|
MYSQL_ROOT_PASSWORD: password
|
|
|
|
MYSQL_DATABASE: nocobase
|
|
|
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
|
|
|
steps:
|
2023-10-18 07:40:39 +08:00
|
|
|
- uses: actions/checkout@v4
|
2022-10-28 11:41:48 +08:00
|
|
|
- name: Use Node.js ${{ matrix.node_version }}
|
2023-10-18 07:40:39 +08:00
|
|
|
uses: actions/setup-node@v3
|
2022-10-28 11:41:48 +08:00
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node_version }}
|
2023-10-18 07:40:39 +08:00
|
|
|
- name: Get yarn cache directory path
|
|
|
|
id: yarn-cache-dir-path
|
|
|
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
|
|
|
|
|
|
- uses: actions/cache@v3
|
|
|
|
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
|
|
|
with:
|
|
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-yarn-
|
|
|
|
- name: Install project dependencies
|
|
|
|
run: yarn --prefer-offline
|
2022-01-08 17:16:11 +08:00
|
|
|
- name: Test with MySQL
|
2023-10-17 22:22:45 +08:00
|
|
|
run: |
|
|
|
|
./node_modules/.bin/tsx packages/core/test/src/scripts/test-db-creator.ts &
|
|
|
|
sleep 1
|
2023-12-21 20:39:11 +08:00
|
|
|
yarn test --server --single-thread=false
|
2022-01-08 17:16:11 +08:00
|
|
|
env:
|
2023-07-27 21:57:13 +08:00
|
|
|
LOGGER_LEVEL: error
|
2022-01-08 17:16:11 +08:00
|
|
|
DB_DIALECT: mysql
|
|
|
|
DB_HOST: mysql
|
|
|
|
DB_PORT: 3306
|
|
|
|
DB_USER: root
|
|
|
|
DB_PASSWORD: password
|
|
|
|
DB_DATABASE: nocobase
|
2023-02-16 10:53:04 +08:00
|
|
|
DB_UNDERSCORED: ${{ matrix.underscored }}
|
2023-10-17 22:22:45 +08:00
|
|
|
DB_TEST_DISTRIBUTOR_PORT: 23450
|
|
|
|
DB_TEST_PREFIX: test_
|
2023-08-24 17:47:45 +08:00
|
|
|
timeout-minutes: 40
|
2023-11-20 08:54:40 +08:00
|
|
|
mariadb-test:
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
node_version: ['18']
|
|
|
|
underscored: [true, false]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container: node:${{ matrix.node_version }}
|
|
|
|
services:
|
|
|
|
mariadb:
|
|
|
|
image: mariadb:10.9
|
|
|
|
env:
|
|
|
|
MARIADB_ROOT_PASSWORD: password
|
|
|
|
MARIADB_DATABASE: nocobase
|
|
|
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Use Node.js ${{ matrix.node_version }}
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node_version }}
|
|
|
|
- name: Get yarn cache directory path
|
|
|
|
id: yarn-cache-dir-path
|
|
|
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
|
|
|
|
|
|
- uses: actions/cache@v3
|
|
|
|
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
|
|
|
with:
|
|
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-yarn-
|
|
|
|
- name: Install project dependencies
|
|
|
|
run: yarn --prefer-offline
|
|
|
|
- name: Test with MariaDB
|
|
|
|
run: |
|
|
|
|
./node_modules/.bin/tsx packages/core/test/src/scripts/test-db-creator.ts &
|
|
|
|
sleep 1
|
2023-12-21 20:39:11 +08:00
|
|
|
yarn test --server --single-thread=false
|
2023-11-20 08:54:40 +08:00
|
|
|
env:
|
|
|
|
LOGGER_LEVEL: error
|
|
|
|
DB_DIALECT: mariadb
|
|
|
|
DB_HOST: mariadb
|
|
|
|
DB_PORT: 3306
|
|
|
|
DB_USER: root
|
|
|
|
DB_PASSWORD: password
|
|
|
|
DB_DATABASE: nocobase
|
|
|
|
DB_UNDERSCORED: ${{ matrix.underscored }}
|
|
|
|
DB_TEST_DISTRIBUTOR_PORT: 23450
|
|
|
|
DB_TEST_PREFIX: test_
|
|
|
|
timeout-minutes: 40
|