diff --git a/.github/workflows/plugin-lint.yaml b/.github/workflows/plugin-lint.yaml index 47fe856..bed8aae 100644 --- a/.github/workflows/plugin-lint.yaml +++ b/.github/workflows/plugin-lint.yaml @@ -1,4 +1,4 @@ -name: Plugin Lint +name: Plugin Linting & Testing on: pull_request: @@ -16,6 +16,6 @@ jobs: - name: Lint run: docker compose run --rm lint -# TODO: Setup testing once we begin the flesh out the plugin -# - name: Test -# run: docker compose run --rm tests + + - name: Test + run: docker compose run --rm tests diff --git a/.gitignore b/.gitignore index 5f38968..4b07725 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ # VIM swap files *.swp src/*.html + +# Go Release artifacts +src/dist \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 67fbb96..1ae8dad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,7 @@ services: image: buildkite/plugin-tester:v4.0.0 volumes: - ".:/plugin" + build: build: context: src diff --git a/src/plugin/config.go b/src/plugin/config.go index e3d07fd..6c6527e 100644 --- a/src/plugin/config.go +++ b/src/plugin/config.go @@ -11,7 +11,7 @@ type Config struct { type EnvironmentConfigFetcher struct { } -const pluginEnvironmentPrefix = "BUILDKITE_PLUGIN_EXAMPLE_GO" +const pluginEnvironmentPrefix = "BUILDKITE_PLUGIN_ECS_TASK_RUNNER" func (f EnvironmentConfigFetcher) Fetch(config *Config) error { return envconfig.Process(pluginEnvironmentPrefix, config) diff --git a/tests/download.bats b/tests/download.bats new file mode 100755 index 0000000..5ea6f14 --- /dev/null +++ b/tests/download.bats @@ -0,0 +1,50 @@ +#!/usr/bin/env bats + +load '/usr/local/lib/bats/load.bash' + +load '../lib/download.bash' + +# +# Tests for top-level docker bootstrap command. The rest of the plugin runs in Go. +# + +# Uncomment the following line to debug stub failures +# export [stub_command]_STUB_DEBUG=/dev/tty +#export DOCKER_STUB_DEBUG=/dev/tty + +#TODO: Update this to reflect what we need to test in the task runner code +setup() { + export BUILDKITE_PLUGIN_ECR_TASK_RUNNER_BUILDKITE_PLUGIN_MESSAGE=true +} + +#TODO: Update this to reflect what we need to test in the task runner code +teardown() { + unset BUILDKITE_PLUGIN_ECR_TASK_RUNNER_BUILDKITE_PLUGIN_MESSAGE + rm ./ecs-task-runner-buildkite-plugin || true +} + +create_script() { +cat > "$1" << EOM +set -euo pipefail + +echo "executing $1:\$@" + +EOM +} + +@test "Downloads and runs the command for the current architecture" { + + function downloader() { + echo "$@"; + create_script $2 + } + export -f downloader + + run download_binary_and_run + + unset downloader + + assert_success + assert_line --regexp "https://github.com/cultureamp/ecs-task-runner-buildkite-plugin/releases/latest/download/ecs-task-runner-buildkite-plugin_linux_amd64 ecs-task-runner-buildkite-plugin" + assert_line --regexp "executing ecs-task-runner-buildkite-plugin" +}