first commit
This commit is contained in:
42
.devcontainer/devcontainer.json
Normal file
42
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"name": "GitHub Actions (TypeScript)",
|
||||||
|
"image": "mcr.microsoft.com/devcontainers/typescript-node:20",
|
||||||
|
"postCreateCommand": "npm install",
|
||||||
|
"customizations": {
|
||||||
|
"codespaces": {
|
||||||
|
"openFiles": ["README.md"]
|
||||||
|
},
|
||||||
|
"vscode": {
|
||||||
|
"extensions": [
|
||||||
|
"bierner.markdown-preview-github-styles",
|
||||||
|
"davidanson.vscode-markdownlint",
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"esbenp.prettier-vscode",
|
||||||
|
"github.copilot",
|
||||||
|
"github.copilot-chat",
|
||||||
|
"github.vscode-github-actions",
|
||||||
|
"github.vscode-pull-request-github",
|
||||||
|
"me-dutour-mathieu.vscode-github-actions",
|
||||||
|
"redhat.vscode-yaml",
|
||||||
|
"rvest.vs-code-prettier-eslint",
|
||||||
|
"yzhang.markdown-all-in-one"
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
|
"editor.tabSize": 2,
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"markdown.extension.list.indentationSize": "adaptive",
|
||||||
|
"markdown.extension.italic.indicator": "_",
|
||||||
|
"markdown.extension.orderedList.marker": "one"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"remoteEnv": {
|
||||||
|
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}"
|
||||||
|
},
|
||||||
|
"features": {
|
||||||
|
"ghcr.io/devcontainers/features/github-cli:1": {},
|
||||||
|
"ghcr.io/devcontainers-community/npm-features/prettier:1": {},
|
||||||
|
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
.ghadocs.json
Normal file
17
.ghadocs.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"paths": {
|
||||||
|
"action": "action.yml",
|
||||||
|
"readme": "README.md"
|
||||||
|
},
|
||||||
|
"show_logo": true,
|
||||||
|
"versioning": {
|
||||||
|
"enabled": true,
|
||||||
|
"override": "",
|
||||||
|
"prefix": "v",
|
||||||
|
"branch": "main"
|
||||||
|
},
|
||||||
|
"owner": "hoverkraft-tech",
|
||||||
|
"repo": "compose-action",
|
||||||
|
"title_prefix": "GitHub Action: ",
|
||||||
|
"prettier": true
|
||||||
|
}
|
||||||
3
.gitattributes
vendored
Normal file
3
.gitattributes
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
* text=auto eol=lf
|
||||||
|
|
||||||
|
dist/** -diff linguist-generated=true
|
||||||
37
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
37
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a bug report
|
||||||
|
title: ""
|
||||||
|
labels: bug, needs triage
|
||||||
|
assignees: ""
|
||||||
|
---
|
||||||
|
|
||||||
|
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
|
||||||
|
<!--- Before opening up a new bug report, please make sure to check for similar existing issues -->
|
||||||
|
|
||||||
|
**Description:** A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**Action version:** Specify the action version
|
||||||
|
|
||||||
|
**Platform:**
|
||||||
|
|
||||||
|
- [ ] Ubuntu
|
||||||
|
- [ ] macOS
|
||||||
|
- [ ] Windows
|
||||||
|
|
||||||
|
**Runner type:**
|
||||||
|
|
||||||
|
- [ ] Hosted
|
||||||
|
- [ ] Self-hosted
|
||||||
|
|
||||||
|
**Tools version:**
|
||||||
|
|
||||||
|
<!--- Please specify versions of node and package manager (npm, yarn, pnpm and etc)-->
|
||||||
|
|
||||||
|
**Repro steps:**
|
||||||
|
A description with steps to reproduce the issue. If you have a public example or
|
||||||
|
repository to share, please provide the link.
|
||||||
|
|
||||||
|
**Expected behavior:** A description of what you expected to happen.
|
||||||
|
|
||||||
|
**Actual behavior:** A description of what is actually happening.
|
||||||
19
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
19
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ""
|
||||||
|
labels: ""
|
||||||
|
assignees: ""
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.** A clear and
|
||||||
|
concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like** A clear and concise description of what you
|
||||||
|
want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered** A clear and concise description of
|
||||||
|
any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context** Add any other context or screenshots about the feature
|
||||||
|
request here.
|
||||||
66
.github/dependabot.yml
vendored
Normal file
66
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: github-actions
|
||||||
|
directory: /
|
||||||
|
open-pull-requests-limit: 20
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
|
day: friday
|
||||||
|
time: "04:00"
|
||||||
|
groups:
|
||||||
|
github-actions-dependencies:
|
||||||
|
patterns:
|
||||||
|
- "*"
|
||||||
|
|
||||||
|
- package-ecosystem: docker
|
||||||
|
directories:
|
||||||
|
- "/test"
|
||||||
|
- "/"
|
||||||
|
open-pull-requests-limit: 20
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
|
day: friday
|
||||||
|
time: "04:00"
|
||||||
|
groups:
|
||||||
|
docker-dependencies:
|
||||||
|
patterns:
|
||||||
|
- "*"
|
||||||
|
|
||||||
|
- package-ecosystem: docker-compose
|
||||||
|
directory: "/test"
|
||||||
|
open-pull-requests-limit: 20
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
|
day: friday
|
||||||
|
time: "04:00"
|
||||||
|
groups:
|
||||||
|
docker-compose-dependencies:
|
||||||
|
patterns:
|
||||||
|
- "*"
|
||||||
|
|
||||||
|
- package-ecosystem: npm
|
||||||
|
directory: "/"
|
||||||
|
open-pull-requests-limit: 20
|
||||||
|
versioning-strategy: increase
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
|
day: friday
|
||||||
|
time: "04:00"
|
||||||
|
groups:
|
||||||
|
actions-dependencies:
|
||||||
|
patterns:
|
||||||
|
- "@actions/*"
|
||||||
|
npm-dev-dependencies:
|
||||||
|
dependency-type: development
|
||||||
|
|
||||||
|
- package-ecosystem: "devcontainers"
|
||||||
|
open-pull-requests-limit: 20
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
|
day: friday
|
||||||
|
time: "04:00"
|
||||||
|
groups:
|
||||||
|
devcontainers-dependencies:
|
||||||
|
patterns:
|
||||||
|
- "*"
|
||||||
67
.github/ghadocs/branding.svg
vendored
Normal file
67
.github/ghadocs/branding.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 3.5 MiB |
13
.github/ghadocs/examples/1_environment-variables.md
vendored
Normal file
13
.github/ghadocs/examples/1_environment-variables.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<!-- markdownlint-disable first-line-heading -->
|
||||||
|
|
||||||
|
### Example Using environment variables
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4.2.2
|
||||||
|
- uses: hoverkraft-tech/compose-action@v1.5.1
|
||||||
|
with:
|
||||||
|
compose-file: "./docker/docker-compose.yml"
|
||||||
|
env:
|
||||||
|
CUSTOM_VARIABLE: "test"
|
||||||
|
```
|
||||||
17
.github/ghadocs/examples/2_services.md
vendored
Normal file
17
.github/ghadocs/examples/2_services.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<!-- markdownlint-disable first-line-heading -->
|
||||||
|
|
||||||
|
### Example using `services`
|
||||||
|
|
||||||
|
Perform `docker compose up` to some given service instead of all of them
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# need checkout before using compose-action
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: hoverkraft-tech/compose-action@v1.5.1
|
||||||
|
with:
|
||||||
|
compose-file: "./docker/docker-compose.yml"
|
||||||
|
services: |
|
||||||
|
helloworld2
|
||||||
|
helloworld3
|
||||||
|
```
|
||||||
8
.github/ghadocs/examples/3_up-flags.md
vendored
Normal file
8
.github/ghadocs/examples/3_up-flags.md
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<!-- markdownlint-disable first-line-heading -->
|
||||||
|
|
||||||
|
### Example using `up-flags`
|
||||||
|
|
||||||
|
Specify flags to pass to the `docker compose up`. Default is none. Can be used
|
||||||
|
to pass the `--build` flag, for example, if you want persistent volumes to be
|
||||||
|
deleted as well during cleanup. A full list of flags can be found in the
|
||||||
|
[docker compose up documentation](https://docs.docker.com/compose/reference/up/).
|
||||||
9
.github/ghadocs/examples/4_down-flags.md
vendored
Normal file
9
.github/ghadocs/examples/4_down-flags.md
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<!-- markdownlint-disable first-line-heading -->
|
||||||
|
|
||||||
|
### Example using `down-flags`
|
||||||
|
|
||||||
|
Specify flags to pass to the `docker-compose down` command during cleanup.
|
||||||
|
Default is none. Can be used to pass the `--volumes` flag, for example, if you
|
||||||
|
want persistent volumes to be deleted as well during cleanup. A full list of
|
||||||
|
flags can be found in the
|
||||||
|
[docker-compose down documentation](https://docs.docker.com/compose/reference/down/).
|
||||||
19
.github/ghadocs/examples/5_compose-flags.md
vendored
Normal file
19
.github/ghadocs/examples/5_compose-flags.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<!-- markdownlint-disable first-line-heading -->
|
||||||
|
|
||||||
|
### Example using `compose-flags`
|
||||||
|
|
||||||
|
Specify flags to pass to the `docker compose` command. Default is none. A full
|
||||||
|
list of flags can be found in the
|
||||||
|
[docker compose documentation](https://docs.docker.com/compose/reference/#command-options-overview-and-help).
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# need checkout before using compose-action
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: hoverkraft-tech/compose-action@v1.5.1
|
||||||
|
with:
|
||||||
|
compose-file: "./docker/docker-compose.yml"
|
||||||
|
services: |
|
||||||
|
helloworld2
|
||||||
|
helloworld3
|
||||||
|
```
|
||||||
18
.github/ghadocs/examples/6_multiple-compose-files.md
vendored
Normal file
18
.github/ghadocs/examples/6_multiple-compose-files.md
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<!-- markdownlint-disable first-line-heading -->
|
||||||
|
|
||||||
|
### Example with multiple compose files
|
||||||
|
|
||||||
|
Specify multiple compose files to use with the `docker compose` command. This is
|
||||||
|
useful when you have a base compose file and additional files for different
|
||||||
|
environments or configurations.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# need checkout before using compose-action
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: hoverkraft-tech/compose-action@v1.5.1
|
||||||
|
with:
|
||||||
|
compose-file: |
|
||||||
|
./docker/docker-compose.yml
|
||||||
|
./docker/docker-compose.ci.yml
|
||||||
|
```
|
||||||
24479
.github/ghadocs/social-preview.svg
vendored
Normal file
24479
.github/ghadocs/social-preview.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 3.5 MiB |
3
.github/linters/.jscpd.json
vendored
Normal file
3
.github/linters/.jscpd.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"ignore": ["**/dist/**"]
|
||||||
|
}
|
||||||
274
.github/workflows/__check-action.yml
vendored
Normal file
274
.github/workflows/__check-action.yml
vendored
Normal file
@@ -0,0 +1,274 @@
|
|||||||
|
name: Internal - Tests for action
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-action-with-services:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test with services
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
|
- name: Act
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
compose-file: "./test/docker-compose.yml"
|
||||||
|
services: |
|
||||||
|
service-b
|
||||||
|
service-c
|
||||||
|
|
||||||
|
- name: "Assert: only expected services are running"
|
||||||
|
run: |
|
||||||
|
docker compose -f ./test/docker-compose.yml ps
|
||||||
|
|
||||||
|
docker compose -f ./test/docker-compose.yml ps | grep test-service-b-1 || (echo "Service service-b is not running" && exit 1)
|
||||||
|
docker compose -f ./test/docker-compose.yml ps | grep test-service-c-1 || (echo "Service service-c is not running" && exit 1)
|
||||||
|
(docker compose -f ./test/docker-compose.yml ps | grep test-service-a-1 && echo "Unexpected service service-a is running" && exit 1) || true
|
||||||
|
|
||||||
|
test-action-with-down-flags:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test compose action
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
|
- name: Act
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
compose-file: "./test/docker-compose.yml"
|
||||||
|
down-flags: "--volumes"
|
||||||
|
|
||||||
|
test-action-with-compose-flags:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test with compose flags
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
|
- name: Act
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
compose-file: "./test/docker-compose.yml"
|
||||||
|
compose-flags: "--profile profile-1"
|
||||||
|
down-flags: "--volumes"
|
||||||
|
|
||||||
|
- name: "Assert: profile is used"
|
||||||
|
run: |
|
||||||
|
docker compose -f ./test/docker-compose.yml -p profile-1 ps || (echo "Profile not used" && exit 1)
|
||||||
|
|
||||||
|
test-action-with-env:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test with env
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
|
- name: Act
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
compose-file: "./test/docker-compose-with-env.yml"
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: busybox
|
||||||
|
|
||||||
|
- name: "Assert: env is used"
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: busybox
|
||||||
|
run: |
|
||||||
|
docker compose -f ./test/docker-compose-with-env.yml ps
|
||||||
|
|
||||||
|
docker compose -f ./test/docker-compose-with-env.yml ps | grep test-service-a-1 || (echo "Service service-a is not running" && exit 1)
|
||||||
|
|
||||||
|
test-action-with-multiple-compose-files:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test with multiple compose files
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
|
- name: Act
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
compose-file: |
|
||||||
|
./test/docker-compose.yml
|
||||||
|
./test/docker-compose.ci.yml
|
||||||
|
services: |
|
||||||
|
service-b
|
||||||
|
service-d
|
||||||
|
|
||||||
|
- name: "Assert: only expected services are running"
|
||||||
|
run: |
|
||||||
|
docker compose -f ./test/docker-compose.yml -f ./test/docker-compose.ci.yml ps
|
||||||
|
|
||||||
|
docker compose -f ./test/docker-compose.yml -f ./test/docker-compose.ci.yml ps | grep test-service-b-1 || (echo "Service service-b is not running" && exit 1)
|
||||||
|
docker compose -f ./test/docker-compose.yml -f ./test/docker-compose.ci.yml ps | grep test-service-d-1 || (echo "Service service-d is not running" && exit 1)
|
||||||
|
(docker compose -f ./test/docker-compose.yml -f ./test/docker-compose.ci.yml ps | grep test-service-a-1 && echo "Unexpected service service-a is running" && exit 1) || true
|
||||||
|
(docker compose -f ./test/docker-compose.yml -f ./test/docker-compose.ci.yml ps | grep test-service-c-1 && echo "Unexpected service service-c is running" && exit 1) || true
|
||||||
|
|
||||||
|
test-action-with-cwd:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test with cwd
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
|
- name: Act
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
compose-file: "docker-compose.yml"
|
||||||
|
cwd: "./test"
|
||||||
|
services: |
|
||||||
|
service-b
|
||||||
|
service-c
|
||||||
|
|
||||||
|
- name: "Assert: only expected services are running"
|
||||||
|
run: |
|
||||||
|
docker compose -f ./test/docker-compose.yml ps
|
||||||
|
|
||||||
|
docker compose -f ./test/docker-compose.yml ps | grep test-service-b-1 || (echo "Service service-b is not running" && exit 1)
|
||||||
|
docker compose -f ./test/docker-compose.yml ps | grep test-service-c-1 || (echo "Service service-c is not running" && exit 1)
|
||||||
|
(docker compose -f ./test/docker-compose.yml ps | grep test-service-a-1 && echo "Unexpected service service-a is running" && exit 1) || true
|
||||||
|
|
||||||
|
test-action-with-absolute-path:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test with absolute path
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
|
- name: Act
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
compose-file: "${{ github.workspace }}/test/docker-compose.yml"
|
||||||
|
services: |
|
||||||
|
service-b
|
||||||
|
service-c
|
||||||
|
|
||||||
|
- name: "Assert: only expected services are running"
|
||||||
|
run: |
|
||||||
|
docker compose -f ./test/docker-compose.yml ps
|
||||||
|
|
||||||
|
docker compose -f ./test/docker-compose.yml ps | grep test-service-b-1 || (echo "Service service-b is not running" && exit 1)
|
||||||
|
docker compose -f ./test/docker-compose.yml ps | grep test-service-c-1 || (echo "Service service-c is not running" && exit 1)
|
||||||
|
(docker compose -f ./test/docker-compose.yml ps | grep test-service-a-1 && echo "Unexpected service service-a is running" && exit 1) || true
|
||||||
|
|
||||||
|
test-abort-on-container-exit:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test with --abort-on-container-exit
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
|
- name: Act
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
compose-file: "test/docker-compose-web-mysql.yml"
|
||||||
|
up-flags: "--build --abort-on-container-exit --exit-code-from=web"
|
||||||
|
|
||||||
|
test-attach-dependencies-failure:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test with --attach-dependencies and service failure
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
|
- name: Act
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
compose-file: "test/docker-compose-fail.yml"
|
||||||
|
up-flags: "--attach-dependencies"
|
||||||
|
|
||||||
|
- name: Assert
|
||||||
|
run: |
|
||||||
|
EXIT_CODE=$(docker compose -f ./test/docker-compose-fail.yml ps service-a --all --format json | jq ".ExitCode")
|
||||||
|
[ "$EXIT_CODE" == "1" ] || (echo "Service service-a did not exit with code 1" && exit 1)
|
||||||
|
|
||||||
|
test-action-with-compose-version:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test with compose version
|
||||||
|
env:
|
||||||
|
DOCKER_COMPOSE_VERSION: "2.29.0"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
|
- name: "Arrange: ensure original docker compose version is not the expected one"
|
||||||
|
run: |
|
||||||
|
CURRENT_DOCKER_COMPOSE_VERSION=$(docker compose version --short)
|
||||||
|
echo "Current docker compose version: $CURRENT_DOCKER_COMPOSE_VERSION"
|
||||||
|
|
||||||
|
if [ "$CURRENT_DOCKER_COMPOSE_VERSION" == "$DOCKER_COMPOSE_VERSION" ]; then
|
||||||
|
echo "Docker compose version is already in $DOCKER_COMPOSE_VERSION version"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Act
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
compose-file: "./test/docker-compose.yml"
|
||||||
|
compose-version: "2.29.0"
|
||||||
|
|
||||||
|
- name: "Assert: compose version is used"
|
||||||
|
run: |
|
||||||
|
CURRENT_DOCKER_COMPOSE_VERSION=$(docker compose version --short)
|
||||||
|
echo "Current docker compose version: $CURRENT_DOCKER_COMPOSE_VERSION"
|
||||||
|
|
||||||
|
if [ "$CURRENT_DOCKER_COMPOSE_VERSION" != "$DOCKER_COMPOSE_VERSION" ]; then
|
||||||
|
echo "Docker compose version is not in $DOCKER_COMPOSE_VERSION version"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
test-action-with-compose-version-latest:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test with compose version latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
|
- name: "Arrange: retrieve latest version of docker compose"
|
||||||
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const dockerComposeVersion = (await github.rest.repos.getLatestRelease({
|
||||||
|
owner: "docker",
|
||||||
|
repo: "compose",
|
||||||
|
})).data.tag_name.replace("v", "");
|
||||||
|
|
||||||
|
core.exportVariable('DOCKER_COMPOSE_VERSION', dockerComposeVersion);
|
||||||
|
|
||||||
|
- name: "Arrange: ensure original docker compose version is not the expected one"
|
||||||
|
run: |
|
||||||
|
CURRENT_DOCKER_COMPOSE_VERSION=$(docker compose version --short)
|
||||||
|
echo "Current docker compose version: $CURRENT_DOCKER_COMPOSE_VERSION"
|
||||||
|
|
||||||
|
if [ "$CURRENT_DOCKER_COMPOSE_VERSION" == "$DOCKER_COMPOSE_VERSION" ]; then
|
||||||
|
echo "Docker compose version is already in $DOCKER_COMPOSE_VERSION version"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Act
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
compose-file: "./test/docker-compose.yml"
|
||||||
|
compose-version: "latest"
|
||||||
|
|
||||||
|
- name: "Assert: compose version is used"
|
||||||
|
run: |
|
||||||
|
CURRENT_DOCKER_COMPOSE_VERSION=$(docker compose version --short)
|
||||||
|
echo "Current docker compose version: $CURRENT_DOCKER_COMPOSE_VERSION"
|
||||||
|
|
||||||
|
if [ "$CURRENT_DOCKER_COMPOSE_VERSION" != "$DOCKER_COMPOSE_VERSION" ]; then
|
||||||
|
echo "Docker compose version is not in $DOCKER_COMPOSE_VERSION version"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
test-action-with-docker-context:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test with docker context
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
|
- name: Set up Docker
|
||||||
|
uses: docker/setup-docker-action@b60f85385d03ac8acfca6d9996982511d8620a19 # v4.3.0
|
||||||
|
with:
|
||||||
|
context: test-context
|
||||||
|
|
||||||
|
- name: Act
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
docker-flags: "--context test-context"
|
||||||
|
compose-file: "./test/docker-compose.yml"
|
||||||
|
compose-version: "latest"
|
||||||
39
.github/workflows/__check-dist.yml
vendored
Normal file
39
.github/workflows/__check-dist.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
name: Internal - Checks for dist
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-dist:
|
||||||
|
name: Check dist
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
- uses: hoverkraft-tech/ci-github-nodejs/actions/setup-node@77c905a25700b1ca630037812b5df42d2d7c40ae # 0.12.0
|
||||||
|
|
||||||
|
- name: Build dist/ Directory
|
||||||
|
id: package
|
||||||
|
run: npm run package
|
||||||
|
|
||||||
|
# This will fail the workflow if the PR wasn't created by Dependabot.
|
||||||
|
- name: Compare Directories
|
||||||
|
id: diff
|
||||||
|
run: |
|
||||||
|
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
|
||||||
|
echo "Detected uncommitted changes after package. See status below:"
|
||||||
|
git diff --ignore-space-at-eol --text dist/
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If `dist/` was different than expected, and this was not a Dependabot
|
||||||
|
# PR, upload the expected version as a workflow artifact.
|
||||||
|
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
|
||||||
|
name: Upload Artifact
|
||||||
|
id: upload
|
||||||
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
|
with:
|
||||||
|
name: dist
|
||||||
|
path: dist/
|
||||||
19
.github/workflows/__check-nodejs.yml
vendored
Normal file
19
.github/workflows/__check-nodejs.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
name: Internal - Checks for nodejs
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-nodejs:
|
||||||
|
uses: hoverkraft-tech/ci-github-nodejs/.github/workflows/continuous-integration.yml@77c905a25700b1ca630037812b5df42d2d7c40ae # 0.12.0
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
|
security-events: write
|
||||||
|
contents: read
|
||||||
|
with:
|
||||||
|
build: ""
|
||||||
41
.github/workflows/__shared-ci.yml
vendored
Normal file
41
.github/workflows/__shared-ci.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
name: Common Continuous Integration tasks
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
packages: read
|
||||||
|
security-events: write
|
||||||
|
statuses: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
linter:
|
||||||
|
uses: hoverkraft-tech/ci-github-common/.github/workflows/linter.yml@9a3d71ca9f68bc1061db8ea1442084ac31a0f8bf # 0.23.0
|
||||||
|
with:
|
||||||
|
linter-env: |
|
||||||
|
FILTER_REGEX_EXCLUDE=dist/**/*
|
||||||
|
VALIDATE_JSCPD=false
|
||||||
|
VALIDATE_TYPESCRIPT_STANDARD=false
|
||||||
|
VALIDATE_TYPESCRIPT_ES=false
|
||||||
|
VALIDATE_TYPESCRIPT_PRETTIER=false
|
||||||
|
VALIDATE_JAVASCRIPT_ES=false
|
||||||
|
VALIDATE_JAVASCRIPT_STANDARD=false
|
||||||
|
|
||||||
|
check-nodejs:
|
||||||
|
name: Test nodejs
|
||||||
|
needs: linter
|
||||||
|
uses: ./.github/workflows/__check-nodejs.yml
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
check-dist:
|
||||||
|
name: Test nodejs
|
||||||
|
needs: linter
|
||||||
|
uses: ./.github/workflows/__check-dist.yml
|
||||||
|
|
||||||
|
check-action:
|
||||||
|
name: Test action
|
||||||
|
needs: [check-nodejs, check-dist]
|
||||||
|
uses: ./.github/workflows/__check-action.yml
|
||||||
16
.github/workflows/greetings.yml
vendored
Normal file
16
.github/workflows/greetings.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
name: Greetings
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened]
|
||||||
|
pull_request_target:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
greetings:
|
||||||
|
uses: hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml@9a3d71ca9f68bc1061db8ea1442084ac31a0f8bf # 0.23.0
|
||||||
57
.github/workflows/main-ci.yml
vendored
Normal file
57
.github/workflows/main-ci.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
name: Internal - Main - Continuous Integration
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
tags: ["*"]
|
||||||
|
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
schedule:
|
||||||
|
- cron: "25 8 * * 1"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
packages: read
|
||||||
|
security-events: write
|
||||||
|
statuses: write
|
||||||
|
# FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
uses: ./.github/workflows/__shared-ci.yml
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: ci
|
||||||
|
if: github.event_name != 'schedule'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
- uses: bitflight-devops/github-action-readme-generator@f750ff0ac8a4b68a3c2d622cc50a5ad20bcebaa1 # v1.8.0
|
||||||
|
with:
|
||||||
|
owner: ${{ github.repository_owner }}
|
||||||
|
repo: ${{ github.event.repository.name }}
|
||||||
|
|
||||||
|
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
|
||||||
|
id: generate-token
|
||||||
|
with:
|
||||||
|
app-id: ${{ vars.CI_BOT_APP_ID }}
|
||||||
|
private-key: ${{ secrets.CI_BOT_APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
|
- uses: hoverkraft-tech/ci-github-common/actions/create-and-merge-pull-request@9a3d71ca9f68bc1061db8ea1442084ac31a0f8bf # 0.23.0
|
||||||
|
with:
|
||||||
|
github-token: ${{ steps.generate-token.outputs.token }}
|
||||||
|
branch: docs/actions-workflows-documentation-update
|
||||||
|
title: "docs: update actions and workflows documentation"
|
||||||
|
body: Update actions and workflows documentation
|
||||||
|
commit-message: |
|
||||||
|
docs: update actions and workflows documentation
|
||||||
|
|
||||||
|
[skip ci]
|
||||||
27
.github/workflows/need-fix-to-issue.yml
vendored
Normal file
27
.github/workflows/need-fix-to-issue.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
name: Need fix to Issue
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
#checkov:skip=CKV_GHA_7: required
|
||||||
|
manual-commit-ref:
|
||||||
|
description: "The SHA of the commit to get the diff for"
|
||||||
|
required: true
|
||||||
|
manual-base-ref:
|
||||||
|
description: "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
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
issues: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
main:
|
||||||
|
uses: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml@9a3d71ca9f68bc1061db8ea1442084ac31a0f8bf # 0.23.0
|
||||||
|
with:
|
||||||
|
manual-commit-ref: ${{ inputs.manual-commit-ref }}
|
||||||
|
manual-base-ref: ${{ inputs.manual-base-ref }}
|
||||||
23
.github/workflows/pull-request-ci.yml
vendored
Normal file
23
.github/workflows/pull-request-ci.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
name: Pull request - Continuous Integration
|
||||||
|
|
||||||
|
on:
|
||||||
|
merge_group:
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
packages: read
|
||||||
|
statuses: write
|
||||||
|
security-events: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
uses: ./.github/workflows/__shared-ci.yml
|
||||||
|
secrets: inherit
|
||||||
29
.github/workflows/release-new-action-version.yml
vendored
Normal file
29
.github/workflows/release-new-action-version.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
name: Release new action version
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [released]
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
#checkov:skip=CKV_GHA_7: required
|
||||||
|
TAG_NAME:
|
||||||
|
description: "Tag name that the major tag will point to"
|
||||||
|
required: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update_tag:
|
||||||
|
name: Update the major tag to include the ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} changes
|
||||||
|
environment:
|
||||||
|
name: releaseNewActionVersion
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Update the ${{ env.TAG_NAME }} tag
|
||||||
|
uses: actions/publish-action@f784495ce78a41bac4ed7e34a73f0034015764bb # v0.3.0
|
||||||
|
with:
|
||||||
|
source-tag: ${{ env.TAG_NAME }}
|
||||||
16
.github/workflows/semantic-pull-request.yml
vendored
Normal file
16
.github/workflows/semantic-pull-request.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
name: "Pull Request - Semantic Lint"
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- edited
|
||||||
|
- synchronize
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
main:
|
||||||
|
uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@9a3d71ca9f68bc1061db8ea1442084ac31a0f8bf # 0.23.0
|
||||||
13
.github/workflows/stale.yml
vendored
Normal file
13
.github/workflows/stale.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
name: Mark stale issues and pull requests
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "30 1 * * *"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
main:
|
||||||
|
uses: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml@9a3d71ca9f68bc1061db8ea1442084ac31a0f8bf # 0.23.0
|
||||||
103
.gitignore
vendored
Normal file
103
.gitignore
vendored
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
# Dependency directory
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# TypeScript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variables file
|
||||||
|
.env
|
||||||
|
.env.test
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# next.js build output
|
||||||
|
.next
|
||||||
|
|
||||||
|
# nuxt.js build output
|
||||||
|
.nuxt
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# OS metadata
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Ignore built ts files
|
||||||
|
__tests__/runner/*
|
||||||
|
|
||||||
|
# IDE files
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
*.code-workspace
|
||||||
1
.node-version
Normal file
1
.node-version
Normal file
@@ -0,0 +1 @@
|
|||||||
|
20.19.3
|
||||||
1
.prettierignore
Normal file
1
.prettierignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
dist
|
||||||
128
CODE_OF_CONDUCT.md
Normal file
128
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
We as members, contributors, and leaders pledge to make participation in our
|
||||||
|
community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||||
|
identity and expression, level of experience, education, socio-economic status,
|
||||||
|
nationality, personal appearance, race, religion, or sexual identity
|
||||||
|
and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||||
|
diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to a positive environment for our
|
||||||
|
community include:
|
||||||
|
|
||||||
|
- Demonstrating empathy and kindness toward other people
|
||||||
|
- Being respectful of differing opinions, viewpoints, and experiences
|
||||||
|
- Giving and gracefully accepting constructive feedback
|
||||||
|
- Accepting responsibility and apologizing to those affected by our mistakes,
|
||||||
|
and learning from the experience
|
||||||
|
- Focusing on what is best not just for us as individuals, but for the
|
||||||
|
overall community
|
||||||
|
|
||||||
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
|
- The use of sexualized language or imagery, and sexual attention or
|
||||||
|
advances of any kind
|
||||||
|
- Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
|
- Public or private harassment
|
||||||
|
- Publishing others' private information, such as a physical or email
|
||||||
|
address, without their explicit permission
|
||||||
|
- Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
|
Community leaders are responsible for clarifying and enforcing our standards of
|
||||||
|
acceptable behavior and will take appropriate and fair corrective action in
|
||||||
|
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||||
|
or harmful.
|
||||||
|
|
||||||
|
Community leaders have the right and responsibility to remove, edit, or reject
|
||||||
|
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||||
|
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||||
|
decisions when appropriate.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all community spaces, and also applies when
|
||||||
|
an individual is officially representing the community in public spaces.
|
||||||
|
Examples of representing our community include using an official email address,
|
||||||
|
posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported to the community leaders responsible for enforcement at
|
||||||
|
.
|
||||||
|
All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
|
reporter of any incident.
|
||||||
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining
|
||||||
|
the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||||
|
unprofessional or unwelcome in the community.
|
||||||
|
|
||||||
|
**Consequence**: A private, written warning from community leaders, providing
|
||||||
|
clarity around the nature of the violation and an explanation of why the
|
||||||
|
behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
|
||||||
|
**Community Impact**: A violation through a single incident or series
|
||||||
|
of actions.
|
||||||
|
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No
|
||||||
|
interaction with the people involved, including unsolicited interaction with
|
||||||
|
those enforcing the Code of Conduct, for a specified period of time. This
|
||||||
|
includes avoiding interactions in community spaces as well as external channels
|
||||||
|
like social media. Violating these terms may lead to a temporary or
|
||||||
|
permanent ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
|
||||||
|
**Community Impact**: A serious violation of community standards, including
|
||||||
|
sustained inappropriate behavior.
|
||||||
|
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public
|
||||||
|
communication with the community for a specified period of time. No public or
|
||||||
|
private interaction with the people involved, including unsolicited interaction
|
||||||
|
with those enforcing the Code of Conduct, is allowed during this period.
|
||||||
|
Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within
|
||||||
|
the community.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||||
|
version 2.0, available at
|
||||||
|
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html).
|
||||||
|
|
||||||
|
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||||
|
enforcement ladder](https://github.com/mozilla/diversity).
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see the FAQ at
|
||||||
|
[https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are available at
|
||||||
|
[https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations).
|
||||||
92
CONTRIBUTING.md
Normal file
92
CONTRIBUTING.md
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
When contributing to this repository, please first discuss the change you wish to make via issue,
|
||||||
|
email, or any other method with the owners of this repository before making a change.
|
||||||
|
|
||||||
|
Please note we have a code of conduct, please follow it in all your interactions with the project.
|
||||||
|
|
||||||
|
## Pull Request Process
|
||||||
|
|
||||||
|
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
|
||||||
|
build.
|
||||||
|
2. Update the README.md with details of changes to the interface, this includes new environment
|
||||||
|
variables, exposed ports, useful file locations and container parameters.
|
||||||
|
3. Ensure that the changes are well tested and continuous integration checks are succeeded.
|
||||||
|
4. Ensure the build assets have been updated.
|
||||||
|
5. You may merge the Pull Request in once you have the sign-off of one maintainer, or if you
|
||||||
|
do not have permission to do that, you may request the reviewer to merge it for you.
|
||||||
|
|
||||||
|
## Code of Conduct
|
||||||
|
|
||||||
|
### Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as
|
||||||
|
contributors and maintainers pledge to making participation in our project and
|
||||||
|
our community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||||
|
nationality, personal appearance, race, religion, or sexual identity and
|
||||||
|
orientation.
|
||||||
|
|
||||||
|
### Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment
|
||||||
|
include:
|
||||||
|
|
||||||
|
- Using welcoming and inclusive language
|
||||||
|
- Being respectful of differing viewpoints and experiences
|
||||||
|
- Gracefully accepting constructive criticism
|
||||||
|
- Focusing on what is best for the community
|
||||||
|
- Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
- The use of sexualized language or imagery and unwelcome sexual attention or
|
||||||
|
advances
|
||||||
|
- Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
- Public or private harassment
|
||||||
|
- Publishing others' private information, such as a physical or electronic
|
||||||
|
address, without explicit permission
|
||||||
|
- Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
### Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable
|
||||||
|
behavior and are expected to take appropriate and fair corrective action in
|
||||||
|
response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or
|
||||||
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||||
|
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||||
|
permanently any contributor for other behaviors that they deem inappropriate,
|
||||||
|
threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
### Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public spaces
|
||||||
|
when an individual is representing the project or its community. Examples of
|
||||||
|
representing a project or community include using an official project email
|
||||||
|
address, posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event. Representation of a project may be
|
||||||
|
further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
### Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
|
||||||
|
complaints will be reviewed and investigated and will result in a response that
|
||||||
|
is deemed necessary and appropriate to the circumstances. The project team is
|
||||||
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||||
|
Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||||
|
faith may face temporary or permanent repercussions as determined by other
|
||||||
|
members of the project's leadership.
|
||||||
|
|
||||||
|
### Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||||
|
available at [http://contributor-covenant.org/version/1/4][version]
|
||||||
|
|
||||||
|
[homepage]: http://contributor-covenant.org
|
||||||
|
[version]: http://contributor-covenant.org/version/1/4/
|
||||||
12
Dockerfile
Normal file
12
Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#checkov:skip=CKV_DOCKER_2: required
|
||||||
|
FROM ghcr.io/super-linter/super-linter:slim-v7
|
||||||
|
|
||||||
|
ARG UID=1000
|
||||||
|
ARG GID=1000
|
||||||
|
RUN chown -R ${UID}:${GID} /github/home
|
||||||
|
USER ${UID}:${GID}
|
||||||
|
|
||||||
|
ENV RUN_LOCAL=true
|
||||||
|
ENV USE_FIND_ALGORITHM=true
|
||||||
|
ENV LOG_LEVEL=WARN
|
||||||
|
ENV LOG_FILE="/github/home/logs"
|
||||||
20
LICENSE
Normal file
20
LICENSE
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright hoverkraft
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
47
Makefile
Normal file
47
Makefile
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
.PHONY: help
|
||||||
|
|
||||||
|
help: ## Display help
|
||||||
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||||
|
|
||||||
|
lint: ## Execute linting
|
||||||
|
$(call run_linter,)
|
||||||
|
|
||||||
|
lint-fix: ## Execute linting and fix
|
||||||
|
$(call run_linter, \
|
||||||
|
-e FIX_JSON_PRETTIER=true \
|
||||||
|
-e FIX_YAML_PRETTIER=true \
|
||||||
|
-e FIX_MARKDOWN=true \
|
||||||
|
-e FIX_MARKDOWN_PRETTIER=true \
|
||||||
|
-e FIX_NATURAL_LANGUAGE=true)
|
||||||
|
|
||||||
|
all: ## Execute all formats and checks
|
||||||
|
@npm run all
|
||||||
|
$(MAKE) lint-fix
|
||||||
|
|
||||||
|
define run_linter
|
||||||
|
DEFAULT_WORKSPACE="$(CURDIR)"; \
|
||||||
|
LINTER_IMAGE="linter:latest"; \
|
||||||
|
VOLUME="$$DEFAULT_WORKSPACE:$$DEFAULT_WORKSPACE"; \
|
||||||
|
docker build --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --tag $$LINTER_IMAGE .; \
|
||||||
|
docker run \
|
||||||
|
-e DEFAULT_WORKSPACE="$$DEFAULT_WORKSPACE" \
|
||||||
|
-e FILTER_REGEX_INCLUDE="$(filter-out $@,$(MAKECMDGOALS))" \
|
||||||
|
-e IGNORE_GITIGNORED_FILES=true \
|
||||||
|
-e KUBERNETES_KUBECONFORM_OPTIONS="--schema-location default --schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json'" \
|
||||||
|
-e FILTER_REGEX_EXCLUDE=dist/**/* \
|
||||||
|
-e VALIDATE_TYPESCRIPT_STANDARD=false \
|
||||||
|
-e VALIDATE_TYPESCRIPT_ES=false \
|
||||||
|
-e VALIDATE_TYPESCRIPT_PRETTIER=false \
|
||||||
|
-e VALIDATE_JAVASCRIPT_ES=false \
|
||||||
|
-e VALIDATE_JAVASCRIPT_STANDARD=false \
|
||||||
|
$(1) \
|
||||||
|
-v $$VOLUME \
|
||||||
|
--rm \
|
||||||
|
$$LINTER_IMAGE
|
||||||
|
endef
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# Argument fix workaround
|
||||||
|
#############################
|
||||||
|
%:
|
||||||
|
@:
|
||||||
234
README.md
Normal file
234
README.md
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
<!-- markdownlint-disable-next-line first-line-heading -->
|
||||||
|
<div align="center" width="100%">
|
||||||
|
<!-- start branding -->
|
||||||
|
|
||||||
|
<img src=".github/ghadocs/branding.svg" width="15%" align="center" alt="branding<icon:anchor color:blue>" />
|
||||||
|
|
||||||
|
<!-- end branding -->
|
||||||
|
<!-- start title -->
|
||||||
|
|
||||||
|
# <img src=".github/ghadocs/branding.svg" width="60px" align="center" alt="branding<icon:anchor color:blue>" /> GitHub Action: Docker Compose Action
|
||||||
|
|
||||||
|
<!-- end title -->
|
||||||
|
<!-- markdownlint-disable MD013 -->
|
||||||
|
<!-- start badges -->
|
||||||
|
|
||||||
|
<a href="https%3A%2F%2Fgithub.com%2Fhoverkraft-tech%2Fcompose-action%2Freleases%2Flatest"><img src="https://img.shields.io/github/v/release/hoverkraft-tech/compose-action?display_name=tag&sort=semver&logo=github&style=flat-square" alt="Release%20by%20tag" /></a><a href="https%3A%2F%2Fgithub.com%2Fhoverkraft-tech%2Fcompose-action%2Freleases%2Flatest"><img src="https://img.shields.io/github/release-date/hoverkraft-tech/compose-action?display_name=tag&sort=semver&logo=github&style=flat-square" alt="Release%20by%20date" /></a><img src="https://img.shields.io/github/last-commit/hoverkraft-tech/compose-action?logo=github&style=flat-square" alt="Commit" /><a href="https%3A%2F%2Fgithub.com%2Fhoverkraft-tech%2Fcompose-action%2Fissues"><img src="https://img.shields.io/github/issues/hoverkraft-tech/compose-action?logo=github&style=flat-square" alt="Open%20Issues" /></a><img src="https://img.shields.io/github/downloads/hoverkraft-tech/compose-action/total?logo=github&style=flat-square" alt="Downloads" />
|
||||||
|
|
||||||
|
<!-- end badges -->
|
||||||
|
<!-- markdownlint-enable MD013 -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- start description -->
|
||||||
|
|
||||||
|
This action runs your compose file(s) and clean up before action finished
|
||||||
|
|
||||||
|
<!-- end description -->
|
||||||
|
|
||||||
|
<!-- start contents -->
|
||||||
|
<!-- end contents -->
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Action
|
||||||
|
|
||||||
|
The action will run `docker compose up` to start the services defined in the given compose file(s).
|
||||||
|
The compose file(s) can be specified using the `compose-file` input.
|
||||||
|
Some extra options can be passed to the `docker compose up` command using the `up-flags` input.
|
||||||
|
|
||||||
|
### Post hook
|
||||||
|
|
||||||
|
On post hook, the action will run `docker compose down` to clean up the services.
|
||||||
|
|
||||||
|
Logs of the Docker Compose services are logged using GitHub `core.ts` API before the cleanup.
|
||||||
|
The log level can be set using the `services-log-level` input. The default is `debug`, which will
|
||||||
|
only print logs if [debug mode](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/troubleshooting-workflows/enabling-debug-logging) is switched on.
|
||||||
|
|
||||||
|
Some extra options can be passed to the `docker compose down` command using the `down-flags` input.
|
||||||
|
|
||||||
|
<!-- start usage -->
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: hoverkraft-tech/compose-action@v0.0.0
|
||||||
|
with:
|
||||||
|
# Description: Additional options to pass to `docker` command.
|
||||||
|
#
|
||||||
|
docker-flags: ""
|
||||||
|
|
||||||
|
# Description: Path to compose file(s). It can be a list of files. It can be
|
||||||
|
# absolute or relative to the current working directory (cwd).
|
||||||
|
#
|
||||||
|
# Default: ./docker-compose.yml
|
||||||
|
compose-file: ""
|
||||||
|
|
||||||
|
# Description: Services to perform docker compose up.
|
||||||
|
#
|
||||||
|
services: ""
|
||||||
|
|
||||||
|
# Description: Additional options to pass to `docker compose up` command.
|
||||||
|
#
|
||||||
|
# Default:
|
||||||
|
up-flags: ""
|
||||||
|
|
||||||
|
# Description: Additional options to pass to `docker compose down` command.
|
||||||
|
#
|
||||||
|
# Default:
|
||||||
|
down-flags: ""
|
||||||
|
|
||||||
|
# Description: Additional options to pass to `docker compose` command.
|
||||||
|
#
|
||||||
|
# Default:
|
||||||
|
compose-flags: ""
|
||||||
|
|
||||||
|
# Description: Current working directory
|
||||||
|
#
|
||||||
|
# Default: ${{ github.workspace }}
|
||||||
|
cwd: ""
|
||||||
|
|
||||||
|
# Description: Compose version to use. If null (default), it will use the current
|
||||||
|
# installed version. If "latest", it will install the latest version.
|
||||||
|
#
|
||||||
|
compose-version: ""
|
||||||
|
|
||||||
|
# Description: The log level used for Docker Compose service logs. Can be one of
|
||||||
|
# "debug", "info".
|
||||||
|
#
|
||||||
|
# Default: debug
|
||||||
|
services-log-level: ""
|
||||||
|
|
||||||
|
# Description: The GitHub token used to create an authenticated client (to fetch
|
||||||
|
# the latest version of docker compose).
|
||||||
|
#
|
||||||
|
# Default: ${{ github.token }}
|
||||||
|
github-token: ""
|
||||||
|
```
|
||||||
|
|
||||||
|
<!-- end usage -->
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
|
||||||
|
<!-- start inputs -->
|
||||||
|
|
||||||
|
| **Input** | **Description** | **Default** | **Required** |
|
||||||
|
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------ | ------------ |
|
||||||
|
| <code>docker-flags</code> | Additional options to pass to <code>docker</code> command. | | **false** |
|
||||||
|
| <code>compose-file</code> | Path to compose file(s). It can be a list of files. It can be absolute or relative to the current working directory (cwd). | <code>./docker-compose.yml</code> | **false** |
|
||||||
|
| <code>services</code> | Services to perform docker compose up. | | **false** |
|
||||||
|
| <code>up-flags</code> | Additional options to pass to <code>docker compose up</code> command. | | **false** |
|
||||||
|
| <code>down-flags</code> | Additional options to pass to <code>docker compose down</code> command. | | **false** |
|
||||||
|
| <code>compose-flags</code> | Additional options to pass to <code>docker compose</code> command. | | **false** |
|
||||||
|
| <code>cwd</code> | Current working directory | <code>${{ github.workspace }}</code> | **false** |
|
||||||
|
| <code>compose-version</code> | Compose version to use.<br />If null (default), it will use the current installed version.<br />If "latest", it will install the latest version. | | **false** |
|
||||||
|
| <code>services-log-level</code> | The log level used for Docker Compose service logs.<br />Can be one of "debug", "info". | <code>debug</code> | **false** |
|
||||||
|
| <code>github-token</code> | The GitHub token used to create an authenticated client (to fetch the latest version of docker compose). | <code>${{ github.token }}</code> | **false** |
|
||||||
|
|
||||||
|
<!-- end inputs -->
|
||||||
|
<!-- start outputs -->
|
||||||
|
<!-- end outputs -->
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Example using in a full workflow
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: Docker Compose Action
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4.2.2
|
||||||
|
|
||||||
|
- name: Run docker compose
|
||||||
|
uses: hoverkraft-tech/compose-action@v2.0.1
|
||||||
|
with:
|
||||||
|
compose-file: "./docker/docker-compose.yml"
|
||||||
|
|
||||||
|
- name: Execute tests in the running services
|
||||||
|
run: |
|
||||||
|
docker compose exec test-app pytest
|
||||||
|
```
|
||||||
|
|
||||||
|
<!-- start [.github/ghadocs/examples/] -->
|
||||||
|
<!-- end [.github/ghadocs/examples/] -->
|
||||||
|
|
||||||
|
### Example Using environment variables
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4.2.2
|
||||||
|
- uses: hoverkraft-tech/compose-action@v2.0.1
|
||||||
|
with:
|
||||||
|
compose-file: "./docker/docker-compose.yml"
|
||||||
|
env:
|
||||||
|
CUSTOM_VARIABLE: "test"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example using `services`
|
||||||
|
|
||||||
|
Perform `docker compose up` to some given service instead of all of them
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# need checkout before using compose-action
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: hoverkraft-tech/compose-action@v2.0.1
|
||||||
|
with:
|
||||||
|
compose-file: "./docker/docker-compose.yml"
|
||||||
|
services: |
|
||||||
|
helloworld2
|
||||||
|
helloworld3
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example using `up-flags`
|
||||||
|
|
||||||
|
Specify flags to pass to the `docker compose up`. Default is none. Can be used
|
||||||
|
to pass the `--build` flag, for example, if you want persistent volumes to be
|
||||||
|
deleted as well during cleanup. A full list of flags can be found in the
|
||||||
|
[docker compose up documentation](https://docs.docker.com/compose/reference/up/).
|
||||||
|
|
||||||
|
### Example using `down-flags`
|
||||||
|
|
||||||
|
Specify flags to pass to the `docker compose down` command during cleanup.
|
||||||
|
Default is none. Can be used to pass the `--volumes` flag, for example, if you
|
||||||
|
want persistent volumes to be deleted as well during cleanup. A full list of
|
||||||
|
flags can be found in the
|
||||||
|
[docker compose down documentation](https://docs.docker.com/compose/reference/down/).
|
||||||
|
|
||||||
|
### Example using `compose-flags`
|
||||||
|
|
||||||
|
Specify flags to pass to the `docker compose` command. Default is none. A full
|
||||||
|
list of flags can be found in the
|
||||||
|
[docker compose documentation](https://docs.docker.com/compose/reference/#command-options-overview-and-help).
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# need checkout before using compose-action
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: hoverkraft-tech/compose-action@v2.0.1
|
||||||
|
with:
|
||||||
|
compose-file: "./docker/docker-compose.yml"
|
||||||
|
services: |
|
||||||
|
helloworld2
|
||||||
|
helloworld3
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example with multiple compose files
|
||||||
|
|
||||||
|
Specify multiple compose files to use with the `docker compose` command. This is
|
||||||
|
useful when you have a base compose file and additional files for different
|
||||||
|
environments or configurations.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
# need checkout before using compose-action
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: hoverkraft-tech/compose-action@v1.5.1
|
||||||
|
with:
|
||||||
|
compose-file: |
|
||||||
|
./docker/docker-compose.yml
|
||||||
|
./docker/docker-compose.ci.yml
|
||||||
|
```
|
||||||
55
action.yml
Normal file
55
action.yml
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
name: "Docker Compose Action"
|
||||||
|
description: "This action runs your compose file(s) and clean up before action finished"
|
||||||
|
author: "hoverkraft"
|
||||||
|
branding:
|
||||||
|
icon: anchor
|
||||||
|
color: blue
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
docker-flags:
|
||||||
|
description: "Additional options to pass to `docker` command."
|
||||||
|
required: false
|
||||||
|
compose-file:
|
||||||
|
description: "Path to compose file(s). It can be a list of files. It can be absolute or relative to the current working directory (cwd)."
|
||||||
|
required: false
|
||||||
|
default: "./docker-compose.yml"
|
||||||
|
services:
|
||||||
|
description: "Services to perform docker compose up."
|
||||||
|
required: false
|
||||||
|
up-flags:
|
||||||
|
description: "Additional options to pass to `docker compose up` command."
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
down-flags:
|
||||||
|
description: "Additional options to pass to `docker compose down` command."
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
compose-flags:
|
||||||
|
description: "Additional options to pass to `docker compose` command."
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
cwd:
|
||||||
|
description: "Current working directory"
|
||||||
|
required: false
|
||||||
|
default: ${{ github.workspace }}
|
||||||
|
compose-version:
|
||||||
|
description: |
|
||||||
|
Compose version to use.
|
||||||
|
If null (default), it will use the current installed version.
|
||||||
|
If "latest", it will install the latest version.
|
||||||
|
required: false
|
||||||
|
services-log-level:
|
||||||
|
description: |
|
||||||
|
The log level used for Docker Compose service logs.
|
||||||
|
Can be one of "debug", "info".
|
||||||
|
required: false
|
||||||
|
default: "debug"
|
||||||
|
github-token:
|
||||||
|
description: The GitHub token used to create an authenticated client (to fetch the latest version of docker compose).
|
||||||
|
default: ${{ github.token }}
|
||||||
|
required: false
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: node20
|
||||||
|
main: dist/index.js
|
||||||
|
post: dist/post.js
|
||||||
43921
dist/index.js
generated
vendored
Normal file
43921
dist/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
661
dist/licenses.txt
generated
vendored
Normal file
661
dist/licenses.txt
generated
vendored
Normal file
@@ -0,0 +1,661 @@
|
|||||||
|
@actions/core
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright 2019 GitHub
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
@actions/exec
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright 2019 GitHub
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
@actions/github
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright 2019 GitHub
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
@actions/http-client
|
||||||
|
MIT
|
||||||
|
Actions Http Client for Node.js
|
||||||
|
|
||||||
|
Copyright (c) GitHub, Inc.
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||||
|
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||||
|
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
@actions/io
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright 2019 GitHub
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
@actions/tool-cache
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright 2019 GitHub
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
@fastify/busboy
|
||||||
|
MIT
|
||||||
|
Copyright Brian White. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to
|
||||||
|
deal in the Software without restriction, including without limitation the
|
||||||
|
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
IN THE SOFTWARE.
|
||||||
|
|
||||||
|
@octokit/auth-token
|
||||||
|
MIT
|
||||||
|
The MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Octokit contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
@octokit/core
|
||||||
|
MIT
|
||||||
|
The MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Octokit contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
@octokit/endpoint
|
||||||
|
MIT
|
||||||
|
The MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2018 Octokit contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
@octokit/graphql
|
||||||
|
MIT
|
||||||
|
The MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2018 Octokit contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
@octokit/plugin-paginate-rest
|
||||||
|
MIT
|
||||||
|
MIT License Copyright (c) 2019 Octokit contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
@octokit/plugin-rest-endpoint-methods
|
||||||
|
MIT
|
||||||
|
MIT License Copyright (c) 2019 Octokit contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
@octokit/request
|
||||||
|
MIT
|
||||||
|
The MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2018 Octokit contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
@octokit/request-error
|
||||||
|
MIT
|
||||||
|
The MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Octokit contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
before-after-hook
|
||||||
|
Apache-2.0
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright 2018 Gregor Martynus and other contributors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
|
deprecation
|
||||||
|
ISC
|
||||||
|
The ISC License
|
||||||
|
|
||||||
|
Copyright (c) Gregor Martynus and contributors
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||||
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
docker-compose
|
||||||
|
MIT
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2017 - 2021 PDMLab
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
once
|
||||||
|
ISC
|
||||||
|
The ISC License
|
||||||
|
|
||||||
|
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||||
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
semver
|
||||||
|
ISC
|
||||||
|
The ISC License
|
||||||
|
|
||||||
|
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||||
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
tunnel
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2012 Koichi Kobayashi
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
undici
|
||||||
|
MIT
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Matteo Collina and Undici contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
universal-user-agent
|
||||||
|
ISC
|
||||||
|
# [ISC License](https://spdx.org/licenses/ISC)
|
||||||
|
|
||||||
|
Copyright (c) 2018, Gregor Martynus (https://github.com/gr2m)
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
wrappy
|
||||||
|
ISC
|
||||||
|
The ISC License
|
||||||
|
|
||||||
|
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||||
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
yaml
|
||||||
|
ISC
|
||||||
|
Copyright Eemeli Aro <eemeli@gmail.com>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose
|
||||||
|
with or without fee is hereby granted, provided that the above copyright notice
|
||||||
|
and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||||
|
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||||
|
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||||
|
THIS SOFTWARE.
|
||||||
36938
dist/post.js
generated
vendored
Normal file
36938
dist/post.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
10700
package-lock.json
generated
Normal file
10700
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
144
package.json
Normal file
144
package.json
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
{
|
||||||
|
"name": "compose-action",
|
||||||
|
"description": "Docker Compose Action",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"author": "hoverkraft",
|
||||||
|
"license": "MIT",
|
||||||
|
"homepage": "https://github.com/hoverkraft-tech/compose-action",
|
||||||
|
"private": true,
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/hoverkraft-tech/compose-action.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/hoverkraft-tech/compose-action/issues"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"actions",
|
||||||
|
"docker-compose"
|
||||||
|
],
|
||||||
|
"exports": {
|
||||||
|
".": "./dist/index.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/core": "^1.11.1",
|
||||||
|
"@actions/github": "^6.0.1",
|
||||||
|
"@actions/tool-cache": "^2.0.2",
|
||||||
|
"@octokit/action": "^8.0.2",
|
||||||
|
"docker-compose": "^1.2.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@ts-dev-tools/core": "^1.6.2",
|
||||||
|
"@vercel/ncc": "^0.38.3",
|
||||||
|
"eslint-plugin-github": "^6.0.0",
|
||||||
|
"eslint-plugin-jsonc": "^2.20.1"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"package": "npm run package:index && npm run package:post",
|
||||||
|
"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:watch": "npm run package -- --watch",
|
||||||
|
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
||||||
|
"all": "npm run format && npm run lint && npm run test && npm run package",
|
||||||
|
"build": "tsc --noEmit",
|
||||||
|
"format": "prettier --cache --write .",
|
||||||
|
"jest": "jest --detectOpenHandles --forceExit",
|
||||||
|
"test": "npm run jest --maxWorkers=50%",
|
||||||
|
"test:watch": "npm run jest --watch --maxWorkers=25%",
|
||||||
|
"test:cov": "npm run test --coverage",
|
||||||
|
"test:ci": "npm run test:cov --runInBand",
|
||||||
|
"prepare": "ts-dev-tools install"
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"preset": "ts-jest",
|
||||||
|
"verbose": true,
|
||||||
|
"clearMocks": true,
|
||||||
|
"testEnvironment": "node",
|
||||||
|
"moduleFileExtensions": [
|
||||||
|
"js",
|
||||||
|
"ts"
|
||||||
|
],
|
||||||
|
"testMatch": [
|
||||||
|
"**/*.test.ts",
|
||||||
|
"**/__tests__/**/*.[jt]s?(x)",
|
||||||
|
"**/?(*.)+(spec|test)?(.*).+(ts|tsx|js)"
|
||||||
|
],
|
||||||
|
"testPathIgnorePatterns": [
|
||||||
|
"/node_modules/",
|
||||||
|
"/dist/"
|
||||||
|
],
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.ts$": "ts-jest"
|
||||||
|
},
|
||||||
|
"coverageReporters": [
|
||||||
|
"json-summary",
|
||||||
|
"text",
|
||||||
|
"lcov"
|
||||||
|
],
|
||||||
|
"collectCoverage": true,
|
||||||
|
"collectCoverageFrom": [
|
||||||
|
"./src/**",
|
||||||
|
"**/src/**/*.[jt]s?(x)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"eslintConfig": {
|
||||||
|
"root": true,
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint",
|
||||||
|
"jest"
|
||||||
|
],
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:jest/recommended",
|
||||||
|
"prettier"
|
||||||
|
],
|
||||||
|
"env": {
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"jsx": true
|
||||||
|
},
|
||||||
|
"ecmaVersion": 12,
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"jest": {
|
||||||
|
"version": "detect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ignorePatterns": [
|
||||||
|
"dist",
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"prettier": {
|
||||||
|
"semi": true,
|
||||||
|
"printWidth": 100,
|
||||||
|
"trailingComma": "es5"
|
||||||
|
},
|
||||||
|
"commitlint": {
|
||||||
|
"extends": [
|
||||||
|
"@commitlint/config-conventional"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"*.{js,ts,tsx}": [
|
||||||
|
"eslint --fix"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"importSort": {
|
||||||
|
".js, .jsx, .ts, .tsx": {
|
||||||
|
"style": "module",
|
||||||
|
"parser": "typescript"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tsDevTools": {
|
||||||
|
"version": "20220617100200-prettier-cache"
|
||||||
|
}
|
||||||
|
}
|
||||||
156
src/index-runner.test.ts
Normal file
156
src/index-runner.test.ts
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
import * as core from "@actions/core";
|
||||||
|
import { InputService } from "./services/input.service";
|
||||||
|
import { LoggerService, LogLevel } from "./services/logger.service";
|
||||||
|
import { DockerComposeInstallerService } from "./services/docker-compose-installer.service";
|
||||||
|
import * as indexRunner from "./index-runner";
|
||||||
|
import { DockerComposeService } from "./services/docker-compose.service";
|
||||||
|
|
||||||
|
describe("run", () => {
|
||||||
|
// Mock the external libraries and services used by the action
|
||||||
|
let infoMock: jest.SpiedFunction<typeof LoggerService.prototype.info>;
|
||||||
|
let debugMock: jest.SpiedFunction<typeof LoggerService.prototype.debug>;
|
||||||
|
let setFailedMock: jest.SpiedFunction<typeof core.setFailed>;
|
||||||
|
let getInputsMock: jest.SpiedFunction<typeof InputService.prototype.getInputs>;
|
||||||
|
let installMock: jest.SpiedFunction<typeof DockerComposeInstallerService.prototype.install>;
|
||||||
|
let upMock: jest.SpiedFunction<typeof DockerComposeService.prototype.up>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
|
||||||
|
infoMock = jest.spyOn(LoggerService.prototype, "info").mockImplementation();
|
||||||
|
debugMock = jest.spyOn(LoggerService.prototype, "debug").mockImplementation();
|
||||||
|
setFailedMock = jest.spyOn(core, "setFailed").mockImplementation();
|
||||||
|
getInputsMock = jest.spyOn(InputService.prototype, "getInputs");
|
||||||
|
installMock = jest.spyOn(DockerComposeInstallerService.prototype, "install");
|
||||||
|
upMock = jest.spyOn(DockerComposeService.prototype, "up");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should install docker compose with specified version", async () => {
|
||||||
|
// Arrange
|
||||||
|
getInputsMock.mockImplementation(() => ({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: [],
|
||||||
|
composeFlags: [],
|
||||||
|
upFlags: [],
|
||||||
|
downFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
composeVersion: "1.29.2",
|
||||||
|
githubToken: null,
|
||||||
|
serviceLogLevel: LogLevel.Debug,
|
||||||
|
}));
|
||||||
|
|
||||||
|
installMock.mockResolvedValue("1.29.2");
|
||||||
|
|
||||||
|
upMock.mockResolvedValue();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await indexRunner.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(infoMock).toHaveBeenCalledWith("Setting up docker compose version 1.29.2");
|
||||||
|
|
||||||
|
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"}'
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(installMock).toHaveBeenCalledWith({
|
||||||
|
composeVersion: "1.29.2",
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
githubToken: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(upMock).toHaveBeenCalledWith({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
composeFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
upFlags: [],
|
||||||
|
services: [],
|
||||||
|
serviceLogger: debugMock,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(setFailedMock).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should bring up docker compose services", async () => {
|
||||||
|
// Arrange
|
||||||
|
getInputsMock.mockImplementation(() => ({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: ["web"],
|
||||||
|
composeFlags: [],
|
||||||
|
upFlags: [],
|
||||||
|
downFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
composeVersion: null,
|
||||||
|
githubToken: null,
|
||||||
|
serviceLogLevel: LogLevel.Debug,
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await indexRunner.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(upMock).toHaveBeenCalledWith({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
composeFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
upFlags: [],
|
||||||
|
services: ["web"],
|
||||||
|
serviceLogger: debugMock,
|
||||||
|
});
|
||||||
|
expect(setFailedMock).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle errors and call setFailed", async () => {
|
||||||
|
// Arrange
|
||||||
|
const error = new Error("Test error");
|
||||||
|
upMock.mockRejectedValue(error);
|
||||||
|
|
||||||
|
getInputsMock.mockImplementation(() => ({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: ["web"],
|
||||||
|
composeFlags: [],
|
||||||
|
upFlags: [],
|
||||||
|
downFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
composeVersion: null,
|
||||||
|
githubToken: null,
|
||||||
|
serviceLogLevel: LogLevel.Debug,
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await indexRunner.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(setFailedMock).toHaveBeenCalledWith("Error: Test error");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle unknown errors and call setFailed", async () => {
|
||||||
|
// Arrange
|
||||||
|
const error = "Test error";
|
||||||
|
upMock.mockRejectedValue(error);
|
||||||
|
|
||||||
|
getInputsMock.mockImplementation(() => ({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: ["web"],
|
||||||
|
composeFlags: [],
|
||||||
|
upFlags: [],
|
||||||
|
downFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
composeVersion: null,
|
||||||
|
githubToken: null,
|
||||||
|
serviceLogLevel: LogLevel.Debug,
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await indexRunner.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(setFailedMock).toHaveBeenCalledWith('"Test error"');
|
||||||
|
});
|
||||||
|
});
|
||||||
51
src/index-runner.ts
Normal file
51
src/index-runner.ts
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import { setFailed } from "@actions/core";
|
||||||
|
import { InputService } from "./services/input.service";
|
||||||
|
import { LoggerService } from "./services/logger.service";
|
||||||
|
import { DockerComposeService } from "./services/docker-compose.service";
|
||||||
|
import { DockerComposeInstallerService } from "./services/docker-compose-installer.service";
|
||||||
|
import { ManualInstallerAdapter } from "./services/installer-adapter/manual-installer-adapter";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The run function for the action.
|
||||||
|
* @returns {Promise<void>} Resolves when the action is complete.
|
||||||
|
*/
|
||||||
|
export async function run(): Promise<void> {
|
||||||
|
try {
|
||||||
|
const loggerService = new LoggerService();
|
||||||
|
const inputService = new InputService();
|
||||||
|
const dockerComposeInstallerService = new DockerComposeInstallerService(
|
||||||
|
new ManualInstallerAdapter()
|
||||||
|
);
|
||||||
|
const dockerComposeService = new DockerComposeService();
|
||||||
|
|
||||||
|
const inputs = inputService.getInputs();
|
||||||
|
loggerService.debug(`inputs: ${JSON.stringify(inputs)}`);
|
||||||
|
|
||||||
|
loggerService.info(
|
||||||
|
"Setting up docker compose" +
|
||||||
|
(inputs.composeVersion ? ` version ${inputs.composeVersion}` : "")
|
||||||
|
);
|
||||||
|
|
||||||
|
const installedVersion = await dockerComposeInstallerService.install({
|
||||||
|
composeVersion: inputs.composeVersion,
|
||||||
|
cwd: inputs.cwd,
|
||||||
|
githubToken: inputs.githubToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
loggerService.info(`docker compose version: ${installedVersion}`);
|
||||||
|
|
||||||
|
loggerService.info("Bringing up docker compose service(s)");
|
||||||
|
await dockerComposeService.up({
|
||||||
|
dockerFlags: inputs.dockerFlags,
|
||||||
|
composeFiles: inputs.composeFiles,
|
||||||
|
composeFlags: inputs.composeFlags,
|
||||||
|
cwd: inputs.cwd,
|
||||||
|
upFlags: inputs.upFlags,
|
||||||
|
services: inputs.services,
|
||||||
|
serviceLogger: loggerService.getServiceLogger(inputs.serviceLogLevel),
|
||||||
|
});
|
||||||
|
loggerService.info("docker compose service(s) are up");
|
||||||
|
} catch (error) {
|
||||||
|
setFailed(`${error instanceof Error ? error : JSON.stringify(error)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
72
src/index.test.ts
Normal file
72
src/index.test.ts
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
import * as core from "@actions/core";
|
||||||
|
import { DockerComposeService } from "./services/docker-compose.service";
|
||||||
|
import { InputService } from "./services/input.service";
|
||||||
|
import { LoggerService, LogLevel } from "./services/logger.service";
|
||||||
|
import { DockerComposeInstallerService } from "./services/docker-compose-installer.service";
|
||||||
|
|
||||||
|
let setFailedMock: jest.SpiedFunction<typeof core.setFailed>;
|
||||||
|
let getInputsMock: jest.SpiedFunction<typeof InputService.prototype.getInputs>;
|
||||||
|
let debugMock: jest.SpiedFunction<typeof LoggerService.prototype.debug>;
|
||||||
|
let infoMock: jest.SpiedFunction<typeof LoggerService.prototype.info>;
|
||||||
|
let installMock: jest.SpiedFunction<typeof DockerComposeInstallerService.prototype.install>;
|
||||||
|
let upMock: jest.SpiedFunction<typeof DockerComposeService.prototype.up>;
|
||||||
|
|
||||||
|
describe("index", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
|
||||||
|
setFailedMock = jest.spyOn(core, "setFailed").mockImplementation();
|
||||||
|
infoMock = jest.spyOn(LoggerService.prototype, "info").mockImplementation();
|
||||||
|
debugMock = jest.spyOn(LoggerService.prototype, "debug").mockImplementation();
|
||||||
|
getInputsMock = jest.spyOn(InputService.prototype, "getInputs");
|
||||||
|
installMock = jest.spyOn(DockerComposeInstallerService.prototype, "install");
|
||||||
|
upMock = jest.spyOn(DockerComposeService.prototype, "up");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("calls run when imported", async () => {
|
||||||
|
getInputsMock.mockImplementation(() => ({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: [],
|
||||||
|
composeFlags: [],
|
||||||
|
upFlags: [],
|
||||||
|
downFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
composeVersion: null,
|
||||||
|
githubToken: null,
|
||||||
|
serviceLogLevel: LogLevel.Debug,
|
||||||
|
}));
|
||||||
|
|
||||||
|
installMock.mockResolvedValue("1.2.3");
|
||||||
|
upMock.mockResolvedValueOnce();
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
|
await require("../src/index");
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||||
|
|
||||||
|
expect(infoMock).toHaveBeenNthCalledWith(1, "Setting up docker compose");
|
||||||
|
expect(infoMock).toHaveBeenNthCalledWith(2, "docker compose version: 1.2.3");
|
||||||
|
|
||||||
|
// Verify that all of the functions were called correctly
|
||||||
|
expect(debugMock).toHaveBeenNthCalledWith(
|
||||||
|
1,
|
||||||
|
'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(upMock).toHaveBeenCalledWith({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: [],
|
||||||
|
composeFlags: [],
|
||||||
|
upFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
serviceLogger: debugMock,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(setFailedMock).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
expect(infoMock).toHaveBeenNthCalledWith(4, "docker compose service(s) are up");
|
||||||
|
});
|
||||||
|
});
|
||||||
7
src/index.ts
Normal file
7
src/index.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* The entrypoint for the action.
|
||||||
|
*/
|
||||||
|
import { run } from "./index-runner";
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
|
run();
|
||||||
187
src/post-runner.test.ts
Normal file
187
src/post-runner.test.ts
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
import * as core from "@actions/core";
|
||||||
|
import { InputService } from "./services/input.service";
|
||||||
|
import { LoggerService, LogLevel } from "./services/logger.service";
|
||||||
|
import * as postRunner from "./post-runner";
|
||||||
|
import { DockerComposeService } from "./services/docker-compose.service";
|
||||||
|
|
||||||
|
// Mock the external libraries and services used by the action
|
||||||
|
let infoMock: jest.SpiedFunction<typeof LoggerService.prototype.info>;
|
||||||
|
let debugMock: jest.SpiedFunction<typeof LoggerService.prototype.debug>;
|
||||||
|
let setFailedMock: jest.SpiedFunction<typeof core.setFailed>;
|
||||||
|
let getInputsMock: jest.SpiedFunction<typeof InputService.prototype.getInputs>;
|
||||||
|
let downMock: jest.SpiedFunction<typeof DockerComposeService.prototype.down>;
|
||||||
|
let logsMock: jest.SpiedFunction<typeof DockerComposeService.prototype.logs>;
|
||||||
|
|
||||||
|
describe("run", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
|
||||||
|
infoMock = jest.spyOn(LoggerService.prototype, "info").mockImplementation();
|
||||||
|
debugMock = jest.spyOn(LoggerService.prototype, "debug").mockImplementation();
|
||||||
|
setFailedMock = jest.spyOn(core, "setFailed").mockImplementation();
|
||||||
|
getInputsMock = jest.spyOn(InputService.prototype, "getInputs");
|
||||||
|
downMock = jest.spyOn(DockerComposeService.prototype, "down");
|
||||||
|
logsMock = jest.spyOn(DockerComposeService.prototype, "logs");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should bring down docker compose service(s) and log output", async () => {
|
||||||
|
// Arrange
|
||||||
|
getInputsMock.mockImplementation(() => ({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: [],
|
||||||
|
composeFlags: [],
|
||||||
|
upFlags: [],
|
||||||
|
downFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
composeVersion: null,
|
||||||
|
githubToken: null,
|
||||||
|
serviceLogLevel: LogLevel.Debug,
|
||||||
|
}));
|
||||||
|
|
||||||
|
logsMock.mockResolvedValue({ error: "", output: "test logs" });
|
||||||
|
|
||||||
|
downMock.mockResolvedValue();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await postRunner.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(logsMock).toHaveBeenCalledWith({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
composeFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
services: [],
|
||||||
|
serviceLogger: debugMock,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(downMock).toHaveBeenCalledWith({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
composeFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
downFlags: [],
|
||||||
|
serviceLogger: debugMock,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(debugMock).toHaveBeenCalledWith("docker compose logs:\ntest logs");
|
||||||
|
|
||||||
|
expect(infoMock).toHaveBeenCalledWith("docker compose is down");
|
||||||
|
|
||||||
|
expect(setFailedMock).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should log docker composer errors if any", async () => {
|
||||||
|
// Arrange
|
||||||
|
getInputsMock.mockImplementation(() => ({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: [],
|
||||||
|
composeFlags: [],
|
||||||
|
upFlags: [],
|
||||||
|
downFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
composeVersion: null,
|
||||||
|
githubToken: null,
|
||||||
|
serviceLogLevel: LogLevel.Debug,
|
||||||
|
}));
|
||||||
|
|
||||||
|
logsMock.mockResolvedValue({
|
||||||
|
error: "test logs error",
|
||||||
|
output: "test logs output",
|
||||||
|
});
|
||||||
|
|
||||||
|
downMock.mockResolvedValue();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await postRunner.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(logsMock).toHaveBeenCalledWith({
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
composeFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
dockerFlags: [],
|
||||||
|
services: [],
|
||||||
|
serviceLogger: debugMock,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(downMock).toHaveBeenCalledWith({
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
composeFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
dockerFlags: [],
|
||||||
|
downFlags: [],
|
||||||
|
serviceLogger: debugMock,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(debugMock).toHaveBeenCalledWith("docker compose error:\ntest logs error");
|
||||||
|
expect(debugMock).toHaveBeenCalledWith("docker compose logs:\ntest logs output");
|
||||||
|
|
||||||
|
expect(infoMock).toHaveBeenCalledWith("docker compose is down");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should set failed when an error occurs", async () => {
|
||||||
|
// Arrange
|
||||||
|
getInputsMock.mockImplementation(() => {
|
||||||
|
throw new Error("An error occurred");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await postRunner.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(setFailedMock).toHaveBeenCalledWith("Error: An error occurred");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle errors and call setFailed", async () => {
|
||||||
|
// Arrange
|
||||||
|
const error = new Error("Test error");
|
||||||
|
downMock.mockRejectedValue(error);
|
||||||
|
|
||||||
|
getInputsMock.mockImplementation(() => ({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: ["web"],
|
||||||
|
composeFlags: [],
|
||||||
|
upFlags: [],
|
||||||
|
downFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
composeVersion: null,
|
||||||
|
githubToken: null,
|
||||||
|
serviceLogLevel: LogLevel.Debug,
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await postRunner.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(setFailedMock).toHaveBeenCalledWith("Error: Test error");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle unknown errors and call setFailed", async () => {
|
||||||
|
// Arrange
|
||||||
|
const error = "Test error";
|
||||||
|
downMock.mockRejectedValue(error);
|
||||||
|
|
||||||
|
getInputsMock.mockImplementation(() => ({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: ["web"],
|
||||||
|
composeFlags: [],
|
||||||
|
upFlags: [],
|
||||||
|
downFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
composeVersion: null,
|
||||||
|
githubToken: null,
|
||||||
|
serviceLogLevel: LogLevel.Debug,
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await postRunner.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(setFailedMock).toHaveBeenCalledWith('"Test error"');
|
||||||
|
});
|
||||||
|
});
|
||||||
46
src/post-runner.ts
Normal file
46
src/post-runner.ts
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import { setFailed } from "@actions/core";
|
||||||
|
import { InputService } from "./services/input.service";
|
||||||
|
import { LoggerService } from "./services/logger.service";
|
||||||
|
import { DockerComposeService } from "./services/docker-compose.service";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The run function for the action.
|
||||||
|
* @returns {Promise<void>} Resolves when the action is complete.
|
||||||
|
*/
|
||||||
|
export async function run(): Promise<void> {
|
||||||
|
try {
|
||||||
|
const loggerService = new LoggerService();
|
||||||
|
const inputService = new InputService();
|
||||||
|
const dockerComposeService = new DockerComposeService();
|
||||||
|
|
||||||
|
const inputs = inputService.getInputs();
|
||||||
|
|
||||||
|
const { error, output } = await dockerComposeService.logs({
|
||||||
|
dockerFlags: inputs.dockerFlags,
|
||||||
|
composeFiles: inputs.composeFiles,
|
||||||
|
composeFlags: inputs.composeFlags,
|
||||||
|
cwd: inputs.cwd,
|
||||||
|
services: inputs.services,
|
||||||
|
serviceLogger: loggerService.getServiceLogger(inputs.serviceLogLevel),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
loggerService.debug("docker compose error:\n" + error);
|
||||||
|
}
|
||||||
|
|
||||||
|
loggerService.debug("docker compose logs:\n" + output);
|
||||||
|
|
||||||
|
await dockerComposeService.down({
|
||||||
|
dockerFlags: inputs.dockerFlags,
|
||||||
|
composeFiles: inputs.composeFiles,
|
||||||
|
composeFlags: inputs.composeFlags,
|
||||||
|
cwd: inputs.cwd,
|
||||||
|
downFlags: inputs.downFlags,
|
||||||
|
serviceLogger: loggerService.getServiceLogger(inputs.serviceLogLevel),
|
||||||
|
});
|
||||||
|
|
||||||
|
loggerService.info("docker compose is down");
|
||||||
|
} catch (error) {
|
||||||
|
setFailed(`${error instanceof Error ? error : JSON.stringify(error)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
69
src/post.test.ts
Normal file
69
src/post.test.ts
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import * as core from "@actions/core";
|
||||||
|
import { DockerComposeService } from "./services/docker-compose.service";
|
||||||
|
import { InputService } from "./services/input.service";
|
||||||
|
import { LoggerService, LogLevel } from "./services/logger.service";
|
||||||
|
|
||||||
|
let setFailedMock: jest.SpiedFunction<typeof core.setFailed>;
|
||||||
|
let getInputsMock: jest.SpiedFunction<typeof InputService.prototype.getInputs>;
|
||||||
|
let debugMock: jest.SpiedFunction<typeof LoggerService.prototype.debug>;
|
||||||
|
let infoMock: jest.SpiedFunction<typeof LoggerService.prototype.info>;
|
||||||
|
let logsMock: jest.SpiedFunction<typeof DockerComposeService.prototype.logs>;
|
||||||
|
let downMock: jest.SpiedFunction<typeof DockerComposeService.prototype.down>;
|
||||||
|
|
||||||
|
describe("post", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
|
||||||
|
setFailedMock = jest.spyOn(core, "setFailed").mockImplementation();
|
||||||
|
infoMock = jest.spyOn(LoggerService.prototype, "info").mockImplementation();
|
||||||
|
debugMock = jest.spyOn(LoggerService.prototype, "debug").mockImplementation();
|
||||||
|
getInputsMock = jest.spyOn(InputService.prototype, "getInputs");
|
||||||
|
logsMock = jest.spyOn(DockerComposeService.prototype, "logs");
|
||||||
|
downMock = jest.spyOn(DockerComposeService.prototype, "down");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("calls run when imported", async () => {
|
||||||
|
getInputsMock.mockImplementation(() => ({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: [],
|
||||||
|
composeFlags: [],
|
||||||
|
upFlags: [],
|
||||||
|
downFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
composeVersion: null,
|
||||||
|
githubToken: null,
|
||||||
|
serviceLogLevel: LogLevel.Debug,
|
||||||
|
}));
|
||||||
|
|
||||||
|
logsMock.mockResolvedValue({ error: "", output: "test logs" });
|
||||||
|
downMock.mockResolvedValueOnce();
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
|
await require("../src/post");
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||||
|
|
||||||
|
expect(logsMock).toHaveBeenCalledWith({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
composeFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
services: [],
|
||||||
|
serviceLogger: debugMock,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(downMock).toHaveBeenCalledWith({
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
composeFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
downFlags: [],
|
||||||
|
serviceLogger: debugMock,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(debugMock).toHaveBeenNthCalledWith(1, "docker compose logs:\ntest logs");
|
||||||
|
expect(infoMock).toHaveBeenNthCalledWith(1, "docker compose is down");
|
||||||
|
|
||||||
|
expect(setFailedMock).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
7
src/post.ts
Normal file
7
src/post.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* The entrypoint for the post action.
|
||||||
|
*/
|
||||||
|
import { run } from "./post-runner";
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
|
run();
|
||||||
210
src/services/docker-compose-installer.service.test.ts
Normal file
210
src/services/docker-compose-installer.service.test.ts
Normal file
@@ -0,0 +1,210 @@
|
|||||||
|
import * as dockerCompose from "docker-compose";
|
||||||
|
import { DockerComposeInstallerService } from "./docker-compose-installer.service";
|
||||||
|
import { ManualInstallerAdapter } from "./installer-adapter/manual-installer-adapter";
|
||||||
|
import { MockAgent, setGlobalDispatcher } from "undici";
|
||||||
|
|
||||||
|
jest.mock("docker-compose");
|
||||||
|
|
||||||
|
describe("DockerComposeInstallerService", () => {
|
||||||
|
let mockAgent: MockAgent;
|
||||||
|
let versionMock: jest.SpiedFunction<typeof dockerCompose.version>;
|
||||||
|
let manualInstallerAdapterMock: jest.Mocked<ManualInstallerAdapter>;
|
||||||
|
let service: DockerComposeInstallerService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
mockAgent = new MockAgent();
|
||||||
|
mockAgent.disableNetConnect();
|
||||||
|
|
||||||
|
versionMock = jest.spyOn(dockerCompose, "version").mockImplementation();
|
||||||
|
|
||||||
|
manualInstallerAdapterMock = {
|
||||||
|
install: jest.fn(),
|
||||||
|
} as unknown as jest.Mocked<ManualInstallerAdapter>;
|
||||||
|
|
||||||
|
service = new DockerComposeInstallerService(manualInstallerAdapterMock);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("install", () => {
|
||||||
|
it("should not install anything when expected version is already installed", async () => {
|
||||||
|
// Arrange
|
||||||
|
versionMock.mockResolvedValue({
|
||||||
|
exitCode: 0,
|
||||||
|
out: "",
|
||||||
|
err: "",
|
||||||
|
data: {
|
||||||
|
version: "1.2.3",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = await service.install({
|
||||||
|
composeVersion: "1.2.3",
|
||||||
|
cwd: "/path/to/cwd",
|
||||||
|
githubToken: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe("1.2.3");
|
||||||
|
expect(manualInstallerAdapterMock.install).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should install the requested version if it is not already installed", async () => {
|
||||||
|
// Arrange
|
||||||
|
versionMock.mockResolvedValueOnce({
|
||||||
|
exitCode: 0,
|
||||||
|
out: "",
|
||||||
|
err: "",
|
||||||
|
data: {
|
||||||
|
version: "1.2.3",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const expectedVersion = "1.3.0";
|
||||||
|
versionMock.mockResolvedValueOnce({
|
||||||
|
exitCode: 0,
|
||||||
|
out: "",
|
||||||
|
err: "",
|
||||||
|
data: {
|
||||||
|
version: expectedVersion,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.defineProperty(process, "platform", {
|
||||||
|
value: "linux",
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = await service.install({
|
||||||
|
composeVersion: expectedVersion,
|
||||||
|
cwd: "/path/to/cwd",
|
||||||
|
githubToken: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(expectedVersion);
|
||||||
|
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(expectedVersion);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should install the latest version if requested", async () => {
|
||||||
|
// Arrange
|
||||||
|
versionMock.mockResolvedValueOnce({
|
||||||
|
exitCode: 0,
|
||||||
|
out: "",
|
||||||
|
err: "",
|
||||||
|
data: {
|
||||||
|
version: "1.2.3",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const latestVersion = "v1.4.0";
|
||||||
|
|
||||||
|
const mockClient = mockAgent.get("https://api.github.com");
|
||||||
|
mockClient
|
||||||
|
.intercept({
|
||||||
|
path: "/repos/docker/compose/releases/latest",
|
||||||
|
method: "GET",
|
||||||
|
})
|
||||||
|
.reply(
|
||||||
|
200,
|
||||||
|
{
|
||||||
|
tag_name: latestVersion,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
"content-type": "application/json",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
setGlobalDispatcher(mockClient);
|
||||||
|
|
||||||
|
versionMock.mockResolvedValueOnce({
|
||||||
|
exitCode: 0,
|
||||||
|
out: "",
|
||||||
|
err: "",
|
||||||
|
data: {
|
||||||
|
version: latestVersion,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.defineProperty(process, "platform", {
|
||||||
|
value: "linux",
|
||||||
|
});
|
||||||
|
Object.defineProperty(globalThis, "fetch", {
|
||||||
|
value: jest.fn(),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = await service.install({
|
||||||
|
composeVersion: "latest",
|
||||||
|
cwd: "/path/to/cwd",
|
||||||
|
githubToken: "token",
|
||||||
|
});
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(latestVersion);
|
||||||
|
expect(manualInstallerAdapterMock.install).toHaveBeenCalledWith(latestVersion);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should throw an error if the latest version if requested and no Github token is provided", async () => {
|
||||||
|
// Arrange
|
||||||
|
versionMock.mockResolvedValueOnce({
|
||||||
|
exitCode: 0,
|
||||||
|
out: "",
|
||||||
|
err: "",
|
||||||
|
data: {
|
||||||
|
version: "1.2.3",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act & Assert
|
||||||
|
await expect(
|
||||||
|
service.install({
|
||||||
|
composeVersion: "latest",
|
||||||
|
cwd: "/path/to/cwd",
|
||||||
|
githubToken: null,
|
||||||
|
})
|
||||||
|
).rejects.toThrow("GitHub token is required to install the latest version");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should throw an error on unsupported platforms", async () => {
|
||||||
|
// Arrange
|
||||||
|
versionMock.mockResolvedValueOnce({
|
||||||
|
exitCode: 0,
|
||||||
|
out: "",
|
||||||
|
err: "",
|
||||||
|
data: {
|
||||||
|
version: "1.2.3",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const expectedVersion = "1.3.0";
|
||||||
|
versionMock.mockResolvedValueOnce({
|
||||||
|
exitCode: 0,
|
||||||
|
out: "",
|
||||||
|
err: "",
|
||||||
|
data: {
|
||||||
|
version: expectedVersion,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.defineProperty(process, "platform", {
|
||||||
|
value: "win32",
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act & Assert
|
||||||
|
await expect(
|
||||||
|
service.install({
|
||||||
|
composeVersion: expectedVersion,
|
||||||
|
cwd: "/path/to/cwd",
|
||||||
|
githubToken: null,
|
||||||
|
})
|
||||||
|
).rejects.toThrow(`Unsupported platform: win32`);
|
||||||
|
|
||||||
|
expect(manualInstallerAdapterMock.install).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
70
src/services/docker-compose-installer.service.ts
Normal file
70
src/services/docker-compose-installer.service.ts
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import * as github from "@actions/github";
|
||||||
|
import { version } from "docker-compose";
|
||||||
|
import { COMPOSE_VERSION_LATEST, Inputs } from "./input.service";
|
||||||
|
import { ManualInstallerAdapter } from "./installer-adapter/manual-installer-adapter";
|
||||||
|
|
||||||
|
export type InstallInputs = {
|
||||||
|
composeVersion: Inputs["composeVersion"];
|
||||||
|
cwd: Inputs["cwd"];
|
||||||
|
githubToken: Inputs["githubToken"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type VersionInputs = {
|
||||||
|
cwd: Inputs["cwd"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export class DockerComposeInstallerService {
|
||||||
|
constructor(private readonly manualInstallerAdapter: ManualInstallerAdapter) {}
|
||||||
|
|
||||||
|
async install({ composeVersion, cwd, githubToken }: InstallInputs): Promise<string> {
|
||||||
|
const currentVersion = await this.version({ cwd });
|
||||||
|
|
||||||
|
if (!composeVersion) {
|
||||||
|
return currentVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentVersion === composeVersion) {
|
||||||
|
return currentVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (composeVersion === COMPOSE_VERSION_LATEST) {
|
||||||
|
if (!githubToken) {
|
||||||
|
throw new Error("GitHub token is required to install the latest version");
|
||||||
|
}
|
||||||
|
composeVersion = await this.getLatestVersion(githubToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.installVersion(composeVersion);
|
||||||
|
|
||||||
|
return this.version({ cwd });
|
||||||
|
}
|
||||||
|
|
||||||
|
private async version({ cwd }: VersionInputs): Promise<string> {
|
||||||
|
const result = await version({
|
||||||
|
cwd,
|
||||||
|
});
|
||||||
|
return result.data.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getLatestVersion(githubToken: string): Promise<string> {
|
||||||
|
const octokit = github.getOctokit(githubToken);
|
||||||
|
|
||||||
|
const response = await octokit.rest.repos.getLatestRelease({
|
||||||
|
owner: "docker",
|
||||||
|
repo: "compose",
|
||||||
|
});
|
||||||
|
|
||||||
|
return response.data.tag_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async installVersion(version: string): Promise<void> {
|
||||||
|
switch (process.platform) {
|
||||||
|
case "linux":
|
||||||
|
case "darwin":
|
||||||
|
await this.manualInstallerAdapter.install(version);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error(`Unsupported platform: ${process.platform}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
170
src/services/docker-compose.service.test.ts
Normal file
170
src/services/docker-compose.service.test.ts
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
import * as dockerCompose from "docker-compose";
|
||||||
|
import { DockerComposeService, DownInputs, LogsInputs, UpInputs } from "./docker-compose.service";
|
||||||
|
|
||||||
|
jest.mock("docker-compose");
|
||||||
|
|
||||||
|
describe("DockerComposeService", () => {
|
||||||
|
let service: DockerComposeService;
|
||||||
|
let upAllMock: jest.SpiedFunction<typeof dockerCompose.upAll>;
|
||||||
|
let upManyMock: jest.SpiedFunction<typeof dockerCompose.upMany>;
|
||||||
|
let downMock: jest.SpiedFunction<typeof dockerCompose.down>;
|
||||||
|
let logsMock: jest.SpiedFunction<typeof dockerCompose.logs>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
service = new DockerComposeService();
|
||||||
|
upAllMock = jest.spyOn(dockerCompose, "upAll").mockImplementation();
|
||||||
|
upManyMock = jest.spyOn(dockerCompose, "upMany").mockImplementation();
|
||||||
|
downMock = jest.spyOn(dockerCompose, "down").mockImplementation();
|
||||||
|
logsMock = jest.spyOn(dockerCompose, "logs").mockImplementation();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("up", () => {
|
||||||
|
it("should call up with correct options", async () => {
|
||||||
|
const upInputs: UpInputs = {
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: [],
|
||||||
|
composeFlags: [],
|
||||||
|
upFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
serviceLogger: jest.fn(),
|
||||||
|
};
|
||||||
|
|
||||||
|
await service.up(upInputs);
|
||||||
|
|
||||||
|
expect(upAllMock).toHaveBeenCalledWith({
|
||||||
|
composeOptions: [],
|
||||||
|
commandOptions: [],
|
||||||
|
config: ["docker-compose.yml"],
|
||||||
|
executable: {
|
||||||
|
executablePath: "docker",
|
||||||
|
options: [],
|
||||||
|
},
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
callback: expect.any(Function),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ensure callback is calling the service logger
|
||||||
|
const callback = upAllMock?.mock?.calls[0][0]?.callback;
|
||||||
|
expect(callback).toBeDefined();
|
||||||
|
|
||||||
|
const message = "test log output";
|
||||||
|
callback ? callback(Buffer.from(message)) : null;
|
||||||
|
|
||||||
|
expect(upInputs.serviceLogger).toHaveBeenCalledWith("test log output");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should call up with specific docker flags", async () => {
|
||||||
|
const upInputs: UpInputs = {
|
||||||
|
dockerFlags: ["--context", "dev"],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: [],
|
||||||
|
composeFlags: [],
|
||||||
|
upFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
serviceLogger: jest.fn(),
|
||||||
|
};
|
||||||
|
|
||||||
|
await service.up(upInputs);
|
||||||
|
|
||||||
|
expect(upAllMock).toHaveBeenCalledWith({
|
||||||
|
composeOptions: [],
|
||||||
|
commandOptions: [],
|
||||||
|
config: ["docker-compose.yml"],
|
||||||
|
executable: {
|
||||||
|
executablePath: "docker",
|
||||||
|
options: ["--context", "dev"],
|
||||||
|
},
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
callback: expect.any(Function),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should call up with specific services", async () => {
|
||||||
|
const upInputs: UpInputs = {
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: ["helloworld2", "helloworld3"],
|
||||||
|
composeFlags: [],
|
||||||
|
upFlags: ["--build"],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
serviceLogger: jest.fn(),
|
||||||
|
};
|
||||||
|
|
||||||
|
await service.up(upInputs);
|
||||||
|
|
||||||
|
expect(upManyMock).toHaveBeenCalledWith(["helloworld2", "helloworld3"], {
|
||||||
|
composeOptions: [],
|
||||||
|
commandOptions: ["--build"],
|
||||||
|
config: ["docker-compose.yml"],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
callback: expect.any(Function),
|
||||||
|
executable: {
|
||||||
|
executablePath: "docker",
|
||||||
|
options: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("down", () => {
|
||||||
|
it("should call down with correct options", async () => {
|
||||||
|
const downInputs: DownInputs = {
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: [],
|
||||||
|
composeFlags: [],
|
||||||
|
downFlags: ["--volumes", "--remove-orphans"],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
serviceLogger: jest.fn(),
|
||||||
|
};
|
||||||
|
|
||||||
|
await service.down(downInputs);
|
||||||
|
|
||||||
|
expect(downMock).toHaveBeenCalledWith({
|
||||||
|
composeOptions: [],
|
||||||
|
commandOptions: ["--volumes", "--remove-orphans"],
|
||||||
|
config: [],
|
||||||
|
executable: {
|
||||||
|
executablePath: "docker",
|
||||||
|
options: [],
|
||||||
|
},
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
callback: expect.any(Function),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("logs", () => {
|
||||||
|
it("should call logs with correct options", async () => {
|
||||||
|
const debugMock = jest.fn();
|
||||||
|
const logsInputs: LogsInputs = {
|
||||||
|
dockerFlags: [],
|
||||||
|
composeFiles: ["docker-compose.yml"],
|
||||||
|
services: ["helloworld2", "helloworld3"],
|
||||||
|
composeFlags: [],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
serviceLogger: debugMock,
|
||||||
|
};
|
||||||
|
|
||||||
|
logsMock.mockResolvedValue({ exitCode: 0, err: "", out: "logs" });
|
||||||
|
|
||||||
|
await service.logs(logsInputs);
|
||||||
|
|
||||||
|
expect(dockerCompose.logs).toHaveBeenCalledWith(["helloworld2", "helloworld3"], {
|
||||||
|
composeOptions: [],
|
||||||
|
config: ["docker-compose.yml"],
|
||||||
|
cwd: "/current/working/dir",
|
||||||
|
executable: {
|
||||||
|
executablePath: "docker",
|
||||||
|
options: [],
|
||||||
|
},
|
||||||
|
follow: false,
|
||||||
|
callback: expect.any(Function),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
82
src/services/docker-compose.service.ts
Normal file
82
src/services/docker-compose.service.ts
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
import {
|
||||||
|
down,
|
||||||
|
IDockerComposeLogOptions,
|
||||||
|
IDockerComposeOptions,
|
||||||
|
logs,
|
||||||
|
upAll,
|
||||||
|
upMany,
|
||||||
|
} from "docker-compose";
|
||||||
|
import { Inputs } from "./input.service";
|
||||||
|
|
||||||
|
type OptionsInputs = {
|
||||||
|
dockerFlags: Inputs["dockerFlags"];
|
||||||
|
composeFiles: Inputs["composeFiles"];
|
||||||
|
composeFlags: Inputs["composeFlags"];
|
||||||
|
cwd: Inputs["cwd"];
|
||||||
|
serviceLogger: (message: string) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type UpInputs = OptionsInputs & { upFlags: Inputs["upFlags"]; services: Inputs["services"] };
|
||||||
|
export type DownInputs = OptionsInputs & { downFlags: Inputs["downFlags"] };
|
||||||
|
export type LogsInputs = OptionsInputs & { services: Inputs["services"] };
|
||||||
|
|
||||||
|
export class DockerComposeService {
|
||||||
|
async up({ upFlags, services, ...optionsInputs }: UpInputs): Promise<void> {
|
||||||
|
const options: IDockerComposeOptions = {
|
||||||
|
...this.getCommonOptions(optionsInputs),
|
||||||
|
commandOptions: upFlags,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (services.length > 0) {
|
||||||
|
await upMany(services, options);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await upAll(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down({ downFlags, ...optionsInputs }: DownInputs): Promise<void> {
|
||||||
|
const options: IDockerComposeOptions = {
|
||||||
|
...this.getCommonOptions(optionsInputs),
|
||||||
|
commandOptions: downFlags,
|
||||||
|
};
|
||||||
|
|
||||||
|
await down(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
async logs({ services, ...optionsInputs }: LogsInputs): Promise<{
|
||||||
|
error: string;
|
||||||
|
output: string;
|
||||||
|
}> {
|
||||||
|
const options: IDockerComposeLogOptions = {
|
||||||
|
...this.getCommonOptions(optionsInputs),
|
||||||
|
follow: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
const { err, out } = await logs(services, options);
|
||||||
|
|
||||||
|
return {
|
||||||
|
error: err,
|
||||||
|
output: out,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private getCommonOptions({
|
||||||
|
dockerFlags,
|
||||||
|
composeFiles,
|
||||||
|
composeFlags,
|
||||||
|
cwd,
|
||||||
|
serviceLogger,
|
||||||
|
}: OptionsInputs): IDockerComposeOptions {
|
||||||
|
return {
|
||||||
|
config: composeFiles,
|
||||||
|
composeOptions: composeFlags,
|
||||||
|
cwd: cwd,
|
||||||
|
callback: (chunk) => serviceLogger(chunk.toString()),
|
||||||
|
executable: {
|
||||||
|
executablePath: "docker",
|
||||||
|
options: dockerFlags,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
312
src/services/input.service.test.ts
Normal file
312
src/services/input.service.test.ts
Normal file
@@ -0,0 +1,312 @@
|
|||||||
|
import * as core from "@actions/core";
|
||||||
|
import fs from "fs";
|
||||||
|
import { InputService, InputNames } from "./input.service";
|
||||||
|
import { LogLevel } from "./logger.service";
|
||||||
|
|
||||||
|
describe("InputService", () => {
|
||||||
|
let service: InputService;
|
||||||
|
let getInputMock: jest.SpiedFunction<typeof core.getInput>;
|
||||||
|
let getMultilineInputMock: jest.SpiedFunction<typeof core.getMultilineInput>;
|
||||||
|
let existsSyncMock: jest.SpiedFunction<typeof fs.existsSync>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
|
||||||
|
existsSyncMock = jest.spyOn(fs, "existsSync").mockImplementation();
|
||||||
|
getInputMock = jest.spyOn(core, "getInput").mockImplementation();
|
||||||
|
getMultilineInputMock = jest.spyOn(core, "getMultilineInput").mockImplementation();
|
||||||
|
|
||||||
|
getMultilineInputMock.mockImplementation((inputName) => {
|
||||||
|
switch (inputName) {
|
||||||
|
case InputNames.ComposeFile:
|
||||||
|
return ["file1"];
|
||||||
|
default:
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
service = new InputService();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("getInputs", () => {
|
||||||
|
describe("docker-flags", () => {
|
||||||
|
it("should return given docker-flags input", () => {
|
||||||
|
getInputMock.mockImplementation((inputName) => {
|
||||||
|
switch (inputName) {
|
||||||
|
case InputNames.DockerFlags:
|
||||||
|
return "docker-flag1 docker-flag2";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
const inputs = service.getInputs();
|
||||||
|
|
||||||
|
expect(inputs.dockerFlags).toEqual(["docker-flag1", "docker-flag2"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return empty array when no docker-flags input", () => {
|
||||||
|
getInputMock.mockReturnValue("");
|
||||||
|
|
||||||
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
const inputs = service.getInputs();
|
||||||
|
|
||||||
|
expect(inputs.dockerFlags).toEqual([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("composeFiles", () => {
|
||||||
|
it("should return given composeFiles input", () => {
|
||||||
|
getMultilineInputMock.mockImplementation((inputName) => {
|
||||||
|
switch (inputName) {
|
||||||
|
case InputNames.ComposeFile:
|
||||||
|
return ["file1", "file2"];
|
||||||
|
default:
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
getInputMock.mockReturnValue("");
|
||||||
|
|
||||||
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
const inputs = service.getInputs();
|
||||||
|
|
||||||
|
expect(inputs.composeFiles).toEqual(["file1", "file2"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should throws an error when a compose file does not exist", () => {
|
||||||
|
getMultilineInputMock.mockImplementation((inputName) => {
|
||||||
|
switch (inputName) {
|
||||||
|
case InputNames.ComposeFile:
|
||||||
|
return ["file1", "file2"];
|
||||||
|
default:
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
getInputMock.mockImplementation((inputName) => {
|
||||||
|
switch (inputName) {
|
||||||
|
case InputNames.Cwd:
|
||||||
|
return "/current/working/directory";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
existsSyncMock.mockImplementation((file) => file === "/current/working/directory/file1");
|
||||||
|
|
||||||
|
expect(() => service.getInputs()).toThrow(
|
||||||
|
'Compose file not found in "/current/working/directory/file2", "file2"'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should throws an error when no composeFiles input", () => {
|
||||||
|
getMultilineInputMock.mockReturnValue([]);
|
||||||
|
|
||||||
|
getInputMock.mockReturnValue("");
|
||||||
|
|
||||||
|
expect(() => service.getInputs()).toThrow("No compose files found");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("services", () => {
|
||||||
|
it("should return given services input", () => {
|
||||||
|
getMultilineInputMock.mockImplementation((inputName) => {
|
||||||
|
switch (inputName) {
|
||||||
|
case InputNames.Services:
|
||||||
|
return ["service1", "service2"];
|
||||||
|
case InputNames.ComposeFile:
|
||||||
|
return ["file1"];
|
||||||
|
default:
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
getInputMock.mockReturnValue("");
|
||||||
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
const inputs = service.getInputs();
|
||||||
|
|
||||||
|
expect(inputs.services).toEqual(["service1", "service2"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("compose-flags", () => {
|
||||||
|
it("should return given compose-flags input", () => {
|
||||||
|
getInputMock.mockImplementation((inputName) => {
|
||||||
|
switch (inputName) {
|
||||||
|
case InputNames.ComposeFlags:
|
||||||
|
return "compose-flag1 compose-flag2";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
const inputs = service.getInputs();
|
||||||
|
|
||||||
|
expect(inputs.composeFlags).toEqual(["compose-flag1", "compose-flag2"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return empty array when no compose-flags input", () => {
|
||||||
|
getInputMock.mockReturnValue("");
|
||||||
|
|
||||||
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
const inputs = service.getInputs();
|
||||||
|
|
||||||
|
expect(inputs.composeFlags).toEqual([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("up-flags", () => {
|
||||||
|
it("should return given up-flags input", () => {
|
||||||
|
getInputMock.mockImplementation((inputName) => {
|
||||||
|
switch (inputName) {
|
||||||
|
case InputNames.UpFlags:
|
||||||
|
return "up-flag1 up-flag2";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
const inputs = service.getInputs();
|
||||||
|
|
||||||
|
expect(inputs.upFlags).toEqual(["up-flag1", "up-flag2"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return empty array when no up-flags input", () => {
|
||||||
|
getInputMock.mockReturnValue("");
|
||||||
|
|
||||||
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
const inputs = service.getInputs();
|
||||||
|
|
||||||
|
expect(inputs.upFlags).toEqual([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("down-flags", () => {
|
||||||
|
it("should return given down-flags input", () => {
|
||||||
|
getInputMock.mockImplementation((inputName) => {
|
||||||
|
switch (inputName) {
|
||||||
|
case InputNames.DownFlags:
|
||||||
|
return "down-flag1 down-flag2";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
const inputs = service.getInputs();
|
||||||
|
|
||||||
|
expect(inputs.downFlags).toEqual(["down-flag1", "down-flag2"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return empty array when no down-flags input", () => {
|
||||||
|
getInputMock.mockReturnValue("");
|
||||||
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
const inputs = service.getInputs();
|
||||||
|
|
||||||
|
expect(inputs.downFlags).toEqual([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("cwd", () => {
|
||||||
|
it("should return given cwd input", () => {
|
||||||
|
getInputMock.mockImplementation((inputName) => {
|
||||||
|
switch (inputName) {
|
||||||
|
case InputNames.Cwd:
|
||||||
|
return "cwd";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
const inputs = service.getInputs();
|
||||||
|
|
||||||
|
expect(inputs.cwd).toEqual("cwd");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("compose-version", () => {
|
||||||
|
it("should return given compose-version input", () => {
|
||||||
|
getInputMock.mockImplementation((inputName) => {
|
||||||
|
switch (inputName) {
|
||||||
|
case InputNames.ComposeVersion:
|
||||||
|
return "compose-version";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
const inputs = service.getInputs();
|
||||||
|
|
||||||
|
expect(inputs.composeVersion).toEqual("compose-version");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("services-log-level", () => {
|
||||||
|
it("should return given services-log-level input", () => {
|
||||||
|
getInputMock.mockImplementation((inputName) => {
|
||||||
|
switch (inputName) {
|
||||||
|
case InputNames.ServiceLogLevel:
|
||||||
|
return "info";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
const inputs = service.getInputs();
|
||||||
|
expect(inputs.serviceLogLevel).toEqual(LogLevel.Info);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return default services-log-level input", () => {
|
||||||
|
getInputMock.mockImplementation((inputName) => {
|
||||||
|
switch (inputName) {
|
||||||
|
case InputNames.ServiceLogLevel:
|
||||||
|
return "";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
const inputs = service.getInputs();
|
||||||
|
expect(inputs.serviceLogLevel).toEqual(LogLevel.Debug);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should throw an error when services-log-level input is invalid", () => {
|
||||||
|
getInputMock.mockImplementation((inputName) => {
|
||||||
|
switch (inputName) {
|
||||||
|
case InputNames.ServiceLogLevel:
|
||||||
|
return "invalid-log-level";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
existsSyncMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
expect(() => service.getInputs()).toThrow(
|
||||||
|
'Invalid service log level "invalid-log-level". Valid values are: debug, info'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
132
src/services/input.service.ts
Normal file
132
src/services/input.service.ts
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
import { getInput, getMultilineInput } from "@actions/core";
|
||||||
|
import { existsSync } from "fs";
|
||||||
|
import { join } from "path";
|
||||||
|
import { LogLevel } from "./logger.service";
|
||||||
|
|
||||||
|
export type Inputs = {
|
||||||
|
dockerFlags: string[];
|
||||||
|
composeFiles: string[];
|
||||||
|
services: string[];
|
||||||
|
composeFlags: string[];
|
||||||
|
upFlags: string[];
|
||||||
|
downFlags: string[];
|
||||||
|
cwd: string;
|
||||||
|
composeVersion: string | null;
|
||||||
|
githubToken: string | null;
|
||||||
|
serviceLogLevel: LogLevel;
|
||||||
|
};
|
||||||
|
|
||||||
|
export enum InputNames {
|
||||||
|
DockerFlags = "docker-flags",
|
||||||
|
ComposeFile = "compose-file",
|
||||||
|
Services = "services",
|
||||||
|
ComposeFlags = "compose-flags",
|
||||||
|
UpFlags = "up-flags",
|
||||||
|
DownFlags = "down-flags",
|
||||||
|
Cwd = "cwd",
|
||||||
|
ComposeVersion = "compose-version",
|
||||||
|
GithubToken = "github-token",
|
||||||
|
ServiceLogLevel = "services-log-level",
|
||||||
|
}
|
||||||
|
|
||||||
|
export const COMPOSE_VERSION_LATEST = "latest";
|
||||||
|
|
||||||
|
export class InputService {
|
||||||
|
getInputs(): Inputs {
|
||||||
|
return {
|
||||||
|
dockerFlags: this.getDockerFlags(),
|
||||||
|
composeFiles: this.getComposeFiles(),
|
||||||
|
services: this.getServices(),
|
||||||
|
composeFlags: this.getComposeFlags(),
|
||||||
|
upFlags: this.getUpFlags(),
|
||||||
|
downFlags: this.getDownFlags(),
|
||||||
|
cwd: this.getCwd(),
|
||||||
|
composeVersion: this.getComposeVersion(),
|
||||||
|
githubToken: this.getGithubToken(),
|
||||||
|
serviceLogLevel: this.getServiceLogLevel(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private getDockerFlags(): string[] {
|
||||||
|
return this.parseFlags(getInput(InputNames.DockerFlags));
|
||||||
|
}
|
||||||
|
|
||||||
|
private getComposeFiles(): string[] {
|
||||||
|
const cwd = this.getCwd();
|
||||||
|
const composeFiles = getMultilineInput(InputNames.ComposeFile).filter((composeFile: string) => {
|
||||||
|
if (!composeFile.trim().length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const possiblePaths = [join(cwd, composeFile), composeFile];
|
||||||
|
|
||||||
|
for (const path of possiblePaths) {
|
||||||
|
if (existsSync(path)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(`Compose file not found in "${possiblePaths.join('", "')}"`);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!composeFiles.length) {
|
||||||
|
throw new Error("No compose files found");
|
||||||
|
}
|
||||||
|
|
||||||
|
return composeFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
private getServices(): string[] {
|
||||||
|
return getMultilineInput(InputNames.Services, { required: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
private getComposeFlags(): string[] {
|
||||||
|
return this.parseFlags(getInput(InputNames.ComposeFlags));
|
||||||
|
}
|
||||||
|
|
||||||
|
private getUpFlags(): string[] {
|
||||||
|
return this.parseFlags(getInput(InputNames.UpFlags));
|
||||||
|
}
|
||||||
|
|
||||||
|
private getDownFlags(): string[] {
|
||||||
|
return this.parseFlags(getInput(InputNames.DownFlags));
|
||||||
|
}
|
||||||
|
|
||||||
|
private parseFlags(flags: string | null): string[] {
|
||||||
|
if (!flags) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return flags.trim().split(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
private getCwd(): string {
|
||||||
|
return getInput(InputNames.Cwd);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getComposeVersion(): string | null {
|
||||||
|
return (
|
||||||
|
getInput(InputNames.ComposeVersion, {
|
||||||
|
required: false,
|
||||||
|
}) || null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getGithubToken(): string | null {
|
||||||
|
return (
|
||||||
|
getInput(InputNames.GithubToken, {
|
||||||
|
required: false,
|
||||||
|
}) || null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getServiceLogLevel(): LogLevel {
|
||||||
|
const configuredLevel = getInput(InputNames.ServiceLogLevel, { required: false });
|
||||||
|
if (configuredLevel && !Object.values(LogLevel).includes(configuredLevel as LogLevel)) {
|
||||||
|
throw new Error(
|
||||||
|
`Invalid service log level "${configuredLevel}". Valid values are: ${Object.values(LogLevel).join(", ")}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (configuredLevel as LogLevel) || LogLevel.Debug;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export interface DockerComposeInstallerAdapter {
|
||||||
|
install(version: string): Promise<void>;
|
||||||
|
}
|
||||||
119
src/services/installer-adapter/manual-installer-adapter.test.ts
Normal file
119
src/services/installer-adapter/manual-installer-adapter.test.ts
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
import { ManualInstallerAdapter } from "./manual-installer-adapter";
|
||||||
|
import * as exec from "@actions/exec";
|
||||||
|
import * as io from "@actions/io";
|
||||||
|
import * as toolCache from "@actions/tool-cache";
|
||||||
|
|
||||||
|
jest.mock("@actions/exec");
|
||||||
|
jest.mock("@actions/io");
|
||||||
|
jest.mock("@actions/tool-cache");
|
||||||
|
|
||||||
|
describe("ManualInstallerAdapter", () => {
|
||||||
|
let mkdirPMock: jest.SpiedFunction<typeof io.mkdirP>;
|
||||||
|
let execMock: jest.SpiedFunction<typeof exec.exec>;
|
||||||
|
let cacheFileMock: jest.SpiedFunction<typeof toolCache.cacheFile>;
|
||||||
|
let downloadToolMock: jest.SpiedFunction<typeof toolCache.downloadTool>;
|
||||||
|
|
||||||
|
let adapter: ManualInstallerAdapter;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
mkdirPMock = jest.spyOn(io, "mkdirP").mockImplementation();
|
||||||
|
execMock = jest.spyOn(exec, "exec").mockImplementation();
|
||||||
|
cacheFileMock = jest.spyOn(toolCache, "cacheFile").mockImplementation();
|
||||||
|
downloadToolMock = jest.spyOn(toolCache, "downloadTool").mockImplementation();
|
||||||
|
|
||||||
|
adapter = new ManualInstallerAdapter();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("install", () => {
|
||||||
|
it("should install docker compose correctly", async () => {
|
||||||
|
// Arrange
|
||||||
|
const version = "v2.29.0";
|
||||||
|
|
||||||
|
// Uname -s
|
||||||
|
execMock.mockResolvedValueOnce(0);
|
||||||
|
|
||||||
|
// Uname -m
|
||||||
|
execMock.mockResolvedValueOnce(0);
|
||||||
|
|
||||||
|
Object.defineProperty(process.env, "HOME", {
|
||||||
|
value: "/home/test",
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await adapter.install(version);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(mkdirPMock).toHaveBeenCalledWith("docker-compose");
|
||||||
|
expect(execMock).toHaveBeenNthCalledWith(1, "uname -s", [], {
|
||||||
|
listeners: { stdout: expect.any(Function) },
|
||||||
|
});
|
||||||
|
expect(execMock).toHaveBeenNthCalledWith(2, "uname -m", [], {
|
||||||
|
listeners: { stdout: expect.any(Function) },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(downloadToolMock).toHaveBeenCalledWith(
|
||||||
|
"https://github.com/docker/compose/releases/download/v2.29.0/docker-compose--",
|
||||||
|
"/home/test/.docker/cli-plugins/docker-compose"
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(cacheFileMock).toHaveBeenCalledWith(
|
||||||
|
"/home/test/.docker/cli-plugins/docker-compose",
|
||||||
|
"docker-compose",
|
||||||
|
"docker-compose",
|
||||||
|
version
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle version without 'v' prefix", async () => {
|
||||||
|
// Arrange
|
||||||
|
const version = "2.29.0";
|
||||||
|
|
||||||
|
// Uname -s
|
||||||
|
execMock.mockResolvedValueOnce(0);
|
||||||
|
|
||||||
|
// Uname -m
|
||||||
|
execMock.mockResolvedValueOnce(0);
|
||||||
|
|
||||||
|
Object.defineProperty(process.env, "HOME", {
|
||||||
|
value: "/home/test",
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await adapter.install(version);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(mkdirPMock).toHaveBeenCalledWith("docker-compose");
|
||||||
|
expect(execMock).toHaveBeenNthCalledWith(1, "uname -s", [], {
|
||||||
|
listeners: { stdout: expect.any(Function) },
|
||||||
|
});
|
||||||
|
expect(execMock).toHaveBeenNthCalledWith(2, "uname -m", [], {
|
||||||
|
listeners: { stdout: expect.any(Function) },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(downloadToolMock).toHaveBeenCalledWith(
|
||||||
|
"https://github.com/docker/compose/releases/download/v2.29.0/docker-compose--",
|
||||||
|
"/home/test/.docker/cli-plugins/docker-compose"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should throw an error if a command fails", async () => {
|
||||||
|
// Arrange
|
||||||
|
const version = "v2.29.0";
|
||||||
|
|
||||||
|
// Uname -s
|
||||||
|
execMock.mockResolvedValueOnce(1);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await expect(adapter.install(version)).rejects.toThrow("Failed to run command: uname -s");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(execMock).toHaveBeenNthCalledWith(1, "uname -s", [], {
|
||||||
|
listeners: { stdout: expect.any(Function) },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
60
src/services/installer-adapter/manual-installer-adapter.ts
Normal file
60
src/services/installer-adapter/manual-installer-adapter.ts
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import { exec } from "@actions/exec";
|
||||||
|
import { mkdirP } from "@actions/io";
|
||||||
|
import { basename } from "path";
|
||||||
|
import { cacheFile, downloadTool } from "@actions/tool-cache";
|
||||||
|
import { DockerComposeInstallerAdapter } from "./docker-compose-installer-adapter";
|
||||||
|
|
||||||
|
export class ManualInstallerAdapter implements DockerComposeInstallerAdapter {
|
||||||
|
async install(version: string): Promise<void> {
|
||||||
|
const dockerComposePluginPath = await this.getDockerComposePluginPath();
|
||||||
|
|
||||||
|
// Create the directory if it doesn't exist
|
||||||
|
await mkdirP(basename(dockerComposePluginPath));
|
||||||
|
|
||||||
|
await this.downloadFile(version, dockerComposePluginPath);
|
||||||
|
await exec(`chmod +x ${dockerComposePluginPath}`);
|
||||||
|
await cacheFile(dockerComposePluginPath, "docker-compose", "docker-compose", version);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getDockerComposePluginPath(): Promise<string> {
|
||||||
|
const dockerConfig = process.env.DOCKER_CONFIG || `${process.env.HOME}/.docker`;
|
||||||
|
|
||||||
|
const dockerComposePluginPath = `${dockerConfig}/cli-plugins/docker-compose`;
|
||||||
|
return dockerComposePluginPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async downloadFile(version: string, installerPath: string): Promise<void> {
|
||||||
|
if (!version.startsWith("v") && parseInt(version.split(".")[0], 10) >= 2) {
|
||||||
|
version = `v${version}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const system = await this.getSystem();
|
||||||
|
const hardware = await this.getHardware();
|
||||||
|
|
||||||
|
const url = `https://github.com/docker/compose/releases/download/${version}/docker-compose-${system}-${hardware}`;
|
||||||
|
await downloadTool(url, installerPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getSystem(): Promise<string> {
|
||||||
|
return this.runCommand("uname -s");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getHardware(): Promise<string> {
|
||||||
|
return this.runCommand("uname -m");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async runCommand(command: string): Promise<string> {
|
||||||
|
let output = "";
|
||||||
|
const result = await exec(command, [], {
|
||||||
|
listeners: {
|
||||||
|
stdout: (data: Buffer) => {
|
||||||
|
output += data.toString();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (result !== 0) {
|
||||||
|
throw new Error(`Failed to run command: ${command}`);
|
||||||
|
}
|
||||||
|
return output.trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
63
src/services/logger.service.test.ts
Normal file
63
src/services/logger.service.test.ts
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import { LoggerService, LogLevel } from "./logger.service";
|
||||||
|
import { debug, info, warning } from "@actions/core";
|
||||||
|
|
||||||
|
jest.mock("@actions/core", () => ({
|
||||||
|
warning: jest.fn(),
|
||||||
|
info: jest.fn(),
|
||||||
|
debug: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe("LoggerService", () => {
|
||||||
|
let loggerService: LoggerService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
loggerService = new LoggerService();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("warn", () => {
|
||||||
|
it("should call warning with the correct message", () => {
|
||||||
|
const message = "This is a warning message";
|
||||||
|
loggerService.warn(message);
|
||||||
|
expect(warning).toHaveBeenCalledWith(message);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("info", () => {
|
||||||
|
it("should call info with the correct message", () => {
|
||||||
|
const message = "This is an info message";
|
||||||
|
|
||||||
|
loggerService.info(message);
|
||||||
|
expect(info).toHaveBeenCalledWith(message);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("debug", () => {
|
||||||
|
it("should call debug with the correct message", () => {
|
||||||
|
const message = "This is a debug message";
|
||||||
|
|
||||||
|
loggerService.debug(message);
|
||||||
|
expect(debug).toHaveBeenCalledWith(message);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("getServiceLogger", () => {
|
||||||
|
it("should return the correct logger function for debug level", () => {
|
||||||
|
const logger = loggerService.getServiceLogger(LogLevel.Debug);
|
||||||
|
expect(logger).toBe(loggerService.debug);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return the correct logger function for info level", () => {
|
||||||
|
const logger = loggerService.getServiceLogger(LogLevel.Info);
|
||||||
|
expect(logger).toBe(loggerService.info);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should default to info level if an unknown level is provided", () => {
|
||||||
|
const logger = loggerService.getServiceLogger("unknown" as LogLevel);
|
||||||
|
expect(logger).toBe(loggerService.info);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
31
src/services/logger.service.ts
Normal file
31
src/services/logger.service.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { debug, info, warning } from "@actions/core";
|
||||||
|
|
||||||
|
export class LoggerService {
|
||||||
|
warn(message: string): void {
|
||||||
|
warning(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
info(message: string): void {
|
||||||
|
info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
debug(message: string) {
|
||||||
|
debug(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
getServiceLogger(level: LogLevel): (message: string) => void {
|
||||||
|
switch (level) {
|
||||||
|
case LogLevel.Debug:
|
||||||
|
return this.debug;
|
||||||
|
case LogLevel.Info:
|
||||||
|
return this.info;
|
||||||
|
default:
|
||||||
|
return this.info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum LogLevel {
|
||||||
|
Debug = "debug",
|
||||||
|
Info = "info",
|
||||||
|
}
|
||||||
11
test/Dockerfile
Normal file
11
test/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#checkov:skip=CKV_DOCKER_2: required
|
||||||
|
FROM alpine:3
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY entrypoint.sh .
|
||||||
|
RUN chmod +x entrypoint.sh
|
||||||
|
|
||||||
|
CMD ["/bin/sh", "entrypoint.sh"]
|
||||||
|
|
||||||
|
USER 1000:1000
|
||||||
4
test/docker-compose-fail.yml
Normal file
4
test/docker-compose-fail.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
services:
|
||||||
|
service-a:
|
||||||
|
image: busybox
|
||||||
|
command: ["sh", "-c", "exit 1"]
|
||||||
23
test/docker-compose-web-mysql.yml
Normal file
23
test/docker-compose-web-mysql.yml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
services:
|
||||||
|
web:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
volumes:
|
||||||
|
- .:/app
|
||||||
|
- /app/vendor
|
||||||
|
environment:
|
||||||
|
- DB_HOST=mysql
|
||||||
|
- DB_USER=root
|
||||||
|
- DB_PASSWORD=12345
|
||||||
|
- DATABASE=testing
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
|
||||||
|
mysql:
|
||||||
|
image: mariadb:latest
|
||||||
|
environment:
|
||||||
|
- MYSQL_HOST=127.0.0.1
|
||||||
|
- MYSQL_USER=root
|
||||||
|
- MARIADB_ROOT_PASSWORD=12345
|
||||||
|
- MYSQL_DB=testing
|
||||||
7
test/docker-compose-with-env.yml
Normal file
7
test/docker-compose-with-env.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
volumes:
|
||||||
|
test_volume: {}
|
||||||
|
|
||||||
|
services:
|
||||||
|
service-a:
|
||||||
|
image: ${IMAGE_NAME}
|
||||||
|
command: ["tail", "-f", "/dev/null"]
|
||||||
5
test/docker-compose.ci.yml
Normal file
5
test/docker-compose.ci.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
services:
|
||||||
|
service-d:
|
||||||
|
image: busybox
|
||||||
|
command: ["tail", "-f", "/dev/null"]
|
||||||
|
profiles: [profile-2]
|
||||||
17
test/docker-compose.yml
Normal file
17
test/docker-compose.yml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
services:
|
||||||
|
service-a:
|
||||||
|
image: busybox
|
||||||
|
command: ["tail", "-f", "/dev/null"]
|
||||||
|
volumes:
|
||||||
|
- test_volume:/test:Z
|
||||||
|
service-b:
|
||||||
|
image: busybox
|
||||||
|
command: ["tail", "-f", "/dev/null"]
|
||||||
|
profiles: [profile-1]
|
||||||
|
service-c:
|
||||||
|
image: busybox
|
||||||
|
command: ["tail", "-f", "/dev/null"]
|
||||||
|
profiles: [profile-2]
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
test_volume: {}
|
||||||
13
test/entrypoint.sh
Normal file
13
test/entrypoint.sh
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
sleep 2 && cat <<EOF
|
||||||
|
_________________________________________________
|
||||||
|
< It works! >
|
||||||
|
< --abort-on-container-exit --exit-code-from=web >
|
||||||
|
-------------------------------------------------
|
||||||
|
\ ^__^
|
||||||
|
\ (oo)\_______
|
||||||
|
(__)\ )\\/\\
|
||||||
|
||----w |
|
||||||
|
|| ||
|
||||||
|
EOF
|
||||||
21
tsconfig.json
Normal file
21
tsconfig.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/tsconfig",
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"rootDir": "./src",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"baseUrl": "./",
|
||||||
|
"sourceMap": true,
|
||||||
|
"outDir": "./dist",
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"newLine": "lf",
|
||||||
|
"noEmit": true
|
||||||
|
},
|
||||||
|
"exclude": ["./dist", "./node_modules", "./src/**/*.test.ts", "./coverage"],
|
||||||
|
"include": ["./src/**/*"]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user