mirror of
https://github.com/hoverkraft-tech/compose-action.git
synced 2026-01-14 16:43:07 +08:00
Compare commits
1 Commits
f740d6ac99
...
e4df684bc3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4df684bc3 |
12
.github/dependabot.yml
vendored
12
.github/dependabot.yml
vendored
@ -26,18 +26,6 @@ updates:
|
|||||||
patterns:
|
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
|
- package-ecosystem: npm
|
||||||
directory: "/"
|
directory: "/"
|
||||||
open-pull-requests-limit: 20
|
open-pull-requests-limit: 20
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
<!-- markdownlint-disable first-line-heading -->
|
<!-- markdownlint-disable-next-line first-line-heading -->
|
||||||
|
|
||||||
### Example Using environment variables
|
### Example Using environment variables
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
5
.github/ghadocs/examples/2_services.md
vendored
5
.github/ghadocs/examples/2_services.md
vendored
@ -1,8 +1,7 @@
|
|||||||
<!-- markdownlint-disable first-line-heading -->
|
<!-- markdownlint-disable-next-line first-line-heading -->
|
||||||
|
|
||||||
### Example using `services`
|
### Example using `services`
|
||||||
|
|
||||||
Perform `docker compose up` to some given service instead of all of them
|
Perform `docker-compose up` to some given service instead of all of them
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
7
.github/ghadocs/examples/3_up-flags.md
vendored
7
.github/ghadocs/examples/3_up-flags.md
vendored
@ -1,8 +1,7 @@
|
|||||||
<!-- markdownlint-disable first-line-heading -->
|
<!-- markdownlint-disable-next-line first-line-heading -->
|
||||||
|
|
||||||
### Example using `up-flags`
|
### Example using `up-flags`
|
||||||
|
|
||||||
Specify flags to pass to the `docker compose up`. Default is none. Can be used
|
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
|
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
|
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/).
|
[docker-compose up documentation](https://docs.docker.com/compose/reference/up/).
|
||||||
|
|||||||
3
.github/ghadocs/examples/4_down-flags.md
vendored
3
.github/ghadocs/examples/4_down-flags.md
vendored
@ -1,5 +1,4 @@
|
|||||||
<!-- markdownlint-disable first-line-heading -->
|
<!-- markdownlint-disable-next-line first-line-heading -->
|
||||||
|
|
||||||
### Example using `down-flags`
|
### Example using `down-flags`
|
||||||
|
|
||||||
Specify flags to pass to the `docker-compose down` command during cleanup.
|
Specify flags to pass to the `docker-compose down` command during cleanup.
|
||||||
|
|||||||
7
.github/ghadocs/examples/5_compose-flags.md
vendored
7
.github/ghadocs/examples/5_compose-flags.md
vendored
@ -1,10 +1,9 @@
|
|||||||
<!-- markdownlint-disable first-line-heading -->
|
<!-- markdownlint-disable-next-line first-line-heading -->
|
||||||
|
|
||||||
### Example using `compose-flags`
|
### Example using `compose-flags`
|
||||||
|
|
||||||
Specify flags to pass to the `docker compose` command. Default is none. A full
|
Specify flags to pass to the `docker-compose` command. Default is none. A full
|
||||||
list of flags can be found in the
|
list of flags can be found in the
|
||||||
[docker compose documentation](https://docs.docker.com/compose/reference/#command-options-overview-and-help).
|
[docker-compose documentation](https://docs.docker.com/compose/reference/#command-options-overview-and-help).
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
18
.github/workflows/__check-action.yml
vendored
18
.github/workflows/__check-action.yml
vendored
@ -254,21 +254,3 @@ jobs:
|
|||||||
echo "Docker compose version is not in $DOCKER_COMPOSE_VERSION version"
|
echo "Docker compose version is not in $DOCKER_COMPOSE_VERSION version"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
test-action-with-docker-context:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Test with docker context
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Docker
|
|
||||||
uses: docker/setup-docker-action@v4
|
|
||||||
with:
|
|
||||||
context: test-context
|
|
||||||
|
|
||||||
- name: Act
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
docker-flags: "--context test-context"
|
|
||||||
compose-file: "./test/docker-compose.yml"
|
|
||||||
compose-version: "latest"
|
|
||||||
|
|||||||
2
.github/workflows/__check-dist.yml
vendored
2
.github/workflows/__check-dist.yml
vendored
@ -12,7 +12,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: hoverkraft-tech/ci-github-nodejs/actions/setup-node@0.8.0
|
- uses: hoverkraft-tech/ci-github-nodejs/actions/setup-node@0.7.0
|
||||||
|
|
||||||
- name: Build dist/ Directory
|
- name: Build dist/ Directory
|
||||||
id: package
|
id: package
|
||||||
|
|||||||
2
.github/workflows/__check-nodejs.yml
vendored
2
.github/workflows/__check-nodejs.yml
vendored
@ -10,7 +10,7 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-nodejs:
|
test-nodejs:
|
||||||
uses: hoverkraft-tech/ci-github-nodejs/.github/workflows/continuous-integration.yml@0.8.0
|
uses: hoverkraft-tech/ci-github-nodejs/.github/workflows/continuous-integration.yml@0.7.0
|
||||||
permissions:
|
permissions:
|
||||||
id-token: write
|
id-token: write
|
||||||
security-events: write
|
security-events: write
|
||||||
|
|||||||
2
.github/workflows/__shared-ci.yml
vendored
2
.github/workflows/__shared-ci.yml
vendored
@ -12,7 +12,7 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
linter:
|
linter:
|
||||||
uses: hoverkraft-tech/ci-github-common/.github/workflows/linter.yml@0.17.0
|
uses: hoverkraft-tech/ci-github-common/.github/workflows/linter.yml@0.15.0
|
||||||
with:
|
with:
|
||||||
linter-env: |
|
linter-env: |
|
||||||
FILTER_REGEX_EXCLUDE=dist/**/*
|
FILTER_REGEX_EXCLUDE=dist/**/*
|
||||||
|
|||||||
2
.github/workflows/greetings.yml
vendored
2
.github/workflows/greetings.yml
vendored
@ -13,4 +13,4 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
greetings:
|
greetings:
|
||||||
uses: hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml@0.17.0
|
uses: hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml@0.15.0
|
||||||
|
|||||||
2
.github/workflows/main-ci.yml
vendored
2
.github/workflows/main-ci.yml
vendored
@ -37,7 +37,7 @@ jobs:
|
|||||||
app-id: ${{ vars.CI_BOT_APP_ID }}
|
app-id: ${{ vars.CI_BOT_APP_ID }}
|
||||||
private-key: ${{ secrets.CI_BOT_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.CI_BOT_APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
- uses: hoverkraft-tech/ci-github-common/actions/create-and-merge-pull-request@0.17.0
|
- uses: hoverkraft-tech/ci-github-common/actions/create-and-merge-pull-request@0.15.0
|
||||||
with:
|
with:
|
||||||
github-token: ${{ steps.generate-token.outputs.token }}
|
github-token: ${{ steps.generate-token.outputs.token }}
|
||||||
branch: docs/actions-workflows-documentation-update
|
branch: docs/actions-workflows-documentation-update
|
||||||
|
|||||||
2
.github/workflows/need-fix-to-issue.yml
vendored
2
.github/workflows/need-fix-to-issue.yml
vendored
@ -21,7 +21,7 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
uses: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml@0.17.0
|
uses: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml@0.15.0
|
||||||
with:
|
with:
|
||||||
manual-commit-ref: ${{ inputs.manual-commit-ref }}
|
manual-commit-ref: ${{ inputs.manual-commit-ref }}
|
||||||
manual-base-ref: ${{ inputs.manual-base-ref }}
|
manual-base-ref: ${{ inputs.manual-base-ref }}
|
||||||
|
|||||||
29
.github/workflows/release-new-action-version.yml
vendored
29
.github/workflows/release-new-action-version.yml
vendored
@ -1,29 +0,0 @@
|
|||||||
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@v0.3.0
|
|
||||||
with:
|
|
||||||
source-tag: ${{ env.TAG_NAME }}
|
|
||||||
2
.github/workflows/semantic-pull-request.yml
vendored
2
.github/workflows/semantic-pull-request.yml
vendored
@ -13,4 +13,4 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@0.17.0
|
uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@0.15.0
|
||||||
|
|||||||
2
.github/workflows/stale.yml
vendored
2
.github/workflows/stale.yml
vendored
@ -10,4 +10,4 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
uses: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml@0.17.0
|
uses: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml@0.15.0
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
20.9.0
|
20.6.0
|
||||||
|
|||||||
55
README.md
55
README.md
@ -19,7 +19,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- start description -->
|
<!-- start description -->
|
||||||
|
|
||||||
This action runs your compose file(s) and clean up before action finished
|
This action runs your docker-compose file and clean up before action finished
|
||||||
|
|
||||||
<!-- end description -->
|
<!-- end description -->
|
||||||
|
|
||||||
@ -30,47 +30,43 @@ This action runs your compose file(s) and clean up before action finished
|
|||||||
|
|
||||||
### Action
|
### Action
|
||||||
|
|
||||||
The action will run `docker compose up` to start the services defined in the given compose file(s).
|
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.
|
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.
|
Some extra options can be passed to the `docker-compose up` command using the `up-flags` input.
|
||||||
|
|
||||||
### Post hook
|
### Post hook
|
||||||
|
|
||||||
On post hook, the action will run `docker compose down` to clean up the services.
|
On post hook, the action will run `docker-compose down` to clean up the services.
|
||||||
In [debug mode](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/troubleshooting-workflows/enabling-debug-logging), the logs of the running services are printed before the cleanup.
|
In debug mode, the logs of the running services are printed before the cleanup.
|
||||||
|
|
||||||
Some extra options can be passed to the `docker compose down` command using the `down-flags` input.
|
Some extra options can be passed to the `docker-compose down` command using the `down-flags` input.
|
||||||
|
|
||||||
<!-- start usage -->
|
<!-- start usage -->
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: hoverkraft-tech/compose-action@v0.0.0
|
- uses: hoverkraft-tech/compose-action@v0.0.0
|
||||||
with:
|
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
|
# 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).
|
# absolute or relative to the current working directory (cwd).
|
||||||
#
|
#
|
||||||
# Default: ./docker-compose.yml
|
# Default: ./docker-compose.yml
|
||||||
compose-file: ""
|
compose-file: ""
|
||||||
|
|
||||||
# Description: Services to perform docker compose up.
|
# Description: Services to perform docker-compose up.
|
||||||
#
|
#
|
||||||
services: ""
|
services: ""
|
||||||
|
|
||||||
# Description: Additional options to pass to `docker compose up` command.
|
# Description: Additional options to pass to `docker-compose up` command.
|
||||||
#
|
#
|
||||||
# Default:
|
# Default:
|
||||||
up-flags: ""
|
up-flags: ""
|
||||||
|
|
||||||
# Description: Additional options to pass to `docker compose down` command.
|
# Description: Additional options to pass to `docker-compose down` command.
|
||||||
#
|
#
|
||||||
# Default:
|
# Default:
|
||||||
down-flags: ""
|
down-flags: ""
|
||||||
|
|
||||||
# Description: Additional options to pass to `docker compose` command.
|
# Description: Additional options to pass to `docker-compose` command.
|
||||||
#
|
#
|
||||||
# Default:
|
# Default:
|
||||||
compose-flags: ""
|
compose-flags: ""
|
||||||
@ -86,7 +82,7 @@ Some extra options can be passed to the `docker compose down` command using the
|
|||||||
compose-version: ""
|
compose-version: ""
|
||||||
|
|
||||||
# Description: The GitHub token used to create an authenticated client (to fetch
|
# Description: The GitHub token used to create an authenticated client (to fetch
|
||||||
# the latest version of docker compose).
|
# the latest version of docker-compose).
|
||||||
#
|
#
|
||||||
# Default: ${{ github.token }}
|
# Default: ${{ github.token }}
|
||||||
github-token: ""
|
github-token: ""
|
||||||
@ -100,15 +96,14 @@ Some extra options can be passed to the `docker compose down` command using the
|
|||||||
|
|
||||||
| **Input** | **Description** | **Default** | **Required** |
|
| **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>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>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>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>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>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>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>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>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** |
|
| <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 -->
|
<!-- end inputs -->
|
||||||
<!-- start outputs -->
|
<!-- start outputs -->
|
||||||
@ -130,14 +125,14 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Run docker compose
|
- name: Run docker-compose
|
||||||
uses: hoverkraft-tech/compose-action@v2.0.1
|
uses: hoverkraft-tech/compose-action@v2.0.1
|
||||||
with:
|
with:
|
||||||
compose-file: "./docker/docker-compose.yml"
|
compose-file: "./docker/docker-compose.yml"
|
||||||
|
|
||||||
- name: Execute tests in the running services
|
- name: Execute tests in the running services
|
||||||
run: |
|
run: |
|
||||||
docker compose exec test-app pytest
|
docker-compose exec test-app pytest
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- start [.github/ghadocs/examples/] -->
|
<!-- start [.github/ghadocs/examples/] -->
|
||||||
@ -157,7 +152,7 @@ steps:
|
|||||||
|
|
||||||
### Example using `services`
|
### Example using `services`
|
||||||
|
|
||||||
Perform `docker compose up` to some given service instead of all of them
|
Perform `docker-compose up` to some given service instead of all of them
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
@ -173,24 +168,24 @@ steps:
|
|||||||
|
|
||||||
### Example using `up-flags`
|
### Example using `up-flags`
|
||||||
|
|
||||||
Specify flags to pass to the `docker compose up`. Default is none. Can be used
|
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
|
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
|
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/).
|
[docker-compose up documentation](https://docs.docker.com/compose/reference/up/).
|
||||||
|
|
||||||
### Example using `down-flags`
|
### Example using `down-flags`
|
||||||
|
|
||||||
Specify flags to pass to the `docker compose down` command during cleanup.
|
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
|
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
|
want persistent volumes to be deleted as well during cleanup. A full list of
|
||||||
flags can be found in the
|
flags can be found in the
|
||||||
[docker compose down documentation](https://docs.docker.com/compose/reference/down/).
|
[docker-compose down documentation](https://docs.docker.com/compose/reference/down/).
|
||||||
|
|
||||||
### Example using `compose-flags`
|
### Example using `compose-flags`
|
||||||
|
|
||||||
Specify flags to pass to the `docker compose` command. Default is none. A full
|
Specify flags to pass to the `docker-compose` command. Default is none. A full
|
||||||
list of flags can be found in the
|
list of flags can be found in the
|
||||||
[docker compose documentation](https://docs.docker.com/compose/reference/#command-options-overview-and-help).
|
[docker-compose documentation](https://docs.docker.com/compose/reference/#command-options-overview-and-help).
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
15
action.yml
15
action.yml
@ -1,31 +1,28 @@
|
|||||||
name: "Docker Compose Action"
|
name: "Docker Compose Action"
|
||||||
description: "This action runs your compose file(s) and clean up before action finished"
|
description: "This action runs your docker-compose file and clean up before action finished"
|
||||||
author: "Hoverkraft"
|
author: "Hoverkraft"
|
||||||
branding:
|
branding:
|
||||||
icon: anchor
|
icon: anchor
|
||||||
color: gray-dark
|
color: gray-dark
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
docker-flags:
|
|
||||||
description: "Additional options to pass to `docker` command."
|
|
||||||
required: false
|
|
||||||
compose-file:
|
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)."
|
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
|
required: false
|
||||||
default: "./docker-compose.yml"
|
default: "./docker-compose.yml"
|
||||||
services:
|
services:
|
||||||
description: "Services to perform docker compose up."
|
description: "Services to perform docker-compose up."
|
||||||
required: false
|
required: false
|
||||||
up-flags:
|
up-flags:
|
||||||
description: "Additional options to pass to `docker compose up` command."
|
description: "Additional options to pass to `docker-compose up` command."
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
down-flags:
|
down-flags:
|
||||||
description: "Additional options to pass to `docker compose down` command."
|
description: "Additional options to pass to `docker-compose down` command."
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
compose-flags:
|
compose-flags:
|
||||||
description: "Additional options to pass to `docker compose` command."
|
description: "Additional options to pass to `docker-compose` command."
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
cwd:
|
cwd:
|
||||||
@ -39,7 +36,7 @@ inputs:
|
|||||||
If "latest", it will install the latest version.
|
If "latest", it will install the latest version.
|
||||||
required: false
|
required: false
|
||||||
github-token:
|
github-token:
|
||||||
description: The GitHub token used to create an authenticated client (to fetch the latest version of docker compose).
|
description: The GitHub token used to create an authenticated client (to fetch the latest version of docker-compose).
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
|
|||||||
1269
dist/index.js
generated
vendored
1269
dist/index.js
generated
vendored
File diff suppressed because it is too large
Load Diff
13
dist/licenses.txt
generated
vendored
13
dist/licenses.txt
generated
vendored
@ -625,6 +625,19 @@ Permission to use, copy, modify, and/or distribute this software for any purpose
|
|||||||
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.
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
uuid
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2010-2020 Robert Kieffer and other 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.
|
||||||
|
|
||||||
|
|
||||||
wrappy
|
wrappy
|
||||||
ISC
|
ISC
|
||||||
The ISC License
|
The ISC License
|
||||||
|
|||||||
2354
dist/post.js
generated
vendored
2354
dist/post.js
generated
vendored
File diff suppressed because it is too large
Load Diff
3442
package-lock.json
generated
3442
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -76,10 +76,10 @@
|
|||||||
"@actions/github": "^6.0.0",
|
"@actions/github": "^6.0.0",
|
||||||
"@actions/tool-cache": "^2.0.1",
|
"@actions/tool-cache": "^2.0.1",
|
||||||
"@octokit/action": "^7.0.0",
|
"@octokit/action": "^7.0.0",
|
||||||
|
"@ts-dev-tools/core": "^1.8.8",
|
||||||
"docker-compose": "^1.1.0"
|
"docker-compose": "^1.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ts-dev-tools/core": "^1.8.8",
|
|
||||||
"@vercel/ncc": "^0.38.1",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"eslint-plugin-github": "^5.0.1",
|
"eslint-plugin-github": "^5.0.1",
|
||||||
"eslint-plugin-jsonc": "^2.14.1"
|
"eslint-plugin-jsonc": "^2.14.1"
|
||||||
|
|||||||
@ -5,15 +5,15 @@ import { DockerComposeInstallerService } from "./services/docker-compose-install
|
|||||||
import * as indexRunner from "./index-runner";
|
import * as indexRunner from "./index-runner";
|
||||||
import { DockerComposeService } from "./services/docker-compose.service";
|
import { DockerComposeService } from "./services/docker-compose.service";
|
||||||
|
|
||||||
describe("run", () => {
|
// Mock the external libraries and services used by the action
|
||||||
// Mock the external libraries and services used by the action
|
let infoMock: jest.SpiedFunction<typeof LoggerService.prototype.info>;
|
||||||
let infoMock: jest.SpiedFunction<typeof LoggerService.prototype.info>;
|
let debugMock: jest.SpiedFunction<typeof LoggerService.prototype.debug>;
|
||||||
let debugMock: jest.SpiedFunction<typeof LoggerService.prototype.debug>;
|
let setFailedMock: jest.SpiedFunction<typeof core.setFailed>;
|
||||||
let setFailedMock: jest.SpiedFunction<typeof core.setFailed>;
|
let getInputsMock: jest.SpiedFunction<typeof InputService.prototype.getInputs>;
|
||||||
let getInputsMock: jest.SpiedFunction<typeof InputService.prototype.getInputs>;
|
let installMock: jest.SpiedFunction<typeof DockerComposeInstallerService.prototype.install>;
|
||||||
let installMock: jest.SpiedFunction<typeof DockerComposeInstallerService.prototype.install>;
|
let upMock: jest.SpiedFunction<typeof DockerComposeService.prototype.up>;
|
||||||
let upMock: jest.SpiedFunction<typeof DockerComposeService.prototype.up>;
|
|
||||||
|
|
||||||
|
describe("run", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
|
|
||||||
@ -28,7 +28,6 @@ describe("run", () => {
|
|||||||
it("should install docker compose with specified version", async () => {
|
it("should install docker compose with specified version", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
getInputsMock.mockImplementation(() => ({
|
getInputsMock.mockImplementation(() => ({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
services: [],
|
services: [],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
@ -50,7 +49,7 @@ describe("run", () => {
|
|||||||
expect(infoMock).toHaveBeenCalledWith("Setting up docker compose version 1.29.2");
|
expect(infoMock).toHaveBeenCalledWith("Setting up docker compose version 1.29.2");
|
||||||
|
|
||||||
expect(debugMock).toHaveBeenCalledWith(
|
expect(debugMock).toHaveBeenCalledWith(
|
||||||
'inputs: {"dockerFlags":[],"composeFiles":["docker-compose.yml"],"services":[],"composeFlags":[],"upFlags":[],"downFlags":[],"cwd":"/current/working/dir","composeVersion":"1.29.2","githubToken":null}'
|
'inputs: {"composeFiles":["docker-compose.yml"],"services":[],"composeFlags":[],"upFlags":[],"downFlags":[],"cwd":"/current/working/dir","composeVersion":"1.29.2","githubToken":null}'
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(installMock).toHaveBeenCalledWith({
|
expect(installMock).toHaveBeenCalledWith({
|
||||||
@ -60,13 +59,11 @@ describe("run", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(upMock).toHaveBeenCalledWith({
|
expect(upMock).toHaveBeenCalledWith({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
upFlags: [],
|
upFlags: [],
|
||||||
services: [],
|
services: [],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(setFailedMock).not.toHaveBeenCalled();
|
expect(setFailedMock).not.toHaveBeenCalled();
|
||||||
@ -75,7 +72,6 @@ describe("run", () => {
|
|||||||
it("should bring up docker compose services", async () => {
|
it("should bring up docker compose services", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
getInputsMock.mockImplementation(() => ({
|
getInputsMock.mockImplementation(() => ({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
services: ["web"],
|
services: ["web"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
@ -91,13 +87,11 @@ describe("run", () => {
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(upMock).toHaveBeenCalledWith({
|
expect(upMock).toHaveBeenCalledWith({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
upFlags: [],
|
upFlags: [],
|
||||||
services: ["web"],
|
services: ["web"],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
expect(setFailedMock).not.toHaveBeenCalled();
|
expect(setFailedMock).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -108,7 +102,6 @@ describe("run", () => {
|
|||||||
upMock.mockRejectedValue(error);
|
upMock.mockRejectedValue(error);
|
||||||
|
|
||||||
getInputsMock.mockImplementation(() => ({
|
getInputsMock.mockImplementation(() => ({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
services: ["web"],
|
services: ["web"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
@ -132,7 +125,6 @@ describe("run", () => {
|
|||||||
upMock.mockRejectedValue(error);
|
upMock.mockRejectedValue(error);
|
||||||
|
|
||||||
getInputsMock.mockImplementation(() => ({
|
getInputsMock.mockImplementation(() => ({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
services: ["web"],
|
services: ["web"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
|
|||||||
@ -36,13 +36,11 @@ export async function run(): Promise<void> {
|
|||||||
|
|
||||||
loggerService.info("Bringing up docker compose service(s)");
|
loggerService.info("Bringing up docker compose service(s)");
|
||||||
await dockerComposeService.up({
|
await dockerComposeService.up({
|
||||||
dockerFlags: inputs.dockerFlags,
|
|
||||||
composeFiles: inputs.composeFiles,
|
composeFiles: inputs.composeFiles,
|
||||||
composeFlags: inputs.composeFlags,
|
composeFlags: inputs.composeFlags,
|
||||||
cwd: inputs.cwd,
|
cwd: inputs.cwd,
|
||||||
upFlags: inputs.upFlags,
|
upFlags: inputs.upFlags,
|
||||||
services: inputs.services,
|
services: inputs.services,
|
||||||
debug: loggerService.debug,
|
|
||||||
});
|
});
|
||||||
loggerService.info("docker compose service(s) are up");
|
loggerService.info("docker compose service(s) are up");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -25,7 +25,6 @@ describe("index", () => {
|
|||||||
|
|
||||||
it("calls run when imported", async () => {
|
it("calls run when imported", async () => {
|
||||||
getInputsMock.mockImplementation(() => ({
|
getInputsMock.mockImplementation(() => ({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
services: [],
|
services: [],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
@ -49,19 +48,17 @@ describe("index", () => {
|
|||||||
// Verify that all of the functions were called correctly
|
// Verify that all of the functions were called correctly
|
||||||
expect(debugMock).toHaveBeenNthCalledWith(
|
expect(debugMock).toHaveBeenNthCalledWith(
|
||||||
1,
|
1,
|
||||||
'inputs: {"dockerFlags":[],"composeFiles":["docker-compose.yml"],"services":[],"composeFlags":[],"upFlags":[],"downFlags":[],"cwd":"/current/working/dir","composeVersion":null,"githubToken":null}'
|
'inputs: {"composeFiles":["docker-compose.yml"],"services":[],"composeFlags":[],"upFlags":[],"downFlags":[],"cwd":"/current/working/dir","composeVersion":null,"githubToken":null}'
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(infoMock).toHaveBeenNthCalledWith(3, "Bringing up docker compose service(s)");
|
expect(infoMock).toHaveBeenNthCalledWith(3, "Bringing up docker compose service(s)");
|
||||||
|
|
||||||
expect(upMock).toHaveBeenCalledWith({
|
expect(upMock).toHaveBeenCalledWith({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
services: [],
|
services: [],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
upFlags: [],
|
upFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(setFailedMock).not.toHaveBeenCalled();
|
expect(setFailedMock).not.toHaveBeenCalled();
|
||||||
|
|||||||
@ -27,7 +27,6 @@ describe("run", () => {
|
|||||||
it("should bring down docker compose service(s) and log output", async () => {
|
it("should bring down docker compose service(s) and log output", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
getInputsMock.mockImplementation(() => ({
|
getInputsMock.mockImplementation(() => ({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
services: [],
|
services: [],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
@ -47,21 +46,17 @@ describe("run", () => {
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(logsMock).toHaveBeenCalledWith({
|
expect(logsMock).toHaveBeenCalledWith({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
services: [],
|
services: [],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(downMock).toHaveBeenCalledWith({
|
expect(downMock).toHaveBeenCalledWith({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
downFlags: [],
|
downFlags: [],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(debugMock).toHaveBeenCalledWith("docker compose logs:\ntest logs");
|
expect(debugMock).toHaveBeenCalledWith("docker compose logs:\ntest logs");
|
||||||
@ -74,7 +69,6 @@ describe("run", () => {
|
|||||||
it("should log docker composer errors if any", async () => {
|
it("should log docker composer errors if any", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
getInputsMock.mockImplementation(() => ({
|
getInputsMock.mockImplementation(() => ({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
services: [],
|
services: [],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
@ -100,18 +94,14 @@ describe("run", () => {
|
|||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
dockerFlags: [],
|
|
||||||
services: [],
|
services: [],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(downMock).toHaveBeenCalledWith({
|
expect(downMock).toHaveBeenCalledWith({
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
dockerFlags: [],
|
|
||||||
downFlags: [],
|
downFlags: [],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(debugMock).toHaveBeenCalledWith("docker compose error:\ntest logs error");
|
expect(debugMock).toHaveBeenCalledWith("docker compose error:\ntest logs error");
|
||||||
@ -139,7 +129,6 @@ describe("run", () => {
|
|||||||
downMock.mockRejectedValue(error);
|
downMock.mockRejectedValue(error);
|
||||||
|
|
||||||
getInputsMock.mockImplementation(() => ({
|
getInputsMock.mockImplementation(() => ({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
services: ["web"],
|
services: ["web"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
@ -163,7 +152,6 @@ describe("run", () => {
|
|||||||
downMock.mockRejectedValue(error);
|
downMock.mockRejectedValue(error);
|
||||||
|
|
||||||
getInputsMock.mockImplementation(() => ({
|
getInputsMock.mockImplementation(() => ({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
services: ["web"],
|
services: ["web"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
|
|||||||
@ -16,12 +16,10 @@ export async function run(): Promise<void> {
|
|||||||
const inputs = inputService.getInputs();
|
const inputs = inputService.getInputs();
|
||||||
|
|
||||||
const { error, output } = await dockerComposeService.logs({
|
const { error, output } = await dockerComposeService.logs({
|
||||||
dockerFlags: inputs.dockerFlags,
|
|
||||||
composeFiles: inputs.composeFiles,
|
composeFiles: inputs.composeFiles,
|
||||||
composeFlags: inputs.composeFlags,
|
composeFlags: inputs.composeFlags,
|
||||||
cwd: inputs.cwd,
|
cwd: inputs.cwd,
|
||||||
services: inputs.services,
|
services: inputs.services,
|
||||||
debug: loggerService.debug,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
@ -31,12 +29,10 @@ export async function run(): Promise<void> {
|
|||||||
loggerService.debug("docker compose logs:\n" + output);
|
loggerService.debug("docker compose logs:\n" + output);
|
||||||
|
|
||||||
await dockerComposeService.down({
|
await dockerComposeService.down({
|
||||||
dockerFlags: inputs.dockerFlags,
|
|
||||||
composeFiles: inputs.composeFiles,
|
composeFiles: inputs.composeFiles,
|
||||||
composeFlags: inputs.composeFlags,
|
composeFlags: inputs.composeFlags,
|
||||||
cwd: inputs.cwd,
|
cwd: inputs.cwd,
|
||||||
downFlags: inputs.downFlags,
|
downFlags: inputs.downFlags,
|
||||||
debug: loggerService.debug,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
loggerService.info("docker compose is down");
|
loggerService.info("docker compose is down");
|
||||||
|
|||||||
@ -24,7 +24,6 @@ describe("post", () => {
|
|||||||
|
|
||||||
it("calls run when imported", async () => {
|
it("calls run when imported", async () => {
|
||||||
getInputsMock.mockImplementation(() => ({
|
getInputsMock.mockImplementation(() => ({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
services: [],
|
services: [],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
@ -43,21 +42,17 @@ describe("post", () => {
|
|||||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||||
|
|
||||||
expect(logsMock).toHaveBeenCalledWith({
|
expect(logsMock).toHaveBeenCalledWith({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
services: [],
|
services: [],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(downMock).toHaveBeenCalledWith({
|
expect(downMock).toHaveBeenCalledWith({
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
downFlags: [],
|
downFlags: [],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(debugMock).toHaveBeenNthCalledWith(1, "docker compose logs:\ntest logs");
|
expect(debugMock).toHaveBeenNthCalledWith(1, "docker compose logs:\ntest logs");
|
||||||
|
|||||||
@ -25,13 +25,11 @@ describe("DockerComposeService", () => {
|
|||||||
describe("up", () => {
|
describe("up", () => {
|
||||||
it("should call up with correct options", async () => {
|
it("should call up with correct options", async () => {
|
||||||
const upInputs: UpInputs = {
|
const upInputs: UpInputs = {
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
services: [],
|
services: [],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
upFlags: [],
|
upFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
debug: jest.fn(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await service.up(upInputs);
|
await service.up(upInputs);
|
||||||
@ -40,50 +38,18 @@ describe("DockerComposeService", () => {
|
|||||||
composeOptions: [],
|
composeOptions: [],
|
||||||
commandOptions: [],
|
commandOptions: [],
|
||||||
config: ["docker-compose.yml"],
|
config: ["docker-compose.yml"],
|
||||||
executable: {
|
log: true,
|
||||||
executablePath: "docker",
|
|
||||||
options: [],
|
|
||||||
},
|
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
callback: expect.any(Function),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
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",
|
|
||||||
debug: 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 () => {
|
it("should call up with specific services", async () => {
|
||||||
const upInputs: UpInputs = {
|
const upInputs: UpInputs = {
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
services: ["helloworld2", "helloworld3"],
|
services: ["helloworld2", "helloworld3"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
upFlags: ["--build"],
|
upFlags: ["--build"],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
debug: jest.fn(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await service.up(upInputs);
|
await service.up(upInputs);
|
||||||
@ -92,12 +58,8 @@ describe("DockerComposeService", () => {
|
|||||||
composeOptions: [],
|
composeOptions: [],
|
||||||
commandOptions: ["--build"],
|
commandOptions: ["--build"],
|
||||||
config: ["docker-compose.yml"],
|
config: ["docker-compose.yml"],
|
||||||
|
log: true,
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
callback: expect.any(Function),
|
|
||||||
executable: {
|
|
||||||
executablePath: "docker",
|
|
||||||
options: [],
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -105,12 +67,10 @@ describe("DockerComposeService", () => {
|
|||||||
describe("down", () => {
|
describe("down", () => {
|
||||||
it("should call down with correct options", async () => {
|
it("should call down with correct options", async () => {
|
||||||
const downInputs: DownInputs = {
|
const downInputs: DownInputs = {
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: [],
|
composeFiles: [],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
downFlags: ["--volumes", "--remove-orphans"],
|
downFlags: ["--volumes", "--remove-orphans"],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
debug: jest.fn(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await service.down(downInputs);
|
await service.down(downInputs);
|
||||||
@ -119,26 +79,19 @@ describe("DockerComposeService", () => {
|
|||||||
composeOptions: [],
|
composeOptions: [],
|
||||||
commandOptions: ["--volumes", "--remove-orphans"],
|
commandOptions: ["--volumes", "--remove-orphans"],
|
||||||
config: [],
|
config: [],
|
||||||
executable: {
|
log: true,
|
||||||
executablePath: "docker",
|
|
||||||
options: [],
|
|
||||||
},
|
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
callback: expect.any(Function),
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("logs", () => {
|
describe("logs", () => {
|
||||||
it("should call logs with correct options", async () => {
|
it("should call logs with correct options", async () => {
|
||||||
const debugMock = jest.fn();
|
|
||||||
const logsInputs: LogsInputs = {
|
const logsInputs: LogsInputs = {
|
||||||
dockerFlags: [],
|
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
services: ["helloworld2", "helloworld3"],
|
services: ["helloworld2", "helloworld3"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
debug: debugMock,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
logsMock.mockResolvedValue({ exitCode: 0, err: "", out: "logs" });
|
logsMock.mockResolvedValue({ exitCode: 0, err: "", out: "logs" });
|
||||||
@ -148,13 +101,9 @@ describe("DockerComposeService", () => {
|
|||||||
expect(dockerCompose.logs).toHaveBeenCalledWith(["helloworld2", "helloworld3"], {
|
expect(dockerCompose.logs).toHaveBeenCalledWith(["helloworld2", "helloworld3"], {
|
||||||
composeOptions: [],
|
composeOptions: [],
|
||||||
config: ["docker-compose.yml"],
|
config: ["docker-compose.yml"],
|
||||||
|
log: true,
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
executable: {
|
|
||||||
executablePath: "docker",
|
|
||||||
options: [],
|
|
||||||
},
|
|
||||||
follow: false,
|
follow: false,
|
||||||
callback: expect.any(Function),
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,11 +9,9 @@ import {
|
|||||||
import { Inputs } from "./input.service";
|
import { Inputs } from "./input.service";
|
||||||
|
|
||||||
type OptionsInputs = {
|
type OptionsInputs = {
|
||||||
dockerFlags: Inputs["dockerFlags"];
|
|
||||||
composeFiles: Inputs["composeFiles"];
|
composeFiles: Inputs["composeFiles"];
|
||||||
composeFlags: Inputs["composeFlags"];
|
composeFlags: Inputs["composeFlags"];
|
||||||
cwd: Inputs["cwd"];
|
cwd: Inputs["cwd"];
|
||||||
debug: (message: string) => void;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpInputs = OptionsInputs & { upFlags: Inputs["upFlags"]; services: Inputs["services"] };
|
export type UpInputs = OptionsInputs & { upFlags: Inputs["upFlags"]; services: Inputs["services"] };
|
||||||
@ -62,21 +60,15 @@ export class DockerComposeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getCommonOptions({
|
private getCommonOptions({
|
||||||
dockerFlags,
|
|
||||||
composeFiles,
|
composeFiles,
|
||||||
composeFlags,
|
composeFlags,
|
||||||
cwd,
|
cwd,
|
||||||
debug,
|
|
||||||
}: OptionsInputs): IDockerComposeOptions {
|
}: OptionsInputs): IDockerComposeOptions {
|
||||||
return {
|
return {
|
||||||
config: composeFiles,
|
config: composeFiles,
|
||||||
|
log: true,
|
||||||
composeOptions: composeFlags,
|
composeOptions: composeFlags,
|
||||||
cwd: cwd,
|
cwd: cwd,
|
||||||
callback: (chunk) => debug(chunk.toString()),
|
|
||||||
executable: {
|
|
||||||
executablePath: "docker",
|
|
||||||
options: dockerFlags,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,14 @@
|
|||||||
import * as core from "@actions/core";
|
|
||||||
import fs from "fs";
|
|
||||||
import { InputService, InputNames } from "./input.service";
|
import { InputService, InputNames } from "./input.service";
|
||||||
|
import * as core from "@actions/core";
|
||||||
|
import * as fs from "fs";
|
||||||
|
|
||||||
|
jest.mock("fs", () => ({
|
||||||
|
existsSync: jest.fn(),
|
||||||
|
promises: {
|
||||||
|
access: jest.fn(),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
jest.mock("@actions/core");
|
||||||
|
|
||||||
describe("InputService", () => {
|
describe("InputService", () => {
|
||||||
let service: InputService;
|
let service: InputService;
|
||||||
@ -9,13 +17,11 @@ describe("InputService", () => {
|
|||||||
let existsSyncMock: jest.SpiedFunction<typeof fs.existsSync>;
|
let existsSyncMock: jest.SpiedFunction<typeof fs.existsSync>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
service = new InputService();
|
||||||
|
|
||||||
existsSyncMock = jest.spyOn(fs, "existsSync").mockImplementation();
|
existsSyncMock = jest.spyOn(fs, "existsSync").mockImplementation();
|
||||||
getInputMock = jest.spyOn(core, "getInput").mockImplementation();
|
getInputMock = jest.spyOn(core, "getInput").mockImplementation();
|
||||||
getMultilineInputMock = jest.spyOn(core, "getMultilineInput").mockImplementation();
|
getMultilineInputMock = jest.spyOn(core, "getMultilineInput").mockImplementation();
|
||||||
|
|
||||||
service = new InputService();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -23,53 +29,6 @@ describe("InputService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("getInputs", () => {
|
describe("getInputs", () => {
|
||||||
describe("docker-flags", () => {
|
|
||||||
it("should return given docker-flags input", () => {
|
|
||||||
getMultilineInputMock.mockImplementation((inputName) => {
|
|
||||||
switch (inputName) {
|
|
||||||
case InputNames.ComposeFile:
|
|
||||||
return ["file1"];
|
|
||||||
default:
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
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", () => {
|
|
||||||
getMultilineInputMock.mockImplementation((inputName) => {
|
|
||||||
switch (inputName) {
|
|
||||||
case InputNames.ComposeFile:
|
|
||||||
return ["file1"];
|
|
||||||
default:
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
getInputMock.mockReturnValue("");
|
|
||||||
|
|
||||||
existsSyncMock.mockReturnValue(true);
|
|
||||||
|
|
||||||
const inputs = service.getInputs();
|
|
||||||
|
|
||||||
expect(inputs.dockerFlags).toEqual([]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("composeFiles", () => {
|
describe("composeFiles", () => {
|
||||||
it("should return given composeFiles input", () => {
|
it("should return given composeFiles input", () => {
|
||||||
getMultilineInputMock.mockImplementation((inputName) => {
|
getMultilineInputMock.mockImplementation((inputName) => {
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import { existsSync } from "fs";
|
|||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
|
||||||
export type Inputs = {
|
export type Inputs = {
|
||||||
dockerFlags: string[];
|
|
||||||
composeFiles: string[];
|
composeFiles: string[];
|
||||||
services: string[];
|
services: string[];
|
||||||
composeFlags: string[];
|
composeFlags: string[];
|
||||||
@ -15,7 +14,6 @@ export type Inputs = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export enum InputNames {
|
export enum InputNames {
|
||||||
DockerFlags = "docker-flags",
|
|
||||||
ComposeFile = "compose-file",
|
ComposeFile = "compose-file",
|
||||||
Services = "services",
|
Services = "services",
|
||||||
ComposeFlags = "compose-flags",
|
ComposeFlags = "compose-flags",
|
||||||
@ -31,7 +29,6 @@ export const COMPOSE_VERSION_LATEST = "latest";
|
|||||||
export class InputService {
|
export class InputService {
|
||||||
getInputs(): Inputs {
|
getInputs(): Inputs {
|
||||||
return {
|
return {
|
||||||
dockerFlags: this.getDockerFlags(),
|
|
||||||
composeFiles: this.getComposeFiles(),
|
composeFiles: this.getComposeFiles(),
|
||||||
services: this.getServices(),
|
services: this.getServices(),
|
||||||
composeFlags: this.getComposeFlags(),
|
composeFlags: this.getComposeFlags(),
|
||||||
@ -43,10 +40,6 @@ export class InputService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDockerFlags(): string[] {
|
|
||||||
return this.parseFlags(getInput(InputNames.DockerFlags));
|
|
||||||
}
|
|
||||||
|
|
||||||
private getComposeFiles(): string[] {
|
private getComposeFiles(): string[] {
|
||||||
const cwd = this.getCwd();
|
const cwd = this.getCwd();
|
||||||
const composeFiles = getMultilineInput(InputNames.ComposeFile).filter((composeFile: string) => {
|
const composeFiles = getMultilineInput(InputNames.ComposeFile).filter((composeFile: string) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user