mirror of
https://github.com/hoverkraft-tech/compose-action.git
synced 2026-03-06 16:23:08 +08:00
Compare commits
No commits in common. "5a56211d0431ea3cceebfd57ff2e4359dd8028cf" and "265e4765128786260e20f2ad54c8e351d7ab8c74" have entirely different histories.
5a56211d04
...
265e476512
2
.github/workflows/__check-action.yml
vendored
2
.github/workflows/__check-action.yml
vendored
@ -179,7 +179,7 @@ jobs:
|
||||
|
||||
- name: Set up Docker context
|
||||
if: ${{ matrix.docker-context }}
|
||||
uses: docker/setup-docker-action@1a6edb0ba9ac496f6850236981f15d8f9a82254d # v5.0.0
|
||||
uses: docker/setup-docker-action@e43656e248c0bd0647d3f5c195d116aacf6fcaf4 # v4.7.0
|
||||
with:
|
||||
context: ${{ matrix.docker-context }}
|
||||
|
||||
|
||||
2
.github/workflows/main-ci.yml
vendored
2
.github/workflows/main-ci.yml
vendored
@ -74,7 +74,7 @@ jobs:
|
||||
[skip ci]
|
||||
|
||||
- id: upload-artifact
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
||||
with:
|
||||
name: documentation-files-${{ github.run_id }}
|
||||
path: |
|
||||
|
||||
1015
dist/index.js
generated
vendored
1015
dist/index.js
generated
vendored
File diff suppressed because it is too large
Load Diff
25
dist/licenses.txt
generated
vendored
25
dist/licenses.txt
generated
vendored
@ -512,31 +512,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
json-with-bigint
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Ivan Korolenko
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
semver
|
||||
ISC
|
||||
The ISC License
|
||||
|
||||
26
dist/post.js
generated
vendored
26
dist/post.js
generated
vendored
@ -28436,7 +28436,7 @@ function composeCollection(CN, ctx, token, props, onError) {
|
||||
let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType);
|
||||
if (!tag) {
|
||||
const kt = ctx.schema.knownTags[tagName];
|
||||
if (kt?.collection === expType) {
|
||||
if (kt && kt.collection === expType) {
|
||||
ctx.schema.tags.push(Object.assign({}, kt, { default: false }));
|
||||
tag = kt;
|
||||
}
|
||||
@ -29315,7 +29315,7 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, ta
|
||||
});
|
||||
if (!props.found) {
|
||||
if (props.anchor || props.tag || value) {
|
||||
if (value?.type === 'block-seq')
|
||||
if (value && value.type === 'block-seq')
|
||||
onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column');
|
||||
else
|
||||
onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator');
|
||||
@ -29530,7 +29530,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
||||
}
|
||||
}
|
||||
else if (value) {
|
||||
if ('source' in value && value.source?.[0] === ':')
|
||||
if ('source' in value && value.source && value.source[0] === ':')
|
||||
onError(value, 'MISSING_CHAR', `Missing space after : in ${fcName}`);
|
||||
else
|
||||
onError(valueProps.start, 'MISSING_CHAR', `Missing , or : between ${fcName} items`);
|
||||
@ -29574,7 +29574,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
||||
const expectedEnd = isMap ? '}' : ']';
|
||||
const [ce, ...ee] = fc.end;
|
||||
let cePos = offset;
|
||||
if (ce?.source === expectedEnd)
|
||||
if (ce && ce.source === expectedEnd)
|
||||
cePos = ce.offset + ce.source.length;
|
||||
else {
|
||||
const name = fcName[0].toUpperCase() + fcName.substring(1);
|
||||
@ -30943,7 +30943,7 @@ const prettifyError = (src, lc) => (error) => {
|
||||
if (/[^ ]/.test(lineStr)) {
|
||||
let count = 1;
|
||||
const end = error.linePos[1];
|
||||
if (end?.line === line && end.col > col) {
|
||||
if (end && end.line === line && end.col > col) {
|
||||
count = Math.max(1, Math.min(end.col - col, 80 - ci));
|
||||
}
|
||||
const pointer = ' '.repeat(ci) + '^'.repeat(count);
|
||||
@ -31108,7 +31108,7 @@ class Alias extends Node.NodeBase {
|
||||
data = anchors.get(source);
|
||||
}
|
||||
/* istanbul ignore if */
|
||||
if (data?.res === undefined) {
|
||||
if (!data || data.res === undefined) {
|
||||
const msg = 'This should not happen: Alias anchor was not resolved?';
|
||||
throw new ReferenceError(msg);
|
||||
}
|
||||
@ -33434,7 +33434,7 @@ class Parser {
|
||||
}
|
||||
*step() {
|
||||
const top = this.peek(1);
|
||||
if (this.type === 'doc-end' && top?.type !== 'doc-end') {
|
||||
if (this.type === 'doc-end' && (!top || top.type !== 'doc-end')) {
|
||||
while (this.stack.length > 0)
|
||||
yield* this.pop();
|
||||
this.stack.push({
|
||||
@ -33966,7 +33966,7 @@ class Parser {
|
||||
do {
|
||||
yield* this.pop();
|
||||
top = this.peek(1);
|
||||
} while (top?.type === 'flow-collection');
|
||||
} while (top && top.type === 'flow-collection');
|
||||
}
|
||||
else if (fc.end.length === 0) {
|
||||
switch (this.type) {
|
||||
@ -36124,7 +36124,7 @@ function stringifyNumber({ format, minFractionDigits, tag, value }) {
|
||||
const num = typeof value === 'number' ? value : Number(value);
|
||||
if (!isFinite(num))
|
||||
return isNaN(num) ? '.nan' : num < 0 ? '-.inf' : '.inf';
|
||||
let n = Object.is(value, -0) ? '-0' : JSON.stringify(value);
|
||||
let n = JSON.stringify(value);
|
||||
if (!format &&
|
||||
minFractionDigits &&
|
||||
(!tag || tag === 'tag:yaml.org,2002:float') &&
|
||||
@ -36254,7 +36254,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
||||
ws += `\n${stringifyComment.indentComment(cs, ctx.indent)}`;
|
||||
}
|
||||
if (valueStr === '' && !ctx.inFlow) {
|
||||
if (ws === '\n' && valueComment)
|
||||
if (ws === '\n')
|
||||
ws = '\n\n';
|
||||
}
|
||||
else {
|
||||
@ -37108,7 +37108,7 @@ const external_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.me
|
||||
var external_http_ = __nccwpck_require__(8611);
|
||||
// EXTERNAL MODULE: external "https"
|
||||
var external_https_ = __nccwpck_require__(5692);
|
||||
;// CONCATENATED MODULE: ./node_modules/@actions/http-client/lib/proxy.js
|
||||
;// CONCATENATED MODULE: ./node_modules/@actions/core/node_modules/@actions/http-client/lib/proxy.js
|
||||
function getProxyUrl(reqUrl) {
|
||||
const usingSsl = reqUrl.protocol === 'https:';
|
||||
if (checkBypass(reqUrl)) {
|
||||
@ -37203,7 +37203,7 @@ class DecodedURL extends URL {
|
||||
var node_modules_tunnel = __nccwpck_require__(770);
|
||||
// EXTERNAL MODULE: ./node_modules/undici/index.js
|
||||
var undici = __nccwpck_require__(6752);
|
||||
;// CONCATENATED MODULE: ./node_modules/@actions/http-client/lib/index.js
|
||||
;// CONCATENATED MODULE: ./node_modules/@actions/core/node_modules/@actions/http-client/lib/index.js
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
@ -37900,7 +37900,7 @@ class lib_HttpClient {
|
||||
}
|
||||
const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
||||
//# sourceMappingURL=index.js.map
|
||||
;// CONCATENATED MODULE: ./node_modules/@actions/http-client/lib/auth.js
|
||||
;// CONCATENATED MODULE: ./node_modules/@actions/core/node_modules/@actions/http-client/lib/auth.js
|
||||
var auth_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
|
||||
6426
package-lock.json
generated
6426
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -32,10 +32,10 @@
|
||||
"docker-compose": "^1.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ts-dev-tools/core": "^1.11.1",
|
||||
"@ts-dev-tools/core": "^1.10.0",
|
||||
"@vercel/ncc": "^0.38.4",
|
||||
"eslint-plugin-github": "^6.0.0",
|
||||
"eslint-plugin-jsonc": "^3.1.1"
|
||||
"eslint-plugin-jsonc": "^2.21.1"
|
||||
},
|
||||
"scripts": {
|
||||
"package": "npm run package:index && npm run package:post",
|
||||
|
||||
@ -24,25 +24,18 @@ jest.unstable_mockModule("docker-compose", () => ({
|
||||
}));
|
||||
|
||||
// Mock node:fs
|
||||
jest.unstable_mockModule("node:fs", async () => {
|
||||
const actualFs = await jest.requireActual<typeof import("node:fs")>("node:fs");
|
||||
|
||||
return {
|
||||
...actualFs,
|
||||
jest.unstable_mockModule("node:fs", () => ({
|
||||
existsSync: jest.fn().mockReturnValue(true),
|
||||
default: {
|
||||
...actualFs,
|
||||
existsSync: jest.fn().mockReturnValue(true),
|
||||
},
|
||||
};
|
||||
});
|
||||
default: { existsSync: jest.fn().mockReturnValue(true) },
|
||||
}));
|
||||
|
||||
// Dynamic imports after mock setup
|
||||
const { run } = await import("./index-runner.js");
|
||||
const { InputService } = await import("./services/input.service.js");
|
||||
const { LoggerService, LogLevel } = await import("./services/logger.service.js");
|
||||
const { DockerComposeInstallerService } =
|
||||
await import("./services/docker-compose-installer.service.js");
|
||||
const { DockerComposeInstallerService } = await import(
|
||||
"./services/docker-compose-installer.service.js"
|
||||
);
|
||||
const { DockerComposeService } = await import("./services/docker-compose.service.js");
|
||||
|
||||
describe("run", () => {
|
||||
|
||||
@ -24,24 +24,17 @@ jest.unstable_mockModule("docker-compose", () => ({
|
||||
}));
|
||||
|
||||
// Mock node:fs
|
||||
jest.unstable_mockModule("node:fs", async () => {
|
||||
const actualFs = await jest.requireActual<typeof import("node:fs")>("node:fs");
|
||||
|
||||
return {
|
||||
...actualFs,
|
||||
jest.unstable_mockModule("node:fs", () => ({
|
||||
existsSync: jest.fn().mockReturnValue(true),
|
||||
default: {
|
||||
...actualFs,
|
||||
existsSync: jest.fn().mockReturnValue(true),
|
||||
},
|
||||
};
|
||||
});
|
||||
default: { existsSync: jest.fn().mockReturnValue(true) },
|
||||
}));
|
||||
|
||||
// Dynamic imports after mock setup
|
||||
const { InputService } = await import("./services/input.service.js");
|
||||
const { LoggerService, LogLevel } = await import("./services/logger.service.js");
|
||||
const { DockerComposeInstallerService } =
|
||||
await import("./services/docker-compose-installer.service.js");
|
||||
const { DockerComposeInstallerService } = await import(
|
||||
"./services/docker-compose-installer.service.js"
|
||||
);
|
||||
const { DockerComposeService } = await import("./services/docker-compose.service.js");
|
||||
|
||||
let getInputsMock: jest.SpiedFunction<typeof InputService.prototype.getInputs>;
|
||||
|
||||
@ -80,23 +80,6 @@ describe("DockerComposeInstallerService", () => {
|
||||
});
|
||||
|
||||
describe("install", () => {
|
||||
it("should install latest when compose version is not specified and Compose is missing", async () => {
|
||||
// Arrange: first call to version() fails (Compose missing)
|
||||
versionMock.mockRejectedValueOnce(new Error("version not installed"));
|
||||
|
||||
const latestVersion = "v2.0.0";
|
||||
mockLatestRelease(latestVersion);
|
||||
versionMock.mockResolvedValueOnce(composeVersionResponse(latestVersion));
|
||||
setPlatform("linux");
|
||||
|
||||
// Act
|
||||
const result = await installCompose(null, "token");
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(latestVersion);
|
||||
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(latestVersion);
|
||||
});
|
||||
|
||||
it("should return current version when no version is provided", async () => {
|
||||
// Arrange
|
||||
versionMock.mockResolvedValue(composeVersionResponse("2.0.0"));
|
||||
@ -253,20 +236,5 @@ describe("DockerComposeInstallerService", () => {
|
||||
);
|
||||
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(targetVersion);
|
||||
});
|
||||
|
||||
it("should throw with unknown installed version when post-install version check fails", async () => {
|
||||
// Arrange
|
||||
versionMock.mockResolvedValueOnce(composeVersionResponse("1.2.3"));
|
||||
|
||||
const targetVersion = "v1.4.0";
|
||||
versionMock.mockRejectedValueOnce(new Error("version check failed after install"));
|
||||
setPlatform("linux");
|
||||
|
||||
// Act & Assert
|
||||
await expect(installCompose(targetVersion, "token")).rejects.toThrow(
|
||||
`Failed to install Docker Compose version "${targetVersion}", installed version is "unknown"`
|
||||
);
|
||||
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(targetVersion);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
import { jest, describe, it, expect, beforeEach } from "@jest/globals";
|
||||
import type {
|
||||
IDockerComposeLogOptions,
|
||||
IDockerComposeOptions,
|
||||
IDockerComposeResult,
|
||||
} from "docker-compose";
|
||||
import type { IDockerComposeOptions, IDockerComposeResult } from "docker-compose";
|
||||
|
||||
// Mock docker-compose before importing the module under test
|
||||
const upAllMock = jest.fn<(options: IDockerComposeOptions) => Promise<IDockerComposeResult>>();
|
||||
@ -11,9 +7,7 @@ const upManyMock =
|
||||
jest.fn<(services: string[], options: IDockerComposeOptions) => Promise<IDockerComposeResult>>();
|
||||
const downMock = jest.fn<(options: IDockerComposeOptions) => Promise<IDockerComposeResult>>();
|
||||
const logsMock =
|
||||
jest.fn<
|
||||
(services: string[], options: IDockerComposeLogOptions) => Promise<IDockerComposeResult>
|
||||
>();
|
||||
jest.fn<(services: string[], options: IDockerComposeOptions) => Promise<IDockerComposeResult>>();
|
||||
|
||||
jest.unstable_mockModule("docker-compose", () => ({
|
||||
upAll: upAllMock,
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { jest, describe, it, expect, beforeEach } from "@jest/globals";
|
||||
import type { ExecOptions } from "@actions/exec";
|
||||
import type { OutgoingHttpHeaders } from "node:http";
|
||||
|
||||
// Mock @actions/exec
|
||||
const execMock =
|
||||
@ -18,20 +17,8 @@ jest.unstable_mockModule("@actions/io", () => ({
|
||||
}));
|
||||
|
||||
// Mock @actions/tool-cache
|
||||
const cacheFileMock =
|
||||
jest.fn<
|
||||
(
|
||||
sourceFile: string,
|
||||
targetFile: string,
|
||||
tool: string,
|
||||
version: string,
|
||||
arch?: string
|
||||
) => Promise<string>
|
||||
>();
|
||||
const downloadToolMock =
|
||||
jest.fn<
|
||||
(url: string, dest?: string, auth?: string, headers?: OutgoingHttpHeaders) => Promise<string>
|
||||
>();
|
||||
const cacheFileMock = jest.fn<() => Promise<string>>();
|
||||
const downloadToolMock = jest.fn<() => Promise<string>>();
|
||||
|
||||
jest.unstable_mockModule("@actions/tool-cache", () => ({
|
||||
cacheFile: cacheFileMock,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user