Merge pull request #982 from crazy-max/vitest

switch from Jest to Vitest
This commit is contained in:
CrazyMax
2026-02-27 10:49:38 +01:00
committed by GitHub
63 changed files with 1917 additions and 3974 deletions

View File

@@ -48,7 +48,7 @@ jobs:
-
name: Check coverage
run: |
if [ -f ./coverage/clover.xml ] && [ ! -f ./coverage/allSkipped.txt ]; then
if [ -f ./coverage/clover.xml ]; then
echo "RUN_CODECOV=true" >> $GITHUB_ENV
else
echo "RUN_CODECOV=false" >> $GITHUB_ENV
@@ -206,7 +206,7 @@ jobs:
if (testName) {
args.push(`--testNamePattern=^${testName} `);
}
args.push(`--runTestsByPath`, `__tests__/${{ matrix.test }}`, `--coverageDirectory=./coverage`);
args.push(`__tests__/${{ matrix.test }}`, `--coverage.reportsDirectory=./coverage`);
await exec.exec('yarn', args);
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -218,7 +218,7 @@ jobs:
-
name: Check coverage
run: |
if [ -f ./coverage/clover.xml ] && [ ! -f ./coverage/allSkipped.txt ]; then
if [ -f ./coverage/clover.xml ]; then
echo "RUN_CODECOV=true" >> $GITHUB_ENV
else
echo "RUN_CODECOV=false" >> $GITHUB_ENV

7
.gitignore vendored
View File

@@ -38,13 +38,6 @@ jspm_packages/
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# yarn v2
.yarn/cache
.yarn/unplugged

View File

@@ -1,224 +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.
*/
import {jest} from '@jest/globals';
export const context = {
repo: {
owner: 'docker',
repo: 'actions-toolkit'
},
ref: 'refs/heads/master',
runId: 2188748038,
runNumber: 15,
payload: {
after: '860c1904a1ce19322e91ac35af1ab07466440c37',
base_ref: null,
before: '5f3331d7f7044c18ca9f12c77d961c4d7cf3276a',
commits: [
{
author: {
email: 'crazy-max@users.noreply.github.com',
name: 'CrazyMax',
username: 'crazy-max'
},
committer: {
email: 'crazy-max@users.noreply.github.com',
name: 'CrazyMax',
username: 'crazy-max'
},
distinct: true,
id: '860c1904a1ce19322e91ac35af1ab07466440c37',
message: 'hello dev',
timestamp: '2022-04-19T11:27:24+02:00',
tree_id: 'd2c60af597e863787d2d27f569e30495b0b92820',
url: 'https://github.com/docker/test-docker-action/commit/860c1904a1ce19322e91ac35af1ab07466440c37'
}
],
compare: 'https://github.com/docker/test-docker-action/compare/5f3331d7f704...860c1904a1ce',
created: false,
deleted: false,
forced: false,
head_commit: {
author: {
email: 'crazy-max@users.noreply.github.com',
name: 'CrazyMax',
username: 'crazy-max'
},
committer: {
email: 'crazy-max@users.noreply.github.com',
name: 'CrazyMax',
username: 'crazy-max'
},
distinct: true,
id: '860c1904a1ce19322e91ac35af1ab07466440c37',
message: 'hello dev',
timestamp: '2022-04-19T11:27:24+02:00',
tree_id: 'd2c60af597e863787d2d27f569e30495b0b92820',
url: 'https://github.com/docker/test-docker-action/commit/860c1904a1ce19322e91ac35af1ab07466440c37'
},
organization: {
avatar_url: 'https://avatars.githubusercontent.com/u/5429470?v=4',
description: 'Docker helps developers bring their ideas to life by conquering the complexity of app development.',
events_url: 'https://api.github.com/orgs/docker/events',
hooks_url: 'https://api.github.com/orgs/docker/hooks',
id: 5429470,
issues_url: 'https://api.github.com/orgs/docker/issues',
login: 'docker',
members_url: 'https://api.github.com/orgs/docker/members{/member}',
node_id: 'MDEyOk9yZ2FuaXphdGlvbjU0Mjk0NzA=',
public_members_url: 'https://api.github.com/orgs/docker/public_members{/member}',
repos_url: 'https://api.github.com/orgs/docker/repos',
url: 'https://api.github.com/orgs/docker'
},
pusher: {
email: 'github@crazymax.dev',
name: 'crazy-max'
},
ref: 'refs/heads/dev',
repository: {
allow_forking: true,
archive_url: 'https://api.github.com/repos/docker/test-docker-action/{archive_format}{/ref}',
archived: false,
assignees_url: 'https://api.github.com/repos/docker/test-docker-action/assignees{/user}',
blobs_url: 'https://api.github.com/repos/docker/test-docker-action/git/blobs{/sha}',
branches_url: 'https://api.github.com/repos/docker/test-docker-action/branches{/branch}',
clone_url: 'https://github.com/docker/test-docker-action.git',
collaborators_url: 'https://api.github.com/repos/docker/test-docker-action/collaborators{/collaborator}',
comments_url: 'https://api.github.com/repos/docker/test-docker-action/comments{/number}',
commits_url: 'https://api.github.com/repos/docker/test-docker-action/commits{/sha}',
compare_url: 'https://api.github.com/repos/docker/test-docker-action/compare/{base}...{head}',
contents_url: 'https://api.github.com/repos/docker/test-docker-action/contents/{+path}',
contributors_url: 'https://api.github.com/repos/docker/test-docker-action/contributors',
created_at: 1596792180,
default_branch: 'master',
deployments_url: 'https://api.github.com/repos/docker/test-docker-action/deployments',
description: 'Test "Docker" Actions',
disabled: false,
downloads_url: 'https://api.github.com/repos/docker/test-docker-action/downloads',
events_url: 'https://api.github.com/repos/docker/test-docker-action/events',
fork: false,
forks: 1,
forks_count: 1,
forks_url: 'https://api.github.com/repos/docker/test-docker-action/forks',
full_name: 'docker/test-docker-action',
git_commits_url: 'https://api.github.com/repos/docker/test-docker-action/git/commits{/sha}',
git_refs_url: 'https://api.github.com/repos/docker/test-docker-action/git/refs{/sha}',
git_tags_url: 'https://api.github.com/repos/docker/test-docker-action/git/tags{/sha}',
git_url: 'git://github.com/docker/test-docker-action.git',
has_downloads: true,
has_issues: true,
has_pages: false,
has_projects: true,
has_wiki: true,
homepage: '',
hooks_url: 'https://api.github.com/repos/docker/test-docker-action/hooks',
html_url: 'https://github.com/docker/test-docker-action',
id: 285789493,
is_template: false,
issue_comment_url: 'https://api.github.com/repos/docker/test-docker-action/issues/comments{/number}',
issue_events_url: 'https://api.github.com/repos/docker/test-docker-action/issues/events{/number}',
issues_url: 'https://api.github.com/repos/docker/test-docker-action/issues{/number}',
keys_url: 'https://api.github.com/repos/docker/test-docker-action/keys{/key_id}',
labels_url: 'https://api.github.com/repos/docker/test-docker-action/labels{/name}',
language: 'JavaScript',
languages_url: 'https://api.github.com/repos/docker/test-docker-action/languages',
license: {
key: 'mit',
name: 'MIT License',
node_id: 'MDc6TGljZW5zZTEz',
spdx_id: 'MIT',
url: 'https://api.github.com/licenses/mit'
},
master_branch: 'master',
merges_url: 'https://api.github.com/repos/docker/test-docker-action/merges',
milestones_url: 'https://api.github.com/repos/docker/test-docker-action/milestones{/number}',
mirror_url: null,
name: 'test-docker-action',
node_id: 'MDEwOlJlcG9zaXRvcnkyODU3ODk0OTM=',
notifications_url: 'https://api.github.com/repos/docker/test-docker-action/notifications{?since,all,participating}',
open_issues: 6,
open_issues_count: 6,
organization: 'docker',
owner: {
avatar_url: 'https://avatars.githubusercontent.com/u/5429470?v=4',
email: 'info@docker.com',
events_url: 'https://api.github.com/users/docker/events{/privacy}',
followers_url: 'https://api.github.com/users/docker/followers',
following_url: 'https://api.github.com/users/docker/following{/other_user}',
gists_url: 'https://api.github.com/users/docker/gists{/gist_id}',
gravatar_id: '',
html_url: 'https://github.com/docker',
id: 5429470,
login: 'docker',
name: 'docker',
node_id: 'MDEyOk9yZ2FuaXphdGlvbjU0Mjk0NzA=',
organizations_url: 'https://api.github.com/users/docker/orgs',
received_events_url: 'https://api.github.com/users/docker/received_events',
repos_url: 'https://api.github.com/users/docker/repos',
site_admin: false,
starred_url: 'https://api.github.com/users/docker/starred{/owner}{/repo}',
subscriptions_url: 'https://api.github.com/users/docker/subscriptions',
type: 'Organization',
url: 'https://api.github.com/users/docker'
},
private: true,
pulls_url: 'https://api.github.com/repos/docker/test-docker-action/pulls{/number}',
pushed_at: 1650360446,
releases_url: 'https://api.github.com/repos/docker/test-docker-action/releases{/id}',
size: 796,
ssh_url: 'git@github.com:docker/test-docker-action.git',
stargazers: 0,
stargazers_count: 0,
stargazers_url: 'https://api.github.com/repos/docker/test-docker-action/stargazers',
statuses_url: 'https://api.github.com/repos/docker/test-docker-action/statuses/{sha}',
subscribers_url: 'https://api.github.com/repos/docker/test-docker-action/subscribers',
subscription_url: 'https://api.github.com/repos/docker/test-docker-action/subscription',
svn_url: 'https://github.com/docker/test-docker-action',
tags_url: 'https://api.github.com/repos/docker/test-docker-action/tags',
teams_url: 'https://api.github.com/repos/docker/test-docker-action/teams',
topics: [],
trees_url: 'https://api.github.com/repos/docker/test-docker-action/git/trees{/sha}',
updated_at: '2022-04-19T09:05:09Z',
url: 'https://github.com/docker/test-docker-action',
visibility: 'private',
watchers: 0,
watchers_count: 0
},
sender: {
avatar_url: 'https://avatars.githubusercontent.com/u/1951866?v=4',
events_url: 'https://api.github.com/users/crazy-max/events{/privacy}',
followers_url: 'https://api.github.com/users/crazy-max/followers',
following_url: 'https://api.github.com/users/crazy-max/following{/other_user}',
gists_url: 'https://api.github.com/users/crazy-max/gists{/gist_id}',
gravatar_id: '',
html_url: 'https://github.com/crazy-max',
id: 1951866,
login: 'crazy-max',
node_id: 'MDQ6VXNlcjE5NTE4NjY=',
organizations_url: 'https://api.github.com/users/crazy-max/orgs',
received_events_url: 'https://api.github.com/users/crazy-max/received_events',
repos_url: 'https://api.github.com/users/crazy-max/repos',
site_admin: false,
starred_url: 'https://api.github.com/users/crazy-max/starred{/owner}{/repo}',
subscriptions_url: 'https://api.github.com/users/crazy-max/subscriptions',
type: 'User',
url: 'https://api.github.com/users/crazy-max'
}
}
};
export const getOctokit = jest.fn();

View File

@@ -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);
};

View 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`);

View File

@@ -0,0 +1,242 @@
/**
* 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-'));
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')
});
vi.mock('@actions/github', () => ({
context: {
repo: {
owner: 'docker',
repo: 'actions-toolkit'
},
ref: 'refs/heads/master',
runId: 2188748038,
runNumber: 15,
payload: {
after: '860c1904a1ce19322e91ac35af1ab07466440c37',
base_ref: null,
before: '5f3331d7f7044c18ca9f12c77d961c4d7cf3276a',
commits: [
{
author: {
email: 'crazy-max@users.noreply.github.com',
name: 'CrazyMax',
username: 'crazy-max'
},
committer: {
email: 'crazy-max@users.noreply.github.com',
name: 'CrazyMax',
username: 'crazy-max'
},
distinct: true,
id: '860c1904a1ce19322e91ac35af1ab07466440c37',
message: 'hello dev',
timestamp: '2022-04-19T11:27:24+02:00',
tree_id: 'd2c60af597e863787d2d27f569e30495b0b92820',
url: 'https://github.com/docker/test-docker-action/commit/860c1904a1ce19322e91ac35af1ab07466440c37'
}
],
compare: 'https://github.com/docker/test-docker-action/compare/5f3331d7f704...860c1904a1ce',
created: false,
deleted: false,
forced: false,
head_commit: {
author: {
email: 'crazy-max@users.noreply.github.com',
name: 'CrazyMax',
username: 'crazy-max'
},
committer: {
email: 'crazy-max@users.noreply.github.com',
name: 'CrazyMax',
username: 'crazy-max'
},
distinct: true,
id: '860c1904a1ce19322e91ac35af1ab07466440c37',
message: 'hello dev',
timestamp: '2022-04-19T11:27:24+02:00',
tree_id: 'd2c60af597e863787d2d27f569e30495b0b92820',
url: 'https://github.com/docker/test-docker-action/commit/860c1904a1ce19322e91ac35af1ab07466440c37'
},
organization: {
avatar_url: 'https://avatars.githubusercontent.com/u/5429470?v=4',
description: 'Docker helps developers bring their ideas to life by conquering the complexity of app development.',
events_url: 'https://api.github.com/orgs/docker/events',
hooks_url: 'https://api.github.com/orgs/docker/hooks',
id: 5429470,
issues_url: 'https://api.github.com/orgs/docker/issues',
login: 'docker',
members_url: 'https://api.github.com/orgs/docker/members{/member}',
node_id: 'MDEyOk9yZ2FuaXphdGlvbjU0Mjk0NzA=',
public_members_url: 'https://api.github.com/orgs/docker/public_members{/member}',
repos_url: 'https://api.github.com/orgs/docker/repos',
url: 'https://api.github.com/orgs/docker'
},
pusher: {
email: 'github@crazymax.dev',
name: 'crazy-max'
},
ref: 'refs/heads/dev',
repository: {
allow_forking: true,
archive_url: 'https://api.github.com/repos/docker/test-docker-action/{archive_format}{/ref}',
archived: false,
assignees_url: 'https://api.github.com/repos/docker/test-docker-action/assignees{/user}',
blobs_url: 'https://api.github.com/repos/docker/test-docker-action/git/blobs{/sha}',
branches_url: 'https://api.github.com/repos/docker/test-docker-action/branches{/branch}',
clone_url: 'https://github.com/docker/test-docker-action.git',
collaborators_url: 'https://api.github.com/repos/docker/test-docker-action/collaborators{/collaborator}',
comments_url: 'https://api.github.com/repos/docker/test-docker-action/comments{/number}',
commits_url: 'https://api.github.com/repos/docker/test-docker-action/commits{/sha}',
compare_url: 'https://api.github.com/repos/docker/test-docker-action/compare/{base}...{head}',
contents_url: 'https://api.github.com/repos/docker/test-docker-action/contents/{+path}',
contributors_url: 'https://api.github.com/repos/docker/test-docker-action/contributors',
created_at: 1596792180,
default_branch: 'master',
deployments_url: 'https://api.github.com/repos/docker/test-docker-action/deployments',
description: 'Test "Docker" Actions',
disabled: false,
downloads_url: 'https://api.github.com/repos/docker/test-docker-action/downloads',
events_url: 'https://api.github.com/repos/docker/test-docker-action/events',
fork: false,
forks: 1,
forks_count: 1,
forks_url: 'https://api.github.com/repos/docker/test-docker-action/forks',
full_name: 'docker/test-docker-action',
git_commits_url: 'https://api.github.com/repos/docker/test-docker-action/git/commits{/sha}',
git_refs_url: 'https://api.github.com/repos/docker/test-docker-action/git/refs{/sha}',
git_tags_url: 'https://api.github.com/repos/docker/test-docker-action/git/tags{/sha}',
git_url: 'git://github.com/docker/test-docker-action.git',
has_downloads: true,
has_issues: true,
has_pages: false,
has_projects: true,
has_wiki: true,
homepage: '',
hooks_url: 'https://api.github.com/repos/docker/test-docker-action/hooks',
html_url: 'https://github.com/docker/test-docker-action',
id: 285789493,
is_template: false,
issue_comment_url: 'https://api.github.com/repos/docker/test-docker-action/issues/comments{/number}',
issue_events_url: 'https://api.github.com/repos/docker/test-docker-action/issues/events{/number}',
issues_url: 'https://api.github.com/repos/docker/test-docker-action/issues{/number}',
keys_url: 'https://api.github.com/repos/docker/test-docker-action/keys{/key_id}',
labels_url: 'https://api.github.com/repos/docker/test-docker-action/labels{/name}',
language: 'JavaScript',
languages_url: 'https://api.github.com/repos/docker/test-docker-action/languages',
license: {
key: 'mit',
name: 'MIT License',
node_id: 'MDc6TGljZW5zZTEz',
spdx_id: 'MIT',
url: 'https://api.github.com/licenses/mit'
},
master_branch: 'master',
merges_url: 'https://api.github.com/repos/docker/test-docker-action/merges',
milestones_url: 'https://api.github.com/repos/docker/test-docker-action/milestones{/number}',
mirror_url: null,
name: 'test-docker-action',
node_id: 'MDEwOlJlcG9zaXRvcnkyODU3ODk0OTM=',
notifications_url: 'https://api.github.com/repos/docker/test-docker-action/notifications{?since,all,participating}',
open_issues: 6,
open_issues_count: 6,
organization: 'docker',
owner: {
avatar_url: 'https://avatars.githubusercontent.com/u/5429470?v=4',
email: 'info@docker.com',
events_url: 'https://api.github.com/users/docker/events{/privacy}',
followers_url: 'https://api.github.com/users/docker/followers',
following_url: 'https://api.github.com/users/docker/following{/other_user}',
gists_url: 'https://api.github.com/users/docker/gists{/gist_id}',
gravatar_id: '',
html_url: 'https://github.com/docker',
id: 5429470,
login: 'docker',
name: 'docker',
node_id: 'MDEyOk9yZ2FuaXphdGlvbjU0Mjk0NzA=',
organizations_url: 'https://api.github.com/users/docker/orgs',
received_events_url: 'https://api.github.com/users/docker/received_events',
repos_url: 'https://api.github.com/users/docker/repos',
site_admin: false,
starred_url: 'https://api.github.com/users/docker/starred{/owner}{/repo}',
subscriptions_url: 'https://api.github.com/users/docker/subscriptions',
type: 'Organization',
url: 'https://api.github.com/users/docker'
},
private: true,
pulls_url: 'https://api.github.com/repos/docker/test-docker-action/pulls{/number}',
pushed_at: 1650360446,
releases_url: 'https://api.github.com/repos/docker/test-docker-action/releases{/id}',
size: 796,
ssh_url: 'git@github.com:docker/test-docker-action.git',
stargazers: 0,
stargazers_count: 0,
stargazers_url: 'https://api.github.com/repos/docker/test-docker-action/stargazers',
statuses_url: 'https://api.github.com/repos/docker/test-docker-action/statuses/{sha}',
subscribers_url: 'https://api.github.com/repos/docker/test-docker-action/subscribers',
subscription_url: 'https://api.github.com/repos/docker/test-docker-action/subscription',
svn_url: 'https://github.com/docker/test-docker-action',
tags_url: 'https://api.github.com/repos/docker/test-docker-action/tags',
teams_url: 'https://api.github.com/repos/docker/test-docker-action/teams',
topics: [],
trees_url: 'https://api.github.com/repos/docker/test-docker-action/git/trees{/sha}',
updated_at: '2022-04-19T09:05:09Z',
url: 'https://github.com/docker/test-docker-action',
visibility: 'private',
watchers: 0,
watchers_count: 0
},
sender: {
avatar_url: 'https://avatars.githubusercontent.com/u/1951866?v=4',
events_url: 'https://api.github.com/users/crazy-max/events{/privacy}',
followers_url: 'https://api.github.com/users/crazy-max/followers',
following_url: 'https://api.github.com/users/crazy-max/following{/other_user}',
gists_url: 'https://api.github.com/users/crazy-max/gists{/gist_id}',
gravatar_id: '',
html_url: 'https://github.com/crazy-max',
id: 1951866,
login: 'crazy-max',
node_id: 'MDQ6VXNlcjE5NTE4NjY=',
organizations_url: 'https://api.github.com/users/crazy-max/orgs',
received_events_url: 'https://api.github.com/users/crazy-max/received_events',
repos_url: 'https://api.github.com/users/crazy-max/repos',
site_admin: false,
starred_url: 'https://api.github.com/users/crazy-max/starred{/owner}{/repo}',
subscriptions_url: 'https://api.github.com/users/crazy-max/subscriptions',
type: 'User',
url: 'https://api.github.com/users/crazy-max'
}
}
},
getOctokit: vi.fn()
}));

View File

@@ -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 {BuildKit} from '../../src/buildkit/buildkit.js';
import {Builder} from '../../src/buildx/builder.js';
import {BuilderInfo} from '../../src/types/buildx/builder';
import {BuilderInfo} from '../../src/types/buildx/builder.js';
jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
vi.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
return {
name: 'builder2',
driver: 'docker-container',

View File

@@ -14,25 +14,25 @@
* 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';
import * as rimraf from 'rimraf';
import {BuildKit} from '../../src/buildkit/buildkit';
import {Context} from '../../src/context';
import {BuildKit} from '../../src/buildkit/buildkit.js';
import {Context} from '../../src/context.js';
const fixturesDir = path.join(__dirname, '..', '.fixtures');
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildkit-config-'));
const tmpName = path.join(tmpDir, '.tmpname-jest');
const tmpName = path.join(tmpDir, '.tmpname-vi');
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
fs.mkdirSync(tmpDir, {recursive: true});
return tmpDir;
});
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
return tmpName;
});
@@ -66,7 +66,7 @@ describe('resolve', () => {
const configValue = fs.readFileSync(tmpName, 'utf-8');
expect(configValue).toEqual(exValue);
} catch (e) {
// eslint-disable-next-line jest/no-conditional-expect
// eslint-disable-next-line vitest/no-conditional-expect
expect(e.message).toEqual(error?.message);
}
});

View File

@@ -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 {Git} from '../../src/buildkit/git.js';
import {GitRef, GitURL} from '../../src/types/buildkit/git';
import {GitRef, GitURL} from '../../src/types/buildkit/git.js';
beforeEach(() => {
jest.restoreAllMocks();
vi.restoreAllMocks();
});
describe('parseURL', () => {
@@ -195,7 +195,7 @@ describe('parseURL', () => {
if (!expectedErr) {
console.log(err);
}
// eslint-disable-next-line jest/no-conditional-expect
// eslint-disable-next-line vitest/no-conditional-expect
expect(expectedErr).toBeTruthy();
}
});
@@ -337,7 +337,7 @@ describe('parseRef', () => {
if (expected) {
console.log(err);
}
// eslint-disable-next-line jest/no-conditional-expect
// eslint-disable-next-line vitest/no-conditional-expect
expect(expected).toBeUndefined();
}
});

View File

@@ -14,12 +14,12 @@
* 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';
import {Bake} from '../../src/buildx/bake';
import {BakeDefinition} from '../../src/types/buildx/bake';
import {Bake} from '../../src/buildx/bake.js';
import {BakeDefinition} from '../../src/types/buildx/bake.js';
const fixturesDir = path.join(__dirname, '..', '.fixtures');

View File

@@ -14,30 +14,30 @@
* 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';
import * as rimraf from 'rimraf';
import {Bake} from '../../src/buildx/bake';
import {Context} from '../../src/context';
import {Bake} from '../../src/buildx/bake.js';
import {Context} from '../../src/context.js';
import {ExecOptions} from '@actions/exec';
import {BakeDefinition} from '../../src/types/buildx/bake';
import {BuildMetadata} from '../../src/types/buildx/build';
import {BakeDefinition} from '../../src/types/buildx/bake.js';
import {BuildMetadata} from '../../src/types/buildx/build.js';
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;
});

View File

@@ -14,26 +14,26 @@
* 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';
import * as rimraf from 'rimraf';
import {Context} from '../../src/context';
import {Build} from '../../src/buildx/build';
import {Context} from '../../src/context.js';
import {Build} from '../../src/buildx/build.js';
const fixturesDir = path.join(__dirname, '..', '.fixtures');
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-build-'));
const tmpName = path.join(tmpDir, '.tmpname-jest');
const tmpName = path.join(tmpDir, '.tmpname-vi');
const metadata = JSON.parse(fs.readFileSync(path.join(fixturesDir, 'metadata-build.json'), 'utf-8'));
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
fs.mkdirSync(tmpDir, {recursive: true});
return tmpDir;
});
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
return tmpName;
});
@@ -191,7 +191,7 @@ describe('resolveSecret', () => {
expect(secret).toEqual(`id=${exKey},src=${tmpName}`);
expect(fs.readFileSync(tmpName, 'utf-8')).toEqual(exValue);
} catch (e) {
// eslint-disable-next-line jest/no-conditional-expect
// eslint-disable-next-line vitest/no-conditional-expect
expect(e.message).toEqual(error?.message);
}
});
@@ -206,7 +206,7 @@ describe('resolveSecret', () => {
const secret = Build.resolveSecretEnv(kvp);
expect(secret).toEqual(`id=${exKey},env=${exValue}`);
} catch (e) {
// eslint-disable-next-line jest/no-conditional-expect
// eslint-disable-next-line vitest/no-conditional-expect
expect(e.message).toEqual(error?.message);
}
});

View File

@@ -14,18 +14,18 @@
* 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';
import {Builder} from '../../src/buildx/builder';
import {Exec} from '../../src/exec';
import {Builder} from '../../src/buildx/builder.js';
import {Exec} from '../../src/exec.js';
import {BuilderInfo} from '../../src/types/buildx/builder';
import {BuilderInfo} from '../../src/types/buildx/builder.js';
const fixturesDir = path.join(__dirname, '..', '.fixtures');
jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
vi.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
return {
name: 'builder2',
driver: 'docker-container',
@@ -46,7 +46,7 @@ jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<Bu
describe('exists', () => {
it('valid', async () => {
const execSpy = jest.spyOn(Exec, 'getExecOutput');
const execSpy = vi.spyOn(Exec, 'getExecOutput');
const builder = new Builder();
await builder.exists('foo');
expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx', 'inspect', 'foo'], {

View File

@@ -14,16 +14,16 @@
* 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';
import * as core from '@actions/core';
import {Buildx} from '../../src/buildx/buildx';
import {Build} from '../../src/buildx/build';
import {Bake} from '../../src/buildx/bake';
import {Exec} from '../../src/exec';
import {Buildx} from '../../src/buildx/buildx.js';
import {Build} from '../../src/buildx/build.js';
import {Bake} from '../../src/buildx/bake.js';
import {Exec} from '../../src/exec.js';
const fixturesDir = path.join(__dirname, '..', '.fixtures');
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-buildx-itg-'));

View File

@@ -14,29 +14,29 @@
* limitations under the License.
*/
import {describe, expect, it, jest, test, beforeEach, afterEach} from '@jest/globals';
import {describe, expect, it, vi, test, beforeEach, afterEach} from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import * as rimraf from 'rimraf';
import * as semver from 'semver';
import {Buildx} from '../../src/buildx/buildx';
import {Context} from '../../src/context';
import {Exec} from '../../src/exec';
import {Buildx} from '../../src/buildx/buildx.js';
import {Context} from '../../src/context.js';
import {Exec} from '../../src/exec.js';
import {Cert, LocalState} from '../../src/types/buildx/buildx';
import {Cert, LocalState} from '../../src/types/buildx/buildx.js';
const fixturesDir = path.join(__dirname, '..', '.fixtures');
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-buildx-'));
const tmpName = path.join(tmpDir, '.tmpname-jest');
const tmpName = path.join(tmpDir, '.tmpname-vi');
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
fs.mkdirSync(tmpDir, {recursive: true});
return tmpDir;
});
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
return tmpName;
});
@@ -47,7 +47,7 @@ afterEach(() => {
describe('configDir', () => {
const originalEnv = process.env;
beforeEach(() => {
jest.resetModules();
vi.resetModules();
process.env = {
...originalEnv,
BUILDX_CONFIG: '/var/docker/buildx',
@@ -69,7 +69,7 @@ describe('configDir', () => {
describe('certsDir', () => {
const originalEnv = process.env;
beforeEach(() => {
jest.resetModules();
vi.resetModules();
process.env = {
...originalEnv,
BUILDX_CONFIG: '/var/docker/buildx'
@@ -86,7 +86,7 @@ describe('certsDir', () => {
describe('isAvailable', () => {
it('docker cli', async () => {
const execSpy = jest.spyOn(Exec, 'getExecOutput');
const execSpy = vi.spyOn(Exec, 'getExecOutput');
const buildx = new Buildx({
standalone: false
});
@@ -97,7 +97,7 @@ describe('isAvailable', () => {
});
});
it('standalone', async () => {
const execSpy = jest.spyOn(Exec, 'getExecOutput');
const execSpy = vi.spyOn(Exec, 'getExecOutput');
const buildx = new Buildx({
standalone: true
});
@@ -111,7 +111,7 @@ describe('isAvailable', () => {
describe('printVersion', () => {
it('docker cli', async () => {
const execSpy = jest.spyOn(Exec, 'exec');
const execSpy = vi.spyOn(Exec, 'exec');
const buildx = new Buildx({
standalone: false
});
@@ -121,7 +121,7 @@ describe('printVersion', () => {
});
});
it('standalone', async () => {
const execSpy = jest.spyOn(Exec, 'exec');
const execSpy = vi.spyOn(Exec, 'exec');
const buildx = new Buildx({
standalone: true
});
@@ -164,7 +164,7 @@ describe('versionSatisfies', () => {
describe('resolveCertsDriverOpts', () => {
const originalEnv = process.env;
beforeEach(() => {
jest.resetModules();
vi.resetModules();
process.env = {
...originalEnv,
BUILDX_CONFIG: path.join(tmpDir, 'resolveCertsDriverOpts', 'buildx')

View File

@@ -14,16 +14,16 @@
* limitations under the License.
*/
import {describe, expect, it, test} from '@jest/globals';
import {describe, expect, it, test} from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import {Buildx} from '../../src/buildx/buildx';
import {Bake} from '../../src/buildx/bake';
import {Build} from '../../src/buildx/build';
import {History} from '../../src/buildx/history';
import {Exec} from '../../src/exec';
import {Buildx} from '../../src/buildx/buildx.js';
import {Bake} from '../../src/buildx/bake.js';
import {Build} from '../../src/buildx/build.js';
import {History} from '../../src/buildx/history.js';
import {Exec} from '../../src/exec.js';
const fixturesDir = path.join(__dirname, '..', '.fixtures');
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-history-itg-'));

View File

@@ -14,15 +14,15 @@
* limitations under the License.
*/
import {describe, expect, it} from '@jest/globals';
import {describe, expect, it} from 'vitest';
import * as fs from 'fs';
import * as path from 'path';
import {ImageTools} from '../../src/buildx/imagetools';
import {ImageTools} from '../../src/buildx/imagetools.js';
import {Manifest as ImageToolsManifest} from '../../src/types/buildx/imagetools';
import {Image} from '../../src/types/oci/config';
import {Descriptor} from '../../src/types/oci/descriptor';
import {Manifest as ImageToolsManifest} from '../../src/types/buildx/imagetools.js';
import {Image} from '../../src/types/oci/config.js';
import {Descriptor} from '../../src/types/oci/descriptor.js';
const fixturesDir = path.join(__dirname, '..', '.fixtures');

View File

@@ -14,10 +14,10 @@
* limitations under the License.
*/
import {describe, expect, test} from '@jest/globals';
import {describe, expect, test} from 'vitest';
import * as fs from 'fs';
import {Install} from '../../src/buildx/install';
import {Install} from '../../src/buildx/install.js';
const maybe = !process.env.GITHUB_ACTIONS || (process.env.GITHUB_ACTIONS === 'true' && process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) ? describe : describe.skip;

View File

@@ -14,15 +14,15 @@
* limitations under the License.
*/
import {describe, expect, it, test, afterEach} from '@jest/globals';
import {describe, expect, it, test, afterEach} from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import * as rimraf from 'rimraf';
import {mockArch, mockPlatform} from '../.helpers/os';
import {mockArch, mockPlatform} from '../.helpers/os.js';
import {Install} from '../../src/buildx/install';
import {Install} from '../../src/buildx/install.js';
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-install-'));

View File

@@ -14,13 +14,13 @@
* 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';
import {Cache} from '../src/cache';
import {Util} from '../src/util';
import {Cache} from '../src/cache.js';
import {Util} from '../src/util.js';
const fixturesDir = path.join(__dirname, '.fixtures');
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'cache-itg-'));

View File

@@ -14,27 +14,27 @@
* limitations under the License.
*/
import {describe, expect, it, jest, test, afterEach} from '@jest/globals';
import {describe, expect, it, vi, test, afterEach} from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import * as rimraf from 'rimraf';
import * as semver from 'semver';
import {Context} from '../../src/context';
import {Exec} from '../../src/exec';
import {Context} from '../../src/context.js';
import {Exec} from '../../src/exec.js';
import {Compose} from '../../src/compose/compose';
import {Compose} from '../../src/compose/compose.js';
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'compose-compose-'));
const tmpName = path.join(tmpDir, '.tmpname-jest');
const tmpName = path.join(tmpDir, '.tmpname-vi');
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
fs.mkdirSync(tmpDir, {recursive: true});
return tmpDir;
});
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
return tmpName;
});
@@ -44,7 +44,7 @@ afterEach(() => {
describe('isAvailable', () => {
it('docker cli', async () => {
const execSpy = jest.spyOn(Exec, 'getExecOutput');
const execSpy = vi.spyOn(Exec, 'getExecOutput');
const compose = new Compose({
standalone: false
});
@@ -55,7 +55,7 @@ describe('isAvailable', () => {
});
});
it('standalone', async () => {
const execSpy = jest.spyOn(Exec, 'getExecOutput');
const execSpy = vi.spyOn(Exec, 'getExecOutput');
const compose = new Compose({
standalone: true
});
@@ -69,7 +69,7 @@ describe('isAvailable', () => {
describe('printVersion', () => {
it('docker cli', async () => {
const execSpy = jest.spyOn(Exec, 'exec');
const execSpy = vi.spyOn(Exec, 'exec');
const compose = new Compose({
standalone: false
});
@@ -79,7 +79,7 @@ describe('printVersion', () => {
});
});
it('standalone', async () => {
const execSpy = jest.spyOn(Exec, 'exec');
const execSpy = vi.spyOn(Exec, 'exec');
const compose = new Compose({
standalone: true
});

View File

@@ -14,10 +14,10 @@
* limitations under the License.
*/
import {describe, expect, test} from '@jest/globals';
import {describe, expect, test} from 'vitest';
import * as fs from 'fs';
import {Install} from '../../src/compose/install';
import {Install} from '../../src/compose/install.js';
const maybe = !process.env.GITHUB_ACTIONS || (process.env.GITHUB_ACTIONS === 'true' && process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) ? describe : describe.skip;

View File

@@ -14,15 +14,15 @@
* limitations under the License.
*/
import {describe, expect, it, test, afterEach} from '@jest/globals';
import {describe, expect, it, test, afterEach} from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import * as rimraf from 'rimraf';
import {mockArch, mockPlatform} from '../.helpers/os';
import {mockArch, mockPlatform} from '../.helpers/os.js';
import {Install} from '../../src/compose/install';
import {Install} from '../../src/compose/install.js';
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'compose-install-'));

View File

@@ -14,23 +14,23 @@
* limitations under the License.
*/
import {describe, expect, jest, it, afterEach, beforeEach, test} from '@jest/globals';
import {describe, expect, vi, it, afterEach, beforeEach, test} from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import * as rimraf from 'rimraf';
import {Context} from '../src/context';
import {Context} from '../src/context.js';
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'context-'));
const tmpName = path.join(tmpDir, '.tmpname-jest');
const tmpName = path.join(tmpDir, '.tmpname-vi');
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
fs.mkdirSync(tmpDir, {recursive: true});
return tmpDir;
});
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
return tmpName;
});
@@ -47,7 +47,7 @@ describe('gitRef', () => {
describe('parseGitRef', () => {
const originalEnv = process.env;
beforeEach(() => {
jest.resetModules();
vi.resetModules();
process.env = {
...originalEnv,
DOCKER_GIT_CONTEXT_PR_HEAD_REF: ''

View File

@@ -14,19 +14,19 @@
* limitations under the License.
*/
import {describe, expect, it, jest, test} from '@jest/globals';
import {describe, expect, it, vi, test} from 'vitest';
import fs from 'fs';
import path from 'path';
import * as semver from 'semver';
import {Exec} from '../../src/exec';
import {Cosign} from '../../src/cosign/cosign';
import {Exec} from '../../src/exec.js';
import {Cosign} from '../../src/cosign/cosign.js';
const fixturesDir = path.join(__dirname, '..', '.fixtures');
describe('isAvailable', () => {
it('checks Cosign is available', async () => {
const execSpy = jest.spyOn(Exec, 'getExecOutput');
const execSpy = vi.spyOn(Exec, 'getExecOutput');
const cosign = new Cosign();
await cosign.isAvailable();
expect(execSpy).toHaveBeenCalledWith(`cosign`, [], {
@@ -38,7 +38,7 @@ describe('isAvailable', () => {
describe('printVersion', () => {
it('prints Cosign version', async () => {
const execSpy = jest.spyOn(Exec, 'exec');
const execSpy = vi.spyOn(Exec, 'exec');
const cosign = new Cosign();
await cosign.printVersion();
expect(execSpy).toHaveBeenCalledWith(`cosign`, ['version', '--json'], {

View File

@@ -14,10 +14,10 @@
* limitations under the License.
*/
import {describe, expect, it, test} from '@jest/globals';
import {describe, expect, it, test} from 'vitest';
import * as fs from 'fs';
import {Install} from '../../src/cosign/install';
import {Install} from '../../src/cosign/install.js';
const maybe = !process.env.GITHUB_ACTIONS || (process.env.GITHUB_ACTIONS === 'true' && process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) ? describe : describe.skip;

View File

@@ -14,15 +14,15 @@
* limitations under the License.
*/
import {describe, expect, it, test, afterEach} from '@jest/globals';
import {describe, expect, it, test, afterEach} from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import * as rimraf from 'rimraf';
import {mockArch, mockPlatform} from '../.helpers/os';
import {mockArch, mockPlatform} from '../.helpers/os.js';
import {Install} from '../../src/cosign/install';
import {Install} from '../../src/cosign/install.js';
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'cosign-install-'));

View File

@@ -14,9 +14,9 @@
* 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.js';
const maybe = !process.env.GITHUB_ACTIONS || (process.env.GITHUB_ACTIONS === 'true' && process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) ? describe : describe.skip;
@@ -55,7 +55,7 @@ maybe('pull', () => {
if (err === undefined) {
throw new Error(`Expected no error, but got: ${e.message}`);
}
// eslint-disable-next-line jest/no-conditional-expect
// eslint-disable-next-line vitest/no-conditional-expect
expect(e.message).toContain(err);
}
}, 600000);

View File

@@ -14,18 +14,26 @@
* limitations under the License.
*/
import {afterEach, beforeEach, describe, expect, it, jest} from '@jest/globals';
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import * as io from '@actions/io';
import * as rimraf from 'rimraf';
import {mockHomedir} from '../.helpers/os';
import {mockHomedir} from '../.helpers/os.js';
import {Docker} from '../../src/docker/docker';
import {Docker} from '../../src/docker/docker.js';
import {ConfigFile} from '../../src/types/docker/docker';
import {ConfigFile} from '../../src/types/docker/docker.js';
vi.mock('@actions/io', async () => {
const actual = await vi.importActual<typeof import('@actions/io')>('@actions/io');
return {
...actual,
which: vi.fn()
};
});
const fixturesDir = path.join(__dirname, '..', '.fixtures');
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-docker-'));
@@ -37,7 +45,7 @@ afterEach(function () {
describe('configDir', () => {
const originalEnv = process.env;
beforeEach(() => {
jest.resetModules();
vi.resetModules();
process.env = {
...originalEnv,
DOCKER_CONFIG: '/var/docker/config'
@@ -59,7 +67,7 @@ describe('configDir', () => {
describe('configFile', () => {
const originalEnv = process.env;
beforeEach(() => {
jest.resetModules();
vi.resetModules();
if (!fs.existsSync(tmpDir)) {
fs.mkdirSync(tmpDir, {recursive: true});
}
@@ -97,7 +105,7 @@ describe('configFile', () => {
describe('isAvailable', () => {
it('cli', async () => {
const ioWhichSpy = jest.spyOn(io, 'which');
const ioWhichSpy = vi.mocked(io.which).mockResolvedValue('/usr/bin/docker');
await Docker.isAvailable();
expect(ioWhichSpy).toHaveBeenCalledTimes(1);
expect(ioWhichSpy).toHaveBeenCalledWith('docker', true);
@@ -106,7 +114,7 @@ describe('isAvailable', () => {
describe('exec', () => {
it('returns docker version', async () => {
const execSpy = jest.spyOn(Docker, 'exec');
const execSpy = vi.spyOn(Docker, 'exec');
await Docker.exec(['version'], {
ignoreReturnCode: true,
silent: true
@@ -133,7 +141,7 @@ describe('exec', () => {
describe('getExecOutput', () => {
it('returns docker version', async () => {
const execSpy = jest.spyOn(Docker, 'getExecOutput');
const execSpy = vi.spyOn(Docker, 'getExecOutput');
await Docker.getExecOutput(['version'], {
ignoreReturnCode: true,
silent: true
@@ -160,7 +168,7 @@ describe('getExecOutput', () => {
describe('context', () => {
it('call docker context show', async () => {
const execSpy = jest.spyOn(Docker, 'getExecOutput');
const execSpy = vi.spyOn(Docker, 'getExecOutput');
await Docker.context().catch(() => {
// noop
});
@@ -182,7 +190,7 @@ describe('context', () => {
describe('contextInspect', () => {
it('call docker context inspect', async () => {
const execSpy = jest.spyOn(Docker, 'getExecOutput');
const execSpy = vi.spyOn(Docker, 'getExecOutput');
await Docker.contextInspect('foo').catch(() => {
// noop
});
@@ -204,7 +212,7 @@ describe('contextInspect', () => {
describe('printVersion', () => {
it('call docker version', async () => {
const execSpy = jest.spyOn(Docker, 'exec');
const execSpy = vi.spyOn(Docker, 'exec');
await Docker.printVersion().catch(() => {
// noop
});
@@ -220,7 +228,7 @@ describe('printVersion', () => {
describe('printInfo', () => {
it('call docker info', async () => {
const execSpy = jest.spyOn(Docker, 'exec');
const execSpy = vi.spyOn(Docker, 'exec');
await Docker.printInfo().catch(() => {
// noop
});

View File

@@ -14,16 +14,16 @@
* limitations under the License.
*/
import {beforeAll, describe, test, expect} from '@jest/globals';
import {beforeAll, describe, test, expect} from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import {Install, InstallSource, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
import {Docker} from '../../src/docker/docker';
import {Install as RegclientInstall} from '../../src/regclient/install';
import {Install as UndockInstall} from '../../src/undock/install';
import {Exec} from '../../src/exec';
import {Install, InstallSource, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install.js';
import {Docker} from '../../src/docker/docker.js';
import {Install as RegclientInstall} from '../../src/regclient/install.js';
import {Install as UndockInstall} from '../../src/undock/install.js';
import {Exec} from '../../src/exec.js';
const tmpDir = () => fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-itg-'));

View File

@@ -14,15 +14,15 @@
* limitations under the License.
*/
import {describe, expect, jest, test, beforeEach, afterEach, it} from '@jest/globals';
import {describe, expect, vi, test, beforeEach, afterEach, it} from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import * as rimraf from 'rimraf';
import {mockArch, mockPlatform} from '../.helpers/os';
import {mockArch, mockPlatform} from '../.helpers/os.js';
import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install.js';
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-'));
@@ -103,7 +103,7 @@ describe('getRelease', () => {
describe('limaImage', () => {
const originalEnv = process.env;
beforeEach(() => {
jest.resetModules();
vi.resetModules();
process.env = {
...originalEnv,
LIMA_IMAGES: `x86_64:https://cloud-images.ubuntu.com/releases/23.10/release-20231011/ubuntu-23.10-server-cloudimg-amd64.img@sha256:f6529be56da3429a56e4f5ef202bf4958201bc63f8541e478caa6e8eb712e635

View File

@@ -14,24 +14,24 @@
* limitations under the License.
*/
import {describe, expect, jest, it} from '@jest/globals';
import {describe, expect, vi, it} from 'vitest';
import * as fs from 'fs';
import * as path from 'path';
import {DockerHub} from '../src/dockerhub';
import {RepositoryResponse, RepositoryTagsResponse} from '../src/types/dockerhub';
import {DockerHub} from '../src/dockerhub.js';
import {RepositoryResponse, RepositoryTagsResponse} from '../src/types/dockerhub.js';
import repoInfoFixture from './.fixtures/dockerhub-repoinfo.json';
import repoTagsFixture from './.fixtures/dockerhub-repotags.json';
import repoAllTagsFixture from './.fixtures/dockerhub-repoalltags.json';
import repoInfoFixture from './.fixtures/dockerhub-repoinfo.json' with {type: 'json'};
import repoTagsFixture from './.fixtures/dockerhub-repotags.json' with {type: 'json'};
import repoAllTagsFixture from './.fixtures/dockerhub-repoalltags.json' with {type: 'json'};
describe('getRepository', () => {
it('returns repo info', async () => {
jest.spyOn(DockerHub.prototype, 'getRepository').mockImplementation((): Promise<RepositoryResponse> => {
vi.spyOn(DockerHub.prototype, 'getRepository').mockImplementation((): Promise<RepositoryResponse> => {
return <Promise<RepositoryResponse>>(repoInfoFixture as unknown);
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
jest.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
vi.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
const dockerhub = await DockerHub.build({
credentials: {
username: 'foo',
@@ -50,11 +50,11 @@ describe('getRepository', () => {
describe('getRepositoryTags', () => {
it('return repo tags', async () => {
jest.spyOn(DockerHub.prototype, 'getRepositoryTags').mockImplementation((): Promise<RepositoryTagsResponse> => {
vi.spyOn(DockerHub.prototype, 'getRepositoryTags').mockImplementation((): Promise<RepositoryTagsResponse> => {
return <Promise<RepositoryTagsResponse>>(repoTagsFixture as unknown);
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
jest.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
vi.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
const dockerhub = await DockerHub.build({
credentials: {
username: 'foo',
@@ -74,11 +74,11 @@ describe('getRepositoryTags', () => {
describe('getRepositoryAllTags', () => {
it('return repo all tags', async () => {
jest.spyOn(DockerHub.prototype, 'getRepositoryAllTags').mockImplementation((): Promise<RepositoryTagsResponse> => {
vi.spyOn(DockerHub.prototype, 'getRepositoryAllTags').mockImplementation((): Promise<RepositoryTagsResponse> => {
return <Promise<RepositoryTagsResponse>>(repoAllTagsFixture as unknown);
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
jest.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
vi.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
const dockerhub = await DockerHub.build({
credentials: {
username: 'foo',

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
import {describe, expect, it, jest} from '@jest/globals';
import {describe, expect, it, vi} from 'vitest';
import {Exec} from '../src/exec';
import {Exec} from '../src/exec.js';
describe('exec', () => {
it('returns docker version', async () => {
const execSpy = jest.spyOn(Exec, 'exec');
const execSpy = vi.spyOn(Exec, 'exec');
await Exec.exec('docker', ['version'], {
ignoreReturnCode: true,
silent: true
@@ -34,7 +34,7 @@ describe('exec', () => {
describe('getExecOutput', () => {
it('returns docker version', async () => {
const execSpy = jest.spyOn(Exec, 'getExecOutput');
const execSpy = vi.spyOn(Exec, 'getExecOutput');
await Exec.getExecOutput('docker', ['version'], {
ignoreReturnCode: true,
silent: true

25
__tests__/git.test.itg.ts Normal file
View File

@@ -0,0 +1,25 @@
/**
* 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 {describe, expect, it} from 'vitest';
import {Git} from '../src/git.js';
describe('remoteSha', () => {
it('returns sha using github api', async () => {
expect(await Git.remoteSha('https://github.com/docker/buildx.git', 'refs/pull/648/head', process.env.GITHUB_TOKEN)).toEqual('f11797113e5a9b86bd976329c5dbb8a8bfdfadfa');
});
});

View File

@@ -14,19 +14,19 @@
* limitations under the License.
*/
import {beforeEach, describe, expect, it, jest} from '@jest/globals';
import {beforeEach, describe, expect, it, vi} from 'vitest';
import {Git as GitMocked} from '../src/git';
import {Exec} from '../src/exec';
import {Git} from '../src/git.js';
import {Exec} from '../src/exec.js';
import {ExecOutput} from '@actions/exec';
beforeEach(() => {
jest.restoreAllMocks();
vi.restoreAllMocks();
});
describe('context', () => {
it('returns mocked ref and sha', async () => {
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
const fullCmd = `${cmd} ${args?.join(' ')}`;
let result = '';
switch (fullCmd) {
@@ -46,7 +46,7 @@ describe('context', () => {
exitCode: 0
});
});
const ctx = await GitMocked.context();
const ctx = await Git.context();
expect(ctx.ref).toEqual('refs/heads/test');
expect(ctx.sha).toEqual('test-sha');
});
@@ -54,9 +54,9 @@ describe('context', () => {
describe('isInsideWorkTree', () => {
it('have been called', async () => {
const execSpy = jest.spyOn(Exec, 'getExecOutput');
const execSpy = vi.spyOn(Exec, 'getExecOutput');
try {
await GitMocked.isInsideWorkTree();
await Git.isInsideWorkTree();
} catch {
// noop
}
@@ -69,21 +69,15 @@ describe('isInsideWorkTree', () => {
describe('remoteSha', () => {
it('returns sha using git ls-remote', async () => {
expect(await GitMocked.remoteSha('https://github.com/docker/buildx.git', 'refs/pull/648/head')).toEqual('f11797113e5a9b86bd976329c5dbb8a8bfdfadfa');
});
it('returns sha using github api', async () => {
jest.resetModules();
jest.unmock('@actions/github');
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')).toEqual('f11797113e5a9b86bd976329c5dbb8a8bfdfadfa');
});
});
describe('remoteURL', () => {
it('have been called', async () => {
const execSpy = jest.spyOn(Exec, 'getExecOutput');
const execSpy = vi.spyOn(Exec, 'getExecOutput');
try {
await GitMocked.remoteURL();
await Git.remoteURL();
} catch {
// noop
}
@@ -96,7 +90,7 @@ describe('remoteURL', () => {
describe('ref', () => {
it('returns mocked ref', async () => {
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
const fullCmd = `${cmd} ${args?.join(' ')}`;
let result = '';
switch (fullCmd) {
@@ -113,14 +107,12 @@ describe('ref', () => {
exitCode: 0
});
});
const ref = await GitMocked.ref();
const ref = await Git.ref();
expect(ref).toEqual('refs/heads/test');
});
it('returns mocked detached tag ref', async () => {
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
const fullCmd = `${cmd} ${args?.join(' ')}`;
let result = '';
switch (fullCmd) {
@@ -137,14 +129,12 @@ describe('ref', () => {
exitCode: 0
});
});
const ref = await GitMocked.ref();
const ref = await Git.ref();
expect(ref).toEqual('refs/tags/8.0.0');
});
it('returns mocked detached tag ref (shallow clone)', async () => {
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
const fullCmd = `${cmd} ${args?.join(' ')}`;
let result = '';
switch (fullCmd) {
@@ -161,14 +151,12 @@ describe('ref', () => {
exitCode: 0
});
});
const ref = await GitMocked.ref();
const ref = await Git.ref();
expect(ref).toEqual('refs/tags/8.0.0');
});
it('returns mocked detached pull request merge ref (shallow clone)', async () => {
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
const fullCmd = `${cmd} ${args?.join(' ')}`;
let result = '';
switch (fullCmd) {
@@ -185,14 +173,12 @@ describe('ref', () => {
exitCode: 0
});
});
const ref = await GitMocked.ref();
const ref = await Git.ref();
expect(ref).toEqual('refs/pull/221/merge');
});
it('should throws an error when detached HEAD ref is not supported', async () => {
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
const fullCmd = `${cmd} ${args?.join(' ')}`;
let result = '';
switch (fullCmd) {
@@ -209,12 +195,11 @@ describe('ref', () => {
exitCode: 0
});
});
await expect(GitMocked.ref()).rejects.toThrow('Cannot find detached HEAD ref in "wrong, HEAD, tag: 8.0.0"');
await expect(Git.ref()).rejects.toThrow('Cannot find detached HEAD ref in "wrong, HEAD, tag: 8.0.0"');
});
it('returns mocked detached branch ref', async () => {
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
const fullCmd = `${cmd} ${args?.join(' ')}`;
let result = '';
switch (fullCmd) {
@@ -231,14 +216,12 @@ describe('ref', () => {
exitCode: 0
});
});
const ref = await GitMocked.ref();
const ref = await Git.ref();
expect(ref).toEqual('refs/heads/test');
});
it('returns mocked detached branch ref checked out by SHA', async () => {
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
const fullCmd = `${cmd} ${args?.join(' ')}`;
let result = '';
switch (fullCmd) {
@@ -255,14 +238,12 @@ describe('ref', () => {
exitCode: 0
});
});
const ref = await GitMocked.ref();
const ref = await Git.ref();
expect(ref).toEqual('refs/heads/feature-branch');
});
it('infers ref from local branch when detached HEAD returns only "HEAD"', async () => {
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
const fullCmd = `${cmd} ${args?.join(' ')}`;
let result = '';
switch (fullCmd) {
@@ -282,14 +263,12 @@ describe('ref', () => {
exitCode: 0
});
});
const ref = await GitMocked.ref();
const ref = await Git.ref();
expect(ref).toEqual('refs/heads/main');
});
it('infers ref from local branch when detached HEAD returns only "grafted, HEAD"', async () => {
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
const fullCmd = `${cmd} ${args?.join(' ')}`;
let result = '';
switch (fullCmd) {
@@ -309,14 +288,12 @@ describe('ref', () => {
exitCode: 0
});
});
const ref = await GitMocked.ref();
const ref = await Git.ref();
expect(ref).toEqual('refs/heads/main');
});
it('infers ref from remote branch when no local branch contains HEAD', async () => {
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
const fullCmd = `${cmd} ${args?.join(' ')}`;
let result = '';
switch (fullCmd) {
@@ -339,14 +316,12 @@ describe('ref', () => {
exitCode: 0
});
});
const ref = await GitMocked.ref();
const ref = await Git.ref();
expect(ref).toEqual('refs/heads/feature');
});
it('infers ref from tag when no branch contains HEAD', async () => {
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
const fullCmd = `${cmd} ${args?.join(' ')}`;
let result = '';
switch (fullCmd) {
@@ -372,14 +347,12 @@ describe('ref', () => {
exitCode: 0
});
});
const ref = await GitMocked.ref();
const ref = await Git.ref();
expect(ref).toEqual('refs/tags/v1.0.0');
});
it('throws error when cannot infer ref from detached HEAD', async () => {
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
const fullCmd = `${cmd} ${args?.join(' ')}`;
let result = '';
switch (fullCmd) {
@@ -405,12 +378,11 @@ describe('ref', () => {
exitCode: 0
});
});
await expect(GitMocked.ref()).rejects.toThrow('Cannot infer ref from detached HEAD');
await expect(Git.ref()).rejects.toThrow('Cannot infer ref from detached HEAD');
});
it('handles remote ref without branch pattern when inferring from remote', async () => {
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
const fullCmd = `${cmd} ${args?.join(' ')}`;
let result = '';
switch (fullCmd) {
@@ -433,18 +405,16 @@ describe('ref', () => {
exitCode: 0
});
});
const ref = await GitMocked.ref();
const ref = await Git.ref();
expect(ref).toEqual('refs/remotes/unusual-format');
});
});
describe('fullCommit', () => {
it('have been called', async () => {
const execSpy = jest.spyOn(Exec, 'getExecOutput');
const execSpy = vi.spyOn(Exec, 'getExecOutput');
try {
await GitMocked.fullCommit();
await Git.fullCommit();
} catch {
// noop
}
@@ -457,9 +427,9 @@ describe('fullCommit', () => {
describe('shortCommit', () => {
it('have been called', async () => {
const execSpy = jest.spyOn(Exec, 'getExecOutput');
const execSpy = vi.spyOn(Exec, 'getExecOutput');
try {
await GitMocked.shortCommit();
await Git.shortCommit();
} catch {
// noop
}
@@ -472,9 +442,9 @@ describe('shortCommit', () => {
describe('tag', () => {
it('have been called', async () => {
const execSpy = jest.spyOn(Exec, 'getExecOutput');
const execSpy = vi.spyOn(Exec, 'getExecOutput');
try {
await GitMocked.tag();
await Git.tag();
} catch {
// noop
}
@@ -487,7 +457,7 @@ describe('tag', () => {
describe('getCommitDate', () => {
it('head', async () => {
const date = await GitMocked.commitDate('HEAD');
await expect(date).toBeInstanceOf(Date);
const date = await Git.commitDate('HEAD');
expect(date).toBeInstanceOf(Date);
});
});

View File

@@ -14,13 +14,13 @@
* 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';
import {GitHubArtifact} from '../../src/github/artifact';
import {Util} from '../../src/util';
import {GitHubArtifact} from '../../src/github/artifact.js';
import {Util} from '../../src/util.js';
const fixturesDir = path.join(__dirname, '..', '.fixtures');
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'github-itg-'));

View File

@@ -0,0 +1,41 @@
/**
* 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 {describe, expect, it} from 'vitest';
import {GitHub} from '../../src/github/github.js';
describe('repoData', () => {
it('returns docker/actions-toolkit', async () => {
if (!process.env.GITHUB_TOKEN) {
console.log(`GitHub token not available, skipping test`);
return;
}
const originalEnv = process.env;
process.env = {
...originalEnv,
GITHUB_REPOSITORY: 'docker/actions-toolkit'
};
try {
const github = new GitHub({token: process.env.GITHUB_TOKEN});
const repo = await github.repoData();
const fullName = repo.full_name ?? `${repo.owner?.login}/${repo.name}`;
expect(fullName).toEqual('docker/actions-toolkit');
} finally {
process.env = originalEnv;
}
});
});

View File

@@ -14,21 +14,29 @@
* limitations under the License.
*/
import {describe, expect, jest, it, beforeEach, afterEach, test} from '@jest/globals';
import {describe, expect, vi, it, beforeEach, afterEach, test} from 'vitest';
import * as fs from 'fs';
import * as path from 'path';
import * as core from '@actions/core';
import {GitHub} from '../../src/github/github';
import {GitHubRepo} from '../../src/types/github/github';
import {GitHub} from '../../src/github/github.js';
import {GitHubRepo} from '../../src/types/github/github.js';
import repoFixture from '../.fixtures/github-repo.json';
import repoFixture from '../.fixtures/github-repo.json' with {type: 'json'};
const fixturesDir = path.join(__dirname, '..', '.fixtures');
vi.mock('@actions/core', async () => {
const actual = await vi.importActual<typeof import('@actions/core')>('@actions/core');
return {
...actual,
info: vi.fn()
};
});
describe('repoData', () => {
it('returns GitHub repo data', async () => {
jest.spyOn(GitHub.prototype, 'repoData').mockImplementation((): Promise<GitHubRepo> => {
vi.spyOn(GitHub.prototype, 'repoData').mockImplementation((): Promise<GitHubRepo> => {
return <Promise<GitHubRepo>>(repoFixture as unknown);
});
const github = new GitHub();
@@ -36,32 +44,6 @@ describe('repoData', () => {
});
});
describe('repoData (api)', () => {
it('returns docker/actions-toolkit', async () => {
if (!process.env.GITHUB_TOKEN) {
return;
}
const originalEnv = process.env;
process.env = {
...originalEnv,
GITHUB_REPOSITORY: 'docker/actions-toolkit'
};
try {
jest.resetModules();
jest.unmock('@actions/github');
const {GitHub} = await import('../../src/github/github');
const github = new GitHub({token: process.env.GITHUB_TOKEN});
const repo = await github.repoData();
const fullName = repo.full_name ?? `${repo.owner?.login}/${repo.name}`;
expect(fullName).toEqual('docker/actions-toolkit');
} finally {
process.env = originalEnv;
}
});
});
describe('context', () => {
it('returns repository name from payload', async () => {
expect(GitHub.context.payload.repository?.name).toEqual('test-docker-action');
@@ -97,7 +79,7 @@ describe('releases', () => {
describe('serverURL', () => {
const originalEnv = process.env;
beforeEach(() => {
jest.resetModules();
vi.resetModules();
process.env = {
...originalEnv,
GITHUB_SERVER_URL: 'https://foo.github.com'
@@ -118,7 +100,7 @@ describe('serverURL', () => {
describe('apiURL', () => {
const originalEnv = process.env;
beforeEach(() => {
jest.resetModules();
vi.resetModules();
process.env = {
...originalEnv,
GITHUB_API_URL: 'https://bar.github.com'
@@ -154,7 +136,7 @@ describe('workflowRunURL', () => {
describe('actionsRuntimeToken', () => {
const originalEnv = process.env;
beforeEach(() => {
jest.resetModules();
vi.resetModules();
process.env = {
...originalEnv
};
@@ -184,7 +166,7 @@ describe('actionsRuntimeToken', () => {
describe('printActionsRuntimeTokenACs', () => {
const originalEnv = process.env;
beforeEach(() => {
jest.resetModules();
vi.resetModules();
process.env = {
...originalEnv
};
@@ -201,7 +183,7 @@ describe('printActionsRuntimeTokenACs', () => {
await expect(GitHub.printActionsRuntimeTokenACs()).rejects.toThrow(new Error('Cannot parse GitHub Actions Runtime Token: Invalid token specified: missing part #2'));
});
it('refs/heads/master', async () => {
const infoSpy = jest.spyOn(core, 'info');
const infoSpy = vi.mocked(core.info);
process.env.ACTIONS_RUNTIME_TOKEN = fs.readFileSync(path.join(fixturesDir, 'runtimeToken.txt')).toString().trim();
await GitHub.printActionsRuntimeTokenACs();
expect(infoSpy).toHaveBeenCalledTimes(1);

View File

@@ -14,18 +14,18 @@
* limitations under the License.
*/
import {describe, expect, it, test} from '@jest/globals';
import {describe, expect, it, test} from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import {Buildx} from '../../src/buildx/buildx';
import {Bake} from '../../src/buildx/bake';
import {Build} from '../../src/buildx/build';
import {Exec} from '../../src/exec';
import {GitHubArtifact} from '../../src/github/artifact';
import {GitHubSummary} from '../../src/github/summary';
import {History} from '../../src/buildx/history';
import {Buildx} from '../../src/buildx/buildx.js';
import {Bake} from '../../src/buildx/bake.js';
import {Build} from '../../src/buildx/build.js';
import {Exec} from '../../src/exec.js';
import {GitHubArtifact} from '../../src/github/artifact.js';
import {GitHubSummary} from '../../src/github/summary.js';
import {History} from '../../src/buildx/history.js';
const fixturesDir = path.join(__dirname, '..', '.fixtures');
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'github-itg-'));

View File

@@ -14,17 +14,17 @@
* limitations under the License.
*/
import {afterEach, describe, expect, test} from '@jest/globals';
import {afterEach, describe, expect, test} from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import * as rimraf from 'rimraf';
import {mockArch, mockPlatform} from '../.helpers/os';
import {mockArch, mockPlatform} from '../.helpers/os.js';
import {OCI} from '../../src/oci/oci';
import {OCI} from '../../src/oci/oci.js';
import {Platform} from '../../src/types/oci/descriptor';
import {Platform} from '../../src/types/oci/descriptor.js';
const fixturesDir = path.join(__dirname, '..', '.fixtures');
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'oci-oci-'));

View File

@@ -14,10 +14,10 @@
* limitations under the License.
*/
import {describe, expect, test} from '@jest/globals';
import {describe, expect, test} from 'vitest';
import * as fs from 'fs';
import {Install} from '../../src/regclient/install';
import {Install} from '../../src/regclient/install.js';
describe('download', () => {
// prettier-ignore

View File

@@ -14,15 +14,15 @@
* limitations under the License.
*/
import {describe, expect, it, test, afterEach} from '@jest/globals';
import {describe, expect, it, test, afterEach} from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import * as rimraf from 'rimraf';
import {mockArch, mockPlatform} from '../.helpers/os';
import {mockArch, mockPlatform} from '../.helpers/os.js';
import {Install} from '../../src/regclient/install';
import {Install} from '../../src/regclient/install.js';
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'regclient-install-'));

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
import {describe, expect, it, jest, test} from '@jest/globals';
import {describe, expect, it, vi, test} from 'vitest';
import * as semver from 'semver';
import {Exec} from '../../src/exec';
import {Regctl} from '../../src/regclient/regctl';
import {Exec} from '../../src/exec.js';
import {Regctl} from '../../src/regclient/regctl.js';
import {Image} from '../../src/types/oci/config';
import {Image} from '../../src/types/oci/config.js';
describe('manifestGet', () => {
// prettier-ignore
@@ -82,7 +82,7 @@ describe('image config', () => {
describe('isAvailable', () => {
it('checks regctl is available', async () => {
const execSpy = jest.spyOn(Exec, 'getExecOutput');
const execSpy = vi.spyOn(Exec, 'getExecOutput');
const regctl = new Regctl();
await regctl.isAvailable();
expect(execSpy).toHaveBeenCalledWith(`regctl`, [], {
@@ -94,7 +94,7 @@ describe('isAvailable', () => {
describe('printVersion', () => {
it('prints regctl version', async () => {
const execSpy = jest.spyOn(Exec, 'exec');
const execSpy = vi.spyOn(Exec, 'exec');
const regctl = new Regctl();
await regctl.printVersion();
expect(execSpy).toHaveBeenCalledWith(`regctl`, ['version'], {

View File

@@ -14,15 +14,15 @@
* limitations under the License.
*/
import {beforeAll, describe, expect, jest, it} from '@jest/globals';
import {beforeAll, describe, expect, it} from 'vitest';
import * as path from 'path';
import {Buildx} from '../../src/buildx/buildx';
import {Build} from '../../src/buildx/build';
import {Install as CosignInstall} from '../../src/cosign/install';
import {Docker} from '../../src/docker/docker';
import {Exec} from '../../src/exec';
import {Sigstore} from '../../src/sigstore/sigstore';
import {Buildx} from '../../src/buildx/buildx.js';
import {Build} from '../../src/buildx/build.js';
import {Install as CosignInstall} from '../../src/cosign/install.js';
import {Docker} from '../../src/docker/docker.js';
import {Exec} from '../../src/exec.js';
import {Sigstore} from '../../src/sigstore/sigstore.js';
const fixturesDir = path.join(__dirname, '..', '.fixtures');
@@ -30,9 +30,6 @@ const runTest = process.env.GITHUB_ACTIONS && process.env.GITHUB_ACTIONS === 'tr
const maybeIdToken = runTest && process.env.ACTIONS_ID_TOKEN_REQUEST_URL ? describe : describe.skip;
// needs current GitHub repo info
jest.unmock('@actions/github');
beforeAll(async () => {
const cosignInstall = new CosignInstall();
const cosignBinPath = await cosignInstall.download({

View File

@@ -14,17 +14,17 @@
* limitations under the License.
*/
import {beforeAll, describe, expect, jest, it, test} from '@jest/globals';
import {beforeAll, describe, expect, it, test} from 'vitest';
import fs from 'fs';
import * as path from 'path';
import {Buildx} from '../../src/buildx/buildx';
import {Build} from '../../src/buildx/build';
import {Install as CosignInstall} from '../../src/cosign/install';
import {Docker} from '../../src/docker/docker';
import {Exec} from '../../src/exec';
import {OCI} from '../../src/oci/oci';
import {Sigstore} from '../../src/sigstore/sigstore';
import {Buildx} from '../../src/buildx/buildx.js';
import {Build} from '../../src/buildx/build.js';
import {Install as CosignInstall} from '../../src/cosign/install.js';
import {Docker} from '../../src/docker/docker.js';
import {Exec} from '../../src/exec.js';
import {OCI} from '../../src/oci/oci.js';
import {Sigstore} from '../../src/sigstore/sigstore.js';
const fixturesDir = path.join(__dirname, '..', '.fixtures');
@@ -33,9 +33,6 @@ const runTest = process.env.GITHUB_ACTIONS && process.env.GITHUB_ACTIONS === 'tr
const maybe = runTest ? describe : describe.skip;
const maybeIdToken = runTest && process.env.ACTIONS_ID_TOKEN_REQUEST_URL ? describe : describe.skip;
// needs current GitHub repo info
jest.unmock('@actions/github');
beforeAll(async () => {
const cosignInstall = new CosignInstall();
const cosignBinPath = await cosignInstall.download({

View File

@@ -14,10 +14,10 @@
* limitations under the License.
*/
import {describe, expect, test} from '@jest/globals';
import {describe, expect, test} from 'vitest';
import * as fs from 'fs';
import {Install} from '../../src/undock/install';
import {Install} from '../../src/undock/install.js';
describe('download', () => {
// prettier-ignore

View File

@@ -14,15 +14,15 @@
* limitations under the License.
*/
import {describe, expect, it, test, afterEach} from '@jest/globals';
import {describe, expect, it, test, afterEach} from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import * as rimraf from 'rimraf';
import {mockArch, mockPlatform} from '../.helpers/os';
import {mockArch, mockPlatform} from '../.helpers/os.js';
import {Install} from '../../src/undock/install';
import {Install} from '../../src/undock/install.js';
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'undock-install-'));

View File

@@ -14,12 +14,12 @@
* 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 {Undock} from '../../src/undock/undock';
import {Install as UndockInstall} from '../../src/undock/install';
import {Undock} from '../../src/undock/undock.js';
import {Install as UndockInstall} from '../../src/undock/install.js';
describe('run', () => {
it('extracts moby/moby-bin:26.1.5', async () => {

View File

@@ -17,11 +17,11 @@
import fs from 'fs';
import os from 'os';
import path from 'path';
import {describe, expect, it, jest, test} from '@jest/globals';
import {describe, expect, it, vi, test} from 'vitest';
import * as semver from 'semver';
import {Exec} from '../../src/exec';
import {Undock} from '../../src/undock/undock';
import {Exec} from '../../src/exec.js';
import {Undock} from '../../src/undock/undock.js';
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'undock-undock-'));
@@ -43,7 +43,7 @@ describe('run', () => {
describe('isAvailable', () => {
it('checks undock is available', async () => {
const execSpy = jest.spyOn(Exec, 'getExecOutput');
const execSpy = vi.spyOn(Exec, 'getExecOutput');
const undock = new Undock();
await undock.isAvailable();
expect(execSpy).toHaveBeenCalledWith(`undock`, [], {
@@ -55,7 +55,7 @@ describe('isAvailable', () => {
describe('printVersion', () => {
it('prints undock version', async () => {
const execSpy = jest.spyOn(Exec, 'exec');
const execSpy = vi.spyOn(Exec, 'exec');
const undock = new Undock();
await undock.printVersion();
expect(execSpy).toHaveBeenCalledWith(`undock`, ['--version'], {

View File

@@ -14,11 +14,11 @@
* limitations under the License.
*/
import {describe, expect, it, test} from '@jest/globals';
import {describe, expect, it, test} from 'vitest';
import * as fs from 'fs';
import * as path from 'path';
import {Util} from '../src/util';
import {Util} from '../src/util.js';
describe('getInputList', () => {
it('single line correctly', async () => {
@@ -326,10 +326,10 @@ describe('parseBool', () => {
].forEach(({input, expected, throwsError}) => {
test(`parseBool("${input}")`, () => {
if (throwsError) {
// eslint-disable-next-line jest/no-conditional-expect
// eslint-disable-next-line vitest/no-conditional-expect
expect(() => Util.parseBool(input)).toThrow();
} else {
// eslint-disable-next-line jest/no-conditional-expect
// eslint-disable-next-line vitest/no-conditional-expect
expect(Util.parseBool(input)).toBe(expected);
}
});

View File

@@ -96,8 +96,8 @@ RUN --mount=type=bind,target=.,rw \
--mount=type=bind,from=undock,source=/usr/local/bin/undock,target=/usr/bin/undock \
--mount=type=bind,from=regctl,source=/regctl,target=/usr/bin/regctl \
--mount=type=bind,from=cosign,source=/ko-app/cosign,target=/usr/bin/cosign \
--mount=type=secret,id=GITHUB_TOKEN \
GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) yarn run test:coverage --coverageDirectory=/tmp/coverage
--mount=type=secret,id=GITHUB_TOKEN,env=GITHUB_TOKEN \
yarn run test:coverage --coverage.reportsDirectory=/tmp/coverage
FROM scratch AS test-coverage
COPY --from=test /tmp/coverage /

View File

@@ -18,8 +18,9 @@
const {defineConfig, globalIgnores} = require('eslint/config');
const {fixupConfigRules, fixupPluginRules} = require('@eslint/compat');
const typescriptEslint = require('@typescript-eslint/eslint-plugin');
const jestPlugin = require('eslint-plugin-jest');
const eslintPluginImport = require('eslint-plugin-import');
const prettier = require('eslint-plugin-prettier');
const vitest = require('@vitest/eslint-plugin');
const globals = require('globals');
const tsParser = require('@typescript-eslint/parser');
const js = require('@eslint/js');
@@ -33,38 +34,35 @@ const compat = new FlatCompat({
});
module.exports = defineConfig([
globalIgnores(['.yarn/**/*', 'lib/**/*', 'coverage/**/*', 'node_modules/**/*']),
globalIgnores([
// prettier-ignore
'.yarn/**/*',
'coverage/**/*',
'lib/**/*'
]),
{
extends: fixupConfigRules(
compat.extends(
// prettier-ignore
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/errors',
'plugin:import/typescript',
'plugin:import/warnings',
'plugin:jest/recommended',
'plugin:prettier/recommended'
)
),
plugins: {
'@typescript-eslint': fixupPluginRules(typescriptEslint),
jest: fixupPluginRules(jestPlugin),
import: fixupPluginRules(eslintPluginImport),
prettier: fixupPluginRules(prettier)
},
languageOptions: {
globals: {
...globals.node,
...globals.mocha,
...globals.jest
...globals.node
},
parser: tsParser,
ecmaVersion: 2023,
sourceType: 'module'
},
rules: {
'@typescript-eslint/no-require-imports': [
'error',
@@ -75,10 +73,18 @@ module.exports = defineConfig([
'import/no-unresolved': [
'error',
{
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', 'vitest/config']
}
],
'jest/no-disabled-tests': 0
]
}
},
{
files: ['__tests__/**'],
...vitest.configs.recommended,
rules: {
...vitest.configs.recommended.rules,
'vitest/no-conditional-expect': 'error',
'vitest/no-disabled-tests': 0
}
}
]);

View File

@@ -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
};

View File

@@ -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
};

View File

@@ -11,11 +11,11 @@
"eslint:fix": "eslint --fix .",
"prettier": "prettier --check \"./**/*.ts\"",
"prettier:fix": "prettier --write \"./**/*.ts\"",
"test": "jest",
"test:coverage": "jest --coverage",
"test:itg": "jest -c jest.config.itg.cjs --runInBand",
"test:itg-list": "jest -c jest.config.itg.cjs --listTests",
"test:itg-coverage": "jest -c jest.config.itg.cjs --coverage --runInBand"
"test": "vitest run -c vitest.config.ts",
"test:coverage": "vitest run -c vitest.config.ts --coverage",
"test:itg": "vitest run -c vitest.config.itg.ts --maxWorkers=1",
"test:itg-list": "node ./__tests__/.setup/list-itg-tests.mjs",
"test:itg-coverage": "vitest run -c vitest.config.itg.ts --coverage --maxWorkers=1"
},
"repository": {
"type": "git",
@@ -73,7 +73,6 @@
"@eslint/compat": "^2.0.0",
"@eslint/eslintrc": "^3.3.3",
"@eslint/js": "^9.39.2",
"@sigstore/rekor-types": "^4.0.0",
"@types/gunzip-maybe": "^1.4.3",
"@types/he": "^1.2.3",
"@types/js-yaml": "^4.0.9",
@@ -83,17 +82,15 @@
"@types/tmp": "^0.2.6",
"@typescript-eslint/eslint-plugin": "^8.50.0",
"@typescript-eslint/parser": "^8.50.0",
"dotenv": "^17.2.3",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/eslint-plugin": "^1.6.9",
"eslint": "^9.39.2",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-jest": "^29.5.0",
"eslint-plugin-prettier": "^5.5.4",
"jest": "^30.2.0",
"prettier": "^3.7.4",
"rimraf": "^6.1.2",
"ts-jest": "^29.4.6",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
"typescript": "^5.9.3",
"vitest": "^3.2.4"
}
}

View File

@@ -20,7 +20,7 @@ import {DefaultArtifactClient, InvalidResponseError} from '@actions/artifact';
import * as core from '@actions/core';
import {UploadOpts, UploadResponse} from '../types/github/artifact.js';
import {GitHub} from './github';
import {GitHub} from './github.js';
export class GitHubArtifact {
public static async upload(opts: UploadOpts): Promise<UploadResponse> {

View File

@@ -19,7 +19,7 @@ import {dump as yamldump} from 'js-yaml';
import os from 'os';
import * as core from '@actions/core';
import {GitHub} from './github';
import {GitHub} from './github.js';
import {Util} from '../util.js';
import {BuildSummaryOpts, SummaryTableCell} from '../types/github/summary.js';

View File

@@ -16,9 +16,9 @@
import * as core from '@actions/core';
import {UploadResponse} from './artifact';
import {BakeDefinition} from '../buildx/bake';
import {ExportResponse} from '../buildx/history';
import {UploadResponse} from './artifact.js';
import {BakeDefinition} from '../buildx/bake.js';
import {ExportResponse} from '../buildx/history.js';
export type SummaryTableRow = Parameters<typeof core.summary.addTable>[0][number];
export type SummaryTableCell = Exclude<SummaryTableRow[number], string>;

View File

@@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "es2020",
"moduleResolution": "bundler",
"module": "nodenext",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"isolatedModules": true,
"strict": true,
@@ -12,14 +12,10 @@
"rootDir": "./src",
"forceConsistentCasingInFileNames": true,
"noImplicitAny": false,
"resolveJsonModule": true,
"useUnknownInCatchVariables": false,
"skipLibCheck": true,
"skipLibCheck": true
},
"exclude": [
"./__mocks__/**/*",
"./__tests__/**/*",
"./lib/**/*",
"node_modules"
"include": [
"src/**/*.ts"
]
}

View File

@@ -8,9 +8,5 @@
"include": [
"src/**/*.ts",
"__tests__/**/*.ts"
],
"exclude": [
"lib",
"node_modules"
]
}

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2024 actions-toolkit authors
* Copyright 2026 actions-toolkit authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,15 +14,20 @@
* limitations under the License.
*/
/* eslint-disable @typescript-eslint/no-require-imports */
const fs = require('fs');
import {defineConfig} from 'vitest/config';
module.exports = results => {
const allSkipped = results.testResults.every(result => result.skipped);
if (allSkipped) {
console.log('All tests were skipped!');
fs.mkdirSync('./coverage', {recursive: true});
fs.closeSync(fs.openSync('./coverage/allSkipped.txt', 'w'));
export default defineConfig({
test: {
clearMocks: true,
environment: 'node',
include: ['**/*.test.itg.ts'],
testTimeout: 1800000,
coverage: {
all: true,
provider: 'v8',
reporter: ['clover'],
include: ['src/**/*.ts'],
exclude: ['src/**/index.ts']
}
}
return results;
};
});

33
vitest.config.ts Normal file
View 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: ['./__tests__/.setup/setup.unit.ts'],
include: ['**/*.test.ts'],
coverage: {
all: true,
provider: 'v8',
reporter: ['clover'],
include: ['src/**/*.ts'],
exclude: ['src/**/index.ts']
}
}
});

4408
yarn.lock

File diff suppressed because it is too large Load Diff