Skip to content

Commit 209b8b3

Browse files
committed
WIP - linter fucked up
1 parent 7ef9f9c commit 209b8b3

10 files changed

+694
-2172
lines changed

.eslintignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
dist/
22
lib/
33
node_modules/
4-
jest.config.js
5-
__tests__/*.test.ts
4+
vitest.config.ts

.eslintrc.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"plugins": ["jest", "@typescript-eslint"],
3-
"extends": ["plugin:github/recommended"],
2+
"plugins": ["vitest", "@typescript-eslint"],
3+
"extends": ["plugin:github/recommended", "plugin:vitest/recommended"],
44
"parser": "@typescript-eslint/parser",
55
"parserOptions": {
66
"ecmaVersion": 9,
@@ -52,7 +52,6 @@
5252
},
5353
"env": {
5454
"node": true,
55-
"es6": true,
56-
"jest/globals": true
55+
"es6": true
5756
}
5857
}

__tests__/main.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as process from 'process'
22
import * as cp from 'child_process'
33
import * as path from 'path'
4-
import {test} from '@jest/globals'
54

65
// shows how the runner will run a javascript action with env / stdout protocol
7-
test('test runs', () => {
6+
it('test runs', () => {
87
process.env['INPUT_GROOVY-VERSION'] = '4.0.9'
98
const np = process.execPath
109
const ip = path.join(__dirname, '..', 'lib', 'main.js')

__tests__/release.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ describe('release', () => {
66
expect(versions.length).toBeGreaterThan(220)
77
expect(versions[0]).toBe('1.1-beta-2')
88
expect(versions).toContain('4.0.9')
9+
expect(1).toBe(1)
10+
expect(2).toBe(2)
11+
expect(1).toBe(1)
12+
expect(2).toBe(2)
913
})
1014

1115
it("should find the latest version that satisfies '2.x'", async () => {

__tests__/setup-groovy.test.ts

+41-38
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {describe, it, expect, beforeAll, beforeEach, vi} from 'vitest'
12
import * as core from '@actions/core'
23
import {existsSync} from 'fs'
34
import {rm} from 'fs/promises'
@@ -7,42 +8,44 @@ import {setupGroovy} from '../src/setup-groovy'
78
const tempDir = path.join(__dirname, 'runner', 'temp')
89
process.env['RUNNER_TEMP'] = tempDir
910

10-
jest.setTimeout(30_000)
11-
12-
describe('setup-groovy', () => {
13-
beforeAll(async () => {
14-
await rm(tempDir, {recursive: true, force: true})
15-
})
16-
17-
beforeEach(() => {
18-
jest.resetAllMocks()
19-
})
20-
21-
it.each(['4.0.9', '4.0.0-rc-2', '1.8.0-beta-1'])(
22-
"should setup groovy '%s'",
23-
async version => {
24-
const groovyExecutableFolderName = path.join(`groovy-${version}`, 'bin')
25-
jest.spyOn(core, 'getInput').mockReturnValue(version)
26-
27-
const groovyPath = await setupGroovy()
28-
const groovyHome = path.dirname(groovyPath)
29-
30-
expect(groovyPath.endsWith(groovyExecutableFolderName)).toBe(true)
31-
expect(await existsSync(path.join(groovyPath, 'groovy'))).toBe(true)
32-
expect(process.env['GROOVY_HOME']).toBe(groovyHome)
33-
}
34-
)
35-
36-
it("should throw an error when version can't be found", async () => {
37-
const version = '0.0.1'
38-
jest.spyOn(core, 'getInput').mockReturnValue(version)
39-
jest.spyOn(core, 'error').mockImplementation()
40-
41-
await expect(setupGroovy()).rejects.toThrow(
42-
`Unable to find matching Groovy version for: '0.0.1'`
11+
describe(
12+
'setup-groovy',
13+
() => {
14+
beforeAll(async () => {
15+
await rm(tempDir, {recursive: true, force: true})
16+
})
17+
18+
beforeEach(() => {
19+
vi.resetAllMocks()
20+
})
21+
22+
it.each(['4.0.9', '4.0.0-rc-2', '1.8.0-beta-1'])(
23+
"should setup groovy '%s'",
24+
async version => {
25+
const groovyExecutableFolderName = path.join(`groovy-${version}`, 'bin')
26+
vi.spyOn(core, 'getInput').mockReturnValue(version)
27+
28+
const groovyPath = await setupGroovy()
29+
const groovyHome = path.dirname(groovyPath)
30+
31+
expect(groovyPath.endsWith(groovyExecutableFolderName)).toBe(true)
32+
expect(await existsSync(path.join(groovyPath, 'groovy'))).toBe(true)
33+
expect(process.env['GROOVY_HOME']).toBe(groovyHome)
34+
}
4335
)
44-
expect(core.error).toBeCalledWith(
45-
new Error("Unable to find matching Groovy version for: '0.0.1'")
46-
)
47-
})
48-
})
36+
37+
it("should throw an error when version can't be found", async () => {
38+
const version = '0.0.1'
39+
vi.spyOn(core, 'getInput').mockReturnValue(version)
40+
vi.spyOn(core, 'error').mockImplementation(() => vi.fn)
41+
42+
await expect(setupGroovy()).rejects.toThrow(
43+
`Unable to find matching Groovy version for: '0.0.1'`
44+
)
45+
expect(core.error).toBeCalledWith(
46+
new Error("Unable to find matching Groovy version for: '0.0.1'")
47+
)
48+
})
49+
},
50+
{timeout: 30_000}
51+
)

jest.config.js

-11
This file was deleted.

package.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"format-check": "prettier --check **/*.ts",
1111
"lint": "eslint src/**/*.ts",
1212
"package": "ncc build --source-map --license licenses.txt",
13-
"test": "jest",
14-
"coverage": "jest --collectCoverage",
13+
"test": "vitest",
14+
"coverage": "vitest run --coverage",
1515
"update-dist": "yarn run build && yarn run package",
1616
"all": "yarn run build && yarn run format && yarn run lint && yarn run package && yarn coverage"
1717
},
@@ -38,20 +38,19 @@
3838
},
3939
"devDependencies": {
4040
"@octokit/types": "11.1.0",
41-
"@types/jest": "29.5.3",
4241
"@types/node": "16.18.39",
4342
"@types/semver": "7.5.0",
4443
"@typescript-eslint/parser": "6.2.1",
4544
"@vercel/ncc": "0.36.1",
45+
"@vitest/coverage-v8": "0.34.1",
4646
"eslint": "8.46.0",
4747
"eslint-plugin-github": "4.9.2",
48-
"eslint-plugin-jest": "27.2.3",
4948
"eslint-plugin-prettier": "5.0.0",
50-
"jest": "29.6.2",
49+
"eslint-plugin-vitest": "0.2.8",
5150
"js-yaml": "4.1.0",
5251
"prettier": "3.0.1",
53-
"ts-jest": "29.1.1",
5452
"typescript": "5.1.6",
53+
"vitest": "0.34.1",
5554
"webpack": "5.88.2"
5655
}
5756
}

tsconfig.json

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{
22
"compilerOptions": {
3-
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
4-
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
5-
"outDir": "./lib", /* Redirect output structure to the directory. */
6-
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
7-
"strict": true, /* Enable all strict type-checking options. */
8-
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
9-
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
3+
"target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
4+
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
5+
"outDir": "./lib" /* Redirect output structure to the directory. */,
6+
"strict": true /* Enable all strict type-checking options. */,
7+
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
8+
"esModuleInterop": true,
9+
"types": [
10+
"node",
11+
"vitest/globals"
12+
] /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
1013
},
11-
"exclude": ["node_modules", "**/*.test.ts"]
14+
"include": ["src/**/*", "__tests__/**/*"],
15+
"exclude": ["node_modules", "vitest.config.ts"]
1216
}

vitest.config.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {defineConfig} from 'vitest/config'
2+
3+
export default defineConfig({
4+
test: {
5+
globals: true,
6+
clearMocks: true
7+
}
8+
})

0 commit comments

Comments
 (0)