Skip to content

Commit

Permalink
chore: tweaks following end-to-end verification (#7)
Browse files Browse the repository at this point in the history
* chore: releases may be locally tested, avoid committing these

* fix: BK plugin env var must be prefixed after repo

* ci: run Buildkite plugin-specific tests
  • Loading branch information
therealvio authored Dec 3, 2024
1 parent b1ac70b commit 1e4f6bc
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/plugin-lint.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Plugin Lint
name: Plugin Linting & Testing

on:
pull_request:
Expand All @@ -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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
# VIM swap files
*.swp
src/*.html

# Go Release artifacts
src/dist
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
image: buildkite/plugin-tester:v4.0.0
volumes:
- ".:/plugin"

build:
build:
context: src
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
50 changes: 50 additions & 0 deletions tests/download.bats
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 1e4f6bc

Please sign in to comment.