mirror of
https://gitea.com/docker/build-push-action.git
synced 2026-03-04 02:09:50 +00:00
Merge pull request #1466 from crazy-max/esm
switch to ESM and update config/test wiring
This commit is contained in:
commit
d2c9f1ec18
@ -6,6 +6,5 @@
|
|||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"trailingComma": "none",
|
"trailingComma": "none",
|
||||||
"bracketSpacing": false,
|
"bracketSpacing": false,
|
||||||
"arrowParens": "avoid",
|
"arrowParens": "avoid"
|
||||||
"parser": "typescript"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,207 +0,0 @@
|
|||||||
import {jest} from '@jest/globals';
|
|
||||||
|
|
||||||
export const context = {
|
|
||||||
repo: {
|
|
||||||
owner: 'docker',
|
|
||||||
repo: 'build-push-action'
|
|
||||||
},
|
|
||||||
ref: 'refs/heads/master',
|
|
||||||
runId: 123456789,
|
|
||||||
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();
|
|
||||||
@ -1,54 +1,50 @@
|
|||||||
import {afterEach, beforeEach, describe, expect, jest, test} from '@jest/globals';
|
import {afterEach, beforeEach, describe, expect, test, vi} from 'vitest';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import {fileURLToPath} from 'node:url';
|
||||||
|
|
||||||
import {Builder} from '@docker/actions-toolkit/lib/buildx/builder';
|
import {Builder} from '@docker/actions-toolkit/lib/buildx/builder.js';
|
||||||
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx';
|
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx.js';
|
||||||
import {Build} from '@docker/actions-toolkit/lib/buildx/build';
|
import {Build} from '@docker/actions-toolkit/lib/buildx/build.js';
|
||||||
import {Context} from '@docker/actions-toolkit/lib/context';
|
import {Context} from '@docker/actions-toolkit/lib/context.js';
|
||||||
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
import {Docker} from '@docker/actions-toolkit/lib/docker/docker.js';
|
||||||
import {GitHub} from '@docker/actions-toolkit/lib/github';
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit.js';
|
||||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
|
||||||
|
|
||||||
import {BuilderInfo} from '@docker/actions-toolkit/lib/types/buildx/builder';
|
import {BuilderInfo} from '@docker/actions-toolkit/lib/types/buildx/builder.js';
|
||||||
import {GitHubRepo} from '@docker/actions-toolkit/lib/types/github';
|
|
||||||
|
|
||||||
import * as context from '../src/context';
|
import * as context from '../src/context.js';
|
||||||
|
|
||||||
const tmpDir = path.join('/tmp', '.docker-build-push-jest');
|
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');
|
||||||
|
const testDir = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
import repoFixture from './fixtures/github-repo.json';
|
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||||
jest.spyOn(GitHub.prototype, 'repoData').mockImplementation((): Promise<GitHubRepo> => {
|
|
||||||
return <Promise<GitHubRepo>>(repoFixture as unknown);
|
|
||||||
});
|
|
||||||
|
|
||||||
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
|
||||||
if (!fs.existsSync(tmpDir)) {
|
if (!fs.existsSync(tmpDir)) {
|
||||||
fs.mkdirSync(tmpDir, {recursive: true});
|
fs.mkdirSync(tmpDir, {recursive: true});
|
||||||
}
|
}
|
||||||
return tmpDir;
|
return tmpDir;
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||||
return tmpName;
|
return tmpName;
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.spyOn(Docker, 'isAvailable').mockImplementation(async (): Promise<boolean> => {
|
vi.spyOn(Docker, 'isAvailable').mockImplementation(async (): Promise<boolean> => {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
const metadataJson = path.join(tmpDir, 'metadata.json');
|
const metadataJson = path.join(tmpDir, 'metadata.json');
|
||||||
jest.spyOn(Build.prototype, 'getMetadataFilePath').mockImplementation((): string => {
|
vi.spyOn(Build.prototype, 'getMetadataFilePath').mockImplementation((): string => {
|
||||||
return metadataJson;
|
return metadataJson;
|
||||||
});
|
});
|
||||||
|
|
||||||
const imageIDFilePath = path.join(tmpDir, 'iidfile.txt');
|
const imageIDFilePath = path.join(tmpDir, 'iidfile.txt');
|
||||||
jest.spyOn(Build.prototype, 'getImageIDFilePath').mockImplementation((): string => {
|
vi.spyOn(Build.prototype, 'getImageIDFilePath').mockImplementation((): string => {
|
||||||
return imageIDFilePath;
|
return imageIDFilePath;
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
|
vi.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
|
||||||
return {
|
return {
|
||||||
name: 'builder2',
|
name: 'builder2',
|
||||||
driver: 'docker-container',
|
driver: 'docker-container',
|
||||||
@ -346,7 +342,7 @@ ccc`],
|
|||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
||||||
['tag', 'localhost:5000/name/app:latest'],
|
['tag', 'localhost:5000/name/app:latest'],
|
||||||
['secret-files', `MY_SECRET=${path.join(__dirname, 'fixtures', 'secret.txt')}`],
|
['secret-files', `MY_SECRET=${path.join(testDir, 'fixtures', 'secret.txt')}`],
|
||||||
['file', './test/Dockerfile'],
|
['file', './test/Dockerfile'],
|
||||||
['builder', 'builder-git-context-2'],
|
['builder', 'builder-git-context-2'],
|
||||||
['network', 'host'],
|
['network', 'host'],
|
||||||
@ -904,7 +900,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
|
|||||||
])
|
])
|
||||||
],
|
],
|
||||||
])(
|
])(
|
||||||
'[%d] given %p with %p as inputs, returns %p',
|
'[%d] given %o with %o as inputs, returns %o',
|
||||||
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>, envs: Map<string, string> | undefined) => {
|
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>, envs: Map<string, string> | undefined) => {
|
||||||
if (envs) {
|
if (envs) {
|
||||||
envs.forEach((value: string, name: string) => {
|
envs.forEach((value: string, name: string) => {
|
||||||
@ -915,7 +911,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
|
|||||||
setInput(name, value);
|
setInput(name, value);
|
||||||
});
|
});
|
||||||
const toolkit = new Toolkit();
|
const toolkit = new Toolkit();
|
||||||
jest.spyOn(Buildx.prototype, 'version').mockImplementation(async (): Promise<string> => {
|
vi.spyOn(Buildx.prototype, 'version').mockImplementation(async (): Promise<string> => {
|
||||||
return buildxVersion;
|
return buildxVersion;
|
||||||
});
|
});
|
||||||
const inp = await context.getInputs();
|
const inp = await context.getInputs();
|
||||||
|
|||||||
@ -1,362 +0,0 @@
|
|||||||
{
|
|
||||||
"id": 1296269,
|
|
||||||
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
|
|
||||||
"name": "Hello-World",
|
|
||||||
"full_name": "octocat/Hello-World",
|
|
||||||
"owner": {
|
|
||||||
"login": "octocat",
|
|
||||||
"id": 1,
|
|
||||||
"node_id": "MDQ6VXNlcjE=",
|
|
||||||
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
|
||||||
"gravatar_id": "",
|
|
||||||
"url": "https://api.github.com/users/octocat",
|
|
||||||
"html_url": "https://github.com/octocat",
|
|
||||||
"followers_url": "https://api.github.com/users/octocat/followers",
|
|
||||||
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
|
||||||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
|
||||||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
|
||||||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
|
||||||
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
|
||||||
"repos_url": "https://api.github.com/users/octocat/repos",
|
|
||||||
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
|
||||||
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
|
||||||
"type": "User",
|
|
||||||
"site_admin": false
|
|
||||||
},
|
|
||||||
"private": false,
|
|
||||||
"html_url": "https://github.com/octocat/Hello-World",
|
|
||||||
"description": "This your first repo!",
|
|
||||||
"fork": false,
|
|
||||||
"url": "https://api.github.com/repos/octocat/Hello-World",
|
|
||||||
"archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
|
|
||||||
"assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}",
|
|
||||||
"blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
|
|
||||||
"branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}",
|
|
||||||
"collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
|
|
||||||
"comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}",
|
|
||||||
"commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}",
|
|
||||||
"compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
|
|
||||||
"contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}",
|
|
||||||
"contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors",
|
|
||||||
"deployments_url": "http://api.github.com/repos/octocat/Hello-World/deployments",
|
|
||||||
"downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads",
|
|
||||||
"events_url": "http://api.github.com/repos/octocat/Hello-World/events",
|
|
||||||
"forks_url": "http://api.github.com/repos/octocat/Hello-World/forks",
|
|
||||||
"git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
|
|
||||||
"git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
|
|
||||||
"git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
|
|
||||||
"git_url": "git:github.com/octocat/Hello-World.git",
|
|
||||||
"issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
|
|
||||||
"issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
|
|
||||||
"issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}",
|
|
||||||
"keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
|
|
||||||
"labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}",
|
|
||||||
"languages_url": "http://api.github.com/repos/octocat/Hello-World/languages",
|
|
||||||
"merges_url": "http://api.github.com/repos/octocat/Hello-World/merges",
|
|
||||||
"milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}",
|
|
||||||
"notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
|
|
||||||
"pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}",
|
|
||||||
"releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}",
|
|
||||||
"ssh_url": "git@github.com:octocat/Hello-World.git",
|
|
||||||
"stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers",
|
|
||||||
"statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
|
|
||||||
"subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers",
|
|
||||||
"subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription",
|
|
||||||
"tags_url": "http://api.github.com/repos/octocat/Hello-World/tags",
|
|
||||||
"teams_url": "http://api.github.com/repos/octocat/Hello-World/teams",
|
|
||||||
"trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
|
|
||||||
"clone_url": "https://github.com/octocat/Hello-World.git",
|
|
||||||
"mirror_url": "git:git.example.com/octocat/Hello-World",
|
|
||||||
"hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks",
|
|
||||||
"svn_url": "https://svn.github.com/octocat/Hello-World",
|
|
||||||
"homepage": "https://github.com",
|
|
||||||
"language": null,
|
|
||||||
"forks_count": 9,
|
|
||||||
"stargazers_count": 80,
|
|
||||||
"watchers_count": 80,
|
|
||||||
"size": 108,
|
|
||||||
"default_branch": "master",
|
|
||||||
"open_issues_count": 0,
|
|
||||||
"is_template": true,
|
|
||||||
"topics": [
|
|
||||||
"octocat",
|
|
||||||
"atom",
|
|
||||||
"electron",
|
|
||||||
"api"
|
|
||||||
],
|
|
||||||
"has_issues": true,
|
|
||||||
"has_projects": true,
|
|
||||||
"has_wiki": true,
|
|
||||||
"has_pages": false,
|
|
||||||
"has_downloads": true,
|
|
||||||
"archived": false,
|
|
||||||
"disabled": false,
|
|
||||||
"visibility": "public",
|
|
||||||
"pushed_at": "2011-01-26T19:06:43Z",
|
|
||||||
"created_at": "2011-01-26T19:01:12Z",
|
|
||||||
"updated_at": "2011-01-26T19:14:43Z",
|
|
||||||
"permissions": {
|
|
||||||
"pull": true,
|
|
||||||
"triage": true,
|
|
||||||
"push": false,
|
|
||||||
"maintain": false,
|
|
||||||
"admin": false
|
|
||||||
},
|
|
||||||
"allow_rebase_merge": true,
|
|
||||||
"template_repository": null,
|
|
||||||
"temp_clone_token": "ABTLWHOULUVAXGTRYU7OC2876QJ2O",
|
|
||||||
"allow_squash_merge": true,
|
|
||||||
"delete_branch_on_merge": true,
|
|
||||||
"allow_merge_commit": true,
|
|
||||||
"subscribers_count": 42,
|
|
||||||
"network_count": 0,
|
|
||||||
"license": {
|
|
||||||
"key": "mit",
|
|
||||||
"name": "MIT License",
|
|
||||||
"spdx_id": "MIT",
|
|
||||||
"url": "https://api.github.com/licenses/mit",
|
|
||||||
"node_id": "MDc6TGljZW5zZW1pdA=="
|
|
||||||
},
|
|
||||||
"organization": {
|
|
||||||
"login": "octocat",
|
|
||||||
"id": 1,
|
|
||||||
"node_id": "MDQ6VXNlcjE=",
|
|
||||||
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
|
||||||
"gravatar_id": "",
|
|
||||||
"url": "https://api.github.com/users/octocat",
|
|
||||||
"html_url": "https://github.com/octocat",
|
|
||||||
"followers_url": "https://api.github.com/users/octocat/followers",
|
|
||||||
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
|
||||||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
|
||||||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
|
||||||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
|
||||||
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
|
||||||
"repos_url": "https://api.github.com/users/octocat/repos",
|
|
||||||
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
|
||||||
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
|
||||||
"type": "Organization",
|
|
||||||
"site_admin": false
|
|
||||||
},
|
|
||||||
"parent": {
|
|
||||||
"id": 1296269,
|
|
||||||
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
|
|
||||||
"name": "Hello-World",
|
|
||||||
"full_name": "octocat/Hello-World",
|
|
||||||
"owner": {
|
|
||||||
"login": "octocat",
|
|
||||||
"id": 1,
|
|
||||||
"node_id": "MDQ6VXNlcjE=",
|
|
||||||
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
|
||||||
"gravatar_id": "",
|
|
||||||
"url": "https://api.github.com/users/octocat",
|
|
||||||
"html_url": "https://github.com/octocat",
|
|
||||||
"followers_url": "https://api.github.com/users/octocat/followers",
|
|
||||||
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
|
||||||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
|
||||||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
|
||||||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
|
||||||
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
|
||||||
"repos_url": "https://api.github.com/users/octocat/repos",
|
|
||||||
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
|
||||||
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
|
||||||
"type": "User",
|
|
||||||
"site_admin": false
|
|
||||||
},
|
|
||||||
"private": false,
|
|
||||||
"html_url": "https://github.com/octocat/Hello-World",
|
|
||||||
"description": "This your first repo!",
|
|
||||||
"fork": false,
|
|
||||||
"url": "https://api.github.com/repos/octocat/Hello-World",
|
|
||||||
"archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
|
|
||||||
"assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}",
|
|
||||||
"blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
|
|
||||||
"branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}",
|
|
||||||
"collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
|
|
||||||
"comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}",
|
|
||||||
"commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}",
|
|
||||||
"compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
|
|
||||||
"contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}",
|
|
||||||
"contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors",
|
|
||||||
"deployments_url": "http://api.github.com/repos/octocat/Hello-World/deployments",
|
|
||||||
"downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads",
|
|
||||||
"events_url": "http://api.github.com/repos/octocat/Hello-World/events",
|
|
||||||
"forks_url": "http://api.github.com/repos/octocat/Hello-World/forks",
|
|
||||||
"git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
|
|
||||||
"git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
|
|
||||||
"git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
|
|
||||||
"git_url": "git:github.com/octocat/Hello-World.git",
|
|
||||||
"issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
|
|
||||||
"issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
|
|
||||||
"issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}",
|
|
||||||
"keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
|
|
||||||
"labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}",
|
|
||||||
"languages_url": "http://api.github.com/repos/octocat/Hello-World/languages",
|
|
||||||
"merges_url": "http://api.github.com/repos/octocat/Hello-World/merges",
|
|
||||||
"milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}",
|
|
||||||
"notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
|
|
||||||
"pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}",
|
|
||||||
"releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}",
|
|
||||||
"ssh_url": "git@github.com:octocat/Hello-World.git",
|
|
||||||
"stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers",
|
|
||||||
"statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
|
|
||||||
"subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers",
|
|
||||||
"subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription",
|
|
||||||
"tags_url": "http://api.github.com/repos/octocat/Hello-World/tags",
|
|
||||||
"teams_url": "http://api.github.com/repos/octocat/Hello-World/teams",
|
|
||||||
"trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
|
|
||||||
"clone_url": "https://github.com/octocat/Hello-World.git",
|
|
||||||
"mirror_url": "git:git.example.com/octocat/Hello-World",
|
|
||||||
"hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks",
|
|
||||||
"svn_url": "https://svn.github.com/octocat/Hello-World",
|
|
||||||
"homepage": "https://github.com",
|
|
||||||
"language": null,
|
|
||||||
"forks_count": 9,
|
|
||||||
"stargazers_count": 80,
|
|
||||||
"watchers_count": 80,
|
|
||||||
"size": 108,
|
|
||||||
"default_branch": "master",
|
|
||||||
"open_issues_count": 0,
|
|
||||||
"is_template": true,
|
|
||||||
"topics": [
|
|
||||||
"octocat",
|
|
||||||
"atom",
|
|
||||||
"electron",
|
|
||||||
"api"
|
|
||||||
],
|
|
||||||
"has_issues": true,
|
|
||||||
"has_projects": true,
|
|
||||||
"has_wiki": true,
|
|
||||||
"has_pages": false,
|
|
||||||
"has_downloads": true,
|
|
||||||
"archived": false,
|
|
||||||
"disabled": false,
|
|
||||||
"visibility": "public",
|
|
||||||
"pushed_at": "2011-01-26T19:06:43Z",
|
|
||||||
"created_at": "2011-01-26T19:01:12Z",
|
|
||||||
"updated_at": "2011-01-26T19:14:43Z",
|
|
||||||
"permissions": {
|
|
||||||
"admin": false,
|
|
||||||
"push": false,
|
|
||||||
"pull": true
|
|
||||||
},
|
|
||||||
"allow_rebase_merge": true,
|
|
||||||
"template_repository": null,
|
|
||||||
"temp_clone_token": "ABTLWHOULUVAXGTRYU7OC2876QJ2O",
|
|
||||||
"allow_squash_merge": true,
|
|
||||||
"delete_branch_on_merge": true,
|
|
||||||
"allow_merge_commit": true,
|
|
||||||
"subscribers_count": 42,
|
|
||||||
"network_count": 0
|
|
||||||
},
|
|
||||||
"source": {
|
|
||||||
"id": 1296269,
|
|
||||||
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
|
|
||||||
"name": "Hello-World",
|
|
||||||
"full_name": "octocat/Hello-World",
|
|
||||||
"owner": {
|
|
||||||
"login": "octocat",
|
|
||||||
"id": 1,
|
|
||||||
"node_id": "MDQ6VXNlcjE=",
|
|
||||||
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
|
||||||
"gravatar_id": "",
|
|
||||||
"url": "https://api.github.com/users/octocat",
|
|
||||||
"html_url": "https://github.com/octocat",
|
|
||||||
"followers_url": "https://api.github.com/users/octocat/followers",
|
|
||||||
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
|
||||||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
|
||||||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
|
||||||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
|
||||||
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
|
||||||
"repos_url": "https://api.github.com/users/octocat/repos",
|
|
||||||
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
|
||||||
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
|
||||||
"type": "User",
|
|
||||||
"site_admin": false
|
|
||||||
},
|
|
||||||
"private": false,
|
|
||||||
"html_url": "https://github.com/octocat/Hello-World",
|
|
||||||
"description": "This your first repo!",
|
|
||||||
"fork": false,
|
|
||||||
"url": "https://api.github.com/repos/octocat/Hello-World",
|
|
||||||
"archive_url": "http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
|
|
||||||
"assignees_url": "http://api.github.com/repos/octocat/Hello-World/assignees{/user}",
|
|
||||||
"blobs_url": "http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
|
|
||||||
"branches_url": "http://api.github.com/repos/octocat/Hello-World/branches{/branch}",
|
|
||||||
"collaborators_url": "http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
|
|
||||||
"comments_url": "http://api.github.com/repos/octocat/Hello-World/comments{/number}",
|
|
||||||
"commits_url": "http://api.github.com/repos/octocat/Hello-World/commits{/sha}",
|
|
||||||
"compare_url": "http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
|
|
||||||
"contents_url": "http://api.github.com/repos/octocat/Hello-World/contents/{+path}",
|
|
||||||
"contributors_url": "http://api.github.com/repos/octocat/Hello-World/contributors",
|
|
||||||
"deployments_url": "http://api.github.com/repos/octocat/Hello-World/deployments",
|
|
||||||
"downloads_url": "http://api.github.com/repos/octocat/Hello-World/downloads",
|
|
||||||
"events_url": "http://api.github.com/repos/octocat/Hello-World/events",
|
|
||||||
"forks_url": "http://api.github.com/repos/octocat/Hello-World/forks",
|
|
||||||
"git_commits_url": "http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
|
|
||||||
"git_refs_url": "http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
|
|
||||||
"git_tags_url": "http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
|
|
||||||
"git_url": "git:github.com/octocat/Hello-World.git",
|
|
||||||
"issue_comment_url": "http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
|
|
||||||
"issue_events_url": "http://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
|
|
||||||
"issues_url": "http://api.github.com/repos/octocat/Hello-World/issues{/number}",
|
|
||||||
"keys_url": "http://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
|
|
||||||
"labels_url": "http://api.github.com/repos/octocat/Hello-World/labels{/name}",
|
|
||||||
"languages_url": "http://api.github.com/repos/octocat/Hello-World/languages",
|
|
||||||
"merges_url": "http://api.github.com/repos/octocat/Hello-World/merges",
|
|
||||||
"milestones_url": "http://api.github.com/repos/octocat/Hello-World/milestones{/number}",
|
|
||||||
"notifications_url": "http://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
|
|
||||||
"pulls_url": "http://api.github.com/repos/octocat/Hello-World/pulls{/number}",
|
|
||||||
"releases_url": "http://api.github.com/repos/octocat/Hello-World/releases{/id}",
|
|
||||||
"ssh_url": "git@github.com:octocat/Hello-World.git",
|
|
||||||
"stargazers_url": "http://api.github.com/repos/octocat/Hello-World/stargazers",
|
|
||||||
"statuses_url": "http://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
|
|
||||||
"subscribers_url": "http://api.github.com/repos/octocat/Hello-World/subscribers",
|
|
||||||
"subscription_url": "http://api.github.com/repos/octocat/Hello-World/subscription",
|
|
||||||
"tags_url": "http://api.github.com/repos/octocat/Hello-World/tags",
|
|
||||||
"teams_url": "http://api.github.com/repos/octocat/Hello-World/teams",
|
|
||||||
"trees_url": "http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
|
|
||||||
"clone_url": "https://github.com/octocat/Hello-World.git",
|
|
||||||
"mirror_url": "git:git.example.com/octocat/Hello-World",
|
|
||||||
"hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks",
|
|
||||||
"svn_url": "https://svn.github.com/octocat/Hello-World",
|
|
||||||
"homepage": "https://github.com",
|
|
||||||
"language": null,
|
|
||||||
"forks_count": 9,
|
|
||||||
"stargazers_count": 80,
|
|
||||||
"watchers_count": 80,
|
|
||||||
"size": 108,
|
|
||||||
"default_branch": "master",
|
|
||||||
"open_issues_count": 0,
|
|
||||||
"is_template": true,
|
|
||||||
"topics": [
|
|
||||||
"octocat",
|
|
||||||
"atom",
|
|
||||||
"electron",
|
|
||||||
"api"
|
|
||||||
],
|
|
||||||
"has_issues": true,
|
|
||||||
"has_projects": true,
|
|
||||||
"has_wiki": true,
|
|
||||||
"has_pages": false,
|
|
||||||
"has_downloads": true,
|
|
||||||
"archived": false,
|
|
||||||
"disabled": false,
|
|
||||||
"visibility": "public",
|
|
||||||
"pushed_at": "2011-01-26T19:06:43Z",
|
|
||||||
"created_at": "2011-01-26T19:01:12Z",
|
|
||||||
"updated_at": "2011-01-26T19:14:43Z",
|
|
||||||
"permissions": {
|
|
||||||
"admin": false,
|
|
||||||
"push": false,
|
|
||||||
"pull": true
|
|
||||||
},
|
|
||||||
"allow_rebase_merge": true,
|
|
||||||
"template_repository": null,
|
|
||||||
"temp_clone_token": "ABTLWHOULUVAXGTRYU7OC2876QJ2O",
|
|
||||||
"allow_squash_merge": true,
|
|
||||||
"delete_branch_on_merge": true,
|
|
||||||
"allow_merge_commit": true,
|
|
||||||
"subscribers_count": 42,
|
|
||||||
"network_count": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
243
__tests__/setup.unit.ts
Normal file
243
__tests__/setup.unit.ts
Normal file
@ -0,0 +1,243 @@
|
|||||||
|
import fs from 'node:fs';
|
||||||
|
import {createRequire} from 'node:module';
|
||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import {vi} from 'vitest';
|
||||||
|
|
||||||
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-build-push-action-'));
|
||||||
|
|
||||||
|
process.env = Object.assign({}, process.env, {
|
||||||
|
TEMP: tmpDir,
|
||||||
|
GITHUB_REPOSITORY: 'docker/build-push-action',
|
||||||
|
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
|
||||||
|
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
|
||||||
|
});
|
||||||
|
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
type RequireCacheEntry = NonNullable<(typeof require.cache)[string]>;
|
||||||
|
|
||||||
|
const githubMock = {
|
||||||
|
context: {
|
||||||
|
repo: {
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'build-push-action'
|
||||||
|
},
|
||||||
|
ref: 'refs/heads/master',
|
||||||
|
runId: 123456789,
|
||||||
|
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()
|
||||||
|
};
|
||||||
|
|
||||||
|
vi.mock('@actions/github', () => githubMock);
|
||||||
|
vi.doMock(require.resolve('@docker/actions-toolkit/node_modules/@actions/github'), () => githubMock);
|
||||||
|
|
||||||
|
for (const mod of ['@docker/actions-toolkit/node_modules/@actions/github']) {
|
||||||
|
try {
|
||||||
|
const resolved = require.resolve(mod);
|
||||||
|
require.cache[resolved] = {
|
||||||
|
id: resolved,
|
||||||
|
filename: resolved,
|
||||||
|
loaded: true,
|
||||||
|
exports: githubMock,
|
||||||
|
children: [],
|
||||||
|
paths: []
|
||||||
|
} as RequireCacheEntry;
|
||||||
|
} catch {
|
||||||
|
// Ignore unresolved optional paths; vi.mock handles module-level mocking.
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,10 +3,11 @@
|
|||||||
ARG NODE_VERSION=20
|
ARG NODE_VERSION=20
|
||||||
|
|
||||||
FROM node:${NODE_VERSION}-alpine AS base
|
FROM node:${NODE_VERSION}-alpine AS base
|
||||||
RUN apk add --no-cache cpio findutils git
|
RUN apk add --no-cache cpio findutils git rsync
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
--mount=type=cache,target=/src/.yarn/cache <<EOT
|
--mount=type=cache,target=/src/.yarn/cache <<EOT
|
||||||
|
set -e
|
||||||
corepack enable
|
corepack enable
|
||||||
yarn --version
|
yarn --version
|
||||||
yarn config set --home enableTelemetry 0
|
yarn config set --home enableTelemetry 0
|
||||||
@ -27,25 +28,34 @@ RUN --mount=type=bind,target=.,rw <<EOT
|
|||||||
git add -A
|
git add -A
|
||||||
cp -rf /vendor/* .
|
cp -rf /vendor/* .
|
||||||
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then
|
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then
|
||||||
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'
|
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor"'
|
||||||
git status --porcelain -- yarn.lock
|
git status --porcelain -- yarn.lock
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
FROM deps AS build
|
FROM deps AS build
|
||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=target=/context \
|
||||||
--mount=type=cache,target=/src/.yarn/cache \
|
--mount=type=cache,target=/src/.yarn/cache \
|
||||||
--mount=type=cache,target=/src/node_modules \
|
--mount=type=cache,target=/src/node_modules <<EOT
|
||||||
yarn run build && mkdir /out && cp -Rf dist /out/
|
set -e
|
||||||
|
rsync -a /context/. .
|
||||||
|
rm -rf dist
|
||||||
|
yarn run build
|
||||||
|
mkdir /out
|
||||||
|
cp -r dist /out
|
||||||
|
EOT
|
||||||
|
|
||||||
FROM scratch AS build-update
|
FROM scratch AS build-update
|
||||||
COPY --from=build /out /
|
COPY --from=build /out /
|
||||||
|
|
||||||
FROM build AS build-validate
|
FROM build AS build-validate
|
||||||
RUN --mount=type=bind,target=.,rw <<EOT
|
RUN --mount=target=/context \
|
||||||
|
--mount=target=.,type=tmpfs <<EOT
|
||||||
set -e
|
set -e
|
||||||
|
rsync -a /context/. .
|
||||||
git add -A
|
git add -A
|
||||||
|
rm -rf dist
|
||||||
cp -rf /out/* .
|
cp -rf /out/* .
|
||||||
if [ -n "$(git status --porcelain -- dist)" ]; then
|
if [ -n "$(git status --porcelain -- dist)" ]; then
|
||||||
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
|
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
|
||||||
@ -58,8 +68,7 @@ FROM deps AS format
|
|||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
--mount=type=cache,target=/src/.yarn/cache \
|
--mount=type=cache,target=/src/.yarn/cache \
|
||||||
--mount=type=cache,target=/src/node_modules \
|
--mount=type=cache,target=/src/node_modules \
|
||||||
yarn run format \
|
yarn run format && mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | cpio -pdm /out
|
||||||
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | cpio -pdm /out
|
|
||||||
|
|
||||||
FROM scratch AS format-update
|
FROM scratch AS format-update
|
||||||
COPY --from=format /out /
|
COPY --from=format /out /
|
||||||
@ -74,7 +83,7 @@ FROM deps AS test
|
|||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
--mount=type=cache,target=/src/.yarn/cache \
|
--mount=type=cache,target=/src/.yarn/cache \
|
||||||
--mount=type=cache,target=/src/node_modules \
|
--mount=type=cache,target=/src/node_modules \
|
||||||
yarn run test --coverage --coverageDirectory=/tmp/coverage
|
yarn run test --coverage --coverage.reportsDirectory=/tmp/coverage
|
||||||
|
|
||||||
FROM scratch AS test-coverage
|
FROM scratch AS test-coverage
|
||||||
COPY --from=test /tmp/coverage /
|
COPY --from=test /tmp/coverage /
|
||||||
|
|||||||
34
dist/index.js
generated
vendored
34
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/licenses.txt
generated
vendored
2
dist/licenses.txt
generated
vendored
@ -2828,7 +2828,7 @@ minimatch
|
|||||||
ISC
|
ISC
|
||||||
The ISC License
|
The ISC License
|
||||||
|
|
||||||
Copyright (c) 2011-2023 Isaac Z. Schlueter and Contributors
|
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|||||||
3
dist/package.json
generated
vendored
Normal file
3
dist/package.json
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"type": "module"
|
||||||
|
}
|
||||||
0
dist/sourcemap-register.js → dist/sourcemap-register.cjs
generated
vendored
0
dist/sourcemap-register.js → dist/sourcemap-register.cjs
generated
vendored
@ -1,58 +0,0 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
||||||
const {defineConfig, globalIgnores} = require('eslint/config');
|
|
||||||
const {fixupConfigRules, fixupPluginRules} = require('@eslint/compat');
|
|
||||||
const typescriptEslint = require('@typescript-eslint/eslint-plugin');
|
|
||||||
const jestPlugin = require('eslint-plugin-jest');
|
|
||||||
const prettier = require('eslint-plugin-prettier');
|
|
||||||
const globals = require('globals');
|
|
||||||
const tsParser = require('@typescript-eslint/parser');
|
|
||||||
const js = require('@eslint/js');
|
|
||||||
const {FlatCompat} = require('@eslint/eslintrc');
|
|
||||||
|
|
||||||
// __dirname and __filename exist natively in CommonJS
|
|
||||||
const compat = new FlatCompat({
|
|
||||||
baseDirectory: __dirname,
|
|
||||||
recommendedConfig: js.configs.recommended,
|
|
||||||
allConfig: js.configs.all
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = defineConfig([
|
|
||||||
globalIgnores(['dist/**/*', 'coverage/**/*', 'node_modules/**/*']),
|
|
||||||
{
|
|
||||||
// prettier-ignore
|
|
||||||
extends: fixupConfigRules(
|
|
||||||
compat.extends(
|
|
||||||
'eslint:recommended',
|
|
||||||
'plugin:@typescript-eslint/eslint-recommended',
|
|
||||||
'plugin:@typescript-eslint/recommended',
|
|
||||||
'plugin:jest/recommended',
|
|
||||||
'plugin:prettier/recommended'
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
plugins: {
|
|
||||||
'@typescript-eslint': fixupPluginRules(typescriptEslint),
|
|
||||||
jest: fixupPluginRules(jestPlugin),
|
|
||||||
prettier: fixupPluginRules(prettier)
|
|
||||||
},
|
|
||||||
|
|
||||||
languageOptions: {
|
|
||||||
globals: {
|
|
||||||
...globals.node,
|
|
||||||
...globals.jest
|
|
||||||
},
|
|
||||||
parser: tsParser,
|
|
||||||
ecmaVersion: 'latest',
|
|
||||||
sourceType: 'module'
|
|
||||||
},
|
|
||||||
|
|
||||||
rules: {
|
|
||||||
'@typescript-eslint/no-require-imports': [
|
|
||||||
'error',
|
|
||||||
{
|
|
||||||
allowAsImport: true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
52
eslint.config.mjs
Normal file
52
eslint.config.mjs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import {defineConfig} from 'eslint/config';
|
||||||
|
import js from '@eslint/js';
|
||||||
|
import tseslint from '@typescript-eslint/eslint-plugin';
|
||||||
|
import vitest from '@vitest/eslint-plugin';
|
||||||
|
import globals from 'globals';
|
||||||
|
import eslintConfigPrettier from 'eslint-config-prettier/flat';
|
||||||
|
import eslintPluginPrettier from 'eslint-plugin-prettier';
|
||||||
|
|
||||||
|
export default defineConfig([
|
||||||
|
{
|
||||||
|
ignores: ['.yarn/**/*', 'coverage/**/*', 'dist/**/*']
|
||||||
|
},
|
||||||
|
js.configs.recommended,
|
||||||
|
...tseslint.configs['flat/recommended'],
|
||||||
|
eslintConfigPrettier,
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.node
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['__tests__/**'],
|
||||||
|
...vitest.configs.recommended,
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.node,
|
||||||
|
...vitest.environments.env.globals
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...vitest.configs.recommended.rules,
|
||||||
|
'vitest/no-conditional-expect': 'error',
|
||||||
|
'vitest/no-disabled-tests': 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
plugins: {
|
||||||
|
prettier: eslintPluginPrettier
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'prettier/prettier': 'error',
|
||||||
|
'@typescript-eslint/no-require-imports': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
allowAsImport: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
@ -1,29 +0,0 @@
|
|||||||
/* 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-build-push-action-'));
|
|
||||||
|
|
||||||
process.env = Object.assign({}, process.env, {
|
|
||||||
TEMP: tmpDir,
|
|
||||||
GITHUB_REPOSITORY: 'docker/build-push-action',
|
|
||||||
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
|
|
||||||
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
clearMocks: false,
|
|
||||||
testEnvironment: 'node',
|
|
||||||
moduleFileExtensions: ['js', 'ts'],
|
|
||||||
testMatch: ['**/*.test.ts'],
|
|
||||||
transform: {
|
|
||||||
'^.+\\.ts$': 'ts-jest'
|
|
||||||
},
|
|
||||||
moduleNameMapper: {
|
|
||||||
'^csv-parse/sync': '<rootDir>/node_modules/csv-parse/dist/cjs/sync.cjs'
|
|
||||||
},
|
|
||||||
collectCoverageFrom: ['src/**/{!(main.ts),}.ts'],
|
|
||||||
coveragePathIgnorePatterns: ['lib/', 'node_modules/', '__mocks__/', '__tests__/'],
|
|
||||||
verbose: true
|
|
||||||
};
|
|
||||||
37
package.json
37
package.json
@ -1,16 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "docker-build-push",
|
"name": "docker-build-push",
|
||||||
"description": "Build and push Docker images",
|
"description": "Build and push Docker images",
|
||||||
|
"type": "module",
|
||||||
"main": "src/main.ts",
|
"main": "src/main.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "ncc build --source-map --minify --license licenses.txt",
|
"build": "ncc build --source-map --minify --license licenses.txt",
|
||||||
"lint": "yarn run prettier && yarn run eslint",
|
"lint": "eslint --max-warnings=0 .",
|
||||||
"format": "yarn run prettier:fix && yarn run eslint:fix",
|
"format": "eslint --fix .",
|
||||||
"eslint": "eslint --max-warnings=0 .",
|
"test": "vitest run"
|
||||||
"eslint:fix": "eslint --fix .",
|
|
||||||
"prettier": "prettier --check \"./**/*.ts\"",
|
|
||||||
"prettier:fix": "prettier --write \"./**/*.ts\"",
|
|
||||||
"test": "jest"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -31,21 +28,19 @@
|
|||||||
"handlebars": "^4.7.7"
|
"handlebars": "^4.7.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/compat": "^2.0.0",
|
"@eslint/js": "^9.39.3",
|
||||||
"@eslint/eslintrc": "^3.3.3",
|
"@types/node": "^20.19.35",
|
||||||
"@eslint/js": "^9.39.2",
|
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
||||||
"@types/node": "^20.19.27",
|
"@typescript-eslint/parser": "^8.56.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.50.0",
|
|
||||||
"@typescript-eslint/parser": "^8.50.0",
|
|
||||||
"@vercel/ncc": "^0.38.4",
|
"@vercel/ncc": "^0.38.4",
|
||||||
"eslint": "^9.39.2",
|
"@vitest/coverage-v8": "^4.0.18",
|
||||||
|
"@vitest/eslint-plugin": "^1.6.9",
|
||||||
|
"eslint": "^9.39.3",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-jest": "^29.5.0",
|
"eslint-plugin-prettier": "^5.5.5",
|
||||||
"eslint-plugin-prettier": "^5.5.4",
|
"globals": "^17.3.0",
|
||||||
"jest": "^30.2.0",
|
"prettier": "^3.8.1",
|
||||||
"prettier": "^3.7.4",
|
"typescript": "^5.9.3",
|
||||||
"ts-jest": "^29.4.6",
|
"vitest": "^4.0.18"
|
||||||
"ts-node": "^10.9.2",
|
|
||||||
"typescript": "^5.9.3"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as handlebars from 'handlebars';
|
import * as handlebars from 'handlebars';
|
||||||
|
|
||||||
import {Build} from '@docker/actions-toolkit/lib/buildx/build';
|
import {Build} from '@docker/actions-toolkit/lib/buildx/build.js';
|
||||||
import {Context} from '@docker/actions-toolkit/lib/context';
|
import {Context} from '@docker/actions-toolkit/lib/context.js';
|
||||||
import {GitHub} from '@docker/actions-toolkit/lib/github';
|
import {GitHub} from '@docker/actions-toolkit/lib/github.js';
|
||||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit.js';
|
||||||
import {Util} from '@docker/actions-toolkit/lib/util';
|
import {Util} from '@docker/actions-toolkit/lib/util.js';
|
||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
'add-hosts': string[];
|
'add-hosts': string[];
|
||||||
|
|||||||
26
src/main.ts
26
src/main.ts
@ -1,23 +1,23 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as stateHelper from './state-helper';
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as actionsToolkit from '@docker/actions-toolkit';
|
import * as actionsToolkit from '@docker/actions-toolkit';
|
||||||
|
|
||||||
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx';
|
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx.js';
|
||||||
import {History as BuildxHistory} from '@docker/actions-toolkit/lib/buildx/history';
|
import {History as BuildxHistory} from '@docker/actions-toolkit/lib/buildx/history.js';
|
||||||
import {Context} from '@docker/actions-toolkit/lib/context';
|
import {Context} from '@docker/actions-toolkit/lib/context.js';
|
||||||
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
import {Docker} from '@docker/actions-toolkit/lib/docker/docker.js';
|
||||||
import {Exec} from '@docker/actions-toolkit/lib/exec';
|
import {Exec} from '@docker/actions-toolkit/lib/exec.js';
|
||||||
import {GitHub} from '@docker/actions-toolkit/lib/github';
|
import {GitHub} from '@docker/actions-toolkit/lib/github.js';
|
||||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit.js';
|
||||||
import {Util} from '@docker/actions-toolkit/lib/util';
|
import {Util} from '@docker/actions-toolkit/lib/util.js';
|
||||||
|
|
||||||
import {BuilderInfo} from '@docker/actions-toolkit/lib/types/buildx/builder';
|
import {BuilderInfo} from '@docker/actions-toolkit/lib/types/buildx/builder.js';
|
||||||
import {ConfigFile} from '@docker/actions-toolkit/lib/types/docker/docker';
|
import {ConfigFile} from '@docker/actions-toolkit/lib/types/docker/docker.js';
|
||||||
import {UploadArtifactResponse} from '@docker/actions-toolkit/lib/types/github';
|
import {UploadArtifactResponse} from '@docker/actions-toolkit/lib/types/github.js';
|
||||||
|
|
||||||
import * as context from './context';
|
import * as context from './context.js';
|
||||||
|
import * as stateHelper from './state-helper.js';
|
||||||
|
|
||||||
actionsToolkit.run(
|
actionsToolkit.run(
|
||||||
// main
|
// main
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
import {Build} from '@docker/actions-toolkit/lib/buildx/build';
|
import {Build} from '@docker/actions-toolkit/lib/buildx/build.js';
|
||||||
|
|
||||||
import {Inputs} from './context';
|
import {Inputs} from './context.js';
|
||||||
|
|
||||||
export const tmpDir = process.env['STATE_tmpDir'] || '';
|
export const tmpDir = process.env['STATE_tmpDir'] || '';
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"module": "nodenext",
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"target": "es6",
|
|
||||||
"module": "commonjs",
|
|
||||||
"strict": true,
|
|
||||||
"newLine": "lf",
|
"newLine": "lf",
|
||||||
"outDir": "./lib",
|
"outDir": "./lib",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
@ -12,11 +11,7 @@
|
|||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"useUnknownInCatchVariables": false,
|
"useUnknownInCatchVariables": false,
|
||||||
},
|
},
|
||||||
"exclude": [
|
"include": [
|
||||||
"./__mocks__/**/*",
|
"src/**/*.ts"
|
||||||
"./__tests__/**/*",
|
|
||||||
"./lib/**/*",
|
|
||||||
"node_modules",
|
|
||||||
"jest.config.ts"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
16
vitest.config.ts
Normal file
16
vitest.config.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import {defineConfig} from 'vitest/config';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
clearMocks: true,
|
||||||
|
environment: 'node',
|
||||||
|
setupFiles: ['./__tests__/setup.unit.ts'],
|
||||||
|
include: ['**/*.test.ts'],
|
||||||
|
coverage: {
|
||||||
|
provider: 'v8',
|
||||||
|
reporter: ['clover'],
|
||||||
|
include: ['src/**/*.ts'],
|
||||||
|
exclude: ['src/**/main.ts']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user