switch from Jest to Vitest
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
@@ -48,7 +48,7 @@ jobs:
|
||||
-
|
||||
name: Check coverage
|
||||
run: |
|
||||
if [ -f ./coverage/clover.xml ] && [ ! -f ./coverage/allSkipped.txt ]; then
|
||||
if [ -f ./coverage/clover.xml ]; then
|
||||
echo "RUN_CODECOV=true" >> $GITHUB_ENV
|
||||
else
|
||||
echo "RUN_CODECOV=false" >> $GITHUB_ENV
|
||||
@@ -206,7 +206,7 @@ jobs:
|
||||
if (testName) {
|
||||
args.push(`--testNamePattern=^${testName} `);
|
||||
}
|
||||
args.push(`--runTestsByPath`, `__tests__/${{ matrix.test }}`, `--coverageDirectory=./coverage`);
|
||||
args.push(`__tests__/${{ matrix.test }}`, `--coverage.reportsDirectory=./coverage`);
|
||||
await exec.exec('yarn', args);
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -218,7 +218,7 @@ jobs:
|
||||
-
|
||||
name: Check coverage
|
||||
run: |
|
||||
if [ -f ./coverage/clover.xml ] && [ ! -f ./coverage/allSkipped.txt ]; then
|
||||
if [ -f ./coverage/clover.xml ]; then
|
||||
echo "RUN_CODECOV=true" >> $GITHUB_ENV
|
||||
else
|
||||
echo "RUN_CODECOV=false" >> $GITHUB_ENV
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {jest} from '@jest/globals';
|
||||
import {vi} from 'vitest';
|
||||
|
||||
export const context = {
|
||||
repo: {
|
||||
@@ -221,4 +221,4 @@ export const context = {
|
||||
}
|
||||
};
|
||||
|
||||
export const getOctokit = jest.fn();
|
||||
export const getOctokit = vi.fn();
|
||||
|
||||
@@ -14,17 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {jest} from '@jest/globals';
|
||||
import {vi} from 'vitest';
|
||||
import os from 'os';
|
||||
|
||||
export const mockPlatform = (platform: NodeJS.Platform) => {
|
||||
return jest.spyOn(os, 'platform').mockImplementation(() => platform);
|
||||
return vi.spyOn(os, 'platform').mockImplementation(() => platform);
|
||||
};
|
||||
|
||||
export const mockArch = (arch: string) => {
|
||||
return jest.spyOn(os, 'arch').mockImplementation(() => arch);
|
||||
return vi.spyOn(os, 'arch').mockImplementation(() => arch);
|
||||
};
|
||||
|
||||
export const mockHomedir = (dir: string) => {
|
||||
return jest.spyOn(os, 'homedir').mockImplementation(() => dir);
|
||||
return vi.spyOn(os, 'homedir').mockImplementation(() => dir);
|
||||
};
|
||||
|
||||
38
__tests__/.setup/list-itg-tests.mjs
Normal file
38
__tests__/.setup/list-itg-tests.mjs
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright 2026 actions-toolkit authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
const testsRoot = path.resolve('__tests__');
|
||||
const results = [];
|
||||
|
||||
const walk = dir => {
|
||||
for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
|
||||
const fullPath = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
walk(fullPath);
|
||||
continue;
|
||||
}
|
||||
if (entry.isFile() && entry.name.endsWith('.test.itg.ts')) {
|
||||
results.push(fullPath.replaceAll(path.sep, '/'));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
walk(testsRoot);
|
||||
results.sort((a, b) => a.localeCompare(b));
|
||||
process.stdout.write(`${results.join('\n')}\n`);
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright 2024 actions-toolkit authors
|
||||
* Copyright 2026 actions-toolkit authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,15 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||
const fs = require('fs');
|
||||
import {vi} from 'vitest';
|
||||
|
||||
module.exports = results => {
|
||||
const allSkipped = results.testResults.every(result => result.skipped);
|
||||
if (allSkipped) {
|
||||
console.log('All tests were skipped!');
|
||||
fs.mkdirSync('./coverage', {recursive: true});
|
||||
fs.closeSync(fs.openSync('./coverage/allSkipped.txt', 'w'));
|
||||
}
|
||||
return results;
|
||||
};
|
||||
vi.mock('@actions/github');
|
||||
36
__tests__/.setup/setup.unit.ts
Normal file
36
__tests__/.setup/setup.unit.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright 2026 actions-toolkit authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import {vi} from 'vitest';
|
||||
|
||||
const envTmpDir = process.env.DOCKER_ACTIONS_TOOLKIT_TMPDIR;
|
||||
const tmpDir = envTmpDir || fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-'));
|
||||
|
||||
vi.mock('@actions/github');
|
||||
|
||||
process.env = Object.assign({}, process.env, {
|
||||
DOCKER_ACTIONS_TOOLKIT_TMPDIR: tmpDir,
|
||||
TEMP: tmpDir,
|
||||
GITHUB_REPOSITORY: 'docker/actions-toolkit',
|
||||
GITHUB_RUN_ATTEMPT: '2',
|
||||
GITHUB_RUN_ID: '2188748038',
|
||||
GITHUB_RUN_NUMBER: '15',
|
||||
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
|
||||
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
|
||||
});
|
||||
@@ -14,14 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, jest, test} from '@jest/globals';
|
||||
import {describe, expect, it, vi, test} from 'vitest';
|
||||
|
||||
import {BuildKit} from '../../src/buildkit/buildkit';
|
||||
import {Builder} from '../../src/buildx/builder';
|
||||
|
||||
import {BuilderInfo} from '../../src/types/buildx/builder';
|
||||
|
||||
jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
|
||||
vi.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
|
||||
return {
|
||||
name: 'builder2',
|
||||
driver: 'docker-container',
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, jest, test, afterEach} from '@jest/globals';
|
||||
import {describe, expect, vi, test, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -25,14 +25,14 @@ import {Context} from '../../src/context';
|
||||
|
||||
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildkit-config-'));
|
||||
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||
const tmpName = path.join(tmpDir, '.tmpname-vi');
|
||||
|
||||
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
return tmpDir;
|
||||
});
|
||||
|
||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
return tmpName;
|
||||
});
|
||||
|
||||
@@ -66,7 +66,7 @@ describe('resolve', () => {
|
||||
const configValue = fs.readFileSync(tmpName, 'utf-8');
|
||||
expect(configValue).toEqual(exValue);
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(e.message).toEqual(error?.message);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
||||
import {beforeEach, describe, expect, vi, test} from 'vitest';
|
||||
|
||||
import {Git} from '../../src/buildkit/git';
|
||||
|
||||
import {GitRef, GitURL} from '../../src/types/buildkit/git';
|
||||
|
||||
beforeEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
describe('parseURL', () => {
|
||||
@@ -195,7 +195,7 @@ describe('parseURL', () => {
|
||||
if (!expectedErr) {
|
||||
console.log(err);
|
||||
}
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(expectedErr).toBeTruthy();
|
||||
}
|
||||
});
|
||||
@@ -337,7 +337,7 @@ describe('parseRef', () => {
|
||||
if (expected) {
|
||||
console.log(err);
|
||||
}
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(expected).toBeUndefined();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, test} from '@jest/globals';
|
||||
import {describe, expect, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {afterEach, describe, expect, it, jest, test} from '@jest/globals';
|
||||
import {afterEach, describe, expect, it, vi, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -29,15 +29,15 @@ import {BuildMetadata} from '../../src/types/buildx/build';
|
||||
|
||||
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-bake-'));
|
||||
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||
const tmpName = path.join(tmpDir, '.tmpname-vi');
|
||||
const metadata = JSON.parse(fs.readFileSync(path.join(fixturesDir, 'metadata-bake.json'), 'utf-8'));
|
||||
|
||||
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
return tmpDir;
|
||||
});
|
||||
|
||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
return tmpName;
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {afterEach, beforeEach, describe, expect, it, jest, test} from '@jest/globals';
|
||||
import {afterEach, beforeEach, describe, expect, it, vi, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -25,15 +25,15 @@ import {Build} from '../../src/buildx/build';
|
||||
|
||||
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-build-'));
|
||||
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||
const tmpName = path.join(tmpDir, '.tmpname-vi');
|
||||
const metadata = JSON.parse(fs.readFileSync(path.join(fixturesDir, 'metadata-build.json'), 'utf-8'));
|
||||
|
||||
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
return tmpDir;
|
||||
});
|
||||
|
||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
return tmpName;
|
||||
});
|
||||
|
||||
@@ -191,7 +191,7 @@ describe('resolveSecret', () => {
|
||||
expect(secret).toEqual(`id=${exKey},src=${tmpName}`);
|
||||
expect(fs.readFileSync(tmpName, 'utf-8')).toEqual(exValue);
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(e.message).toEqual(error?.message);
|
||||
}
|
||||
});
|
||||
@@ -206,7 +206,7 @@ describe('resolveSecret', () => {
|
||||
const secret = Build.resolveSecretEnv(kvp);
|
||||
expect(secret).toEqual(`id=${exKey},env=${exValue}`);
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(e.message).toEqual(error?.message);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, jest, test} from '@jest/globals';
|
||||
import {describe, expect, it, vi, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -25,7 +25,7 @@ import {BuilderInfo} from '../../src/types/buildx/builder';
|
||||
|
||||
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||
|
||||
jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
|
||||
vi.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
|
||||
return {
|
||||
name: 'builder2',
|
||||
driver: 'docker-container',
|
||||
@@ -46,7 +46,7 @@ jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<Bu
|
||||
|
||||
describe('exists', () => {
|
||||
it('valid', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const builder = new Builder();
|
||||
await builder.exists('foo');
|
||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx', 'inspect', 'foo'], {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it} from '@jest/globals';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, jest, test, beforeEach, afterEach} from '@jest/globals';
|
||||
import {describe, expect, it, vi, test, beforeEach, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -29,14 +29,14 @@ import {Cert, LocalState} from '../../src/types/buildx/buildx';
|
||||
|
||||
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-buildx-'));
|
||||
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||
const tmpName = path.join(tmpDir, '.tmpname-vi');
|
||||
|
||||
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
return tmpDir;
|
||||
});
|
||||
|
||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
return tmpName;
|
||||
});
|
||||
|
||||
@@ -47,7 +47,7 @@ afterEach(() => {
|
||||
describe('configDir', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
BUILDX_CONFIG: '/var/docker/buildx',
|
||||
@@ -69,7 +69,7 @@ describe('configDir', () => {
|
||||
describe('certsDir', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
BUILDX_CONFIG: '/var/docker/buildx'
|
||||
@@ -86,7 +86,7 @@ describe('certsDir', () => {
|
||||
|
||||
describe('isAvailable', () => {
|
||||
it('docker cli', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const buildx = new Buildx({
|
||||
standalone: false
|
||||
});
|
||||
@@ -97,7 +97,7 @@ describe('isAvailable', () => {
|
||||
});
|
||||
});
|
||||
it('standalone', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const buildx = new Buildx({
|
||||
standalone: true
|
||||
});
|
||||
@@ -111,7 +111,7 @@ describe('isAvailable', () => {
|
||||
|
||||
describe('printVersion', () => {
|
||||
it('docker cli', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
const buildx = new Buildx({
|
||||
standalone: false
|
||||
});
|
||||
@@ -121,7 +121,7 @@ describe('printVersion', () => {
|
||||
});
|
||||
});
|
||||
it('standalone', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
const buildx = new Buildx({
|
||||
standalone: true
|
||||
});
|
||||
@@ -164,7 +164,7 @@ describe('versionSatisfies', () => {
|
||||
describe('resolveCertsDriverOpts', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
BUILDX_CONFIG: path.join(tmpDir, 'resolveCertsDriverOpts', 'buildx')
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test} from '@jest/globals';
|
||||
import {describe, expect, it, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it} from '@jest/globals';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, test} from '@jest/globals';
|
||||
import {describe, expect, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import {Install} from '../../src/buildx/install';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test, afterEach} from '@jest/globals';
|
||||
import {describe, expect, it, test, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it} from '@jest/globals';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, jest, test, afterEach} from '@jest/globals';
|
||||
import {describe, expect, it, vi, test, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -27,14 +27,14 @@ import {Exec} from '../../src/exec';
|
||||
import {Compose} from '../../src/compose/compose';
|
||||
|
||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'compose-compose-'));
|
||||
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||
const tmpName = path.join(tmpDir, '.tmpname-vi');
|
||||
|
||||
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
return tmpDir;
|
||||
});
|
||||
|
||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
return tmpName;
|
||||
});
|
||||
|
||||
@@ -44,7 +44,7 @@ afterEach(() => {
|
||||
|
||||
describe('isAvailable', () => {
|
||||
it('docker cli', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const compose = new Compose({
|
||||
standalone: false
|
||||
});
|
||||
@@ -55,7 +55,7 @@ describe('isAvailable', () => {
|
||||
});
|
||||
});
|
||||
it('standalone', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const compose = new Compose({
|
||||
standalone: true
|
||||
});
|
||||
@@ -69,7 +69,7 @@ describe('isAvailable', () => {
|
||||
|
||||
describe('printVersion', () => {
|
||||
it('docker cli', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
const compose = new Compose({
|
||||
standalone: false
|
||||
});
|
||||
@@ -79,7 +79,7 @@ describe('printVersion', () => {
|
||||
});
|
||||
});
|
||||
it('standalone', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
const compose = new Compose({
|
||||
standalone: true
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, test} from '@jest/globals';
|
||||
import {describe, expect, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import {Install} from '../../src/compose/install';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test, afterEach} from '@jest/globals';
|
||||
import {describe, expect, it, test, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, jest, it, afterEach, beforeEach, test} from '@jest/globals';
|
||||
import {describe, expect, vi, it, afterEach, beforeEach, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -23,14 +23,14 @@ import * as rimraf from 'rimraf';
|
||||
import {Context} from '../src/context';
|
||||
|
||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'context-'));
|
||||
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||
const tmpName = path.join(tmpDir, '.tmpname-vi');
|
||||
|
||||
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
return tmpDir;
|
||||
});
|
||||
|
||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
return tmpName;
|
||||
});
|
||||
|
||||
@@ -47,7 +47,7 @@ describe('gitRef', () => {
|
||||
describe('parseGitRef', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
DOCKER_GIT_CONTEXT_PR_HEAD_REF: ''
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, jest, test} from '@jest/globals';
|
||||
import {describe, expect, it, vi, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import * as semver from 'semver';
|
||||
@@ -26,7 +26,7 @@ const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||
|
||||
describe('isAvailable', () => {
|
||||
it('checks Cosign is available', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const cosign = new Cosign();
|
||||
await cosign.isAvailable();
|
||||
expect(execSpy).toHaveBeenCalledWith(`cosign`, [], {
|
||||
@@ -38,7 +38,7 @@ describe('isAvailable', () => {
|
||||
|
||||
describe('printVersion', () => {
|
||||
it('prints Cosign version', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
const cosign = new Cosign();
|
||||
await cosign.printVersion();
|
||||
expect(execSpy).toHaveBeenCalledWith(`cosign`, ['version', '--json'], {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test} from '@jest/globals';
|
||||
import {describe, expect, it, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import {Install} from '../../src/cosign/install';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test, afterEach} from '@jest/globals';
|
||||
import {describe, expect, it, test, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test} from '@jest/globals';
|
||||
import {describe, expect, it, test} from 'vitest';
|
||||
|
||||
import {Docker} from '../../src/docker/docker';
|
||||
|
||||
@@ -55,7 +55,7 @@ maybe('pull', () => {
|
||||
if (err === undefined) {
|
||||
throw new Error(`Expected no error, but got: ${e.message}`);
|
||||
}
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(e.message).toContain(err);
|
||||
}
|
||||
}, 600000);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {afterEach, beforeEach, describe, expect, it, jest} from '@jest/globals';
|
||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -37,7 +37,7 @@ afterEach(function () {
|
||||
describe('configDir', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
DOCKER_CONFIG: '/var/docker/config'
|
||||
@@ -59,7 +59,7 @@ describe('configDir', () => {
|
||||
describe('configFile', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
if (!fs.existsSync(tmpDir)) {
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
}
|
||||
@@ -97,7 +97,7 @@ describe('configFile', () => {
|
||||
|
||||
describe('isAvailable', () => {
|
||||
it('cli', async () => {
|
||||
const ioWhichSpy = jest.spyOn(io, 'which');
|
||||
const ioWhichSpy = vi.spyOn(io, 'which');
|
||||
await Docker.isAvailable();
|
||||
expect(ioWhichSpy).toHaveBeenCalledTimes(1);
|
||||
expect(ioWhichSpy).toHaveBeenCalledWith('docker', true);
|
||||
@@ -106,7 +106,7 @@ describe('isAvailable', () => {
|
||||
|
||||
describe('exec', () => {
|
||||
it('returns docker version', async () => {
|
||||
const execSpy = jest.spyOn(Docker, 'exec');
|
||||
const execSpy = vi.spyOn(Docker, 'exec');
|
||||
await Docker.exec(['version'], {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
@@ -133,7 +133,7 @@ describe('exec', () => {
|
||||
|
||||
describe('getExecOutput', () => {
|
||||
it('returns docker version', async () => {
|
||||
const execSpy = jest.spyOn(Docker, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Docker, 'getExecOutput');
|
||||
await Docker.getExecOutput(['version'], {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
@@ -160,7 +160,7 @@ describe('getExecOutput', () => {
|
||||
|
||||
describe('context', () => {
|
||||
it('call docker context show', async () => {
|
||||
const execSpy = jest.spyOn(Docker, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Docker, 'getExecOutput');
|
||||
await Docker.context().catch(() => {
|
||||
// noop
|
||||
});
|
||||
@@ -182,7 +182,7 @@ describe('context', () => {
|
||||
|
||||
describe('contextInspect', () => {
|
||||
it('call docker context inspect', async () => {
|
||||
const execSpy = jest.spyOn(Docker, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Docker, 'getExecOutput');
|
||||
await Docker.contextInspect('foo').catch(() => {
|
||||
// noop
|
||||
});
|
||||
@@ -204,7 +204,7 @@ describe('contextInspect', () => {
|
||||
|
||||
describe('printVersion', () => {
|
||||
it('call docker version', async () => {
|
||||
const execSpy = jest.spyOn(Docker, 'exec');
|
||||
const execSpy = vi.spyOn(Docker, 'exec');
|
||||
await Docker.printVersion().catch(() => {
|
||||
// noop
|
||||
});
|
||||
@@ -220,7 +220,7 @@ describe('printVersion', () => {
|
||||
|
||||
describe('printInfo', () => {
|
||||
it('call docker info', async () => {
|
||||
const execSpy = jest.spyOn(Docker, 'exec');
|
||||
const execSpy = vi.spyOn(Docker, 'exec');
|
||||
await Docker.printInfo().catch(() => {
|
||||
// noop
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {beforeAll, describe, test, expect} from '@jest/globals';
|
||||
import {beforeAll, describe, test, expect} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, jest, test, beforeEach, afterEach, it} from '@jest/globals';
|
||||
import {describe, expect, vi, test, beforeEach, afterEach, it} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -103,7 +103,7 @@ describe('getRelease', () => {
|
||||
describe('limaImage', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
LIMA_IMAGES: `x86_64:https://cloud-images.ubuntu.com/releases/23.10/release-20231011/ubuntu-23.10-server-cloudimg-amd64.img@sha256:f6529be56da3429a56e4f5ef202bf4958201bc63f8541e478caa6e8eb712e635
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, jest, it} from '@jest/globals';
|
||||
import {describe, expect, vi, it} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -27,11 +27,11 @@ import repoAllTagsFixture from './.fixtures/dockerhub-repoalltags.json';
|
||||
|
||||
describe('getRepository', () => {
|
||||
it('returns repo info', async () => {
|
||||
jest.spyOn(DockerHub.prototype, 'getRepository').mockImplementation((): Promise<RepositoryResponse> => {
|
||||
vi.spyOn(DockerHub.prototype, 'getRepository').mockImplementation((): Promise<RepositoryResponse> => {
|
||||
return <Promise<RepositoryResponse>>(repoInfoFixture as unknown);
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
jest.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
|
||||
vi.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
|
||||
const dockerhub = await DockerHub.build({
|
||||
credentials: {
|
||||
username: 'foo',
|
||||
@@ -50,11 +50,11 @@ describe('getRepository', () => {
|
||||
|
||||
describe('getRepositoryTags', () => {
|
||||
it('return repo tags', async () => {
|
||||
jest.spyOn(DockerHub.prototype, 'getRepositoryTags').mockImplementation((): Promise<RepositoryTagsResponse> => {
|
||||
vi.spyOn(DockerHub.prototype, 'getRepositoryTags').mockImplementation((): Promise<RepositoryTagsResponse> => {
|
||||
return <Promise<RepositoryTagsResponse>>(repoTagsFixture as unknown);
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
jest.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
|
||||
vi.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
|
||||
const dockerhub = await DockerHub.build({
|
||||
credentials: {
|
||||
username: 'foo',
|
||||
@@ -74,11 +74,11 @@ describe('getRepositoryTags', () => {
|
||||
|
||||
describe('getRepositoryAllTags', () => {
|
||||
it('return repo all tags', async () => {
|
||||
jest.spyOn(DockerHub.prototype, 'getRepositoryAllTags').mockImplementation((): Promise<RepositoryTagsResponse> => {
|
||||
vi.spyOn(DockerHub.prototype, 'getRepositoryAllTags').mockImplementation((): Promise<RepositoryTagsResponse> => {
|
||||
return <Promise<RepositoryTagsResponse>>(repoAllTagsFixture as unknown);
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
jest.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
|
||||
vi.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
|
||||
const dockerhub = await DockerHub.build({
|
||||
credentials: {
|
||||
username: 'foo',
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, jest} from '@jest/globals';
|
||||
import {describe, expect, it, vi} from 'vitest';
|
||||
|
||||
import {Exec} from '../src/exec';
|
||||
|
||||
describe('exec', () => {
|
||||
it('returns docker version', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
await Exec.exec('docker', ['version'], {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
@@ -34,7 +34,7 @@ describe('exec', () => {
|
||||
|
||||
describe('getExecOutput', () => {
|
||||
it('returns docker version', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
await Exec.getExecOutput('docker', ['version'], {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
|
||||
@@ -14,19 +14,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {beforeEach, describe, expect, it, jest} from '@jest/globals';
|
||||
import {beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
|
||||
import {Git as GitMocked} from '../src/git';
|
||||
import {Exec} from '../src/exec';
|
||||
import {ExecOutput} from '@actions/exec';
|
||||
|
||||
beforeEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
describe('context', () => {
|
||||
it('returns mocked ref and sha', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -54,7 +54,7 @@ describe('context', () => {
|
||||
|
||||
describe('isInsideWorkTree', () => {
|
||||
it('have been called', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
try {
|
||||
await GitMocked.isInsideWorkTree();
|
||||
} catch {
|
||||
@@ -72,8 +72,8 @@ describe('remoteSha', () => {
|
||||
expect(await GitMocked.remoteSha('https://github.com/docker/buildx.git', 'refs/pull/648/head')).toEqual('f11797113e5a9b86bd976329c5dbb8a8bfdfadfa');
|
||||
});
|
||||
it('returns sha using github api', async () => {
|
||||
jest.resetModules();
|
||||
jest.unmock('@actions/github');
|
||||
vi.resetModules();
|
||||
vi.unmock('@actions/github');
|
||||
const {Git} = await import('../src/git');
|
||||
expect(await Git.remoteSha('https://github.com/docker/buildx.git', 'refs/pull/648/head', process.env.GITHUB_TOKEN)).toEqual('f11797113e5a9b86bd976329c5dbb8a8bfdfadfa');
|
||||
});
|
||||
@@ -81,7 +81,7 @@ describe('remoteSha', () => {
|
||||
|
||||
describe('remoteURL', () => {
|
||||
it('have been called', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
try {
|
||||
await GitMocked.remoteURL();
|
||||
} catch {
|
||||
@@ -96,7 +96,7 @@ describe('remoteURL', () => {
|
||||
|
||||
describe('ref', () => {
|
||||
it('returns mocked ref', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -120,7 +120,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('returns mocked detached tag ref', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -144,7 +144,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('returns mocked detached tag ref (shallow clone)', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -168,7 +168,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('returns mocked detached pull request merge ref (shallow clone)', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -192,7 +192,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('should throws an error when detached HEAD ref is not supported', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -214,7 +214,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('returns mocked detached branch ref', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -238,7 +238,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('returns mocked detached branch ref checked out by SHA', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -262,7 +262,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('infers ref from local branch when detached HEAD returns only "HEAD"', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -289,7 +289,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('infers ref from local branch when detached HEAD returns only "grafted, HEAD"', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -316,7 +316,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('infers ref from remote branch when no local branch contains HEAD', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -346,7 +346,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('infers ref from tag when no branch contains HEAD', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -379,7 +379,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('throws error when cannot infer ref from detached HEAD', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -410,7 +410,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('handles remote ref without branch pattern when inferring from remote', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -442,7 +442,7 @@ describe('ref', () => {
|
||||
|
||||
describe('fullCommit', () => {
|
||||
it('have been called', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
try {
|
||||
await GitMocked.fullCommit();
|
||||
} catch {
|
||||
@@ -457,7 +457,7 @@ describe('fullCommit', () => {
|
||||
|
||||
describe('shortCommit', () => {
|
||||
it('have been called', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
try {
|
||||
await GitMocked.shortCommit();
|
||||
} catch {
|
||||
@@ -472,7 +472,7 @@ describe('shortCommit', () => {
|
||||
|
||||
describe('tag', () => {
|
||||
it('have been called', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
try {
|
||||
await GitMocked.tag();
|
||||
} catch {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it} from '@jest/globals';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, jest, it, beforeEach, afterEach, test} from '@jest/globals';
|
||||
import {describe, expect, vi, it, beforeEach, afterEach, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
@@ -28,7 +28,7 @@ const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||
|
||||
describe('repoData', () => {
|
||||
it('returns GitHub repo data', async () => {
|
||||
jest.spyOn(GitHub.prototype, 'repoData').mockImplementation((): Promise<GitHubRepo> => {
|
||||
vi.spyOn(GitHub.prototype, 'repoData').mockImplementation((): Promise<GitHubRepo> => {
|
||||
return <Promise<GitHubRepo>>(repoFixture as unknown);
|
||||
});
|
||||
const github = new GitHub();
|
||||
@@ -49,8 +49,8 @@ describe('repoData (api)', () => {
|
||||
};
|
||||
|
||||
try {
|
||||
jest.resetModules();
|
||||
jest.unmock('@actions/github');
|
||||
vi.resetModules();
|
||||
vi.unmock('@actions/github');
|
||||
const {GitHub} = await import('../../src/github/github');
|
||||
const github = new GitHub({token: process.env.GITHUB_TOKEN});
|
||||
const repo = await github.repoData();
|
||||
@@ -97,7 +97,7 @@ describe('releases', () => {
|
||||
describe('serverURL', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
GITHUB_SERVER_URL: 'https://foo.github.com'
|
||||
@@ -118,7 +118,7 @@ describe('serverURL', () => {
|
||||
describe('apiURL', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
GITHUB_API_URL: 'https://bar.github.com'
|
||||
@@ -154,7 +154,7 @@ describe('workflowRunURL', () => {
|
||||
describe('actionsRuntimeToken', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv
|
||||
};
|
||||
@@ -184,7 +184,7 @@ describe('actionsRuntimeToken', () => {
|
||||
describe('printActionsRuntimeTokenACs', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv
|
||||
};
|
||||
@@ -201,7 +201,7 @@ describe('printActionsRuntimeTokenACs', () => {
|
||||
await expect(GitHub.printActionsRuntimeTokenACs()).rejects.toThrow(new Error('Cannot parse GitHub Actions Runtime Token: Invalid token specified: missing part #2'));
|
||||
});
|
||||
it('refs/heads/master', async () => {
|
||||
const infoSpy = jest.spyOn(core, 'info');
|
||||
const infoSpy = vi.spyOn(core, 'info');
|
||||
process.env.ACTIONS_RUNTIME_TOKEN = fs.readFileSync(path.join(fixturesDir, 'runtimeToken.txt')).toString().trim();
|
||||
await GitHub.printActionsRuntimeTokenACs();
|
||||
expect(infoSpy).toHaveBeenCalledTimes(1);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test} from '@jest/globals';
|
||||
import {describe, expect, it, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {afterEach, describe, expect, test} from '@jest/globals';
|
||||
import {afterEach, describe, expect, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, test} from '@jest/globals';
|
||||
import {describe, expect, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import {Install} from '../../src/regclient/install';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test, afterEach} from '@jest/globals';
|
||||
import {describe, expect, it, test, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, jest, test} from '@jest/globals';
|
||||
import {describe, expect, it, vi, test} from 'vitest';
|
||||
import * as semver from 'semver';
|
||||
|
||||
import {Exec} from '../../src/exec';
|
||||
@@ -82,7 +82,7 @@ describe('image config', () => {
|
||||
|
||||
describe('isAvailable', () => {
|
||||
it('checks regctl is available', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const regctl = new Regctl();
|
||||
await regctl.isAvailable();
|
||||
expect(execSpy).toHaveBeenCalledWith(`regctl`, [], {
|
||||
@@ -94,7 +94,7 @@ describe('isAvailable', () => {
|
||||
|
||||
describe('printVersion', () => {
|
||||
it('prints regctl version', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
const regctl = new Regctl();
|
||||
await regctl.printVersion();
|
||||
expect(execSpy).toHaveBeenCalledWith(`regctl`, ['version'], {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {beforeAll, describe, expect, jest, it} from '@jest/globals';
|
||||
import {beforeAll, describe, expect, vi, it} from 'vitest';
|
||||
import * as path from 'path';
|
||||
|
||||
import {Buildx} from '../../src/buildx/buildx';
|
||||
@@ -31,7 +31,7 @@ const runTest = process.env.GITHUB_ACTIONS && process.env.GITHUB_ACTIONS === 'tr
|
||||
const maybeIdToken = runTest && process.env.ACTIONS_ID_TOKEN_REQUEST_URL ? describe : describe.skip;
|
||||
|
||||
// needs current GitHub repo info
|
||||
jest.unmock('@actions/github');
|
||||
vi.unmock('@actions/github');
|
||||
|
||||
beforeAll(async () => {
|
||||
const cosignInstall = new CosignInstall();
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {beforeAll, describe, expect, jest, it, test} from '@jest/globals';
|
||||
import {beforeAll, describe, expect, vi, it, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -34,7 +34,7 @@ const maybe = runTest ? describe : describe.skip;
|
||||
const maybeIdToken = runTest && process.env.ACTIONS_ID_TOKEN_REQUEST_URL ? describe : describe.skip;
|
||||
|
||||
// needs current GitHub repo info
|
||||
jest.unmock('@actions/github');
|
||||
vi.unmock('@actions/github');
|
||||
|
||||
beforeAll(async () => {
|
||||
const cosignInstall = new CosignInstall();
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, test} from '@jest/globals';
|
||||
import {describe, expect, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import {Install} from '../../src/undock/install';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test, afterEach} from '@jest/globals';
|
||||
import {describe, expect, it, test, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it} from '@jest/globals';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import {describe, expect, it, jest, test} from '@jest/globals';
|
||||
import {describe, expect, it, vi, test} from 'vitest';
|
||||
import * as semver from 'semver';
|
||||
|
||||
import {Exec} from '../../src/exec';
|
||||
@@ -43,7 +43,7 @@ describe('run', () => {
|
||||
|
||||
describe('isAvailable', () => {
|
||||
it('checks undock is available', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const undock = new Undock();
|
||||
await undock.isAvailable();
|
||||
expect(execSpy).toHaveBeenCalledWith(`undock`, [], {
|
||||
@@ -55,7 +55,7 @@ describe('isAvailable', () => {
|
||||
|
||||
describe('printVersion', () => {
|
||||
it('prints undock version', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
const undock = new Undock();
|
||||
await undock.printVersion();
|
||||
expect(execSpy).toHaveBeenCalledWith(`undock`, ['--version'], {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test} from '@jest/globals';
|
||||
import {describe, expect, it, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -326,10 +326,10 @@ describe('parseBool', () => {
|
||||
].forEach(({input, expected, throwsError}) => {
|
||||
test(`parseBool("${input}")`, () => {
|
||||
if (throwsError) {
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(() => Util.parseBool(input)).toThrow();
|
||||
} else {
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(Util.parseBool(input)).toBe(expected);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -96,8 +96,8 @@ RUN --mount=type=bind,target=.,rw \
|
||||
--mount=type=bind,from=undock,source=/usr/local/bin/undock,target=/usr/bin/undock \
|
||||
--mount=type=bind,from=regctl,source=/regctl,target=/usr/bin/regctl \
|
||||
--mount=type=bind,from=cosign,source=/ko-app/cosign,target=/usr/bin/cosign \
|
||||
--mount=type=secret,id=GITHUB_TOKEN \
|
||||
GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) yarn run test:coverage --coverageDirectory=/tmp/coverage
|
||||
--mount=type=secret,id=GITHUB_TOKEN,env=GITHUB_TOKEN \
|
||||
yarn run test:coverage --coverage.reportsDirectory=/tmp/coverage
|
||||
|
||||
FROM scratch AS test-coverage
|
||||
COPY --from=test /tmp/coverage /
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
const {defineConfig, globalIgnores} = require('eslint/config');
|
||||
const {fixupConfigRules, fixupPluginRules} = require('@eslint/compat');
|
||||
const typescriptEslint = require('@typescript-eslint/eslint-plugin');
|
||||
const jestPlugin = require('eslint-plugin-jest');
|
||||
const prettier = require('eslint-plugin-prettier');
|
||||
const globals = require('globals');
|
||||
const tsParser = require('@typescript-eslint/parser');
|
||||
@@ -43,22 +42,20 @@ module.exports = defineConfig([
|
||||
'plugin:import/errors',
|
||||
'plugin:import/typescript',
|
||||
'plugin:import/warnings',
|
||||
'plugin:jest/recommended',
|
||||
'plugin:vitest/recommended',
|
||||
'plugin:prettier/recommended'
|
||||
)
|
||||
),
|
||||
|
||||
plugins: {
|
||||
'@typescript-eslint': fixupPluginRules(typescriptEslint),
|
||||
jest: fixupPluginRules(jestPlugin),
|
||||
prettier: fixupPluginRules(prettier)
|
||||
},
|
||||
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.mocha,
|
||||
...globals.jest
|
||||
...globals.mocha
|
||||
},
|
||||
parser: tsParser,
|
||||
ecmaVersion: 2023,
|
||||
@@ -78,7 +75,7 @@ module.exports = defineConfig([
|
||||
ignore: ['\\.js$', 'csv-parse/sync', '@octokit/openapi-types', '@octokit/core', '@octokit/plugin-rest-endpoint-methods']
|
||||
}
|
||||
],
|
||||
'jest/no-disabled-tests': 0
|
||||
'vitest/no-disabled-tests': 0
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* Copyright 2023 actions-toolkit authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* 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(), 'docker-actions-toolkit-'));
|
||||
|
||||
process.env = Object.assign({}, process.env, {
|
||||
TEMP: tmpDir,
|
||||
GITHUB_REPOSITORY: 'docker/actions-toolkit',
|
||||
GITHUB_RUN_ATTEMPT: 2,
|
||||
GITHUB_RUN_ID: 2188748038,
|
||||
GITHUB_RUN_NUMBER: 15,
|
||||
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'],
|
||||
setupFiles: ['dotenv/config'],
|
||||
testMatch: ['**/*.test.ts'],
|
||||
transform: {
|
||||
'^.+\\.[tj]s$': [
|
||||
'ts-jest',
|
||||
{
|
||||
useESM: true,
|
||||
tsconfig: '<rootDir>/tsconfig.test.json'
|
||||
}
|
||||
]
|
||||
},
|
||||
// prettier-ignore
|
||||
transformIgnorePatterns: ['/node_modules/(?!(?:@actions/artifact|@actions/cache|@actions/core|@actions/exec|@actions/github|@actions/glob|@actions/http-client|@actions/io|@actions/tool-cache|@octokit|universal-user-agent|before-after-hook)/)'],
|
||||
moduleNameMapper: {
|
||||
'^@actions/artifact$': '<rootDir>/node_modules/@actions/artifact/lib/artifact.js',
|
||||
'^@actions/cache$': '<rootDir>/node_modules/@actions/cache/lib/cache.js',
|
||||
'^@actions/core': '<rootDir>/node_modules/@actions/core/lib/core.js',
|
||||
'^@actions/exec$': '<rootDir>/node_modules/@actions/exec/lib/exec.js',
|
||||
'^@actions/github$': '<rootDir>/node_modules/@actions/github/lib/github.js',
|
||||
'^@actions/github/lib/utils$': '<rootDir>/node_modules/@actions/github/lib/utils.js',
|
||||
'^@actions/glob$': '<rootDir>/node_modules/@actions/glob/lib/glob.js',
|
||||
'^@actions/http-client$': '<rootDir>/node_modules/@actions/http-client/lib/index.js',
|
||||
'^@actions/http-client/lib/auth$': '<rootDir>/node_modules/@actions/http-client/lib/auth.js',
|
||||
'^@actions/http-client/lib/interfaces$': '<rootDir>/node_modules/@actions/http-client/lib/interfaces.js',
|
||||
'^@actions/io$': '<rootDir>/node_modules/@actions/io/lib/io.js',
|
||||
'^@actions/io/lib/io-util$': '<rootDir>/node_modules/@actions/io/lib/io-util.js',
|
||||
'^@actions/tool-cache$': '<rootDir>/node_modules/@actions/tool-cache/lib/tool-cache.js',
|
||||
'^(\\.{1,2}/.*)\\.js$': '$1'
|
||||
},
|
||||
extensionsToTreatAsEsm: ['.ts'],
|
||||
collectCoverageFrom: ['src/**/{!(index.ts),}.ts'],
|
||||
coveragePathIgnorePatterns: ['lib/', 'node_modules/', '__mocks__/', '__tests__/'],
|
||||
testResultsProcessor: '<rootDir>/__tests__/testResultsProcessor.cjs',
|
||||
verbose: true
|
||||
};
|
||||
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* Copyright 2023 actions-toolkit authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
testEnvironment: 'node',
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
setupFiles: ['dotenv/config'],
|
||||
testMatch: ['**/*.test.itg.ts'],
|
||||
testTimeout: 1800000, // 30 minutes
|
||||
transform: {
|
||||
'^.+\\.[tj]s$': [
|
||||
'ts-jest',
|
||||
{
|
||||
useESM: true,
|
||||
tsconfig: '<rootDir>/tsconfig.test.json'
|
||||
}
|
||||
]
|
||||
},
|
||||
// prettier-ignore
|
||||
transformIgnorePatterns: ['/node_modules/(?!(?:@actions/artifact|@actions/cache|@actions/core|@actions/exec|@actions/github|@actions/glob|@actions/http-client|@actions/io|@actions/tool-cache|@octokit|universal-user-agent|before-after-hook)/)'],
|
||||
moduleNameMapper: {
|
||||
'^@actions/artifact$': '<rootDir>/node_modules/@actions/artifact/lib/artifact.js',
|
||||
'^@actions/cache$': '<rootDir>/node_modules/@actions/cache/lib/cache.js',
|
||||
'^@actions/core': '<rootDir>/node_modules/@actions/core/lib/core.js',
|
||||
'^@actions/exec$': '<rootDir>/node_modules/@actions/exec/lib/exec.js',
|
||||
'^@actions/github$': '<rootDir>/node_modules/@actions/github/lib/github.js',
|
||||
'^@actions/github/lib/utils$': '<rootDir>/node_modules/@actions/github/lib/utils.js',
|
||||
'^@actions/glob$': '<rootDir>/node_modules/@actions/glob/lib/glob.js',
|
||||
'^@actions/http-client$': '<rootDir>/node_modules/@actions/http-client/lib/index.js',
|
||||
'^@actions/http-client/lib/auth$': '<rootDir>/node_modules/@actions/http-client/lib/auth.js',
|
||||
'^@actions/http-client/lib/interfaces$': '<rootDir>/node_modules/@actions/http-client/lib/interfaces.js',
|
||||
'^@actions/io$': '<rootDir>/node_modules/@actions/io/lib/io.js',
|
||||
'^@actions/io/lib/io-util$': '<rootDir>/node_modules/@actions/io/lib/io-util.js',
|
||||
'^@actions/tool-cache$': '<rootDir>/node_modules/@actions/tool-cache/lib/tool-cache.js',
|
||||
'^(\\.{1,2}/.*)\\.js$': '$1'
|
||||
},
|
||||
extensionsToTreatAsEsm: ['.ts'],
|
||||
testResultsProcessor: '<rootDir>/__tests__/testResultsProcessor.cjs',
|
||||
verbose: false
|
||||
};
|
||||
17
package.json
17
package.json
@@ -11,11 +11,11 @@
|
||||
"eslint:fix": "eslint --fix .",
|
||||
"prettier": "prettier --check \"./**/*.ts\"",
|
||||
"prettier:fix": "prettier --write \"./**/*.ts\"",
|
||||
"test": "jest",
|
||||
"test:coverage": "jest --coverage",
|
||||
"test:itg": "jest -c jest.config.itg.cjs --runInBand",
|
||||
"test:itg-list": "jest -c jest.config.itg.cjs --listTests",
|
||||
"test:itg-coverage": "jest -c jest.config.itg.cjs --coverage --runInBand"
|
||||
"test": "vitest run -c vitest.config.ts",
|
||||
"test:coverage": "vitest run -c vitest.config.ts --coverage",
|
||||
"test:itg": "vitest run -c vitest.config.itg.ts --maxWorkers=1",
|
||||
"test:itg-list": "node ./__tests__/.setup/list-itg-tests.mjs",
|
||||
"test:itg-coverage": "vitest run -c vitest.config.itg.ts --coverage --maxWorkers=1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -83,17 +83,16 @@
|
||||
"@types/tmp": "^0.2.6",
|
||||
"@typescript-eslint/eslint-plugin": "^8.50.0",
|
||||
"@typescript-eslint/parser": "^8.50.0",
|
||||
"@vitest/coverage-v8": "^3.2.4",
|
||||
"dotenv": "^17.2.3",
|
||||
"eslint": "^9.39.2",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-jest": "^29.5.0",
|
||||
"eslint-plugin-prettier": "^5.5.4",
|
||||
"jest": "^30.2.0",
|
||||
"prettier": "^3.7.4",
|
||||
"rimraf": "^6.1.2",
|
||||
"ts-jest": "^29.4.6",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.9.3"
|
||||
"typescript": "^5.9.3",
|
||||
"vitest": "^3.2.4"
|
||||
}
|
||||
}
|
||||
|
||||
34
vitest.config.itg.ts
Normal file
34
vitest.config.itg.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright 2026 actions-toolkit authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {defineConfig} from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
clearMocks: true,
|
||||
environment: 'node',
|
||||
setupFiles: ['dotenv/config', './__tests__/.setup/setup.unit.ts'],
|
||||
include: ['**/*.test.itg.ts'],
|
||||
testTimeout: 1800000,
|
||||
coverage: {
|
||||
all: true,
|
||||
provider: 'v8',
|
||||
reporter: ['clover'],
|
||||
include: ['src/**/*.ts'],
|
||||
exclude: ['src/**/index.ts', 'lib/**', 'node_modules/**', '__mocks__/**', '__tests__/**']
|
||||
}
|
||||
}
|
||||
});
|
||||
33
vitest.config.ts
Normal file
33
vitest.config.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright 2026 actions-toolkit authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {defineConfig} from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
clearMocks: true,
|
||||
environment: 'node',
|
||||
setupFiles: ['dotenv/config', './__tests__/.setup/setup.unit.ts'],
|
||||
include: ['**/*.test.ts'],
|
||||
coverage: {
|
||||
all: true,
|
||||
provider: 'v8',
|
||||
reporter: ['clover'],
|
||||
include: ['src/**/*.ts'],
|
||||
exclude: ['src/**/index.ts', 'lib/**', 'node_modules/**', '__mocks__/**', '__tests__/**']
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user