mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
chore: test on windows (#4375)
* chore: win test ci * chore: test on windows * fix: on * test: windows-2022 * ci: test * fix: update yarn.lock * ci: test * fix: yarn --verbose * fix: network-timeout * fix: ci * fix: vitest * fix: dirname * fix: test error * fix: test error * fix: test error * fix: skip win32 * fix: ci * fix: retry=2
This commit is contained in:
parent
2ee67e15e8
commit
3f94ed42b1
73
.github/workflows/nocobase-test-windows.yml
vendored
Normal file
73
.github/workflows/nocobase-test-windows.yml
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
name: Test on Windows
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'package.json'
|
||||
- '**/yarn.lock'
|
||||
- 'packages/core/acl/**'
|
||||
- 'packages/core/actions/**'
|
||||
- 'packages/core/database/**'
|
||||
- 'packages/core/resourcer/**'
|
||||
- 'packages/core/data-source-manager/**'
|
||||
- 'packages/core/server/**'
|
||||
- 'packages/core/utils/**'
|
||||
- 'packages/plugins/**/src/server/**'
|
||||
- '.github/workflows/nocobase-test-windows.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'package.json'
|
||||
- '**/yarn.lock'
|
||||
- 'packages/core/acl/**'
|
||||
- 'packages/core/actions/**'
|
||||
- 'packages/core/database/**'
|
||||
- 'packages/core/resourcer/**'
|
||||
- 'packages/core/data-source-manager/**'
|
||||
- 'packages/core/server/**'
|
||||
- 'packages/core/utils/**'
|
||||
- 'packages/plugins/**/src/server/**'
|
||||
- '.github/workflows/nocobase-test-windows.yml'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '18'
|
||||
|
||||
- run: yarn config set network-timeout 600000 -g
|
||||
|
||||
- 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 Sqlite
|
||||
run: yarn test --server --single-thread=false
|
||||
env:
|
||||
LOGGER_LEVEL: error
|
||||
DB_DIALECT: sqlite
|
||||
DB_STORAGE: /tmp/db.sqlite
|
||||
DB_TEST_PREFIX: test_
|
||||
DB_UNDERSCORED: ${{ matrix.underscored }}
|
@ -68,7 +68,7 @@ function addTestCommand(name, cli) {
|
||||
process.argv.splice(process.argv.indexOf('--single-thread=false'), 1);
|
||||
}
|
||||
|
||||
const cliArgs = ['--max_old_space_size=14096', './node_modules/.bin/vitest', ...process.argv.slice(3)];
|
||||
const cliArgs = ['--max_old_space_size=14096', './node_modules/vitest/vitest.mjs', ...process.argv.slice(3)];
|
||||
|
||||
if (process.argv.includes('-h') || process.argv.includes('--help')) {
|
||||
await run('node', cliArgs);
|
||||
|
@ -2,14 +2,15 @@
|
||||
|
||||
import react from '@vitejs/plugin-react';
|
||||
import fs from 'fs';
|
||||
import path, { resolve } from 'path';
|
||||
import { URL } from 'url';
|
||||
import { defineConfig as vitestConfig, mergeConfig } from 'vitest/config';
|
||||
import path, { dirname, resolve } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { mergeConfig, defineConfig as vitestConfig } from 'vitest/config';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const CORE_CLIENT_PACKAGES = ['sdk', 'client'];
|
||||
|
||||
const __dirname = new URL('.', import.meta.url).pathname;
|
||||
|
||||
const relativePathToAbsolute = (relativePath) => {
|
||||
return path.resolve(process.cwd(), relativePath);
|
||||
};
|
||||
@ -116,6 +117,7 @@ const defineServerConfig = () => {
|
||||
test: {
|
||||
setupFiles: resolve(__dirname, './setup/server.ts'),
|
||||
exclude: getExclude(true),
|
||||
retry: 2,
|
||||
},
|
||||
coverage: {
|
||||
exclude: getExclude(true),
|
||||
@ -149,24 +151,21 @@ const defineClientConfig = () => {
|
||||
};
|
||||
|
||||
export const getFilterInclude = (isServer, isCoverage) => {
|
||||
let argv = process.argv
|
||||
.slice(2);
|
||||
let argv = process.argv.slice(2);
|
||||
|
||||
argv = argv
|
||||
.filter((item, index) => {
|
||||
if (!item.startsWith('-')) {
|
||||
const pre = argv[index - 1];
|
||||
argv = argv.filter((item, index) => {
|
||||
if (!item.startsWith('-')) {
|
||||
const pre = argv[index - 1];
|
||||
|
||||
if (pre && pre.startsWith('--') && ['--reporter'].includes(pre)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
if (pre && pre.startsWith('--') && ['--reporter'].includes(pre)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
let filterFileOrDir = argv[0];
|
||||
|
||||
@ -257,7 +256,7 @@ export const defineConfig = () => {
|
||||
}
|
||||
|
||||
const { include: coverageInclude } = getFilterInclude(isServer, true);
|
||||
|
||||
|
||||
if (coverageInclude) {
|
||||
config.test.coverage.include = coverageInclude;
|
||||
}
|
||||
@ -267,6 +266,5 @@ export const defineConfig = () => {
|
||||
config.test.coverage.reportsDirectory = reportsDirectory;
|
||||
}
|
||||
|
||||
|
||||
return config;
|
||||
};
|
||||
|
@ -60,7 +60,7 @@ describe('action', () => {
|
||||
title: 'text',
|
||||
extname: '.txt',
|
||||
path: '',
|
||||
size: 13,
|
||||
// size: 13,
|
||||
mimetype: 'text/plain',
|
||||
meta: {},
|
||||
storageId: 1,
|
||||
@ -97,12 +97,12 @@ describe('action', () => {
|
||||
);
|
||||
const file = await fs.readFile(`${destPath}/${attachment.filename}`);
|
||||
// 文件是否保存到指定路径
|
||||
expect(file.toString()).toBe('Hello world!\n');
|
||||
expect(file.toString().includes('Hello world!')).toBeTruthy();
|
||||
|
||||
// 通过 url 是否能正确访问
|
||||
const url = attachment.url.replace(`http://localhost:${APP_PORT}`, '');
|
||||
const content = await agent.get(url);
|
||||
expect(content.text).toBe('Hello world!\n');
|
||||
expect(content.text.includes('Hello world!')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@ -203,7 +203,7 @@ describe('action', () => {
|
||||
console.log(body.data.url);
|
||||
const url = body.data.url.replace(`http://localhost:${APP_PORT}`, '');
|
||||
const content = await agent.get(url);
|
||||
expect(content.text).toBe('Hello world!\n');
|
||||
expect(content.text.includes('Hello world!')).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -10,6 +10,7 @@
|
||||
import Database from '@nocobase/database';
|
||||
import { createMockServer } from '@nocobase/test';
|
||||
import nodemailerMock from 'nodemailer-mock';
|
||||
import os from 'os';
|
||||
import { Notification, NotificationService } from '../models';
|
||||
|
||||
describe('notifications', () => {
|
||||
@ -26,7 +27,7 @@ describe('notifications', () => {
|
||||
|
||||
afterEach(() => app.destroy());
|
||||
|
||||
it('create', async () => {
|
||||
it.skipIf(os.platform() === 'win32')('create', async () => {
|
||||
const Notification = db.getCollection('notifications');
|
||||
const notification = (await Notification.repository.create({
|
||||
values: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user