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
|
name: Check coverage
|
||||||
run: |
|
run: |
|
||||||
if [ -f ./coverage/clover.xml ] && [ ! -f ./coverage/allSkipped.txt ]; then
|
if [ -f ./coverage/clover.xml ]; then
|
||||||
echo "RUN_CODECOV=true" >> $GITHUB_ENV
|
echo "RUN_CODECOV=true" >> $GITHUB_ENV
|
||||||
else
|
else
|
||||||
echo "RUN_CODECOV=false" >> $GITHUB_ENV
|
echo "RUN_CODECOV=false" >> $GITHUB_ENV
|
||||||
@@ -206,7 +206,7 @@ jobs:
|
|||||||
if (testName) {
|
if (testName) {
|
||||||
args.push(`--testNamePattern=^${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);
|
await exec.exec('yarn', args);
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -218,7 +218,7 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Check coverage
|
name: Check coverage
|
||||||
run: |
|
run: |
|
||||||
if [ -f ./coverage/clover.xml ] && [ ! -f ./coverage/allSkipped.txt ]; then
|
if [ -f ./coverage/clover.xml ]; then
|
||||||
echo "RUN_CODECOV=true" >> $GITHUB_ENV
|
echo "RUN_CODECOV=true" >> $GITHUB_ENV
|
||||||
else
|
else
|
||||||
echo "RUN_CODECOV=false" >> $GITHUB_ENV
|
echo "RUN_CODECOV=false" >> $GITHUB_ENV
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {jest} from '@jest/globals';
|
import {vi} from 'vitest';
|
||||||
|
|
||||||
export const context = {
|
export const context = {
|
||||||
repo: {
|
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.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {jest} from '@jest/globals';
|
import {vi} from 'vitest';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
export const mockPlatform = (platform: NodeJS.Platform) => {
|
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) => {
|
export const mockArch = (arch: string) => {
|
||||||
return jest.spyOn(os, 'arch').mockImplementation(() => arch);
|
return vi.spyOn(os, 'arch').mockImplementation(() => arch);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const mockHomedir = (dir: string) => {
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -14,15 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
import {vi} from 'vitest';
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
module.exports = results => {
|
vi.mock('@actions/github');
|
||||||
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;
|
|
||||||
};
|
|
||||||
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.
|
* 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 {BuildKit} from '../../src/buildkit/buildkit';
|
||||||
import {Builder} from '../../src/buildx/builder';
|
import {Builder} from '../../src/buildx/builder';
|
||||||
|
|
||||||
import {BuilderInfo} from '../../src/types/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 {
|
return {
|
||||||
name: 'builder2',
|
name: 'builder2',
|
||||||
driver: 'docker-container',
|
driver: 'docker-container',
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
@@ -25,14 +25,14 @@ import {Context} from '../../src/context';
|
|||||||
|
|
||||||
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildkit-config-'));
|
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});
|
fs.mkdirSync(tmpDir, {recursive: true});
|
||||||
return tmpDir;
|
return tmpDir;
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||||
return tmpName;
|
return tmpName;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ describe('resolve', () => {
|
|||||||
const configValue = fs.readFileSync(tmpName, 'utf-8');
|
const configValue = fs.readFileSync(tmpName, 'utf-8');
|
||||||
expect(configValue).toEqual(exValue);
|
expect(configValue).toEqual(exValue);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// eslint-disable-next-line jest/no-conditional-expect
|
// eslint-disable-next-line vitest/no-conditional-expect
|
||||||
expect(e.message).toEqual(error?.message);
|
expect(e.message).toEqual(error?.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,14 +14,14 @@
|
|||||||
* limitations under the License.
|
* 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 {Git} from '../../src/buildkit/git';
|
||||||
|
|
||||||
import {GitRef, GitURL} from '../../src/types/buildkit/git';
|
import {GitRef, GitURL} from '../../src/types/buildkit/git';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('parseURL', () => {
|
describe('parseURL', () => {
|
||||||
@@ -195,7 +195,7 @@ describe('parseURL', () => {
|
|||||||
if (!expectedErr) {
|
if (!expectedErr) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line jest/no-conditional-expect
|
// eslint-disable-next-line vitest/no-conditional-expect
|
||||||
expect(expectedErr).toBeTruthy();
|
expect(expectedErr).toBeTruthy();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -337,7 +337,7 @@ describe('parseRef', () => {
|
|||||||
if (expected) {
|
if (expected) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line jest/no-conditional-expect
|
// eslint-disable-next-line vitest/no-conditional-expect
|
||||||
expect(expected).toBeUndefined();
|
expect(expected).toBeUndefined();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {describe, expect, test} from '@jest/globals';
|
import {describe, expect, test} from 'vitest';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
@@ -29,15 +29,15 @@ import {BuildMetadata} from '../../src/types/buildx/build';
|
|||||||
|
|
||||||
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-bake-'));
|
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'));
|
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});
|
fs.mkdirSync(tmpDir, {recursive: true});
|
||||||
return tmpDir;
|
return tmpDir;
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||||
return tmpName;
|
return tmpName;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
@@ -25,15 +25,15 @@ import {Build} from '../../src/buildx/build';
|
|||||||
|
|
||||||
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-build-'));
|
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'));
|
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});
|
fs.mkdirSync(tmpDir, {recursive: true});
|
||||||
return tmpDir;
|
return tmpDir;
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||||
return tmpName;
|
return tmpName;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ describe('resolveSecret', () => {
|
|||||||
expect(secret).toEqual(`id=${exKey},src=${tmpName}`);
|
expect(secret).toEqual(`id=${exKey},src=${tmpName}`);
|
||||||
expect(fs.readFileSync(tmpName, 'utf-8')).toEqual(exValue);
|
expect(fs.readFileSync(tmpName, 'utf-8')).toEqual(exValue);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// eslint-disable-next-line jest/no-conditional-expect
|
// eslint-disable-next-line vitest/no-conditional-expect
|
||||||
expect(e.message).toEqual(error?.message);
|
expect(e.message).toEqual(error?.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -206,7 +206,7 @@ describe('resolveSecret', () => {
|
|||||||
const secret = Build.resolveSecretEnv(kvp);
|
const secret = Build.resolveSecretEnv(kvp);
|
||||||
expect(secret).toEqual(`id=${exKey},env=${exValue}`);
|
expect(secret).toEqual(`id=${exKey},env=${exValue}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// eslint-disable-next-line jest/no-conditional-expect
|
// eslint-disable-next-line vitest/no-conditional-expect
|
||||||
expect(e.message).toEqual(error?.message);
|
expect(e.message).toEqual(error?.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ import {BuilderInfo} from '../../src/types/buildx/builder';
|
|||||||
|
|
||||||
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
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 {
|
return {
|
||||||
name: 'builder2',
|
name: 'builder2',
|
||||||
driver: 'docker-container',
|
driver: 'docker-container',
|
||||||
@@ -46,7 +46,7 @@ jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<Bu
|
|||||||
|
|
||||||
describe('exists', () => {
|
describe('exists', () => {
|
||||||
it('valid', async () => {
|
it('valid', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||||
const builder = new Builder();
|
const builder = new Builder();
|
||||||
await builder.exists('foo');
|
await builder.exists('foo');
|
||||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx', 'inspect', 'foo'], {
|
expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx', 'inspect', 'foo'], {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {describe, expect, it} from '@jest/globals';
|
import {describe, expect, it} from 'vitest';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
@@ -29,14 +29,14 @@ import {Cert, LocalState} from '../../src/types/buildx/buildx';
|
|||||||
|
|
||||||
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-buildx-'));
|
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});
|
fs.mkdirSync(tmpDir, {recursive: true});
|
||||||
return tmpDir;
|
return tmpDir;
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||||
return tmpName;
|
return tmpName;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ afterEach(() => {
|
|||||||
describe('configDir', () => {
|
describe('configDir', () => {
|
||||||
const originalEnv = process.env;
|
const originalEnv = process.env;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
vi.resetModules();
|
||||||
process.env = {
|
process.env = {
|
||||||
...originalEnv,
|
...originalEnv,
|
||||||
BUILDX_CONFIG: '/var/docker/buildx',
|
BUILDX_CONFIG: '/var/docker/buildx',
|
||||||
@@ -69,7 +69,7 @@ describe('configDir', () => {
|
|||||||
describe('certsDir', () => {
|
describe('certsDir', () => {
|
||||||
const originalEnv = process.env;
|
const originalEnv = process.env;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
vi.resetModules();
|
||||||
process.env = {
|
process.env = {
|
||||||
...originalEnv,
|
...originalEnv,
|
||||||
BUILDX_CONFIG: '/var/docker/buildx'
|
BUILDX_CONFIG: '/var/docker/buildx'
|
||||||
@@ -86,7 +86,7 @@ describe('certsDir', () => {
|
|||||||
|
|
||||||
describe('isAvailable', () => {
|
describe('isAvailable', () => {
|
||||||
it('docker cli', async () => {
|
it('docker cli', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||||
const buildx = new Buildx({
|
const buildx = new Buildx({
|
||||||
standalone: false
|
standalone: false
|
||||||
});
|
});
|
||||||
@@ -97,7 +97,7 @@ describe('isAvailable', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('standalone', async () => {
|
it('standalone', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||||
const buildx = new Buildx({
|
const buildx = new Buildx({
|
||||||
standalone: true
|
standalone: true
|
||||||
});
|
});
|
||||||
@@ -111,7 +111,7 @@ describe('isAvailable', () => {
|
|||||||
|
|
||||||
describe('printVersion', () => {
|
describe('printVersion', () => {
|
||||||
it('docker cli', async () => {
|
it('docker cli', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'exec');
|
const execSpy = vi.spyOn(Exec, 'exec');
|
||||||
const buildx = new Buildx({
|
const buildx = new Buildx({
|
||||||
standalone: false
|
standalone: false
|
||||||
});
|
});
|
||||||
@@ -121,7 +121,7 @@ describe('printVersion', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('standalone', async () => {
|
it('standalone', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'exec');
|
const execSpy = vi.spyOn(Exec, 'exec');
|
||||||
const buildx = new Buildx({
|
const buildx = new Buildx({
|
||||||
standalone: true
|
standalone: true
|
||||||
});
|
});
|
||||||
@@ -164,7 +164,7 @@ describe('versionSatisfies', () => {
|
|||||||
describe('resolveCertsDriverOpts', () => {
|
describe('resolveCertsDriverOpts', () => {
|
||||||
const originalEnv = process.env;
|
const originalEnv = process.env;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
vi.resetModules();
|
||||||
process.env = {
|
process.env = {
|
||||||
...originalEnv,
|
...originalEnv,
|
||||||
BUILDX_CONFIG: path.join(tmpDir, 'resolveCertsDriverOpts', 'buildx')
|
BUILDX_CONFIG: path.join(tmpDir, 'resolveCertsDriverOpts', 'buildx')
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {describe, expect, it, test} from '@jest/globals';
|
import {describe, expect, it, test} from 'vitest';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
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 path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {describe, expect, test} from '@jest/globals';
|
import {describe, expect, test} from 'vitest';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
import {Install} from '../../src/buildx/install';
|
import {Install} from '../../src/buildx/install';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {describe, expect, it} from '@jest/globals';
|
import {describe, expect, it} from 'vitest';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
@@ -27,14 +27,14 @@ import {Exec} from '../../src/exec';
|
|||||||
import {Compose} from '../../src/compose/compose';
|
import {Compose} from '../../src/compose/compose';
|
||||||
|
|
||||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), '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});
|
fs.mkdirSync(tmpDir, {recursive: true});
|
||||||
return tmpDir;
|
return tmpDir;
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||||
return tmpName;
|
return tmpName;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ afterEach(() => {
|
|||||||
|
|
||||||
describe('isAvailable', () => {
|
describe('isAvailable', () => {
|
||||||
it('docker cli', async () => {
|
it('docker cli', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||||
const compose = new Compose({
|
const compose = new Compose({
|
||||||
standalone: false
|
standalone: false
|
||||||
});
|
});
|
||||||
@@ -55,7 +55,7 @@ describe('isAvailable', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('standalone', async () => {
|
it('standalone', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||||
const compose = new Compose({
|
const compose = new Compose({
|
||||||
standalone: true
|
standalone: true
|
||||||
});
|
});
|
||||||
@@ -69,7 +69,7 @@ describe('isAvailable', () => {
|
|||||||
|
|
||||||
describe('printVersion', () => {
|
describe('printVersion', () => {
|
||||||
it('docker cli', async () => {
|
it('docker cli', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'exec');
|
const execSpy = vi.spyOn(Exec, 'exec');
|
||||||
const compose = new Compose({
|
const compose = new Compose({
|
||||||
standalone: false
|
standalone: false
|
||||||
});
|
});
|
||||||
@@ -79,7 +79,7 @@ describe('printVersion', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('standalone', async () => {
|
it('standalone', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'exec');
|
const execSpy = vi.spyOn(Exec, 'exec');
|
||||||
const compose = new Compose({
|
const compose = new Compose({
|
||||||
standalone: true
|
standalone: true
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {describe, expect, test} from '@jest/globals';
|
import {describe, expect, test} from 'vitest';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
import {Install} from '../../src/compose/install';
|
import {Install} from '../../src/compose/install';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
@@ -23,14 +23,14 @@ import * as rimraf from 'rimraf';
|
|||||||
import {Context} from '../src/context';
|
import {Context} from '../src/context';
|
||||||
|
|
||||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), '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});
|
fs.mkdirSync(tmpDir, {recursive: true});
|
||||||
return tmpDir;
|
return tmpDir;
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||||
return tmpName;
|
return tmpName;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ describe('gitRef', () => {
|
|||||||
describe('parseGitRef', () => {
|
describe('parseGitRef', () => {
|
||||||
const originalEnv = process.env;
|
const originalEnv = process.env;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
vi.resetModules();
|
||||||
process.env = {
|
process.env = {
|
||||||
...originalEnv,
|
...originalEnv,
|
||||||
DOCKER_GIT_CONTEXT_PR_HEAD_REF: ''
|
DOCKER_GIT_CONTEXT_PR_HEAD_REF: ''
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
@@ -26,7 +26,7 @@ const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
|||||||
|
|
||||||
describe('isAvailable', () => {
|
describe('isAvailable', () => {
|
||||||
it('checks Cosign is available', async () => {
|
it('checks Cosign is available', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||||
const cosign = new Cosign();
|
const cosign = new Cosign();
|
||||||
await cosign.isAvailable();
|
await cosign.isAvailable();
|
||||||
expect(execSpy).toHaveBeenCalledWith(`cosign`, [], {
|
expect(execSpy).toHaveBeenCalledWith(`cosign`, [], {
|
||||||
@@ -38,7 +38,7 @@ describe('isAvailable', () => {
|
|||||||
|
|
||||||
describe('printVersion', () => {
|
describe('printVersion', () => {
|
||||||
it('prints Cosign version', async () => {
|
it('prints Cosign version', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'exec');
|
const execSpy = vi.spyOn(Exec, 'exec');
|
||||||
const cosign = new Cosign();
|
const cosign = new Cosign();
|
||||||
await cosign.printVersion();
|
await cosign.printVersion();
|
||||||
expect(execSpy).toHaveBeenCalledWith(`cosign`, ['version', '--json'], {
|
expect(execSpy).toHaveBeenCalledWith(`cosign`, ['version', '--json'], {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
|
|
||||||
import {Install} from '../../src/cosign/install';
|
import {Install} from '../../src/cosign/install';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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';
|
import {Docker} from '../../src/docker/docker';
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ maybe('pull', () => {
|
|||||||
if (err === undefined) {
|
if (err === undefined) {
|
||||||
throw new Error(`Expected no error, but got: ${e.message}`);
|
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);
|
expect(e.message).toContain(err);
|
||||||
}
|
}
|
||||||
}, 600000);
|
}, 600000);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
@@ -37,7 +37,7 @@ afterEach(function () {
|
|||||||
describe('configDir', () => {
|
describe('configDir', () => {
|
||||||
const originalEnv = process.env;
|
const originalEnv = process.env;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
vi.resetModules();
|
||||||
process.env = {
|
process.env = {
|
||||||
...originalEnv,
|
...originalEnv,
|
||||||
DOCKER_CONFIG: '/var/docker/config'
|
DOCKER_CONFIG: '/var/docker/config'
|
||||||
@@ -59,7 +59,7 @@ describe('configDir', () => {
|
|||||||
describe('configFile', () => {
|
describe('configFile', () => {
|
||||||
const originalEnv = process.env;
|
const originalEnv = process.env;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
vi.resetModules();
|
||||||
if (!fs.existsSync(tmpDir)) {
|
if (!fs.existsSync(tmpDir)) {
|
||||||
fs.mkdirSync(tmpDir, {recursive: true});
|
fs.mkdirSync(tmpDir, {recursive: true});
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ describe('configFile', () => {
|
|||||||
|
|
||||||
describe('isAvailable', () => {
|
describe('isAvailable', () => {
|
||||||
it('cli', async () => {
|
it('cli', async () => {
|
||||||
const ioWhichSpy = jest.spyOn(io, 'which');
|
const ioWhichSpy = vi.spyOn(io, 'which');
|
||||||
await Docker.isAvailable();
|
await Docker.isAvailable();
|
||||||
expect(ioWhichSpy).toHaveBeenCalledTimes(1);
|
expect(ioWhichSpy).toHaveBeenCalledTimes(1);
|
||||||
expect(ioWhichSpy).toHaveBeenCalledWith('docker', true);
|
expect(ioWhichSpy).toHaveBeenCalledWith('docker', true);
|
||||||
@@ -106,7 +106,7 @@ describe('isAvailable', () => {
|
|||||||
|
|
||||||
describe('exec', () => {
|
describe('exec', () => {
|
||||||
it('returns docker version', async () => {
|
it('returns docker version', async () => {
|
||||||
const execSpy = jest.spyOn(Docker, 'exec');
|
const execSpy = vi.spyOn(Docker, 'exec');
|
||||||
await Docker.exec(['version'], {
|
await Docker.exec(['version'], {
|
||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
silent: true
|
silent: true
|
||||||
@@ -133,7 +133,7 @@ describe('exec', () => {
|
|||||||
|
|
||||||
describe('getExecOutput', () => {
|
describe('getExecOutput', () => {
|
||||||
it('returns docker version', async () => {
|
it('returns docker version', async () => {
|
||||||
const execSpy = jest.spyOn(Docker, 'getExecOutput');
|
const execSpy = vi.spyOn(Docker, 'getExecOutput');
|
||||||
await Docker.getExecOutput(['version'], {
|
await Docker.getExecOutput(['version'], {
|
||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
silent: true
|
silent: true
|
||||||
@@ -160,7 +160,7 @@ describe('getExecOutput', () => {
|
|||||||
|
|
||||||
describe('context', () => {
|
describe('context', () => {
|
||||||
it('call docker context show', async () => {
|
it('call docker context show', async () => {
|
||||||
const execSpy = jest.spyOn(Docker, 'getExecOutput');
|
const execSpy = vi.spyOn(Docker, 'getExecOutput');
|
||||||
await Docker.context().catch(() => {
|
await Docker.context().catch(() => {
|
||||||
// noop
|
// noop
|
||||||
});
|
});
|
||||||
@@ -182,7 +182,7 @@ describe('context', () => {
|
|||||||
|
|
||||||
describe('contextInspect', () => {
|
describe('contextInspect', () => {
|
||||||
it('call docker context inspect', async () => {
|
it('call docker context inspect', async () => {
|
||||||
const execSpy = jest.spyOn(Docker, 'getExecOutput');
|
const execSpy = vi.spyOn(Docker, 'getExecOutput');
|
||||||
await Docker.contextInspect('foo').catch(() => {
|
await Docker.contextInspect('foo').catch(() => {
|
||||||
// noop
|
// noop
|
||||||
});
|
});
|
||||||
@@ -204,7 +204,7 @@ describe('contextInspect', () => {
|
|||||||
|
|
||||||
describe('printVersion', () => {
|
describe('printVersion', () => {
|
||||||
it('call docker version', async () => {
|
it('call docker version', async () => {
|
||||||
const execSpy = jest.spyOn(Docker, 'exec');
|
const execSpy = vi.spyOn(Docker, 'exec');
|
||||||
await Docker.printVersion().catch(() => {
|
await Docker.printVersion().catch(() => {
|
||||||
// noop
|
// noop
|
||||||
});
|
});
|
||||||
@@ -220,7 +220,7 @@ describe('printVersion', () => {
|
|||||||
|
|
||||||
describe('printInfo', () => {
|
describe('printInfo', () => {
|
||||||
it('call docker info', async () => {
|
it('call docker info', async () => {
|
||||||
const execSpy = jest.spyOn(Docker, 'exec');
|
const execSpy = vi.spyOn(Docker, 'exec');
|
||||||
await Docker.printInfo().catch(() => {
|
await Docker.printInfo().catch(() => {
|
||||||
// noop
|
// noop
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {beforeAll, describe, test, expect} from '@jest/globals';
|
import {beforeAll, describe, test, expect} from 'vitest';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
@@ -103,7 +103,7 @@ describe('getRelease', () => {
|
|||||||
describe('limaImage', () => {
|
describe('limaImage', () => {
|
||||||
const originalEnv = process.env;
|
const originalEnv = process.env;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
vi.resetModules();
|
||||||
process.env = {
|
process.env = {
|
||||||
...originalEnv,
|
...originalEnv,
|
||||||
LIMA_IMAGES: `x86_64:https://cloud-images.ubuntu.com/releases/23.10/release-20231011/ubuntu-23.10-server-cloudimg-amd64.img@sha256:f6529be56da3429a56e4f5ef202bf4958201bc63f8541e478caa6e8eb712e635
|
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.
|
* 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 fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
@@ -27,11 +27,11 @@ import repoAllTagsFixture from './.fixtures/dockerhub-repoalltags.json';
|
|||||||
|
|
||||||
describe('getRepository', () => {
|
describe('getRepository', () => {
|
||||||
it('returns repo info', async () => {
|
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);
|
return <Promise<RepositoryResponse>>(repoInfoFixture as unknown);
|
||||||
});
|
});
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// 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({
|
const dockerhub = await DockerHub.build({
|
||||||
credentials: {
|
credentials: {
|
||||||
username: 'foo',
|
username: 'foo',
|
||||||
@@ -50,11 +50,11 @@ describe('getRepository', () => {
|
|||||||
|
|
||||||
describe('getRepositoryTags', () => {
|
describe('getRepositoryTags', () => {
|
||||||
it('return repo tags', async () => {
|
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);
|
return <Promise<RepositoryTagsResponse>>(repoTagsFixture as unknown);
|
||||||
});
|
});
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// 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({
|
const dockerhub = await DockerHub.build({
|
||||||
credentials: {
|
credentials: {
|
||||||
username: 'foo',
|
username: 'foo',
|
||||||
@@ -74,11 +74,11 @@ describe('getRepositoryTags', () => {
|
|||||||
|
|
||||||
describe('getRepositoryAllTags', () => {
|
describe('getRepositoryAllTags', () => {
|
||||||
it('return repo all tags', async () => {
|
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);
|
return <Promise<RepositoryTagsResponse>>(repoAllTagsFixture as unknown);
|
||||||
});
|
});
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// 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({
|
const dockerhub = await DockerHub.build({
|
||||||
credentials: {
|
credentials: {
|
||||||
username: 'foo',
|
username: 'foo',
|
||||||
|
|||||||
@@ -14,13 +14,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {describe, expect, it, jest} from '@jest/globals';
|
import {describe, expect, it, vi} from 'vitest';
|
||||||
|
|
||||||
import {Exec} from '../src/exec';
|
import {Exec} from '../src/exec';
|
||||||
|
|
||||||
describe('exec', () => {
|
describe('exec', () => {
|
||||||
it('returns docker version', async () => {
|
it('returns docker version', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'exec');
|
const execSpy = vi.spyOn(Exec, 'exec');
|
||||||
await Exec.exec('docker', ['version'], {
|
await Exec.exec('docker', ['version'], {
|
||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
silent: true
|
silent: true
|
||||||
@@ -34,7 +34,7 @@ describe('exec', () => {
|
|||||||
|
|
||||||
describe('getExecOutput', () => {
|
describe('getExecOutput', () => {
|
||||||
it('returns docker version', async () => {
|
it('returns docker version', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||||
await Exec.getExecOutput('docker', ['version'], {
|
await Exec.getExecOutput('docker', ['version'], {
|
||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
silent: true
|
silent: true
|
||||||
|
|||||||
@@ -14,19 +14,19 @@
|
|||||||
* limitations under the License.
|
* 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 {Git as GitMocked} from '../src/git';
|
||||||
import {Exec} from '../src/exec';
|
import {Exec} from '../src/exec';
|
||||||
import {ExecOutput} from '@actions/exec';
|
import {ExecOutput} from '@actions/exec';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('context', () => {
|
describe('context', () => {
|
||||||
it('returns mocked ref and sha', async () => {
|
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(' ')}`;
|
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||||
let result = '';
|
let result = '';
|
||||||
switch (fullCmd) {
|
switch (fullCmd) {
|
||||||
@@ -54,7 +54,7 @@ describe('context', () => {
|
|||||||
|
|
||||||
describe('isInsideWorkTree', () => {
|
describe('isInsideWorkTree', () => {
|
||||||
it('have been called', async () => {
|
it('have been called', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||||
try {
|
try {
|
||||||
await GitMocked.isInsideWorkTree();
|
await GitMocked.isInsideWorkTree();
|
||||||
} catch {
|
} catch {
|
||||||
@@ -72,8 +72,8 @@ describe('remoteSha', () => {
|
|||||||
expect(await GitMocked.remoteSha('https://github.com/docker/buildx.git', 'refs/pull/648/head')).toEqual('f11797113e5a9b86bd976329c5dbb8a8bfdfadfa');
|
expect(await GitMocked.remoteSha('https://github.com/docker/buildx.git', 'refs/pull/648/head')).toEqual('f11797113e5a9b86bd976329c5dbb8a8bfdfadfa');
|
||||||
});
|
});
|
||||||
it('returns sha using github api', async () => {
|
it('returns sha using github api', async () => {
|
||||||
jest.resetModules();
|
vi.resetModules();
|
||||||
jest.unmock('@actions/github');
|
vi.unmock('@actions/github');
|
||||||
const {Git} = await import('../src/git');
|
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');
|
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', () => {
|
describe('remoteURL', () => {
|
||||||
it('have been called', async () => {
|
it('have been called', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||||
try {
|
try {
|
||||||
await GitMocked.remoteURL();
|
await GitMocked.remoteURL();
|
||||||
} catch {
|
} catch {
|
||||||
@@ -96,7 +96,7 @@ describe('remoteURL', () => {
|
|||||||
|
|
||||||
describe('ref', () => {
|
describe('ref', () => {
|
||||||
it('returns mocked ref', async () => {
|
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(' ')}`;
|
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||||
let result = '';
|
let result = '';
|
||||||
switch (fullCmd) {
|
switch (fullCmd) {
|
||||||
@@ -120,7 +120,7 @@ describe('ref', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns mocked detached tag ref', async () => {
|
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(' ')}`;
|
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||||
let result = '';
|
let result = '';
|
||||||
switch (fullCmd) {
|
switch (fullCmd) {
|
||||||
@@ -144,7 +144,7 @@ describe('ref', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns mocked detached tag ref (shallow clone)', async () => {
|
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(' ')}`;
|
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||||
let result = '';
|
let result = '';
|
||||||
switch (fullCmd) {
|
switch (fullCmd) {
|
||||||
@@ -168,7 +168,7 @@ describe('ref', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns mocked detached pull request merge ref (shallow clone)', async () => {
|
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(' ')}`;
|
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||||
let result = '';
|
let result = '';
|
||||||
switch (fullCmd) {
|
switch (fullCmd) {
|
||||||
@@ -192,7 +192,7 @@ describe('ref', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throws an error when detached HEAD ref is not supported', async () => {
|
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(' ')}`;
|
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||||
let result = '';
|
let result = '';
|
||||||
switch (fullCmd) {
|
switch (fullCmd) {
|
||||||
@@ -214,7 +214,7 @@ describe('ref', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns mocked detached branch ref', async () => {
|
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(' ')}`;
|
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||||
let result = '';
|
let result = '';
|
||||||
switch (fullCmd) {
|
switch (fullCmd) {
|
||||||
@@ -238,7 +238,7 @@ describe('ref', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns mocked detached branch ref checked out by SHA', async () => {
|
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(' ')}`;
|
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||||
let result = '';
|
let result = '';
|
||||||
switch (fullCmd) {
|
switch (fullCmd) {
|
||||||
@@ -262,7 +262,7 @@ describe('ref', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('infers ref from local branch when detached HEAD returns only "HEAD"', async () => {
|
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(' ')}`;
|
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||||
let result = '';
|
let result = '';
|
||||||
switch (fullCmd) {
|
switch (fullCmd) {
|
||||||
@@ -289,7 +289,7 @@ describe('ref', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('infers ref from local branch when detached HEAD returns only "grafted, HEAD"', async () => {
|
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(' ')}`;
|
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||||
let result = '';
|
let result = '';
|
||||||
switch (fullCmd) {
|
switch (fullCmd) {
|
||||||
@@ -316,7 +316,7 @@ describe('ref', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('infers ref from remote branch when no local branch contains HEAD', async () => {
|
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(' ')}`;
|
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||||
let result = '';
|
let result = '';
|
||||||
switch (fullCmd) {
|
switch (fullCmd) {
|
||||||
@@ -346,7 +346,7 @@ describe('ref', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('infers ref from tag when no branch contains HEAD', async () => {
|
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(' ')}`;
|
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||||
let result = '';
|
let result = '';
|
||||||
switch (fullCmd) {
|
switch (fullCmd) {
|
||||||
@@ -379,7 +379,7 @@ describe('ref', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('throws error when cannot infer ref from detached HEAD', async () => {
|
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(' ')}`;
|
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||||
let result = '';
|
let result = '';
|
||||||
switch (fullCmd) {
|
switch (fullCmd) {
|
||||||
@@ -410,7 +410,7 @@ describe('ref', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('handles remote ref without branch pattern when inferring from remote', async () => {
|
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(' ')}`;
|
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||||
let result = '';
|
let result = '';
|
||||||
switch (fullCmd) {
|
switch (fullCmd) {
|
||||||
@@ -442,7 +442,7 @@ describe('ref', () => {
|
|||||||
|
|
||||||
describe('fullCommit', () => {
|
describe('fullCommit', () => {
|
||||||
it('have been called', async () => {
|
it('have been called', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||||
try {
|
try {
|
||||||
await GitMocked.fullCommit();
|
await GitMocked.fullCommit();
|
||||||
} catch {
|
} catch {
|
||||||
@@ -457,7 +457,7 @@ describe('fullCommit', () => {
|
|||||||
|
|
||||||
describe('shortCommit', () => {
|
describe('shortCommit', () => {
|
||||||
it('have been called', async () => {
|
it('have been called', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||||
try {
|
try {
|
||||||
await GitMocked.shortCommit();
|
await GitMocked.shortCommit();
|
||||||
} catch {
|
} catch {
|
||||||
@@ -472,7 +472,7 @@ describe('shortCommit', () => {
|
|||||||
|
|
||||||
describe('tag', () => {
|
describe('tag', () => {
|
||||||
it('have been called', async () => {
|
it('have been called', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||||
try {
|
try {
|
||||||
await GitMocked.tag();
|
await GitMocked.tag();
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {describe, expect, it} from '@jest/globals';
|
import {describe, expect, it} from 'vitest';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
@@ -28,7 +28,7 @@ const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
|||||||
|
|
||||||
describe('repoData', () => {
|
describe('repoData', () => {
|
||||||
it('returns GitHub repo data', async () => {
|
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);
|
return <Promise<GitHubRepo>>(repoFixture as unknown);
|
||||||
});
|
});
|
||||||
const github = new GitHub();
|
const github = new GitHub();
|
||||||
@@ -49,8 +49,8 @@ describe('repoData (api)', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
jest.resetModules();
|
vi.resetModules();
|
||||||
jest.unmock('@actions/github');
|
vi.unmock('@actions/github');
|
||||||
const {GitHub} = await import('../../src/github/github');
|
const {GitHub} = await import('../../src/github/github');
|
||||||
const github = new GitHub({token: process.env.GITHUB_TOKEN});
|
const github = new GitHub({token: process.env.GITHUB_TOKEN});
|
||||||
const repo = await github.repoData();
|
const repo = await github.repoData();
|
||||||
@@ -97,7 +97,7 @@ describe('releases', () => {
|
|||||||
describe('serverURL', () => {
|
describe('serverURL', () => {
|
||||||
const originalEnv = process.env;
|
const originalEnv = process.env;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
vi.resetModules();
|
||||||
process.env = {
|
process.env = {
|
||||||
...originalEnv,
|
...originalEnv,
|
||||||
GITHUB_SERVER_URL: 'https://foo.github.com'
|
GITHUB_SERVER_URL: 'https://foo.github.com'
|
||||||
@@ -118,7 +118,7 @@ describe('serverURL', () => {
|
|||||||
describe('apiURL', () => {
|
describe('apiURL', () => {
|
||||||
const originalEnv = process.env;
|
const originalEnv = process.env;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
vi.resetModules();
|
||||||
process.env = {
|
process.env = {
|
||||||
...originalEnv,
|
...originalEnv,
|
||||||
GITHUB_API_URL: 'https://bar.github.com'
|
GITHUB_API_URL: 'https://bar.github.com'
|
||||||
@@ -154,7 +154,7 @@ describe('workflowRunURL', () => {
|
|||||||
describe('actionsRuntimeToken', () => {
|
describe('actionsRuntimeToken', () => {
|
||||||
const originalEnv = process.env;
|
const originalEnv = process.env;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
vi.resetModules();
|
||||||
process.env = {
|
process.env = {
|
||||||
...originalEnv
|
...originalEnv
|
||||||
};
|
};
|
||||||
@@ -184,7 +184,7 @@ describe('actionsRuntimeToken', () => {
|
|||||||
describe('printActionsRuntimeTokenACs', () => {
|
describe('printActionsRuntimeTokenACs', () => {
|
||||||
const originalEnv = process.env;
|
const originalEnv = process.env;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
vi.resetModules();
|
||||||
process.env = {
|
process.env = {
|
||||||
...originalEnv
|
...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'));
|
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 () => {
|
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();
|
process.env.ACTIONS_RUNTIME_TOKEN = fs.readFileSync(path.join(fixturesDir, 'runtimeToken.txt')).toString().trim();
|
||||||
await GitHub.printActionsRuntimeTokenACs();
|
await GitHub.printActionsRuntimeTokenACs();
|
||||||
expect(infoSpy).toHaveBeenCalledTimes(1);
|
expect(infoSpy).toHaveBeenCalledTimes(1);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {describe, expect, it, test} from '@jest/globals';
|
import {describe, expect, it, test} from 'vitest';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {afterEach, describe, expect, test} from '@jest/globals';
|
import {afterEach, describe, expect, test} from 'vitest';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {describe, expect, test} from '@jest/globals';
|
import {describe, expect, test} from 'vitest';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
import {Install} from '../../src/regclient/install';
|
import {Install} from '../../src/regclient/install';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 * as semver from 'semver';
|
||||||
|
|
||||||
import {Exec} from '../../src/exec';
|
import {Exec} from '../../src/exec';
|
||||||
@@ -82,7 +82,7 @@ describe('image config', () => {
|
|||||||
|
|
||||||
describe('isAvailable', () => {
|
describe('isAvailable', () => {
|
||||||
it('checks regctl is available', async () => {
|
it('checks regctl is available', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||||
const regctl = new Regctl();
|
const regctl = new Regctl();
|
||||||
await regctl.isAvailable();
|
await regctl.isAvailable();
|
||||||
expect(execSpy).toHaveBeenCalledWith(`regctl`, [], {
|
expect(execSpy).toHaveBeenCalledWith(`regctl`, [], {
|
||||||
@@ -94,7 +94,7 @@ describe('isAvailable', () => {
|
|||||||
|
|
||||||
describe('printVersion', () => {
|
describe('printVersion', () => {
|
||||||
it('prints regctl version', async () => {
|
it('prints regctl version', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'exec');
|
const execSpy = vi.spyOn(Exec, 'exec');
|
||||||
const regctl = new Regctl();
|
const regctl = new Regctl();
|
||||||
await regctl.printVersion();
|
await regctl.printVersion();
|
||||||
expect(execSpy).toHaveBeenCalledWith(`regctl`, ['version'], {
|
expect(execSpy).toHaveBeenCalledWith(`regctl`, ['version'], {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 * as path from 'path';
|
||||||
|
|
||||||
import {Buildx} from '../../src/buildx/buildx';
|
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;
|
const maybeIdToken = runTest && process.env.ACTIONS_ID_TOKEN_REQUEST_URL ? describe : describe.skip;
|
||||||
|
|
||||||
// needs current GitHub repo info
|
// needs current GitHub repo info
|
||||||
jest.unmock('@actions/github');
|
vi.unmock('@actions/github');
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const cosignInstall = new CosignInstall();
|
const cosignInstall = new CosignInstall();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import * as path from 'path';
|
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;
|
const maybeIdToken = runTest && process.env.ACTIONS_ID_TOKEN_REQUEST_URL ? describe : describe.skip;
|
||||||
|
|
||||||
// needs current GitHub repo info
|
// needs current GitHub repo info
|
||||||
jest.unmock('@actions/github');
|
vi.unmock('@actions/github');
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const cosignInstall = new CosignInstall();
|
const cosignInstall = new CosignInstall();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {describe, expect, test} from '@jest/globals';
|
import {describe, expect, test} from 'vitest';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
import {Install} from '../../src/undock/install';
|
import {Install} from '../../src/undock/install';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {describe, expect, it} from '@jest/globals';
|
import {describe, expect, it} from 'vitest';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
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 * as semver from 'semver';
|
||||||
|
|
||||||
import {Exec} from '../../src/exec';
|
import {Exec} from '../../src/exec';
|
||||||
@@ -43,7 +43,7 @@ describe('run', () => {
|
|||||||
|
|
||||||
describe('isAvailable', () => {
|
describe('isAvailable', () => {
|
||||||
it('checks undock is available', async () => {
|
it('checks undock is available', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||||
const undock = new Undock();
|
const undock = new Undock();
|
||||||
await undock.isAvailable();
|
await undock.isAvailable();
|
||||||
expect(execSpy).toHaveBeenCalledWith(`undock`, [], {
|
expect(execSpy).toHaveBeenCalledWith(`undock`, [], {
|
||||||
@@ -55,7 +55,7 @@ describe('isAvailable', () => {
|
|||||||
|
|
||||||
describe('printVersion', () => {
|
describe('printVersion', () => {
|
||||||
it('prints undock version', async () => {
|
it('prints undock version', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'exec');
|
const execSpy = vi.spyOn(Exec, 'exec');
|
||||||
const undock = new Undock();
|
const undock = new Undock();
|
||||||
await undock.printVersion();
|
await undock.printVersion();
|
||||||
expect(execSpy).toHaveBeenCalledWith(`undock`, ['--version'], {
|
expect(execSpy).toHaveBeenCalledWith(`undock`, ['--version'], {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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 fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
@@ -326,10 +326,10 @@ describe('parseBool', () => {
|
|||||||
].forEach(({input, expected, throwsError}) => {
|
].forEach(({input, expected, throwsError}) => {
|
||||||
test(`parseBool("${input}")`, () => {
|
test(`parseBool("${input}")`, () => {
|
||||||
if (throwsError) {
|
if (throwsError) {
|
||||||
// eslint-disable-next-line jest/no-conditional-expect
|
// eslint-disable-next-line vitest/no-conditional-expect
|
||||||
expect(() => Util.parseBool(input)).toThrow();
|
expect(() => Util.parseBool(input)).toThrow();
|
||||||
} else {
|
} else {
|
||||||
// eslint-disable-next-line jest/no-conditional-expect
|
// eslint-disable-next-line vitest/no-conditional-expect
|
||||||
expect(Util.parseBool(input)).toBe(expected);
|
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=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=regctl,source=/regctl,target=/usr/bin/regctl \
|
||||||
--mount=type=bind,from=cosign,source=/ko-app/cosign,target=/usr/bin/cosign \
|
--mount=type=bind,from=cosign,source=/ko-app/cosign,target=/usr/bin/cosign \
|
||||||
--mount=type=secret,id=GITHUB_TOKEN \
|
--mount=type=secret,id=GITHUB_TOKEN,env=GITHUB_TOKEN \
|
||||||
GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) 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 /
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
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 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');
|
||||||
@@ -43,22 +42,20 @@ module.exports = defineConfig([
|
|||||||
'plugin:import/errors',
|
'plugin:import/errors',
|
||||||
'plugin:import/typescript',
|
'plugin:import/typescript',
|
||||||
'plugin:import/warnings',
|
'plugin:import/warnings',
|
||||||
'plugin:jest/recommended',
|
'plugin:vitest/recommended',
|
||||||
'plugin:prettier/recommended'
|
'plugin:prettier/recommended'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
plugins: {
|
plugins: {
|
||||||
'@typescript-eslint': fixupPluginRules(typescriptEslint),
|
'@typescript-eslint': fixupPluginRules(typescriptEslint),
|
||||||
jest: fixupPluginRules(jestPlugin),
|
|
||||||
prettier: fixupPluginRules(prettier)
|
prettier: fixupPluginRules(prettier)
|
||||||
},
|
},
|
||||||
|
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
globals: {
|
globals: {
|
||||||
...globals.node,
|
...globals.node,
|
||||||
...globals.mocha,
|
...globals.mocha
|
||||||
...globals.jest
|
|
||||||
},
|
},
|
||||||
parser: tsParser,
|
parser: tsParser,
|
||||||
ecmaVersion: 2023,
|
ecmaVersion: 2023,
|
||||||
@@ -78,7 +75,7 @@ module.exports = defineConfig([
|
|||||||
ignore: ['\\.js$', 'csv-parse/sync', '@octokit/openapi-types', '@octokit/core', '@octokit/plugin-rest-endpoint-methods']
|
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 .",
|
"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 -c vitest.config.ts",
|
||||||
"test:coverage": "jest --coverage",
|
"test:coverage": "vitest run -c vitest.config.ts --coverage",
|
||||||
"test:itg": "jest -c jest.config.itg.cjs --runInBand",
|
"test:itg": "vitest run -c vitest.config.itg.ts --maxWorkers=1",
|
||||||
"test:itg-list": "jest -c jest.config.itg.cjs --listTests",
|
"test:itg-list": "node ./__tests__/.setup/list-itg-tests.mjs",
|
||||||
"test:itg-coverage": "jest -c jest.config.itg.cjs --coverage --runInBand"
|
"test:itg-coverage": "vitest run -c vitest.config.itg.ts --coverage --maxWorkers=1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -83,17 +83,16 @@
|
|||||||
"@types/tmp": "^0.2.6",
|
"@types/tmp": "^0.2.6",
|
||||||
"@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",
|
||||||
|
"@vitest/coverage-v8": "^3.2.4",
|
||||||
"dotenv": "^17.2.3",
|
"dotenv": "^17.2.3",
|
||||||
"eslint": "^9.39.2",
|
"eslint": "^9.39.2",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-import": "^2.32.0",
|
"eslint-plugin-import": "^2.32.0",
|
||||||
"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",
|
||||||
"rimraf": "^6.1.2",
|
"rimraf": "^6.1.2",
|
||||||
"ts-jest": "^29.4.6",
|
|
||||||
"ts-node": "^10.9.2",
|
"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