Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,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
Expand Down Expand Up @@ -205,7 +205,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 }}
Expand All @@ -217,7 +217,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
Expand Down
4 changes: 2 additions & 2 deletions __mocks__/@actions/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {jest} from '@jest/globals';
import {vi} from 'vitest';

export const context = {
repo: {
Expand Down Expand Up @@ -221,4 +221,4 @@ export const context = {
}
};

export const getOctokit = jest.fn();
export const getOctokit = vi.fn();
8 changes: 4 additions & 4 deletions __tests__/.helpers/os.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 38 additions & 0 deletions __tests__/.setup/list-itg-tests.mjs
Original file line number Diff line number Diff line change
@@ -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`);
33 changes: 33 additions & 0 deletions __tests__/.setup/setup.unit.ts
Original file line number Diff line number Diff line change
@@ -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 fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';

const envTmpDir = process.env.DOCKER_ACTIONS_TOOLKIT_TMPDIR;
const tmpDir = envTmpDir || fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-'));

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')
});
4 changes: 2 additions & 2 deletions __tests__/buildkit/buildkit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 5 additions & 5 deletions __tests__/buildkit/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
});

Expand Down Expand Up @@ -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);
}
});
Expand Down
8 changes: 4 additions & 4 deletions __tests__/buildkit/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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();
}
});
Expand Down Expand Up @@ -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();
}
});
Expand Down
2 changes: 1 addition & 1 deletion __tests__/buildx/bake.test.itg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
8 changes: 4 additions & 4 deletions __tests__/buildx/bake.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
});

Expand Down
12 changes: 6 additions & 6 deletions __tests__/buildx/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
});

Expand Down Expand Up @@ -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);
}
});
Expand All @@ -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);
}
});
Expand Down
6 changes: 3 additions & 3 deletions __tests__/buildx/builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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',
Expand All @@ -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'], {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/buildx/buildx.test.itg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Loading
Loading