mirror of
https://github.com/hoverkraft-tech/compose-action.git
synced 2026-07-03 12:12:50 +08:00
chore(deps): bump the github-actions-dependencies group with 6 updates
Some checks failed
Internal - Main - Continuous Integration / ci (push) Has been cancelled
Need fix to Issue / main (push) Has been cancelled
Prepare release / release (push) Has been cancelled
Internal - Main - Continuous Integration / prepare-docs (push) Has been cancelled
Internal - Main - Continuous Integration / sync-docs (push) Has been cancelled
Mark stale issues and pull requests / main (push) Has been cancelled
Some checks failed
Internal - Main - Continuous Integration / ci (push) Has been cancelled
Need fix to Issue / main (push) Has been cancelled
Prepare release / release (push) Has been cancelled
Internal - Main - Continuous Integration / prepare-docs (push) Has been cancelled
Internal - Main - Continuous Integration / sync-docs (push) Has been cancelled
Mark stale issues and pull requests / main (push) Has been cancelled
Bumps the github-actions-dependencies group with 6 updates: --- updated-dependencies: - dependency-name: hoverkraft-tech/ci-github-common/.github/workflows/linter.yml dependency-version: 0.36.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml dependency-version: 0.36.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/ci-github-common dependency-version: 0.36.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml dependency-version: 0.36.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml dependency-version: 0.36.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml dependency-version: 0.36.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
This commit is contained in:
parent
98fdf9dfda
commit
9c11768144
@ -18,8 +18,9 @@
|
|||||||
"github.vscode-github-actions",
|
"github.vscode-github-actions",
|
||||||
"ms-vscode.makefile-tools",
|
"ms-vscode.makefile-tools",
|
||||||
"bierner.markdown-preview-github-styles",
|
"bierner.markdown-preview-github-styles",
|
||||||
"dbaeumer.vscode-eslint",
|
"esbenp.prettier-vscode",
|
||||||
"esbenp.prettier-vscode"
|
"biomejs.biome",
|
||||||
|
"vitest.explorer"
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
"terminal.integrated.defaultProfile.linux": "zsh"
|
"terminal.integrated.defaultProfile.linux": "zsh"
|
||||||
|
|||||||
10
.github/dependabot.yml
vendored
10
.github/dependabot.yml
vendored
@ -3,6 +3,8 @@ updates:
|
|||||||
- package-ecosystem: github-actions
|
- package-ecosystem: github-actions
|
||||||
directory: /
|
directory: /
|
||||||
open-pull-requests-limit: 20
|
open-pull-requests-limit: 20
|
||||||
|
cooldown:
|
||||||
|
default-days: 7
|
||||||
schedule:
|
schedule:
|
||||||
interval: weekly
|
interval: weekly
|
||||||
day: friday
|
day: friday
|
||||||
@ -17,6 +19,8 @@ updates:
|
|||||||
- "/test"
|
- "/test"
|
||||||
- "/"
|
- "/"
|
||||||
open-pull-requests-limit: 20
|
open-pull-requests-limit: 20
|
||||||
|
cooldown:
|
||||||
|
default-days: 7
|
||||||
schedule:
|
schedule:
|
||||||
interval: weekly
|
interval: weekly
|
||||||
day: friday
|
day: friday
|
||||||
@ -29,6 +33,8 @@ updates:
|
|||||||
- package-ecosystem: docker-compose
|
- package-ecosystem: docker-compose
|
||||||
directory: "/test"
|
directory: "/test"
|
||||||
open-pull-requests-limit: 20
|
open-pull-requests-limit: 20
|
||||||
|
cooldown:
|
||||||
|
default-days: 7
|
||||||
schedule:
|
schedule:
|
||||||
interval: weekly
|
interval: weekly
|
||||||
day: friday
|
day: friday
|
||||||
@ -42,6 +48,8 @@ updates:
|
|||||||
directory: "/"
|
directory: "/"
|
||||||
open-pull-requests-limit: 20
|
open-pull-requests-limit: 20
|
||||||
versioning-strategy: increase
|
versioning-strategy: increase
|
||||||
|
cooldown:
|
||||||
|
default-days: 7
|
||||||
schedule:
|
schedule:
|
||||||
interval: weekly
|
interval: weekly
|
||||||
day: friday
|
day: friday
|
||||||
@ -62,6 +70,8 @@ updates:
|
|||||||
- package-ecosystem: "devcontainers"
|
- package-ecosystem: "devcontainers"
|
||||||
open-pull-requests-limit: 20
|
open-pull-requests-limit: 20
|
||||||
directory: "/"
|
directory: "/"
|
||||||
|
cooldown:
|
||||||
|
default-days: 7
|
||||||
schedule:
|
schedule:
|
||||||
interval: weekly
|
interval: weekly
|
||||||
day: friday
|
day: friday
|
||||||
|
|||||||
5
.github/workflows/__shared-ci.yml
vendored
5
.github/workflows/__shared-ci.yml
vendored
@ -7,7 +7,7 @@ permissions: {}
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
linter:
|
linter:
|
||||||
uses: hoverkraft-tech/ci-github-common/.github/workflows/linter.yml@66578f5b9aec4ac5558b5dad750c4c74dfcb65c5 # 0.35.5
|
uses: hoverkraft-tech/ci-github-common/.github/workflows/linter.yml@4bb7594b1bf3696c54b2bbae970376056853f8ea # 0.36.0
|
||||||
permissions:
|
permissions:
|
||||||
actions: read
|
actions: read
|
||||||
contents: read
|
contents: read
|
||||||
@ -15,7 +15,7 @@ jobs:
|
|||||||
statuses: write
|
statuses: write
|
||||||
with:
|
with:
|
||||||
linter-env: |
|
linter-env: |
|
||||||
FILTER_REGEX_EXCLUDE=dist/**/*
|
FILTER_REGEX_EXCLUDE=dist/**/*|.github/social-preview.svg|.github/logo.svg
|
||||||
VALIDATE_JSCPD=false
|
VALIDATE_JSCPD=false
|
||||||
VALIDATE_TYPESCRIPT_STANDARD=false
|
VALIDATE_TYPESCRIPT_STANDARD=false
|
||||||
VALIDATE_TYPESCRIPT_ES=false
|
VALIDATE_TYPESCRIPT_ES=false
|
||||||
@ -33,7 +33,6 @@ jobs:
|
|||||||
packages: read
|
packages: read
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
security-events: write
|
security-events: write
|
||||||
secrets: inherit
|
|
||||||
|
|
||||||
check-dist:
|
check-dist:
|
||||||
name: Test nodejs
|
name: Test nodejs
|
||||||
|
|||||||
4
.github/workflows/greetings.yml
vendored
4
.github/workflows/greetings.yml
vendored
@ -3,14 +3,14 @@ name: Greetings
|
|||||||
on:
|
on:
|
||||||
issues:
|
issues:
|
||||||
types: [opened]
|
types: [opened]
|
||||||
pull_request_target:
|
pull_request_target: # zizmor: ignore[dangerous-triggers] metadata-only reusable workflow with explicit write permissions and no checkout
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
permissions: {}
|
permissions: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
greetings:
|
greetings:
|
||||||
uses: hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml@66578f5b9aec4ac5558b5dad750c4c74dfcb65c5 # 0.35.5
|
uses: hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml@4bb7594b1bf3696c54b2bbae970376056853f8ea # 0.36.0
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
issues: write
|
issues: write
|
||||||
|
|||||||
5
.github/workflows/main-ci.yml
vendored
5
.github/workflows/main-ci.yml
vendored
@ -27,7 +27,6 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
security-events: write
|
security-events: write
|
||||||
statuses: write
|
statuses: write
|
||||||
secrets: inherit
|
|
||||||
|
|
||||||
prepare-docs:
|
prepare-docs:
|
||||||
needs: ci
|
needs: ci
|
||||||
@ -65,9 +64,9 @@ jobs:
|
|||||||
id: generate-token
|
id: generate-token
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.CI_BOT_APP_CLIENT_ID }}
|
client-id: ${{ vars.CI_BOT_APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.CI_BOT_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.CI_BOT_APP_PRIVATE_KEY }} # zizmor: ignore[secrets-outside-env] repository automation uses a dedicated app secret without untrusted code execution
|
||||||
|
|
||||||
- uses: hoverkraft-tech/ci-github-common/actions/create-and-merge-pull-request@66578f5b9aec4ac5558b5dad750c4c74dfcb65c5 # 0.35.5
|
- uses: hoverkraft-tech/ci-github-common/actions/create-and-merge-pull-request@4bb7594b1bf3696c54b2bbae970376056853f8ea # 0.36.0
|
||||||
with:
|
with:
|
||||||
github-token: ${{ steps.generate-token.outputs.token }}
|
github-token: ${{ steps.generate-token.outputs.token }}
|
||||||
branch: docs/actions-workflows-documentation-update
|
branch: docs/actions-workflows-documentation-update
|
||||||
|
|||||||
7
.github/workflows/need-fix-to-issue.yml
vendored
7
.github/workflows/need-fix-to-issue.yml
vendored
@ -11,15 +11,16 @@ on:
|
|||||||
description: "The SHA of the commit to get the diff for"
|
description: "The SHA of the commit to get the diff for"
|
||||||
required: true
|
required: true
|
||||||
manual-base-ref:
|
manual-base-ref:
|
||||||
description: "By default, the commit entered above is compared to the one directly
|
description: >-
|
||||||
before it; to go back further, enter an earlier SHA here"
|
By default, the commit entered above is compared to the one directly
|
||||||
|
before it; to go back further, enter an earlier SHA here
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
permissions: {}
|
permissions: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
uses: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml@66578f5b9aec4ac5558b5dad750c4c74dfcb65c5 # 0.35.5
|
uses: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml@4bb7594b1bf3696c54b2bbae970376056853f8ea # 0.36.0
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
issues: write
|
issues: write
|
||||||
|
|||||||
1
.github/workflows/pull-request-ci.yml
vendored
1
.github/workflows/pull-request-ci.yml
vendored
@ -22,4 +22,3 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
security-events: write
|
security-events: write
|
||||||
statuses: write
|
statuses: write
|
||||||
secrets: inherit
|
|
||||||
|
|||||||
4
.github/workflows/semantic-pull-request.yml
vendored
4
.github/workflows/semantic-pull-request.yml
vendored
@ -1,7 +1,7 @@
|
|||||||
name: "Pull Request - Semantic Lint"
|
name: "Pull Request - Semantic Lint"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request_target:
|
pull_request_target: # zizmor: ignore[dangerous-triggers] validates PR metadata only through a pinned reusable workflow without checkout
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
- edited
|
- edited
|
||||||
@ -11,7 +11,7 @@ permissions: {}
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@66578f5b9aec4ac5558b5dad750c4c74dfcb65c5 # 0.35.5
|
uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@4bb7594b1bf3696c54b2bbae970376056853f8ea # 0.36.0
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|||||||
2
.github/workflows/stale.yml
vendored
2
.github/workflows/stale.yml
vendored
@ -8,7 +8,7 @@ permissions: {}
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
uses: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml@66578f5b9aec4ac5558b5dad750c4c74dfcb65c5 # 0.35.5
|
uses: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml@4bb7594b1bf3696c54b2bbae970376056853f8ea # 0.36.0
|
||||||
permissions:
|
permissions:
|
||||||
issues: write
|
issues: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|||||||
7
.gitignore
vendored
7
.gitignore
vendored
@ -12,7 +12,6 @@ lerna-debug.log*
|
|||||||
|
|
||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
eslint-report.json
|
|
||||||
|
|
||||||
# Runtime data
|
# Runtime data
|
||||||
pids
|
pids
|
||||||
@ -54,9 +53,6 @@ typings/
|
|||||||
# Optional npm cache directory
|
# Optional npm cache directory
|
||||||
.npm
|
.npm
|
||||||
|
|
||||||
# Optional eslint cache
|
|
||||||
.eslintcache
|
|
||||||
|
|
||||||
# Optional REPL history
|
# Optional REPL history
|
||||||
.node_repl_history
|
.node_repl_history
|
||||||
|
|
||||||
@ -102,3 +98,6 @@ __tests__/runner/*
|
|||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
*.code-workspace
|
*.code-workspace
|
||||||
|
lint.sarif
|
||||||
|
biome-report.sarif
|
||||||
|
junit.xml
|
||||||
|
|||||||
@ -1,12 +1,5 @@
|
|||||||
FROM ghcr.io/super-linter/super-linter:slim-v8.0.0
|
FROM ghcr.io/hoverkraft-tech/docker-base-images/super-linter:0.6.0
|
||||||
|
|
||||||
HEALTHCHECK --interval=5m --timeout=10s --start-period=30s --retries=3 CMD ["/bin/sh","-c","test -d /github/home"]
|
HEALTHCHECK --interval=5m --timeout=10s --start-period=30s --retries=3 CMD ["/bin/sh","-c","test -d /github/home"]
|
||||||
ARG UID=1000
|
ARG UID=1000
|
||||||
ARG GID=1000
|
ARG GID=1000
|
||||||
RUN chown -R ${UID}:${GID} /github/home
|
|
||||||
USER ${UID}:${GID}
|
USER ${UID}:${GID}
|
||||||
|
|
||||||
ENV RUN_LOCAL=true
|
|
||||||
ENV USE_FIND_ALGORITHM=true
|
|
||||||
ENV LOG_LEVEL=WARN
|
|
||||||
ENV LOG_FILE="/github/home/logs"
|
|
||||||
|
|||||||
14
Makefile
14
Makefile
@ -7,13 +7,13 @@ lint: ## Execute linting
|
|||||||
$(call run_linter,)
|
$(call run_linter,)
|
||||||
|
|
||||||
lint-fix: ## Execute linting and fix
|
lint-fix: ## Execute linting and fix
|
||||||
|
@npm run format
|
||||||
$(call run_linter, \
|
$(call run_linter, \
|
||||||
-e FIX_JSON_PRETTIER=true \
|
|
||||||
-e FIX_JAVASCRIPT_PRETTIER=true \
|
|
||||||
-e FIX_YAML_PRETTIER=true \
|
|
||||||
-e FIX_MARKDOWN=true \
|
-e FIX_MARKDOWN=true \
|
||||||
-e FIX_MARKDOWN_PRETTIER=true \
|
|
||||||
-e FIX_NATURAL_LANGUAGE=true \
|
-e FIX_NATURAL_LANGUAGE=true \
|
||||||
|
-e FIX_SHELL_SHFMT=true \
|
||||||
|
-e FIX_BIOME_LINT=true \
|
||||||
|
-e FIX_BIOME_FORMAT=true \
|
||||||
)
|
)
|
||||||
|
|
||||||
ci: ## Execute all formats and checks
|
ci: ## Execute all formats and checks
|
||||||
@ -29,12 +29,8 @@ define run_linter
|
|||||||
docker build --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --tag $$LINTER_IMAGE .; \
|
docker build --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --tag $$LINTER_IMAGE .; \
|
||||||
docker run \
|
docker run \
|
||||||
-e DEFAULT_WORKSPACE="$$DEFAULT_WORKSPACE" \
|
-e DEFAULT_WORKSPACE="$$DEFAULT_WORKSPACE" \
|
||||||
|
-e FILTER_REGEX_EXCLUDE="dist/**/*|.github/social-preview.svg|.github/logo.svg" \
|
||||||
-e FILTER_REGEX_INCLUDE="$(filter-out $@,$(MAKECMDGOALS))" \
|
-e FILTER_REGEX_INCLUDE="$(filter-out $@,$(MAKECMDGOALS))" \
|
||||||
-e IGNORE_GITIGNORED_FILES=true \
|
|
||||||
-e FILTER_REGEX_EXCLUDE=dist/**/* \
|
|
||||||
-e VALIDATE_TYPESCRIPT_ES=false \
|
|
||||||
-e VALIDATE_TYPESCRIPT_PRETTIER=false \
|
|
||||||
-e VALIDATE_JAVASCRIPT_ES=false \
|
|
||||||
$(1) \
|
$(1) \
|
||||||
-v $$VOLUME \
|
-v $$VOLUME \
|
||||||
--rm \
|
--rm \
|
||||||
|
|||||||
34
biome.json
Normal file
34
biome.json
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://biomejs.dev/schemas/2.4.16/schema.json",
|
||||||
|
"vcs": {
|
||||||
|
"enabled": true,
|
||||||
|
"clientKind": "git",
|
||||||
|
"useIgnoreFile": true
|
||||||
|
},
|
||||||
|
"files": {
|
||||||
|
"includes": ["**", "!!**/dist"]
|
||||||
|
},
|
||||||
|
"formatter": {
|
||||||
|
"enabled": true,
|
||||||
|
"indentStyle": "tab"
|
||||||
|
},
|
||||||
|
"linter": {
|
||||||
|
"enabled": true,
|
||||||
|
"rules": {
|
||||||
|
"recommended": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"javascript": {
|
||||||
|
"formatter": {
|
||||||
|
"quoteStyle": "double"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"assist": {
|
||||||
|
"enabled": true,
|
||||||
|
"actions": {
|
||||||
|
"source": {
|
||||||
|
"organizeImports": "on"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
23
dist/index.js
generated
vendored
23
dist/index.js
generated
vendored
@ -43860,8 +43860,11 @@ class InputService {
|
|||||||
}) || null);
|
}) || null);
|
||||||
}
|
}
|
||||||
getServiceLogLevel() {
|
getServiceLogLevel() {
|
||||||
const configuredLevel = getInput(InputNames.ServiceLogLevel, { required: false });
|
const configuredLevel = getInput(InputNames.ServiceLogLevel, {
|
||||||
if (configuredLevel && !Object.values(LogLevel).includes(configuredLevel)) {
|
required: false,
|
||||||
|
});
|
||||||
|
if (configuredLevel &&
|
||||||
|
!Object.values(LogLevel).includes(configuredLevel)) {
|
||||||
throw new Error(`Invalid service log level "${configuredLevel}". Valid values are: ${Object.values(LogLevel).join(", ")}`);
|
throw new Error(`Invalid service log level "${configuredLevel}". Valid values are: ${Object.values(LogLevel).join(", ")}`);
|
||||||
}
|
}
|
||||||
return configuredLevel || LogLevel.Debug;
|
return configuredLevel || LogLevel.Debug;
|
||||||
@ -43943,12 +43946,12 @@ class DockerComposeService {
|
|||||||
parts.push("Docker Compose command failed");
|
parts.push("Docker Compose command failed");
|
||||||
}
|
}
|
||||||
// Add error stream output if available
|
// Add error stream output if available
|
||||||
if (error.err && error.err.trim()) {
|
if (error.err?.trim()) {
|
||||||
parts.push("\nError output:");
|
parts.push("\nError output:");
|
||||||
parts.push(error.err.trim());
|
parts.push(error.err.trim());
|
||||||
}
|
}
|
||||||
// Add standard output if available and different from error output
|
// Add standard output if available and different from error output
|
||||||
if (error.out && error.out.trim() && error.out !== error.err) {
|
if (error.out?.trim() && error.out !== error.err) {
|
||||||
parts.push("\nStandard output:");
|
parts.push("\nStandard output:");
|
||||||
parts.push(error.out.trim());
|
parts.push(error.out.trim());
|
||||||
}
|
}
|
||||||
@ -48237,14 +48240,17 @@ class DockerComposeInstallerService {
|
|||||||
constructor(manualInstallerAdapter) {
|
constructor(manualInstallerAdapter) {
|
||||||
this.manualInstallerAdapter = manualInstallerAdapter;
|
this.manualInstallerAdapter = manualInstallerAdapter;
|
||||||
}
|
}
|
||||||
async install({ composeVersion, cwd, githubToken }) {
|
async install({ composeVersion, cwd, githubToken, }) {
|
||||||
const currentVersion = await this.version({ cwd });
|
const currentVersion = await this.version({ cwd });
|
||||||
const normalizedCurrentVersion = currentVersion ? this.normalizeVersion(currentVersion) : null;
|
const normalizedCurrentVersion = currentVersion
|
||||||
|
? this.normalizeVersion(currentVersion)
|
||||||
|
: null;
|
||||||
const normalizedRequestedVersion = composeVersion
|
const normalizedRequestedVersion = composeVersion
|
||||||
? this.normalizeVersion(composeVersion)
|
? this.normalizeVersion(composeVersion)
|
||||||
: null;
|
: null;
|
||||||
const needsInstall = !currentVersion ||
|
const needsInstall = !currentVersion ||
|
||||||
(composeVersion && normalizedRequestedVersion !== normalizedCurrentVersion);
|
(composeVersion &&
|
||||||
|
normalizedRequestedVersion !== normalizedCurrentVersion);
|
||||||
if (!needsInstall) {
|
if (!needsInstall) {
|
||||||
return currentVersion;
|
return currentVersion;
|
||||||
}
|
}
|
||||||
@ -48258,7 +48264,8 @@ class DockerComposeInstallerService {
|
|||||||
await this.installVersion(targetVersion);
|
await this.installVersion(targetVersion);
|
||||||
const installedVersion = await this.version({ cwd });
|
const installedVersion = await this.version({ cwd });
|
||||||
if (!installedVersion ||
|
if (!installedVersion ||
|
||||||
this.normalizeVersion(installedVersion) !== this.normalizeVersion(targetVersion)) {
|
this.normalizeVersion(installedVersion) !==
|
||||||
|
this.normalizeVersion(targetVersion)) {
|
||||||
throw new Error(`Failed to install Docker Compose version "${targetVersion}", installed version is "${installedVersion ?? "unknown"}"`);
|
throw new Error(`Failed to install Docker Compose version "${targetVersion}", installed version is "${installedVersion ?? "unknown"}"`);
|
||||||
}
|
}
|
||||||
return installedVersion;
|
return installedVersion;
|
||||||
|
|||||||
11
dist/post.js
generated
vendored
11
dist/post.js
generated
vendored
@ -40112,8 +40112,11 @@ class InputService {
|
|||||||
}) || null);
|
}) || null);
|
||||||
}
|
}
|
||||||
getServiceLogLevel() {
|
getServiceLogLevel() {
|
||||||
const configuredLevel = getInput(InputNames.ServiceLogLevel, { required: false });
|
const configuredLevel = getInput(InputNames.ServiceLogLevel, {
|
||||||
if (configuredLevel && !Object.values(LogLevel).includes(configuredLevel)) {
|
required: false,
|
||||||
|
});
|
||||||
|
if (configuredLevel &&
|
||||||
|
!Object.values(LogLevel).includes(configuredLevel)) {
|
||||||
throw new Error(`Invalid service log level "${configuredLevel}". Valid values are: ${Object.values(LogLevel).join(", ")}`);
|
throw new Error(`Invalid service log level "${configuredLevel}". Valid values are: ${Object.values(LogLevel).join(", ")}`);
|
||||||
}
|
}
|
||||||
return configuredLevel || LogLevel.Debug;
|
return configuredLevel || LogLevel.Debug;
|
||||||
@ -40195,12 +40198,12 @@ class DockerComposeService {
|
|||||||
parts.push("Docker Compose command failed");
|
parts.push("Docker Compose command failed");
|
||||||
}
|
}
|
||||||
// Add error stream output if available
|
// Add error stream output if available
|
||||||
if (error.err && error.err.trim()) {
|
if (error.err?.trim()) {
|
||||||
parts.push("\nError output:");
|
parts.push("\nError output:");
|
||||||
parts.push(error.err.trim());
|
parts.push(error.err.trim());
|
||||||
}
|
}
|
||||||
// Add standard output if available and different from error output
|
// Add standard output if available and different from error output
|
||||||
if (error.out && error.out.trim() && error.out !== error.err) {
|
if (error.out?.trim() && error.out !== error.err) {
|
||||||
parts.push("\nStandard output:");
|
parts.push("\nStandard output:");
|
||||||
parts.push(error.out.trim());
|
parts.push(error.out.trim());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
import tsDevToolsCore from "@ts-dev-tools/core/dist/eslint-plugin-ts-dev-tools/index.js";
|
|
||||||
|
|
||||||
export default tsDevToolsCore.default;
|
|
||||||
10099
package-lock.json
generated
10099
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
88
package.json
88
package.json
@ -32,95 +32,33 @@
|
|||||||
"docker-compose": "^1.4.2"
|
"docker-compose": "^1.4.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ts-dev-tools/core": "^1.12.0",
|
"@ts-dev-tools/core": "^1.12.4",
|
||||||
"@vercel/ncc": "^0.38.4",
|
"@vercel/ncc": "^0.38.4"
|
||||||
"eslint-plugin-github": "^6.0.0",
|
|
||||||
"eslint-plugin-jsonc": "^3.1.2"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"package": "npm run package:index && npm run package:post",
|
"package": "npm run package:index && npm run package:post",
|
||||||
"package:index": "ncc build src/index.ts -o dist --license licenses.txt",
|
"package:index": "ncc build src/index.ts -o dist --license licenses.txt",
|
||||||
"package:post": "ncc build src/post.ts -o dist/post && mv dist/post/index.js dist/post.js && rm -rf dist/post",
|
"package:post": "ncc build src/post.ts -o dist/post && mv dist/post/index.js dist/post.js && rm -rf dist/post",
|
||||||
"package:watch": "npm run package -- --watch",
|
"package:watch": "npm run package -- --watch",
|
||||||
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
"lint": "biome lint --error-on-warnings .",
|
||||||
"lint:ci": "npm run lint -- --output-file eslint-report.json --format json",
|
"lint:ci": "biome lint --error-on-warnings . --reporter=sarif | tee biome-report.sarif",
|
||||||
"all": "npm run format && npm run lint:ci && npm run test:ci && npm run package",
|
"all": "npm run format && npm run lint:ci && npm run test:ci && npm run package",
|
||||||
"build": "tsc --noEmit",
|
"build": "tsc --noEmit",
|
||||||
"format": "prettier --cache --write .",
|
"format": "biome format --write .",
|
||||||
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --detectOpenHandles --forceExit --maxWorkers=50%",
|
"test": "vitest run",
|
||||||
"test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch --maxWorkers=25%",
|
"test:watch": "vitest",
|
||||||
"test:cov": "npm run test -- --coverage",
|
"test:cov": "vitest run --reporter=default --reporter=junit --outputFile=junit.xml --coverage.enabled --coverage.reporter=lcov --coverage.reporter=text",
|
||||||
"test:ci": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage --runInBand --detectOpenHandles --forceExit",
|
"test:ci": "npm run test:cov",
|
||||||
"prepare": "ts-dev-tools install"
|
"prepare": "ts-dev-tools install",
|
||||||
},
|
"check": "biome check --error-on-warnings --write .",
|
||||||
"jest": {
|
"vitest": "vitest"
|
||||||
"preset": "ts-jest/presets/default-esm",
|
|
||||||
"verbose": true,
|
|
||||||
"clearMocks": true,
|
|
||||||
"testEnvironment": "node",
|
|
||||||
"extensionsToTreatAsEsm": [
|
|
||||||
".ts"
|
|
||||||
],
|
|
||||||
"moduleFileExtensions": [
|
|
||||||
"js",
|
|
||||||
"ts"
|
|
||||||
],
|
|
||||||
"testMatch": [
|
|
||||||
"**/*.test.ts",
|
|
||||||
"**/__tests__/**/*.[jt]s?(x)",
|
|
||||||
"**/?(*.)+(spec|test)?(.*).+(ts|tsx|js)"
|
|
||||||
],
|
|
||||||
"testPathIgnorePatterns": [
|
|
||||||
"/node_modules/",
|
|
||||||
"/dist/"
|
|
||||||
],
|
|
||||||
"moduleNameMapper": {
|
|
||||||
"^(\\.{1,2}/.*)\\.js$": "$1"
|
|
||||||
},
|
|
||||||
"transform": {
|
|
||||||
"^.+\\.ts$": [
|
|
||||||
"ts-jest",
|
|
||||||
{
|
|
||||||
"useESM": true,
|
|
||||||
"tsconfig": "tsconfig.json"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"injectGlobals": true,
|
|
||||||
"coverageReporters": [
|
|
||||||
"json-summary",
|
|
||||||
"text",
|
|
||||||
"lcov"
|
|
||||||
],
|
|
||||||
"collectCoverage": true,
|
|
||||||
"collectCoverageFrom": [
|
|
||||||
"./src/**",
|
|
||||||
"**/src/**/*.[jt]s?(x)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"prettier": {
|
|
||||||
"semi": true,
|
|
||||||
"printWidth": 100,
|
|
||||||
"trailingComma": "es5",
|
|
||||||
"plugins": []
|
|
||||||
},
|
},
|
||||||
"commitlint": {
|
"commitlint": {
|
||||||
"extends": [
|
"extends": [
|
||||||
"@commitlint/config-conventional"
|
"@commitlint/config-conventional"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
|
||||||
"*.{js,ts,tsx}": [
|
|
||||||
"eslint --fix"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"importSort": {
|
|
||||||
".js, .jsx, .ts, .tsx": {
|
|
||||||
"style": "module",
|
|
||||||
"parser": "typescript"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tsDevTools": {
|
"tsDevTools": {
|
||||||
"version": "20250623095600-remove-prettier-oxc"
|
"version": "20260604100000-migrate-to-vitest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,38 +1,38 @@
|
|||||||
import { jest, describe, it, expect, beforeEach } from "@jest/globals";
|
import { describe, expect, it, beforeEach, vi } from "vitest";
|
||||||
|
|
||||||
// Mock @actions/core
|
// Mock @actions/core
|
||||||
const setFailedMock = jest.fn();
|
const setFailedMock = vi.fn();
|
||||||
|
|
||||||
jest.unstable_mockModule("@actions/core", () => ({
|
vi.doMock("@actions/core", () => ({
|
||||||
setFailed: setFailedMock,
|
setFailed: setFailedMock,
|
||||||
getInput: jest.fn().mockReturnValue(""),
|
getInput: vi.fn().mockReturnValue(""),
|
||||||
getMultilineInput: jest.fn().mockReturnValue([]),
|
getMultilineInput: vi.fn().mockReturnValue([]),
|
||||||
debug: jest.fn(),
|
debug: vi.fn(),
|
||||||
info: jest.fn(),
|
info: vi.fn(),
|
||||||
warning: jest.fn(),
|
warning: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock docker-compose
|
// Mock docker-compose
|
||||||
jest.unstable_mockModule("docker-compose", () => ({
|
vi.doMock("docker-compose", () => ({
|
||||||
upAll: jest.fn(),
|
upAll: vi.fn(),
|
||||||
upMany: jest.fn(),
|
upMany: vi.fn(),
|
||||||
down: jest.fn(),
|
down: vi.fn(),
|
||||||
logs: jest.fn(),
|
logs: vi.fn(),
|
||||||
version: jest
|
version: vi
|
||||||
.fn<() => Promise<{ data: { version: string } }>>()
|
.fn<() => Promise<{ data: { version: string } }>>()
|
||||||
.mockResolvedValue({ data: { version: "1.2.3" } }),
|
.mockResolvedValue({ data: { version: "1.2.3" } }),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock node:fs
|
// Mock node:fs
|
||||||
jest.unstable_mockModule("node:fs", async () => {
|
vi.doMock("node:fs", async () => {
|
||||||
const actualFs = await jest.requireActual<typeof import("node:fs")>("node:fs");
|
const actualFs = await vi.importActual<typeof import("node:fs")>("node:fs");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...actualFs,
|
...actualFs,
|
||||||
existsSync: jest.fn().mockReturnValue(true),
|
existsSync: vi.fn().mockReturnValue(true),
|
||||||
default: {
|
default: {
|
||||||
...actualFs,
|
...actualFs,
|
||||||
existsSync: jest.fn().mockReturnValue(true),
|
existsSync: vi.fn().mockReturnValue(true),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -40,26 +40,35 @@ jest.unstable_mockModule("node:fs", async () => {
|
|||||||
// Dynamic imports after mock setup
|
// Dynamic imports after mock setup
|
||||||
const { run } = await import("./index-runner.js");
|
const { run } = await import("./index-runner.js");
|
||||||
const { InputService } = await import("./services/input.service.js");
|
const { InputService } = await import("./services/input.service.js");
|
||||||
const { LoggerService, LogLevel } = await import("./services/logger.service.js");
|
const { LoggerService, LogLevel } = await import(
|
||||||
const { DockerComposeInstallerService } =
|
"./services/logger.service.js"
|
||||||
await import("./services/docker-compose-installer.service.js");
|
);
|
||||||
const { DockerComposeService } = await import("./services/docker-compose.service.js");
|
const { DockerComposeInstallerService } = await import(
|
||||||
|
"./services/docker-compose-installer.service.js"
|
||||||
|
);
|
||||||
|
const { DockerComposeService } = await import(
|
||||||
|
"./services/docker-compose.service.js"
|
||||||
|
);
|
||||||
|
|
||||||
describe("run", () => {
|
describe("run", () => {
|
||||||
let infoMock: jest.SpiedFunction<typeof LoggerService.prototype.info>;
|
let infoMock: ReturnType<typeof vi.spyOn>;
|
||||||
let debugMock: jest.SpiedFunction<typeof LoggerService.prototype.debug>;
|
let debugMock: ReturnType<typeof vi.spyOn>;
|
||||||
let getInputsMock: jest.SpiedFunction<typeof InputService.prototype.getInputs>;
|
let getInputsMock: ReturnType<typeof vi.spyOn>;
|
||||||
let installMock: jest.SpiedFunction<typeof DockerComposeInstallerService.prototype.install>;
|
let installMock: ReturnType<typeof vi.spyOn>;
|
||||||
let upMock: jest.SpiedFunction<typeof DockerComposeService.prototype.up>;
|
let upMock: ReturnType<typeof vi.spyOn>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
|
|
||||||
infoMock = jest.spyOn(LoggerService.prototype, "info").mockImplementation(() => {});
|
infoMock = vi
|
||||||
debugMock = jest.spyOn(LoggerService.prototype, "debug").mockImplementation(() => {});
|
.spyOn(LoggerService.prototype, "info")
|
||||||
getInputsMock = jest.spyOn(InputService.prototype, "getInputs");
|
.mockImplementation(() => {});
|
||||||
installMock = jest.spyOn(DockerComposeInstallerService.prototype, "install");
|
debugMock = vi
|
||||||
upMock = jest.spyOn(DockerComposeService.prototype, "up");
|
.spyOn(LoggerService.prototype, "debug")
|
||||||
|
.mockImplementation(() => {});
|
||||||
|
getInputsMock = vi.spyOn(InputService.prototype, "getInputs");
|
||||||
|
installMock = vi.spyOn(DockerComposeInstallerService.prototype, "install");
|
||||||
|
upMock = vi.spyOn(DockerComposeService.prototype, "up");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should install docker compose with specified version", async () => {
|
it("should install docker compose with specified version", async () => {
|
||||||
@ -85,10 +94,12 @@ describe("run", () => {
|
|||||||
await run();
|
await run();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(infoMock).toHaveBeenCalledWith("Setting up docker compose version 1.29.2");
|
expect(infoMock).toHaveBeenCalledWith(
|
||||||
|
"Setting up docker compose version 1.29.2",
|
||||||
|
);
|
||||||
|
|
||||||
expect(debugMock).toHaveBeenCalledWith(
|
expect(debugMock).toHaveBeenCalledWith(
|
||||||
'inputs: {"dockerFlags":[],"composeFiles":["docker-compose.yml"],"services":[],"composeFlags":[],"upFlags":[],"downFlags":[],"cwd":"/current/working/dir","composeVersion":"1.29.2","githubToken":null,"serviceLogLevel":"debug"}'
|
'inputs: {"dockerFlags":[],"composeFiles":["docker-compose.yml"],"services":[],"composeFlags":[],"upFlags":[],"downFlags":[],"cwd":"/current/working/dir","composeVersion":"1.29.2","githubToken":null,"serviceLogLevel":"debug"}',
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(installMock).toHaveBeenCalledWith({
|
expect(installMock).toHaveBeenCalledWith({
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export async function run(): Promise<void> {
|
|||||||
const loggerService = new LoggerService();
|
const loggerService = new LoggerService();
|
||||||
const inputService = new InputService();
|
const inputService = new InputService();
|
||||||
const dockerComposeInstallerService = new DockerComposeInstallerService(
|
const dockerComposeInstallerService = new DockerComposeInstallerService(
|
||||||
new ManualInstallerAdapter()
|
new ManualInstallerAdapter(),
|
||||||
);
|
);
|
||||||
const dockerComposeService = new DockerComposeService();
|
const dockerComposeService = new DockerComposeService();
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ export async function run(): Promise<void> {
|
|||||||
|
|
||||||
loggerService.info(
|
loggerService.info(
|
||||||
"Setting up docker compose" +
|
"Setting up docker compose" +
|
||||||
(inputs.composeVersion ? ` version ${inputs.composeVersion}` : "")
|
(inputs.composeVersion ? ` version ${inputs.composeVersion}` : ""),
|
||||||
);
|
);
|
||||||
|
|
||||||
const installedVersion = await dockerComposeInstallerService.install({
|
const installedVersion = await dockerComposeInstallerService.install({
|
||||||
|
|||||||
@ -1,64 +1,73 @@
|
|||||||
import { jest, describe, it, expect, beforeEach } from "@jest/globals";
|
import { describe, expect, it, beforeEach, vi } from "vitest";
|
||||||
|
|
||||||
// Mock @actions/core
|
// Mock @actions/core
|
||||||
const setFailedMock = jest.fn();
|
const setFailedMock = vi.fn();
|
||||||
|
|
||||||
jest.unstable_mockModule("@actions/core", () => ({
|
vi.doMock("@actions/core", () => ({
|
||||||
setFailed: setFailedMock,
|
setFailed: setFailedMock,
|
||||||
getInput: jest.fn().mockReturnValue(""),
|
getInput: vi.fn().mockReturnValue(""),
|
||||||
getMultilineInput: jest.fn().mockReturnValue([]),
|
getMultilineInput: vi.fn().mockReturnValue([]),
|
||||||
debug: jest.fn(),
|
debug: vi.fn(),
|
||||||
info: jest.fn(),
|
info: vi.fn(),
|
||||||
warning: jest.fn(),
|
warning: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock docker-compose
|
// Mock docker-compose
|
||||||
jest.unstable_mockModule("docker-compose", () => ({
|
vi.doMock("docker-compose", () => ({
|
||||||
upAll: jest.fn(),
|
upAll: vi.fn(),
|
||||||
upMany: jest.fn(),
|
upMany: vi.fn(),
|
||||||
down: jest.fn(),
|
down: vi.fn(),
|
||||||
logs: jest.fn(),
|
logs: vi.fn(),
|
||||||
version: jest
|
version: vi
|
||||||
.fn<() => Promise<{ data: { version: string } }>>()
|
.fn<() => Promise<{ data: { version: string } }>>()
|
||||||
.mockResolvedValue({ data: { version: "1.2.3" } }),
|
.mockResolvedValue({ data: { version: "1.2.3" } }),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock node:fs
|
// Mock node:fs
|
||||||
jest.unstable_mockModule("node:fs", async () => {
|
vi.doMock("node:fs", async () => {
|
||||||
const actualFs = await jest.requireActual<typeof import("node:fs")>("node:fs");
|
const actualFs = await vi.importActual<typeof import("node:fs")>("node:fs");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...actualFs,
|
...actualFs,
|
||||||
existsSync: jest.fn().mockReturnValue(true),
|
existsSync: vi.fn().mockReturnValue(true),
|
||||||
default: {
|
default: {
|
||||||
...actualFs,
|
...actualFs,
|
||||||
existsSync: jest.fn().mockReturnValue(true),
|
existsSync: vi.fn().mockReturnValue(true),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// Dynamic imports after mock setup
|
// Dynamic imports after mock setup
|
||||||
const { InputService } = await import("./services/input.service.js");
|
const { InputService } = await import("./services/input.service.js");
|
||||||
const { LoggerService, LogLevel } = await import("./services/logger.service.js");
|
const { LoggerService, LogLevel } = await import(
|
||||||
const { DockerComposeInstallerService } =
|
"./services/logger.service.js"
|
||||||
await import("./services/docker-compose-installer.service.js");
|
);
|
||||||
const { DockerComposeService } = await import("./services/docker-compose.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>;
|
let getInputsMock: ReturnType<typeof vi.spyOn>;
|
||||||
let debugMock: jest.SpiedFunction<typeof LoggerService.prototype.debug>;
|
let debugMock: ReturnType<typeof vi.spyOn>;
|
||||||
let infoMock: jest.SpiedFunction<typeof LoggerService.prototype.info>;
|
let infoMock: ReturnType<typeof vi.spyOn>;
|
||||||
let installMock: jest.SpiedFunction<typeof DockerComposeInstallerService.prototype.install>;
|
let installMock: ReturnType<typeof vi.spyOn>;
|
||||||
let upMock: jest.SpiedFunction<typeof DockerComposeService.prototype.up>;
|
let upMock: ReturnType<typeof vi.spyOn>;
|
||||||
|
|
||||||
describe("index", () => {
|
describe("index", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
|
|
||||||
infoMock = jest.spyOn(LoggerService.prototype, "info").mockImplementation(() => {});
|
infoMock = vi
|
||||||
debugMock = jest.spyOn(LoggerService.prototype, "debug").mockImplementation(() => {});
|
.spyOn(LoggerService.prototype, "info")
|
||||||
getInputsMock = jest.spyOn(InputService.prototype, "getInputs");
|
.mockImplementation(() => {});
|
||||||
installMock = jest.spyOn(DockerComposeInstallerService.prototype, "install");
|
debugMock = vi
|
||||||
upMock = jest.spyOn(DockerComposeService.prototype, "up");
|
.spyOn(LoggerService.prototype, "debug")
|
||||||
|
.mockImplementation(() => {});
|
||||||
|
getInputsMock = vi.spyOn(InputService.prototype, "getInputs");
|
||||||
|
installMock = vi.spyOn(DockerComposeInstallerService.prototype, "install");
|
||||||
|
upMock = vi.spyOn(DockerComposeService.prototype, "up");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("calls run when imported", async () => {
|
it("calls run when imported", async () => {
|
||||||
@ -82,15 +91,21 @@ describe("index", () => {
|
|||||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||||
|
|
||||||
expect(infoMock).toHaveBeenNthCalledWith(1, "Setting up docker compose");
|
expect(infoMock).toHaveBeenNthCalledWith(1, "Setting up docker compose");
|
||||||
expect(infoMock).toHaveBeenNthCalledWith(2, "docker compose version: 1.2.3");
|
expect(infoMock).toHaveBeenNthCalledWith(
|
||||||
|
2,
|
||||||
|
"docker compose version: 1.2.3",
|
||||||
|
);
|
||||||
|
|
||||||
// Verify that all of the functions were called correctly
|
// Verify that all of the functions were called correctly
|
||||||
expect(debugMock).toHaveBeenNthCalledWith(
|
expect(debugMock).toHaveBeenNthCalledWith(
|
||||||
1,
|
1,
|
||||||
'inputs: {"dockerFlags":[],"composeFiles":["docker-compose.yml"],"services":[],"composeFlags":[],"upFlags":[],"downFlags":[],"cwd":"/current/working/dir","composeVersion":null,"githubToken":null,"serviceLogLevel":"debug"}'
|
'inputs: {"dockerFlags":[],"composeFiles":["docker-compose.yml"],"services":[],"composeFlags":[],"upFlags":[],"downFlags":[],"cwd":"/current/working/dir","composeVersion":null,"githubToken":null,"serviceLogLevel":"debug"}',
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(infoMock).toHaveBeenNthCalledWith(3, "Bringing up docker compose service(s)");
|
expect(infoMock).toHaveBeenNthCalledWith(
|
||||||
|
3,
|
||||||
|
"Bringing up docker compose service(s)",
|
||||||
|
);
|
||||||
|
|
||||||
expect(upMock).toHaveBeenCalledWith({
|
expect(upMock).toHaveBeenCalledWith({
|
||||||
dockerFlags: [],
|
dockerFlags: [],
|
||||||
@ -104,6 +119,9 @@ describe("index", () => {
|
|||||||
|
|
||||||
expect(setFailedMock).not.toHaveBeenCalled();
|
expect(setFailedMock).not.toHaveBeenCalled();
|
||||||
|
|
||||||
expect(infoMock).toHaveBeenNthCalledWith(4, "docker compose service(s) are up");
|
expect(infoMock).toHaveBeenNthCalledWith(
|
||||||
|
4,
|
||||||
|
"docker compose service(s) are up",
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,55 +1,63 @@
|
|||||||
import { jest, describe, it, expect, beforeEach } from "@jest/globals";
|
import { describe, expect, it, beforeEach, vi } from "vitest";
|
||||||
|
|
||||||
// Mock @actions/core
|
// Mock @actions/core
|
||||||
const setFailedMock = jest.fn();
|
const setFailedMock = vi.fn();
|
||||||
|
|
||||||
jest.unstable_mockModule("@actions/core", () => ({
|
vi.doMock("@actions/core", () => ({
|
||||||
setFailed: setFailedMock,
|
setFailed: setFailedMock,
|
||||||
getInput: jest.fn().mockReturnValue(""),
|
getInput: vi.fn().mockReturnValue(""),
|
||||||
getMultilineInput: jest.fn().mockReturnValue([]),
|
getMultilineInput: vi.fn().mockReturnValue([]),
|
||||||
debug: jest.fn(),
|
debug: vi.fn(),
|
||||||
info: jest.fn(),
|
info: vi.fn(),
|
||||||
warning: jest.fn(),
|
warning: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock docker-compose
|
// Mock docker-compose
|
||||||
const logsMock = jest.fn();
|
const logsMock = vi.fn();
|
||||||
const downMock = jest.fn();
|
const downMock = vi.fn();
|
||||||
|
|
||||||
jest.unstable_mockModule("docker-compose", () => ({
|
vi.doMock("docker-compose", () => ({
|
||||||
logs: logsMock,
|
logs: logsMock,
|
||||||
down: downMock,
|
down: downMock,
|
||||||
upAll: jest.fn(),
|
upAll: vi.fn(),
|
||||||
upMany: jest.fn(),
|
upMany: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock node:fs
|
// Mock node:fs
|
||||||
jest.unstable_mockModule("node:fs", () => ({
|
vi.doMock("node:fs", () => ({
|
||||||
existsSync: jest.fn().mockReturnValue(true),
|
existsSync: vi.fn().mockReturnValue(true),
|
||||||
default: { existsSync: jest.fn().mockReturnValue(true) },
|
default: { existsSync: vi.fn().mockReturnValue(true) },
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Dynamic imports after mock setup
|
// Dynamic imports after mock setup
|
||||||
const { run } = await import("./post-runner.js");
|
const { run } = await import("./post-runner.js");
|
||||||
const { InputService } = await import("./services/input.service.js");
|
const { InputService } = await import("./services/input.service.js");
|
||||||
const { LoggerService, LogLevel } = await import("./services/logger.service.js");
|
const { LoggerService, LogLevel } = await import(
|
||||||
const { DockerComposeService } = await import("./services/docker-compose.service.js");
|
"./services/logger.service.js"
|
||||||
|
);
|
||||||
|
const { DockerComposeService } = await import(
|
||||||
|
"./services/docker-compose.service.js"
|
||||||
|
);
|
||||||
|
|
||||||
describe("run", () => {
|
describe("run", () => {
|
||||||
let infoMock: jest.SpiedFunction<typeof LoggerService.prototype.info>;
|
let infoMock: ReturnType<typeof vi.spyOn>;
|
||||||
let debugMock: jest.SpiedFunction<typeof LoggerService.prototype.debug>;
|
let debugMock: ReturnType<typeof vi.spyOn>;
|
||||||
let getInputsMock: jest.SpiedFunction<typeof InputService.prototype.getInputs>;
|
let getInputsMock: ReturnType<typeof vi.spyOn>;
|
||||||
let serviceDownMock: jest.SpiedFunction<typeof DockerComposeService.prototype.down>;
|
let serviceDownMock: ReturnType<typeof vi.spyOn>;
|
||||||
let serviceLogsMock: jest.SpiedFunction<typeof DockerComposeService.prototype.logs>;
|
let serviceLogsMock: ReturnType<typeof vi.spyOn>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
|
|
||||||
infoMock = jest.spyOn(LoggerService.prototype, "info").mockImplementation(() => {});
|
infoMock = vi
|
||||||
debugMock = jest.spyOn(LoggerService.prototype, "debug").mockImplementation(() => {});
|
.spyOn(LoggerService.prototype, "info")
|
||||||
getInputsMock = jest.spyOn(InputService.prototype, "getInputs");
|
.mockImplementation(() => {});
|
||||||
serviceDownMock = jest.spyOn(DockerComposeService.prototype, "down");
|
debugMock = vi
|
||||||
serviceLogsMock = jest.spyOn(DockerComposeService.prototype, "logs");
|
.spyOn(LoggerService.prototype, "debug")
|
||||||
|
.mockImplementation(() => {});
|
||||||
|
getInputsMock = vi.spyOn(InputService.prototype, "getInputs");
|
||||||
|
serviceDownMock = vi.spyOn(DockerComposeService.prototype, "down");
|
||||||
|
serviceLogsMock = vi.spyOn(DockerComposeService.prototype, "logs");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should bring down docker compose service(s) and log output", async () => {
|
it("should bring down docker compose service(s) and log output", async () => {
|
||||||
@ -123,8 +131,12 @@ describe("run", () => {
|
|||||||
await run();
|
await run();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(debugMock).toHaveBeenCalledWith("docker compose error:\ntest logs error");
|
expect(debugMock).toHaveBeenCalledWith(
|
||||||
expect(debugMock).toHaveBeenCalledWith("docker compose logs:\ntest logs output");
|
"docker compose error:\ntest logs error",
|
||||||
|
);
|
||||||
|
expect(debugMock).toHaveBeenCalledWith(
|
||||||
|
"docker compose logs:\ntest logs output",
|
||||||
|
);
|
||||||
expect(infoMock).toHaveBeenCalledWith("docker compose is down");
|
expect(infoMock).toHaveBeenCalledWith("docker compose is down");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,54 +1,62 @@
|
|||||||
import { jest, describe, it, expect, beforeEach } from "@jest/globals";
|
import { describe, expect, it, beforeEach, vi } from "vitest";
|
||||||
|
|
||||||
// Mock @actions/core
|
// Mock @actions/core
|
||||||
const setFailedMock = jest.fn();
|
const setFailedMock = vi.fn();
|
||||||
|
|
||||||
jest.unstable_mockModule("@actions/core", () => ({
|
vi.doMock("@actions/core", () => ({
|
||||||
setFailed: setFailedMock,
|
setFailed: setFailedMock,
|
||||||
getInput: jest.fn().mockReturnValue(""),
|
getInput: vi.fn().mockReturnValue(""),
|
||||||
getMultilineInput: jest.fn().mockReturnValue([]),
|
getMultilineInput: vi.fn().mockReturnValue([]),
|
||||||
debug: jest.fn(),
|
debug: vi.fn(),
|
||||||
info: jest.fn(),
|
info: vi.fn(),
|
||||||
warning: jest.fn(),
|
warning: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock docker-compose
|
// Mock docker-compose
|
||||||
const logsMock = jest.fn();
|
const logsMock = vi.fn();
|
||||||
const downMock = jest.fn();
|
const downMock = vi.fn();
|
||||||
|
|
||||||
jest.unstable_mockModule("docker-compose", () => ({
|
vi.doMock("docker-compose", () => ({
|
||||||
logs: logsMock,
|
logs: logsMock,
|
||||||
down: downMock,
|
down: downMock,
|
||||||
upAll: jest.fn(),
|
upAll: vi.fn(),
|
||||||
upMany: jest.fn(),
|
upMany: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock node:fs
|
// Mock node:fs
|
||||||
jest.unstable_mockModule("node:fs", () => ({
|
vi.doMock("node:fs", () => ({
|
||||||
existsSync: jest.fn().mockReturnValue(true),
|
existsSync: vi.fn().mockReturnValue(true),
|
||||||
default: { existsSync: jest.fn().mockReturnValue(true) },
|
default: { existsSync: vi.fn().mockReturnValue(true) },
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Dynamic imports after mock setup
|
// Dynamic imports after mock setup
|
||||||
const { InputService } = await import("./services/input.service.js");
|
const { InputService } = await import("./services/input.service.js");
|
||||||
const { LoggerService, LogLevel } = await import("./services/logger.service.js");
|
const { LoggerService, LogLevel } = await import(
|
||||||
const { DockerComposeService } = await import("./services/docker-compose.service.js");
|
"./services/logger.service.js"
|
||||||
|
);
|
||||||
|
const { DockerComposeService } = await import(
|
||||||
|
"./services/docker-compose.service.js"
|
||||||
|
);
|
||||||
|
|
||||||
let getInputsMock: jest.SpiedFunction<typeof InputService.prototype.getInputs>;
|
let getInputsMock: ReturnType<typeof vi.spyOn>;
|
||||||
let debugMock: jest.SpiedFunction<typeof LoggerService.prototype.debug>;
|
let debugMock: ReturnType<typeof vi.spyOn>;
|
||||||
let infoMock: jest.SpiedFunction<typeof LoggerService.prototype.info>;
|
let infoMock: ReturnType<typeof vi.spyOn>;
|
||||||
let serviceLogsMock: jest.SpiedFunction<typeof DockerComposeService.prototype.logs>;
|
let serviceLogsMock: ReturnType<typeof vi.spyOn>;
|
||||||
let serviceDownMock: jest.SpiedFunction<typeof DockerComposeService.prototype.down>;
|
let serviceDownMock: ReturnType<typeof vi.spyOn>;
|
||||||
|
|
||||||
describe("post", () => {
|
describe("post", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
|
|
||||||
infoMock = jest.spyOn(LoggerService.prototype, "info").mockImplementation(() => {});
|
infoMock = vi
|
||||||
debugMock = jest.spyOn(LoggerService.prototype, "debug").mockImplementation(() => {});
|
.spyOn(LoggerService.prototype, "info")
|
||||||
getInputsMock = jest.spyOn(InputService.prototype, "getInputs");
|
.mockImplementation(() => {});
|
||||||
serviceLogsMock = jest.spyOn(DockerComposeService.prototype, "logs");
|
debugMock = vi
|
||||||
serviceDownMock = jest.spyOn(DockerComposeService.prototype, "down");
|
.spyOn(LoggerService.prototype, "debug")
|
||||||
|
.mockImplementation(() => {});
|
||||||
|
getInputsMock = vi.spyOn(InputService.prototype, "getInputs");
|
||||||
|
serviceLogsMock = vi.spyOn(DockerComposeService.prototype, "logs");
|
||||||
|
serviceDownMock = vi.spyOn(DockerComposeService.prototype, "down");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("calls run when imported", async () => {
|
it("calls run when imported", async () => {
|
||||||
@ -89,7 +97,10 @@ describe("post", () => {
|
|||||||
serviceLogger: debugMock,
|
serviceLogger: debugMock,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(debugMock).toHaveBeenNthCalledWith(1, "docker compose logs:\ntest logs");
|
expect(debugMock).toHaveBeenNthCalledWith(
|
||||||
|
1,
|
||||||
|
"docker compose logs:\ntest logs",
|
||||||
|
);
|
||||||
expect(infoMock).toHaveBeenNthCalledWith(1, "docker compose is down");
|
expect(infoMock).toHaveBeenNthCalledWith(1, "docker compose is down");
|
||||||
|
|
||||||
expect(setFailedMock).not.toHaveBeenCalled();
|
expect(setFailedMock).not.toHaveBeenCalled();
|
||||||
|
|||||||
@ -1,21 +1,24 @@
|
|||||||
import { jest, describe, it, expect, beforeEach, afterEach } from "@jest/globals";
|
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
||||||
import type { IDockerComposeResult } from "docker-compose";
|
import type { IDockerComposeResult } from "docker-compose";
|
||||||
import { MockAgent, setGlobalDispatcher } from "undici";
|
import { MockAgent, setGlobalDispatcher } from "undici";
|
||||||
|
|
||||||
// Mock docker-compose before importing the module under test
|
// Mock docker-compose before importing the module under test
|
||||||
const versionMock = jest.fn<() => Promise<IDockerComposeResult & { data: { version: string } }>>();
|
const versionMock =
|
||||||
|
vi.fn<() => Promise<IDockerComposeResult & { data: { version: string } }>>();
|
||||||
|
|
||||||
jest.unstable_mockModule("docker-compose", () => ({
|
vi.doMock("docker-compose", () => ({
|
||||||
version: versionMock,
|
version: versionMock,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Create manual installer adapter mock
|
// Create manual installer adapter mock
|
||||||
const manualInstallerAdapterMock = {
|
const manualInstallerAdapterMock = {
|
||||||
install: jest.fn<(version: string) => Promise<void>>(),
|
install: vi.fn<(version: string) => Promise<void>>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Dynamic import after mock setup
|
// Dynamic import after mock setup
|
||||||
const { DockerComposeInstallerService } = await import("./docker-compose-installer.service.js");
|
const { DockerComposeInstallerService } = await import(
|
||||||
|
"./docker-compose-installer.service.js"
|
||||||
|
);
|
||||||
|
|
||||||
describe("DockerComposeInstallerService", () => {
|
describe("DockerComposeInstallerService", () => {
|
||||||
let mockAgent: MockAgent;
|
let mockAgent: MockAgent;
|
||||||
@ -30,7 +33,10 @@ describe("DockerComposeInstallerService", () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const installCompose = (composeVersion: string | null, githubToken: string | null) =>
|
const installCompose = (
|
||||||
|
composeVersion: string | null,
|
||||||
|
githubToken: string | null,
|
||||||
|
) =>
|
||||||
service.install({
|
service.install({
|
||||||
composeVersion,
|
composeVersion,
|
||||||
cwd: "/path/to/cwd",
|
cwd: "/path/to/cwd",
|
||||||
@ -59,24 +65,26 @@ describe("DockerComposeInstallerService", () => {
|
|||||||
headers: {
|
headers: {
|
||||||
"content-type": "application/json",
|
"content-type": "application/json",
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
setGlobalDispatcher(mockClient);
|
setGlobalDispatcher(mockClient);
|
||||||
Object.defineProperty(globalThis, "fetch", {
|
Object.defineProperty(globalThis, "fetch", {
|
||||||
value: jest.fn(),
|
value: vi.fn(),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
mockAgent = new MockAgent();
|
mockAgent = new MockAgent();
|
||||||
mockAgent.disableNetConnect();
|
mockAgent.disableNetConnect();
|
||||||
|
|
||||||
service = new DockerComposeInstallerService(manualInstallerAdapterMock as never);
|
service = new DockerComposeInstallerService(
|
||||||
|
manualInstallerAdapterMock as never,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.resetAllMocks();
|
vi.resetAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("install", () => {
|
describe("install", () => {
|
||||||
@ -94,7 +102,9 @@ describe("DockerComposeInstallerService", () => {
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBe(latestVersion);
|
expect(result).toBe(latestVersion);
|
||||||
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(latestVersion);
|
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(
|
||||||
|
latestVersion,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return current version when no version is provided", async () => {
|
it("should return current version when no version is provided", async () => {
|
||||||
@ -126,7 +136,9 @@ describe("DockerComposeInstallerService", () => {
|
|||||||
versionMock.mockResolvedValueOnce(composeVersionResponse("1.2.3"));
|
versionMock.mockResolvedValueOnce(composeVersionResponse("1.2.3"));
|
||||||
|
|
||||||
const expectedVersion = "1.3.0";
|
const expectedVersion = "1.3.0";
|
||||||
versionMock.mockResolvedValueOnce(composeVersionResponse(expectedVersion));
|
versionMock.mockResolvedValueOnce(
|
||||||
|
composeVersionResponse(expectedVersion),
|
||||||
|
);
|
||||||
setPlatform("linux");
|
setPlatform("linux");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@ -134,7 +146,9 @@ describe("DockerComposeInstallerService", () => {
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBe(expectedVersion);
|
expect(result).toBe(expectedVersion);
|
||||||
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(expectedVersion);
|
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(
|
||||||
|
expectedVersion,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should install the latest version if requested", async () => {
|
it("should install the latest version if requested", async () => {
|
||||||
@ -151,7 +165,9 @@ describe("DockerComposeInstallerService", () => {
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBe(latestVersion);
|
expect(result).toBe(latestVersion);
|
||||||
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(latestVersion);
|
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(
|
||||||
|
latestVersion,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should throw an error if the latest version if requested and no Github token is provided", async () => {
|
it("should throw an error if the latest version if requested and no Github token is provided", async () => {
|
||||||
@ -160,7 +176,7 @@ describe("DockerComposeInstallerService", () => {
|
|||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
await expect(installCompose("latest", null)).rejects.toThrow(
|
await expect(installCompose("latest", null)).rejects.toThrow(
|
||||||
"GitHub token is required to install the latest version"
|
"GitHub token is required to install the latest version",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -169,12 +185,14 @@ describe("DockerComposeInstallerService", () => {
|
|||||||
versionMock.mockResolvedValueOnce(composeVersionResponse("1.2.3"));
|
versionMock.mockResolvedValueOnce(composeVersionResponse("1.2.3"));
|
||||||
|
|
||||||
const expectedVersion = "1.3.0";
|
const expectedVersion = "1.3.0";
|
||||||
versionMock.mockResolvedValueOnce(composeVersionResponse(expectedVersion));
|
versionMock.mockResolvedValueOnce(
|
||||||
|
composeVersionResponse(expectedVersion),
|
||||||
|
);
|
||||||
setPlatform("win32");
|
setPlatform("win32");
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
await expect(installCompose(expectedVersion, null)).rejects.toThrow(
|
await expect(installCompose(expectedVersion, null)).rejects.toThrow(
|
||||||
`Unsupported platform: win32`
|
`Unsupported platform: win32`,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(manualInstallerAdapterMock.install).not.toHaveBeenCalled();
|
expect(manualInstallerAdapterMock.install).not.toHaveBeenCalled();
|
||||||
@ -187,7 +205,9 @@ describe("DockerComposeInstallerService", () => {
|
|||||||
const installedVersion = "2.0.0";
|
const installedVersion = "2.0.0";
|
||||||
|
|
||||||
// After installation, version() returns the new version
|
// After installation, version() returns the new version
|
||||||
versionMock.mockResolvedValueOnce(composeVersionResponse(installedVersion));
|
versionMock.mockResolvedValueOnce(
|
||||||
|
composeVersionResponse(installedVersion),
|
||||||
|
);
|
||||||
setPlatform("linux");
|
setPlatform("linux");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@ -195,7 +215,9 @@ describe("DockerComposeInstallerService", () => {
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBe(installedVersion);
|
expect(result).toBe(installedVersion);
|
||||||
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(installedVersion);
|
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(
|
||||||
|
installedVersion,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should install latest version when missing or unspecified", async () => {
|
it("should install latest version when missing or unspecified", async () => {
|
||||||
@ -214,7 +236,9 @@ describe("DockerComposeInstallerService", () => {
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBe(latestVersion);
|
expect(result).toBe(latestVersion);
|
||||||
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(latestVersion);
|
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(
|
||||||
|
latestVersion,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should throw if Compose is missing and no GitHub token is provided", async () => {
|
it("should throw if Compose is missing and no GitHub token is provided", async () => {
|
||||||
@ -223,7 +247,7 @@ describe("DockerComposeInstallerService", () => {
|
|||||||
setPlatform("linux");
|
setPlatform("linux");
|
||||||
|
|
||||||
await expect(installCompose("latest", null)).rejects.toThrow(
|
await expect(installCompose("latest", null)).rejects.toThrow(
|
||||||
"GitHub token is required to install the latest version"
|
"GitHub token is required to install the latest version",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -249,9 +273,11 @@ describe("DockerComposeInstallerService", () => {
|
|||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
await expect(installCompose(targetVersion, "token")).rejects.toThrow(
|
await expect(installCompose(targetVersion, "token")).rejects.toThrow(
|
||||||
`Failed to install Docker Compose version "${targetVersion}", installed version is "1.3.0"`
|
`Failed to install Docker Compose version "${targetVersion}", installed version is "1.3.0"`,
|
||||||
|
);
|
||||||
|
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(
|
||||||
|
targetVersion,
|
||||||
);
|
);
|
||||||
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(targetVersion);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should throw with unknown installed version when post-install version check fails", async () => {
|
it("should throw with unknown installed version when post-install version check fails", async () => {
|
||||||
@ -259,14 +285,18 @@ describe("DockerComposeInstallerService", () => {
|
|||||||
versionMock.mockResolvedValueOnce(composeVersionResponse("1.2.3"));
|
versionMock.mockResolvedValueOnce(composeVersionResponse("1.2.3"));
|
||||||
|
|
||||||
const targetVersion = "v1.4.0";
|
const targetVersion = "v1.4.0";
|
||||||
versionMock.mockRejectedValueOnce(new Error("version check failed after install"));
|
versionMock.mockRejectedValueOnce(
|
||||||
|
new Error("version check failed after install"),
|
||||||
|
);
|
||||||
setPlatform("linux");
|
setPlatform("linux");
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
await expect(installCompose(targetVersion, "token")).rejects.toThrow(
|
await expect(installCompose(targetVersion, "token")).rejects.toThrow(
|
||||||
`Failed to install Docker Compose version "${targetVersion}", installed version is "unknown"`
|
`Failed to install Docker Compose version "${targetVersion}", installed version is "unknown"`,
|
||||||
|
);
|
||||||
|
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(
|
||||||
|
targetVersion,
|
||||||
);
|
);
|
||||||
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(targetVersion);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as github from "@actions/github";
|
import * as github from "@actions/github";
|
||||||
import { version } from "docker-compose";
|
import { version } from "docker-compose";
|
||||||
import { COMPOSE_VERSION_LATEST, Inputs } from "./input.service.js";
|
import { COMPOSE_VERSION_LATEST, type Inputs } from "./input.service.js";
|
||||||
import { ManualInstallerAdapter } from "./installer-adapter/manual-installer-adapter.js";
|
import type { ManualInstallerAdapter } from "./installer-adapter/manual-installer-adapter.js";
|
||||||
|
|
||||||
export type InstallInputs = {
|
export type InstallInputs = {
|
||||||
composeVersion: Inputs["composeVersion"];
|
composeVersion: Inputs["composeVersion"];
|
||||||
@ -14,19 +14,28 @@ export type VersionInputs = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export class DockerComposeInstallerService {
|
export class DockerComposeInstallerService {
|
||||||
constructor(private readonly manualInstallerAdapter: ManualInstallerAdapter) {}
|
constructor(
|
||||||
|
private readonly manualInstallerAdapter: ManualInstallerAdapter,
|
||||||
|
) {}
|
||||||
|
|
||||||
async install({ composeVersion, cwd, githubToken }: InstallInputs): Promise<string> {
|
async install({
|
||||||
|
composeVersion,
|
||||||
|
cwd,
|
||||||
|
githubToken,
|
||||||
|
}: InstallInputs): Promise<string> {
|
||||||
const currentVersion = await this.version({ cwd });
|
const currentVersion = await this.version({ cwd });
|
||||||
|
|
||||||
const normalizedCurrentVersion = currentVersion ? this.normalizeVersion(currentVersion) : null;
|
const normalizedCurrentVersion = currentVersion
|
||||||
|
? this.normalizeVersion(currentVersion)
|
||||||
|
: null;
|
||||||
const normalizedRequestedVersion = composeVersion
|
const normalizedRequestedVersion = composeVersion
|
||||||
? this.normalizeVersion(composeVersion)
|
? this.normalizeVersion(composeVersion)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const needsInstall =
|
const needsInstall =
|
||||||
!currentVersion ||
|
!currentVersion ||
|
||||||
(composeVersion && normalizedRequestedVersion !== normalizedCurrentVersion);
|
(composeVersion &&
|
||||||
|
normalizedRequestedVersion !== normalizedCurrentVersion);
|
||||||
if (!needsInstall) {
|
if (!needsInstall) {
|
||||||
return currentVersion;
|
return currentVersion;
|
||||||
}
|
}
|
||||||
@ -35,7 +44,9 @@ export class DockerComposeInstallerService {
|
|||||||
|
|
||||||
if (targetVersion === COMPOSE_VERSION_LATEST) {
|
if (targetVersion === COMPOSE_VERSION_LATEST) {
|
||||||
if (!githubToken) {
|
if (!githubToken) {
|
||||||
throw new Error("GitHub token is required to install the latest version");
|
throw new Error(
|
||||||
|
"GitHub token is required to install the latest version",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
targetVersion = await this.getLatestVersion(githubToken);
|
targetVersion = await this.getLatestVersion(githubToken);
|
||||||
}
|
}
|
||||||
@ -46,10 +57,11 @@ export class DockerComposeInstallerService {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
!installedVersion ||
|
!installedVersion ||
|
||||||
this.normalizeVersion(installedVersion) !== this.normalizeVersion(targetVersion)
|
this.normalizeVersion(installedVersion) !==
|
||||||
|
this.normalizeVersion(targetVersion)
|
||||||
) {
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Failed to install Docker Compose version "${targetVersion}", installed version is "${installedVersion ?? "unknown"}"`
|
`Failed to install Docker Compose version "${targetVersion}", installed version is "${installedVersion ?? "unknown"}"`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { jest, describe, it, expect, beforeEach } from "@jest/globals";
|
import { describe, expect, it, beforeEach, vi } from "vitest";
|
||||||
import type {
|
import type {
|
||||||
IDockerComposeLogOptions,
|
IDockerComposeLogOptions,
|
||||||
IDockerComposeOptions,
|
IDockerComposeOptions,
|
||||||
@ -6,16 +6,26 @@ import type {
|
|||||||
} from "docker-compose";
|
} from "docker-compose";
|
||||||
|
|
||||||
// Mock docker-compose before importing the module under test
|
// Mock docker-compose before importing the module under test
|
||||||
const upAllMock = jest.fn<(options: IDockerComposeOptions) => Promise<IDockerComposeResult>>();
|
const upAllMock =
|
||||||
|
vi.fn<(options: IDockerComposeOptions) => Promise<IDockerComposeResult>>();
|
||||||
const upManyMock =
|
const upManyMock =
|
||||||
jest.fn<(services: string[], options: IDockerComposeOptions) => Promise<IDockerComposeResult>>();
|
vi.fn<
|
||||||
const downMock = jest.fn<(options: IDockerComposeOptions) => Promise<IDockerComposeResult>>();
|
(
|
||||||
|
services: string[],
|
||||||
|
options: IDockerComposeOptions,
|
||||||
|
) => Promise<IDockerComposeResult>
|
||||||
|
>();
|
||||||
|
const downMock =
|
||||||
|
vi.fn<(options: IDockerComposeOptions) => Promise<IDockerComposeResult>>();
|
||||||
const logsMock =
|
const logsMock =
|
||||||
jest.fn<
|
vi.fn<
|
||||||
(services: string[], options: IDockerComposeLogOptions) => Promise<IDockerComposeResult>
|
(
|
||||||
|
services: string[],
|
||||||
|
options: IDockerComposeLogOptions,
|
||||||
|
) => Promise<IDockerComposeResult>
|
||||||
>();
|
>();
|
||||||
|
|
||||||
jest.unstable_mockModule("docker-compose", () => ({
|
vi.doMock("docker-compose", () => ({
|
||||||
upAll: upAllMock,
|
upAll: upAllMock,
|
||||||
upMany: upManyMock,
|
upMany: upManyMock,
|
||||||
down: downMock,
|
down: downMock,
|
||||||
@ -29,7 +39,7 @@ describe("DockerComposeService", () => {
|
|||||||
let service: InstanceType<typeof DockerComposeService>;
|
let service: InstanceType<typeof DockerComposeService>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
service = new DockerComposeService();
|
service = new DockerComposeService();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -42,7 +52,7 @@ describe("DockerComposeService", () => {
|
|||||||
composeFlags: [] as string[],
|
composeFlags: [] as string[],
|
||||||
upFlags: [] as string[],
|
upFlags: [] as string[],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
serviceLogger: jest.fn(),
|
serviceLogger: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
upAllMock.mockResolvedValue({ exitCode: 0, err: "", out: "" });
|
upAllMock.mockResolvedValue({ exitCode: 0, err: "", out: "" });
|
||||||
@ -62,7 +72,8 @@ describe("DockerComposeService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Ensure callback is calling the service logger
|
// Ensure callback is calling the service logger
|
||||||
const callback = (upAllMock.mock.calls[0][0] as IDockerComposeOptions)?.callback;
|
const callback = (upAllMock.mock.calls[0][0] as IDockerComposeOptions)
|
||||||
|
?.callback;
|
||||||
expect(callback).toBeDefined();
|
expect(callback).toBeDefined();
|
||||||
|
|
||||||
const message = "test log output";
|
const message = "test log output";
|
||||||
@ -82,7 +93,7 @@ describe("DockerComposeService", () => {
|
|||||||
composeFlags: [] as string[],
|
composeFlags: [] as string[],
|
||||||
upFlags: [] as string[],
|
upFlags: [] as string[],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
serviceLogger: jest.fn(),
|
serviceLogger: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
upAllMock.mockResolvedValue({ exitCode: 0, err: "", out: "" });
|
upAllMock.mockResolvedValue({ exitCode: 0, err: "", out: "" });
|
||||||
@ -110,7 +121,7 @@ describe("DockerComposeService", () => {
|
|||||||
composeFlags: [] as string[],
|
composeFlags: [] as string[],
|
||||||
upFlags: ["--build"],
|
upFlags: ["--build"],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
serviceLogger: jest.fn(),
|
serviceLogger: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
upManyMock.mockResolvedValue({ exitCode: 0, err: "", out: "" });
|
upManyMock.mockResolvedValue({ exitCode: 0, err: "", out: "" });
|
||||||
@ -138,7 +149,7 @@ describe("DockerComposeService", () => {
|
|||||||
composeFlags: [] as string[],
|
composeFlags: [] as string[],
|
||||||
upFlags: [] as string[],
|
upFlags: [] as string[],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
serviceLogger: jest.fn(),
|
serviceLogger: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const dockerComposeError = {
|
const dockerComposeError = {
|
||||||
@ -150,9 +161,11 @@ describe("DockerComposeService", () => {
|
|||||||
upAllMock.mockRejectedValue(dockerComposeError);
|
upAllMock.mockRejectedValue(dockerComposeError);
|
||||||
|
|
||||||
await expect(service.up(upInputs)).rejects.toThrow(
|
await expect(service.up(upInputs)).rejects.toThrow(
|
||||||
"Docker Compose command failed with exit code 1"
|
"Docker Compose command failed with exit code 1",
|
||||||
|
);
|
||||||
|
await expect(service.up(upInputs)).rejects.toThrow(
|
||||||
|
"unable to pull image",
|
||||||
);
|
);
|
||||||
await expect(service.up(upInputs)).rejects.toThrow("unable to pull image");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should throw formatted error when upMany fails with docker-compose result", async () => {
|
it("should throw formatted error when upMany fails with docker-compose result", async () => {
|
||||||
@ -163,7 +176,7 @@ describe("DockerComposeService", () => {
|
|||||||
composeFlags: [] as string[],
|
composeFlags: [] as string[],
|
||||||
upFlags: [] as string[],
|
upFlags: [] as string[],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
serviceLogger: jest.fn(),
|
serviceLogger: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const dockerComposeError = {
|
const dockerComposeError = {
|
||||||
@ -175,9 +188,11 @@ describe("DockerComposeService", () => {
|
|||||||
upManyMock.mockRejectedValue(dockerComposeError);
|
upManyMock.mockRejectedValue(dockerComposeError);
|
||||||
|
|
||||||
await expect(service.up(upInputs)).rejects.toThrow(
|
await expect(service.up(upInputs)).rejects.toThrow(
|
||||||
"Docker Compose command failed with exit code 1"
|
"Docker Compose command failed with exit code 1",
|
||||||
|
);
|
||||||
|
await expect(service.up(upInputs)).rejects.toThrow(
|
||||||
|
"Service 'web' failed to start",
|
||||||
);
|
);
|
||||||
await expect(service.up(upInputs)).rejects.toThrow("Service 'web' failed to start");
|
|
||||||
await expect(service.up(upInputs)).rejects.toThrow("Starting web...");
|
await expect(service.up(upInputs)).rejects.toThrow("Starting web...");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -189,7 +204,7 @@ describe("DockerComposeService", () => {
|
|||||||
composeFlags: [] as string[],
|
composeFlags: [] as string[],
|
||||||
upFlags: [] as string[],
|
upFlags: [] as string[],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
serviceLogger: jest.fn(),
|
serviceLogger: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const dockerComposeError = {
|
const dockerComposeError = {
|
||||||
@ -200,7 +215,37 @@ describe("DockerComposeService", () => {
|
|||||||
|
|
||||||
upAllMock.mockRejectedValue(dockerComposeError);
|
upAllMock.mockRejectedValue(dockerComposeError);
|
||||||
|
|
||||||
await expect(service.up(upInputs)).rejects.toThrow("Some error without exit code");
|
await expect(service.up(upInputs)).rejects.toThrow(
|
||||||
|
"Some error without exit code",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should format docker-compose result when streams are undefined", async () => {
|
||||||
|
const upInputs = {
|
||||||
|
dockerFlags: [] as string[],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: [] as string[],
|
||||||
|
composeFlags: [] as string[],
|
||||||
|
upFlags: [] as string[],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
serviceLogger: vi.fn(),
|
||||||
|
};
|
||||||
|
|
||||||
|
const dockerComposeError = {
|
||||||
|
exitCode: 1,
|
||||||
|
err: undefined,
|
||||||
|
out: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
upAllMock.mockRejectedValue(dockerComposeError);
|
||||||
|
|
||||||
|
await expect(service.up(upInputs)).rejects.toThrow(
|
||||||
|
"Docker Compose command failed with exit code 1",
|
||||||
|
);
|
||||||
|
await expect(service.up(upInputs)).rejects.not.toThrow("Error output:");
|
||||||
|
await expect(service.up(upInputs)).rejects.not.toThrow(
|
||||||
|
"Standard output:",
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should pass through standard Error objects", async () => {
|
it("should pass through standard Error objects", async () => {
|
||||||
@ -211,13 +256,15 @@ describe("DockerComposeService", () => {
|
|||||||
composeFlags: [] as string[],
|
composeFlags: [] as string[],
|
||||||
upFlags: [] as string[],
|
upFlags: [] as string[],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
serviceLogger: jest.fn(),
|
serviceLogger: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const standardError = new Error("Standard error message");
|
const standardError = new Error("Standard error message");
|
||||||
upAllMock.mockRejectedValue(standardError);
|
upAllMock.mockRejectedValue(standardError);
|
||||||
|
|
||||||
await expect(service.up(upInputs)).rejects.toThrow("Standard error message");
|
await expect(service.up(upInputs)).rejects.toThrow(
|
||||||
|
"Standard error message",
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should pass through error strings", async () => {
|
it("should pass through error strings", async () => {
|
||||||
@ -228,7 +275,7 @@ describe("DockerComposeService", () => {
|
|||||||
composeFlags: [] as string[],
|
composeFlags: [] as string[],
|
||||||
upFlags: [] as string[],
|
upFlags: [] as string[],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
serviceLogger: jest.fn(),
|
serviceLogger: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const unknownError = "Some unknown error";
|
const unknownError = "Some unknown error";
|
||||||
@ -245,13 +292,15 @@ describe("DockerComposeService", () => {
|
|||||||
composeFlags: [] as string[],
|
composeFlags: [] as string[],
|
||||||
upFlags: [] as string[],
|
upFlags: [] as string[],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
serviceLogger: jest.fn(),
|
serviceLogger: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const unknownError = { unexpected: "error format" };
|
const unknownError = { unexpected: "error format" };
|
||||||
upAllMock.mockRejectedValue(unknownError);
|
upAllMock.mockRejectedValue(unknownError);
|
||||||
|
|
||||||
await expect(service.up(upInputs)).rejects.toThrow(JSON.stringify(unknownError));
|
await expect(service.up(upInputs)).rejects.toThrow(
|
||||||
|
JSON.stringify(unknownError),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -263,7 +312,7 @@ describe("DockerComposeService", () => {
|
|||||||
composeFlags: [] as string[],
|
composeFlags: [] as string[],
|
||||||
downFlags: ["--volumes", "--remove-orphans"],
|
downFlags: ["--volumes", "--remove-orphans"],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
serviceLogger: jest.fn(),
|
serviceLogger: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
downMock.mockResolvedValue({ exitCode: 0, err: "", out: "" });
|
downMock.mockResolvedValue({ exitCode: 0, err: "", out: "" });
|
||||||
@ -290,7 +339,7 @@ describe("DockerComposeService", () => {
|
|||||||
composeFlags: [] as string[],
|
composeFlags: [] as string[],
|
||||||
downFlags: [] as string[],
|
downFlags: [] as string[],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
serviceLogger: jest.fn(),
|
serviceLogger: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const dockerComposeError = {
|
const dockerComposeError = {
|
||||||
@ -302,15 +351,17 @@ describe("DockerComposeService", () => {
|
|||||||
downMock.mockRejectedValue(dockerComposeError);
|
downMock.mockRejectedValue(dockerComposeError);
|
||||||
|
|
||||||
await expect(service.down(downInputs)).rejects.toThrow(
|
await expect(service.down(downInputs)).rejects.toThrow(
|
||||||
"Docker Compose command failed with exit code 1"
|
"Docker Compose command failed with exit code 1",
|
||||||
|
);
|
||||||
|
await expect(service.down(downInputs)).rejects.toThrow(
|
||||||
|
"Error stopping containers",
|
||||||
);
|
);
|
||||||
await expect(service.down(downInputs)).rejects.toThrow("Error stopping containers");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("logs", () => {
|
describe("logs", () => {
|
||||||
it("should call logs with correct options", async () => {
|
it("should call logs with correct options", async () => {
|
||||||
const debugMock = jest.fn();
|
const debugMock = vi.fn();
|
||||||
const logsInputs = {
|
const logsInputs = {
|
||||||
dockerFlags: [] as string[],
|
dockerFlags: [] as string[],
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import {
|
import {
|
||||||
down,
|
down,
|
||||||
IDockerComposeLogOptions,
|
type IDockerComposeLogOptions,
|
||||||
IDockerComposeOptions,
|
type IDockerComposeOptions,
|
||||||
IDockerComposeResult,
|
type IDockerComposeResult,
|
||||||
logs,
|
logs,
|
||||||
upAll,
|
upAll,
|
||||||
upMany,
|
upMany,
|
||||||
} from "docker-compose";
|
} from "docker-compose";
|
||||||
import { Inputs } from "./input.service.js";
|
import type { Inputs } from "./input.service.js";
|
||||||
|
|
||||||
type OptionsInputs = {
|
type OptionsInputs = {
|
||||||
dockerFlags: Inputs["dockerFlags"];
|
dockerFlags: Inputs["dockerFlags"];
|
||||||
@ -17,7 +17,10 @@ type OptionsInputs = {
|
|||||||
serviceLogger: (message: string) => void;
|
serviceLogger: (message: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpInputs = OptionsInputs & { upFlags: Inputs["upFlags"]; services: Inputs["services"] };
|
export type UpInputs = OptionsInputs & {
|
||||||
|
upFlags: Inputs["upFlags"];
|
||||||
|
services: Inputs["services"];
|
||||||
|
};
|
||||||
export type DownInputs = OptionsInputs & { downFlags: Inputs["downFlags"] };
|
export type DownInputs = OptionsInputs & { downFlags: Inputs["downFlags"] };
|
||||||
export type LogsInputs = OptionsInputs & { services: Inputs["services"] };
|
export type LogsInputs = OptionsInputs & { services: Inputs["services"] };
|
||||||
|
|
||||||
@ -104,19 +107,21 @@ export class DockerComposeService {
|
|||||||
|
|
||||||
// Add exit code information
|
// Add exit code information
|
||||||
if (error.exitCode !== null) {
|
if (error.exitCode !== null) {
|
||||||
parts.push(`Docker Compose command failed with exit code ${error.exitCode}`);
|
parts.push(
|
||||||
|
`Docker Compose command failed with exit code ${error.exitCode}`,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
parts.push("Docker Compose command failed");
|
parts.push("Docker Compose command failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add error stream output if available
|
// Add error stream output if available
|
||||||
if (error.err && error.err.trim()) {
|
if (error.err?.trim()) {
|
||||||
parts.push("\nError output:");
|
parts.push("\nError output:");
|
||||||
parts.push(error.err.trim());
|
parts.push(error.err.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add standard output if available and different from error output
|
// Add standard output if available and different from error output
|
||||||
if (error.out && error.out.trim() && error.out !== error.err) {
|
if (error.out?.trim() && error.out !== error.err) {
|
||||||
parts.push("\nStandard output:");
|
parts.push("\nStandard output:");
|
||||||
parts.push(error.out.trim());
|
parts.push(error.out.trim());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,22 +1,23 @@
|
|||||||
import { jest, describe, it, expect, beforeEach } from "@jest/globals";
|
import { describe, expect, it, beforeEach, vi } from "vitest";
|
||||||
|
|
||||||
// Mock @actions/core before importing the module under test
|
// Mock @actions/core before importing the module under test
|
||||||
const getInputMock = jest.fn<(name: string, options?: { required?: boolean }) => string>();
|
const getInputMock =
|
||||||
|
vi.fn<(name: string, options?: { required?: boolean }) => string>();
|
||||||
const getMultilineInputMock =
|
const getMultilineInputMock =
|
||||||
jest.fn<(name: string, options?: { required?: boolean }) => string[]>();
|
vi.fn<(name: string, options?: { required?: boolean }) => string[]>();
|
||||||
|
|
||||||
jest.unstable_mockModule("@actions/core", () => ({
|
vi.doMock("@actions/core", () => ({
|
||||||
getInput: getInputMock,
|
getInput: getInputMock,
|
||||||
getMultilineInput: getMultilineInputMock,
|
getMultilineInput: getMultilineInputMock,
|
||||||
debug: jest.fn(),
|
debug: vi.fn(),
|
||||||
info: jest.fn(),
|
info: vi.fn(),
|
||||||
warning: jest.fn(),
|
warning: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock node:fs
|
// Mock node:fs
|
||||||
const existsSyncMock = jest.fn<(path: string) => boolean>();
|
const existsSyncMock = vi.fn<(path: string) => boolean>();
|
||||||
|
|
||||||
jest.unstable_mockModule("node:fs", () => ({
|
vi.doMock("node:fs", () => ({
|
||||||
existsSync: existsSyncMock,
|
existsSync: existsSyncMock,
|
||||||
default: { existsSync: existsSyncMock },
|
default: { existsSync: existsSyncMock },
|
||||||
}));
|
}));
|
||||||
@ -29,7 +30,7 @@ describe("InputService", () => {
|
|||||||
let service: InstanceType<typeof InputService>;
|
let service: InstanceType<typeof InputService>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
|
|
||||||
getMultilineInputMock.mockImplementation((inputName) => {
|
getMultilineInputMock.mockImplementation((inputName) => {
|
||||||
switch (inputName) {
|
switch (inputName) {
|
||||||
@ -160,7 +161,9 @@ describe("InputService", () => {
|
|||||||
|
|
||||||
const inputs = service.getInputs();
|
const inputs = service.getInputs();
|
||||||
|
|
||||||
expect(inputs.composeFiles).toEqual(["oci://docker.io/hoverkraft/compose-app:latest"]);
|
expect(inputs.composeFiles).toEqual([
|
||||||
|
"oci://docker.io/hoverkraft/compose-app:latest",
|
||||||
|
]);
|
||||||
expect(existsSyncMock).not.toHaveBeenCalled();
|
expect(existsSyncMock).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -183,10 +186,12 @@ describe("InputService", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
existsSyncMock.mockImplementation((file) => file === "/current/working/directory/file1");
|
existsSyncMock.mockImplementation(
|
||||||
|
(file) => file === "/current/working/directory/file1",
|
||||||
|
);
|
||||||
|
|
||||||
expect(() => service.getInputs()).toThrow(
|
expect(() => service.getInputs()).toThrow(
|
||||||
'Compose file not found in "/current/working/directory/file2", "file2"'
|
'Compose file not found in "/current/working/directory/file2", "file2"',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -386,7 +391,7 @@ describe("InputService", () => {
|
|||||||
existsSyncMock.mockReturnValue(true);
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
expect(() => service.getInputs()).toThrow(
|
expect(() => service.getInputs()).toThrow(
|
||||||
'Invalid service log level "invalid-log-level". Valid values are: debug, info'
|
'Invalid service log level "invalid-log-level". Valid values are: debug, info',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -53,7 +53,8 @@ export class InputService {
|
|||||||
|
|
||||||
private getComposeFiles(): string[] {
|
private getComposeFiles(): string[] {
|
||||||
const cwd = this.getCwd();
|
const cwd = this.getCwd();
|
||||||
const composeFiles = getMultilineInput(InputNames.ComposeFile).filter((composeFile: string) => {
|
const composeFiles = getMultilineInput(InputNames.ComposeFile).filter(
|
||||||
|
(composeFile: string) => {
|
||||||
const trimmedComposeFile = composeFile.trim();
|
const trimmedComposeFile = composeFile.trim();
|
||||||
|
|
||||||
if (!trimmedComposeFile.length) {
|
if (!trimmedComposeFile.length) {
|
||||||
@ -72,8 +73,11 @@ export class InputService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Compose file not found in "${possiblePaths.join('", "')}"`);
|
throw new Error(
|
||||||
});
|
`Compose file not found in "${possiblePaths.join('", "')}"`,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
if (!composeFiles.length) {
|
if (!composeFiles.length) {
|
||||||
throw new Error("No compose files found");
|
throw new Error("No compose files found");
|
||||||
@ -127,10 +131,15 @@ export class InputService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getServiceLogLevel(): LogLevel {
|
private getServiceLogLevel(): LogLevel {
|
||||||
const configuredLevel = getInput(InputNames.ServiceLogLevel, { required: false });
|
const configuredLevel = getInput(InputNames.ServiceLogLevel, {
|
||||||
if (configuredLevel && !Object.values(LogLevel).includes(configuredLevel as LogLevel)) {
|
required: false,
|
||||||
|
});
|
||||||
|
if (
|
||||||
|
configuredLevel &&
|
||||||
|
!Object.values(LogLevel).includes(configuredLevel as LogLevel)
|
||||||
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Invalid service log level "${configuredLevel}". Valid values are: ${Object.values(LogLevel).join(", ")}`
|
`Invalid service log level "${configuredLevel}". Valid values are: ${Object.values(LogLevel).join(", ")}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return (configuredLevel as LogLevel) || LogLevel.Debug;
|
return (configuredLevel as LogLevel) || LogLevel.Debug;
|
||||||
|
|||||||
@ -1,52 +1,73 @@
|
|||||||
import { jest, describe, it, expect, beforeEach } from "@jest/globals";
|
import { describe, expect, it, beforeEach, vi } from "vitest";
|
||||||
import type { ExecOptions } from "@actions/exec";
|
import type { ExecOptions } from "@actions/exec";
|
||||||
import type { OutgoingHttpHeaders } from "node:http";
|
import type { OutgoingHttpHeaders } from "node:http";
|
||||||
|
|
||||||
// Mock @actions/exec
|
// Mock @actions/exec
|
||||||
const execMock =
|
const execMock =
|
||||||
jest.fn<(command: string, args?: string[], options?: ExecOptions) => Promise<number>>();
|
vi.fn<
|
||||||
|
(command: string, args?: string[], options?: ExecOptions) => Promise<number>
|
||||||
|
>();
|
||||||
|
|
||||||
jest.unstable_mockModule("@actions/exec", () => ({
|
vi.doMock("@actions/exec", () => ({
|
||||||
exec: execMock,
|
exec: execMock,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock @actions/io
|
// Mock @actions/io
|
||||||
const mkdirPMock = jest.fn<(fsPath: string) => Promise<void>>();
|
const mkdirPMock = vi.fn<(fsPath: string) => Promise<void>>();
|
||||||
|
|
||||||
jest.unstable_mockModule("@actions/io", () => ({
|
vi.doMock("@actions/io", () => ({
|
||||||
mkdirP: mkdirPMock,
|
mkdirP: mkdirPMock,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock @actions/tool-cache
|
// Mock @actions/tool-cache
|
||||||
const cacheFileMock =
|
const cacheFileMock =
|
||||||
jest.fn<
|
vi.fn<
|
||||||
(
|
(
|
||||||
sourceFile: string,
|
sourceFile: string,
|
||||||
targetFile: string,
|
targetFile: string,
|
||||||
tool: string,
|
tool: string,
|
||||||
version: string,
|
version: string,
|
||||||
arch?: string
|
arch?: string,
|
||||||
) => Promise<string>
|
) => Promise<string>
|
||||||
>();
|
>();
|
||||||
const downloadToolMock =
|
const downloadToolMock =
|
||||||
jest.fn<
|
vi.fn<
|
||||||
(url: string, dest?: string, auth?: string, headers?: OutgoingHttpHeaders) => Promise<string>
|
(
|
||||||
|
url: string,
|
||||||
|
dest?: string,
|
||||||
|
auth?: string,
|
||||||
|
headers?: OutgoingHttpHeaders,
|
||||||
|
) => Promise<string>
|
||||||
>();
|
>();
|
||||||
|
|
||||||
jest.unstable_mockModule("@actions/tool-cache", () => ({
|
vi.doMock("@actions/tool-cache", () => ({
|
||||||
cacheFile: cacheFileMock,
|
cacheFile: cacheFileMock,
|
||||||
downloadTool: downloadToolMock,
|
downloadTool: downloadToolMock,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Dynamic import after mock setup
|
// Dynamic import after mock setup
|
||||||
const { ManualInstallerAdapter } = await import("./manual-installer-adapter.js");
|
const { ManualInstallerAdapter } = await import(
|
||||||
|
"./manual-installer-adapter.js"
|
||||||
|
);
|
||||||
|
|
||||||
|
const originalHome = process.env.HOME;
|
||||||
|
const originalDockerConfig = process.env.DOCKER_CONFIG;
|
||||||
|
|
||||||
describe("ManualInstallerAdapter", () => {
|
describe("ManualInstallerAdapter", () => {
|
||||||
let adapter: InstanceType<typeof ManualInstallerAdapter>;
|
let adapter: InstanceType<typeof ManualInstallerAdapter>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
vi.resetAllMocks();
|
||||||
|
if (originalHome === undefined) {
|
||||||
|
delete process.env.HOME;
|
||||||
|
} else {
|
||||||
|
process.env.HOME = originalHome;
|
||||||
|
}
|
||||||
|
if (originalDockerConfig === undefined) {
|
||||||
delete process.env.DOCKER_CONFIG;
|
delete process.env.DOCKER_CONFIG;
|
||||||
|
} else {
|
||||||
|
process.env.DOCKER_CONFIG = originalDockerConfig;
|
||||||
|
}
|
||||||
adapter = new ManualInstallerAdapter();
|
adapter = new ManualInstallerAdapter();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -55,16 +76,18 @@ describe("ManualInstallerAdapter", () => {
|
|||||||
// Arrange
|
// Arrange
|
||||||
const version = "v2.29.0";
|
const version = "v2.29.0";
|
||||||
|
|
||||||
// Uname -s
|
execMock.mockImplementationOnce(async (_command, _args, options) => {
|
||||||
execMock.mockResolvedValueOnce(0);
|
options?.listeners?.stdout?.(Buffer.from("Linux\n"));
|
||||||
|
return 0;
|
||||||
// Uname -m
|
|
||||||
execMock.mockResolvedValueOnce(0);
|
|
||||||
|
|
||||||
Object.defineProperty(process.env, "HOME", {
|
|
||||||
value: "/home/test",
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
execMock.mockImplementationOnce(async (_command, _args, options) => {
|
||||||
|
options?.listeners?.stdout?.(Buffer.from("x86_64\n"));
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
process.env.HOME = "/home/test";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await adapter.install(version);
|
await adapter.install(version);
|
||||||
|
|
||||||
@ -78,15 +101,15 @@ describe("ManualInstallerAdapter", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(downloadToolMock).toHaveBeenCalledWith(
|
expect(downloadToolMock).toHaveBeenCalledWith(
|
||||||
"https://github.com/docker/compose/releases/download/v2.29.0/docker-compose--",
|
"https://github.com/docker/compose/releases/download/v2.29.0/docker-compose-Linux-x86_64",
|
||||||
"/home/test/.docker/cli-plugins/docker-compose"
|
"/home/test/.docker/cli-plugins/docker-compose",
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(cacheFileMock).toHaveBeenCalledWith(
|
expect(cacheFileMock).toHaveBeenCalledWith(
|
||||||
"/home/test/.docker/cli-plugins/docker-compose",
|
"/home/test/.docker/cli-plugins/docker-compose",
|
||||||
"docker-compose",
|
"docker-compose",
|
||||||
"docker-compose",
|
"docker-compose",
|
||||||
version
|
version,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -112,7 +135,7 @@ describe("ManualInstallerAdapter", () => {
|
|||||||
// Assert
|
// Assert
|
||||||
expect(downloadToolMock).toHaveBeenCalledWith(
|
expect(downloadToolMock).toHaveBeenCalledWith(
|
||||||
"https://github.com/docker/compose/releases/download/v2.29.0/docker-compose-Linux-x86_64",
|
"https://github.com/docker/compose/releases/download/v2.29.0/docker-compose-Linux-x86_64",
|
||||||
"/custom/docker/cli-plugins/docker-compose"
|
"/custom/docker/cli-plugins/docker-compose",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -120,16 +143,18 @@ describe("ManualInstallerAdapter", () => {
|
|||||||
// Arrange
|
// Arrange
|
||||||
const version = "2.29.0";
|
const version = "2.29.0";
|
||||||
|
|
||||||
// Uname -s
|
execMock.mockImplementationOnce(async (_command, _args, options) => {
|
||||||
execMock.mockResolvedValueOnce(0);
|
options?.listeners?.stdout?.(Buffer.from("Linux\n"));
|
||||||
|
return 0;
|
||||||
// Uname -m
|
|
||||||
execMock.mockResolvedValueOnce(0);
|
|
||||||
|
|
||||||
Object.defineProperty(process.env, "HOME", {
|
|
||||||
value: "/home/test",
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
execMock.mockImplementationOnce(async (_command, _args, options) => {
|
||||||
|
options?.listeners?.stdout?.(Buffer.from("x86_64\n"));
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
process.env.HOME = "/home/test";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await adapter.install(version);
|
await adapter.install(version);
|
||||||
|
|
||||||
@ -143,8 +168,8 @@ describe("ManualInstallerAdapter", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(downloadToolMock).toHaveBeenCalledWith(
|
expect(downloadToolMock).toHaveBeenCalledWith(
|
||||||
"https://github.com/docker/compose/releases/download/v2.29.0/docker-compose--",
|
"https://github.com/docker/compose/releases/download/v2.29.0/docker-compose-Linux-x86_64",
|
||||||
"/home/test/.docker/cli-plugins/docker-compose"
|
"/home/test/.docker/cli-plugins/docker-compose",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -163,9 +188,7 @@ describe("ManualInstallerAdapter", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
delete process.env.DOCKER_CONFIG;
|
delete process.env.DOCKER_CONFIG;
|
||||||
Object.defineProperty(process.env, "HOME", {
|
process.env.HOME = "/home/test";
|
||||||
value: "/home/test",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await adapter.install(version);
|
await adapter.install(version);
|
||||||
@ -173,7 +196,7 @@ describe("ManualInstallerAdapter", () => {
|
|||||||
// Assert
|
// Assert
|
||||||
expect(downloadToolMock).toHaveBeenCalledWith(
|
expect(downloadToolMock).toHaveBeenCalledWith(
|
||||||
"https://github.com/docker/compose/releases/download/1.29.0/docker-compose-Linux-x86_64",
|
"https://github.com/docker/compose/releases/download/1.29.0/docker-compose-Linux-x86_64",
|
||||||
"/home/test/.docker/cli-plugins/docker-compose"
|
"/home/test/.docker/cli-plugins/docker-compose",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -185,7 +208,9 @@ describe("ManualInstallerAdapter", () => {
|
|||||||
execMock.mockResolvedValueOnce(1);
|
execMock.mockResolvedValueOnce(1);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await expect(adapter.install(version)).rejects.toThrow("Failed to run command: uname -s");
|
await expect(adapter.install(version)).rejects.toThrow(
|
||||||
|
"Failed to run command: uname -s",
|
||||||
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(execMock).toHaveBeenNthCalledWith(1, "uname -s", [], {
|
expect(execMock).toHaveBeenNthCalledWith(1, "uname -s", [], {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { exec } from "@actions/exec";
|
|||||||
import { mkdirP } from "@actions/io";
|
import { mkdirP } from "@actions/io";
|
||||||
import { basename } from "node:path";
|
import { basename } from "node:path";
|
||||||
import { cacheFile, downloadTool } from "@actions/tool-cache";
|
import { cacheFile, downloadTool } from "@actions/tool-cache";
|
||||||
import { DockerComposeInstallerAdapter } from "./docker-compose-installer-adapter.js";
|
import type { DockerComposeInstallerAdapter } from "./docker-compose-installer-adapter.js";
|
||||||
|
|
||||||
export class ManualInstallerAdapter implements DockerComposeInstallerAdapter {
|
export class ManualInstallerAdapter implements DockerComposeInstallerAdapter {
|
||||||
async install(version: string): Promise<void> {
|
async install(version: string): Promise<void> {
|
||||||
@ -13,17 +13,26 @@ export class ManualInstallerAdapter implements DockerComposeInstallerAdapter {
|
|||||||
|
|
||||||
await this.downloadFile(version, dockerComposePluginPath);
|
await this.downloadFile(version, dockerComposePluginPath);
|
||||||
await exec(`chmod +x ${dockerComposePluginPath}`);
|
await exec(`chmod +x ${dockerComposePluginPath}`);
|
||||||
await cacheFile(dockerComposePluginPath, "docker-compose", "docker-compose", version);
|
await cacheFile(
|
||||||
|
dockerComposePluginPath,
|
||||||
|
"docker-compose",
|
||||||
|
"docker-compose",
|
||||||
|
version,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getDockerComposePluginPath(): Promise<string> {
|
private async getDockerComposePluginPath(): Promise<string> {
|
||||||
const dockerConfig = process.env.DOCKER_CONFIG || `${process.env.HOME}/.docker`;
|
const dockerConfig =
|
||||||
|
process.env.DOCKER_CONFIG || `${process.env.HOME}/.docker`;
|
||||||
|
|
||||||
const dockerComposePluginPath = `${dockerConfig}/cli-plugins/docker-compose`;
|
const dockerComposePluginPath = `${dockerConfig}/cli-plugins/docker-compose`;
|
||||||
return dockerComposePluginPath;
|
return dockerComposePluginPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async downloadFile(version: string, installerPath: string): Promise<void> {
|
private async downloadFile(
|
||||||
|
version: string,
|
||||||
|
installerPath: string,
|
||||||
|
): Promise<void> {
|
||||||
if (!version.startsWith("v") && parseInt(version.split(".")[0], 10) >= 2) {
|
if (!version.startsWith("v") && parseInt(version.split(".")[0], 10) >= 2) {
|
||||||
version = `v${version}`;
|
version = `v${version}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
import { jest, describe, it, expect, beforeEach } from "@jest/globals";
|
import { describe, expect, it, beforeEach, vi } from "vitest";
|
||||||
|
|
||||||
// Import types directly from the module
|
// Import types directly from the module
|
||||||
import type { LogLevel as LogLevelType } from "./logger.service.js";
|
import type { LogLevel as LogLevelType } from "./logger.service.js";
|
||||||
|
|
||||||
// Mock @actions/core before importing the module under test
|
// Mock @actions/core before importing the module under test
|
||||||
const warningMock = jest.fn();
|
const warningMock = vi.fn();
|
||||||
const infoMock = jest.fn();
|
const infoMock = vi.fn();
|
||||||
const debugMock = jest.fn();
|
const debugMock = vi.fn();
|
||||||
|
|
||||||
jest.unstable_mockModule("@actions/core", () => ({
|
vi.doMock("@actions/core", () => ({
|
||||||
warning: warningMock,
|
warning: warningMock,
|
||||||
info: infoMock,
|
info: infoMock,
|
||||||
debug: debugMock,
|
debug: debugMock,
|
||||||
@ -21,7 +21,7 @@ describe("LoggerService", () => {
|
|||||||
let loggerService: InstanceType<typeof LoggerService>;
|
let loggerService: InstanceType<typeof LoggerService>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
loggerService = new LoggerService();
|
loggerService = new LoggerService();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,8 @@ WORKDIR /app
|
|||||||
COPY entrypoint.sh .
|
COPY entrypoint.sh .
|
||||||
RUN chmod +x entrypoint.sh
|
RUN chmod +x entrypoint.sh
|
||||||
|
|
||||||
|
HEALTHCHECK CMD grep -qa "entrypoint.sh" /proc/1/cmdline || exit 1
|
||||||
|
|
||||||
CMD ["/bin/sh", "entrypoint.sh"]
|
CMD ["/bin/sh", "entrypoint.sh"]
|
||||||
|
|
||||||
USER 1000:1000
|
USER 1000:1000
|
||||||
|
|||||||
12
vitest.config.ts
Normal file
12
vitest.config.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { defineConfig } from "vitest/config";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
coverage: {
|
||||||
|
include: ["src/**/*.{ts,tsx,js,jsx}"],
|
||||||
|
provider: "v8",
|
||||||
|
},
|
||||||
|
environment: "node",
|
||||||
|
globals: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user