-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 22c90b6
Showing
8 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
steps: | ||
- label: run bats tests | ||
command: tests/ | ||
plugins: | ||
${BUILDKITE_REPO}#${BUILDKITE_COMMIT}: | ||
run: tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM lucor/bats | ||
|
||
ENV LIBS_BATS_MOCK_VERSION "1.0.1" | ||
RUN mkdir -p /usr/local/lib/bats/bats-mock \ | ||
&& curl -sSL https://github.com/lox/bats-mock/archive/master.tar.gz -o /tmp/bats-mock.tgz \ | ||
&& tar -zxf /tmp/bats-mock.tgz -C /usr/local/lib/bats/bats-mock --strip 1 \ | ||
&& printf 'source "%s"\n' "/usr/local/lib/bats/bats-mock/stub.bash" >> /usr/local/lib/bats/load.bash \ | ||
&& rm -rf /tmp/bats-mock.tgz | ||
|
||
RUN apk --no-cache add ncurses | ||
|
||
WORKDIR /app | ||
ENTRYPOINT ["/usr/local/bin/bats"] | ||
CMD ["tests/"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2017 Buildkite | ||
|
||
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Docker Buildkite Plugin | ||
|
||
A simple [Buildkite](https://buildkite.com/) Docker plugin allowing you to run a command in a Docker container. If you need more control, please see the [docker-compose Buildkite Plugin](https://github.com/buildkite-plugins/docker-compose-buildkite-plugin). | ||
|
||
## Example | ||
|
||
The following pipeline will run `yarn install && yarn run test` inside a Docker container: | ||
|
||
```yml | ||
steps: | ||
- command: yarn install && yarn run test | ||
plugins: | ||
docker#v1.0.0: | ||
image: "node:7" | ||
workdir: /app | ||
``` | ||
## Configuration | ||
### `image` | ||
|
||
The name of the Docker image to use. For example, `node:7`. | ||
|
||
### `workdir` | ||
|
||
The working directory where the pipeline’s code will be mounted to, and run from, inside the container. For example, `/app`. | ||
|
||
## License | ||
|
||
MIT (see [LICENSE](LICENSE)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: '2' | ||
services: | ||
tests: | ||
build: . | ||
volumes: | ||
- .:/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
docker run \ | ||
-it \ | ||
--rm \ | ||
-v "$(pwd):${BUILDKITE_PLUGIN_DOCKER_WORKDIR}" \ | ||
"${BUILDKITE_PLUGIN_DOCKER_IMAGE}" \ | ||
bash -c "${BUILDKITE_COMMAND}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "docker", | ||
"description": "Run any CI step in an isolated Docker containers using Docker", | ||
"author": "@buildkite", | ||
"public": true, | ||
"requirements": ["docker"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bats | ||
|
||
load '/usr/local/lib/bats/load.bash' | ||
|
||
export DOCKER_STUB_DEBUG=/dev/tty | ||
|
||
@test "Runs the command using docker" { | ||
export BUILDKITE_PLUGIN_DOCKER_WORKDIR=/app | ||
export BUILDKITE_PLUGIN_DOCKER_IMAGE=image:tag | ||
export BUILDKITE_COMMAND="command1 \"a string\" && command2" | ||
|
||
stub docker \ | ||
"run -it --rm -v $PWD:/app image:tag bash -c 'command1 \"a string\" && command2' : echo ran command in docker" | ||
|
||
run $PWD/hooks/command | ||
|
||
unstub docker | ||
assert_success | ||
assert_output --partial "ran command in docker" | ||
} |