mirror of
https://github.com/crazy-max/ghaction-upx.git
synced 2026-04-14 02:22:58 -06:00
switch from jest to vitest
This commit is contained in:
@@ -85,7 +85,7 @@ ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
|
|||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
--mount=type=cache,target=/src/.yarn/cache \
|
--mount=type=cache,target=/src/.yarn/cache \
|
||||||
--mount=type=cache,target=/src/node_modules \
|
--mount=type=cache,target=/src/node_modules \
|
||||||
yarn run test --coverage --coverageDirectory=/tmp/coverage
|
yarn run test --coverage --coverage.reportsDirectory=/tmp/coverage
|
||||||
|
|
||||||
FROM scratch AS test-coverage
|
FROM scratch AS test-coverage
|
||||||
COPY --from=test /tmp/coverage /
|
COPY --from=test /tmp/coverage /
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
const {defineConfig, globalIgnores} = require('eslint/config');
|
const {defineConfig, globalIgnores} = require('eslint/config');
|
||||||
const {fixupConfigRules, fixupPluginRules} = require('@eslint/compat');
|
const {fixupConfigRules, fixupPluginRules} = require('@eslint/compat');
|
||||||
const typescriptEslint = require('@typescript-eslint/eslint-plugin');
|
const typescriptEslint = require('@typescript-eslint/eslint-plugin');
|
||||||
const jestPlugin = require('eslint-plugin-jest');
|
const vitestPlugin = require('@vitest/eslint-plugin');
|
||||||
const prettier = require('eslint-plugin-prettier');
|
const prettier = require('eslint-plugin-prettier');
|
||||||
const globals = require('globals');
|
const globals = require('globals');
|
||||||
const tsParser = require('@typescript-eslint/parser');
|
const tsParser = require('@typescript-eslint/parser');
|
||||||
@@ -25,21 +25,21 @@ module.exports = defineConfig([
|
|||||||
'eslint:recommended',
|
'eslint:recommended',
|
||||||
'plugin:@typescript-eslint/eslint-recommended',
|
'plugin:@typescript-eslint/eslint-recommended',
|
||||||
'plugin:@typescript-eslint/recommended',
|
'plugin:@typescript-eslint/recommended',
|
||||||
'plugin:jest/recommended',
|
'plugin:@vitest/legacy-recommended',
|
||||||
'plugin:prettier/recommended'
|
'plugin:prettier/recommended'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
plugins: {
|
plugins: {
|
||||||
'@typescript-eslint': fixupPluginRules(typescriptEslint),
|
'@typescript-eslint': fixupPluginRules(typescriptEslint),
|
||||||
jest: fixupPluginRules(jestPlugin),
|
'@vitest': fixupPluginRules(vitestPlugin),
|
||||||
prettier: fixupPluginRules(prettier)
|
prettier: fixupPluginRules(prettier)
|
||||||
},
|
},
|
||||||
|
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
globals: {
|
globals: {
|
||||||
...globals.node,
|
...globals.node,
|
||||||
...globals.jest
|
...vitestPlugin.environments.env.globals
|
||||||
},
|
},
|
||||||
parser: tsParser,
|
parser: tsParser,
|
||||||
ecmaVersion: 'latest',
|
ecmaVersion: 'latest',
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
||||||
const fs = require('fs');
|
|
||||||
const os = require('os');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ghaction-upx-'));
|
|
||||||
|
|
||||||
process.env = Object.assign({}, process.env, {
|
|
||||||
TEMP: tmpDir,
|
|
||||||
GITHUB_REPOSITORY: 'crazy-max/ghaction-upx',
|
|
||||||
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
|
|
||||||
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
clearMocks: true,
|
|
||||||
testEnvironment: 'node',
|
|
||||||
moduleFileExtensions: ['js', 'ts'],
|
|
||||||
testMatch: ['**/*.test.ts'],
|
|
||||||
transform: {
|
|
||||||
'^.+\\.ts$': 'ts-jest'
|
|
||||||
},
|
|
||||||
collectCoverageFrom: ['src/**/{!(main.ts),}.ts'],
|
|
||||||
coveragePathIgnorePatterns: ['dist/', 'node_modules/', '__tests__/'],
|
|
||||||
verbose: true
|
|
||||||
};
|
|
||||||
10
package.json
10
package.json
@@ -10,7 +10,7 @@
|
|||||||
"eslint:fix": "eslint --fix .",
|
"eslint:fix": "eslint --fix .",
|
||||||
"prettier": "prettier --check \"./**/*.ts\"",
|
"prettier": "prettier --check \"./**/*.ts\"",
|
||||||
"prettier:fix": "prettier --write \"./**/*.ts\"",
|
"prettier:fix": "prettier --write \"./**/*.ts\"",
|
||||||
"test": "jest",
|
"test": "vitest run",
|
||||||
"all": "yarn run build && yarn run format && yarn test"
|
"all": "yarn run build && yarn run format && yarn test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -38,14 +38,14 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^8.50.0",
|
"@typescript-eslint/eslint-plugin": "^8.50.0",
|
||||||
"@typescript-eslint/parser": "^8.50.0",
|
"@typescript-eslint/parser": "^8.50.0",
|
||||||
"@vercel/ncc": "^0.38.0",
|
"@vercel/ncc": "^0.38.0",
|
||||||
|
"@vitest/coverage-v8": "^4.0.18",
|
||||||
|
"@vitest/eslint-plugin": "^1.6.9",
|
||||||
"eslint": "^9.39.2",
|
"eslint": "^9.39.2",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-jest": "^29.5.0",
|
|
||||||
"eslint-plugin-prettier": "^5.5.4",
|
"eslint-plugin-prettier": "^5.5.4",
|
||||||
"jest": "^30.2.0",
|
|
||||||
"prettier": "^3.7.4",
|
"prettier": "^3.7.4",
|
||||||
"ts-jest": "^29.4.6",
|
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3",
|
||||||
|
"vitest": "^4.0.18"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import {describe, expect, it} from '@jest/globals';
|
import {describe, expect, it} from 'vitest';
|
||||||
import * as context from '../src/context';
|
|
||||||
import * as core from '@actions/core';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
|
import * as context from '../src/context';
|
||||||
|
|
||||||
describe('getInputList', () => {
|
describe('getInputList', () => {
|
||||||
it('handles single line correctly', async () => {
|
it('handles single line correctly', async () => {
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import {describe, expect, it} from '@jest/globals';
|
import {describe, expect, it} from 'vitest';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
import * as installer from '../src/installer';
|
import * as installer from '../src/installer';
|
||||||
|
|
||||||
describe('getRelease', () => {
|
describe('getRelease', () => {
|
||||||
@@ -14,6 +14,6 @@
|
|||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"**/*.test.ts",
|
"**/*.test.ts",
|
||||||
"jest.config.ts"
|
"vitest.config.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
16
vitest.config.ts
Normal file
16
vitest.config.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import {defineConfig} from 'vitest/config';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
environment: 'node',
|
||||||
|
setupFiles: ['./vitest.setup.ts'],
|
||||||
|
include: ['tests/**/*.test.ts'],
|
||||||
|
coverage: {
|
||||||
|
provider: 'v8',
|
||||||
|
reporter: ['text', 'clover', 'lcov'],
|
||||||
|
reportsDirectory: 'coverage',
|
||||||
|
include: ['src/**/*.ts'],
|
||||||
|
exclude: ['src/main.ts']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
11
vitest.setup.ts
Normal file
11
vitest.setup.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import * as fs from 'node:fs';
|
||||||
|
import * as os from 'node:os';
|
||||||
|
import * as path from 'node:path';
|
||||||
|
|
||||||
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ghaction-upx-'));
|
||||||
|
|
||||||
|
process.env = Object.assign({}, process.env, {
|
||||||
|
TEMP: tmpDir,
|
||||||
|
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
|
||||||
|
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user