From f1b0a1004dd805156f3197c22427f57c586c1b15 Mon Sep 17 00:00:00 2001 From: Lachlan Donald Date: Tue, 5 Sep 2017 10:52:27 +1000 Subject: [PATCH] Initial commit --- .buildkite/pipeline.yml | 5 +++++ LICENSE | 22 ++++++++++++++++++++++ README.md | 15 +++++++++++++++ docker-compose.yml | 6 ++++++ hooks/post-checkout | 11 +++++++++++ plugin.json | 6 ++++++ tests/command.bats | 19 +++++++++++++++++++ 7 files changed, 84 insertions(+) create mode 100644 .buildkite/pipeline.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100755 hooks/post-checkout create mode 100644 plugin.json create mode 100644 tests/command.bats diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml new file mode 100644 index 0000000..6039938 --- /dev/null +++ b/.buildkite/pipeline.yml @@ -0,0 +1,5 @@ +steps: + - label: "🤡 :hammer:" + plugins: + docker-compose#v1.3.1: + run: tests diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fbbacd6 --- /dev/null +++ b/LICENSE @@ -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. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..4d27f58 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# Clown Detection Buildkite Plugin + +A [Buildkite](https://buildkite.com/) plugin for detecting whether your code has any clowns in it. + +## Example + +```yml +steps: + - plugins: + detect-clowns#v1.0.0 +``` + +## License + +MIT (see [LICENSE](LICENSE)) \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..0d4b1ec --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,6 @@ +version: '2' +services: + tests: + image: buildkite/plugin-tester + volumes: + - ".:/plugin:ro" diff --git a/hooks/post-checkout b/hooks/post-checkout new file mode 100755 index 0000000..023af20 --- /dev/null +++ b/hooks/post-checkout @@ -0,0 +1,11 @@ +#!/bin/bash +set -euo pipefail + +echo "--- Searching for Clowns 🤡" +echo "$BUILDKITE_BUILD_CHECKOUT_PATH" + +if grep -inIEr --color=ALWAYS -C1 "🤡" . ; then + echo "^^^ +++" + echo "+++ :warning: Detected clowns! 🔪" + exit 1 +fi \ No newline at end of file diff --git a/plugin.json b/plugin.json new file mode 100644 index 0000000..6dc6bfb --- /dev/null +++ b/plugin.json @@ -0,0 +1,6 @@ +{ + "name": "detect-clowns ", + "description": "Detects clown emojis in your codebase", + "author": "@buildkite", + "public": true +} \ No newline at end of file diff --git a/tests/command.bats b/tests/command.bats new file mode 100644 index 0000000..538345d --- /dev/null +++ b/tests/command.bats @@ -0,0 +1,19 @@ +#!/usr/bin/env bats + +load '/usr/local/lib/bats/load.bash' + +@test "Post-checkout filters clowns" { + tmp_dir=$(mktemp -d -t clowns-checkout) + hook_path="$PWD/hooks/post-checkout" + + cd "$tmp_dir" + echo "Beware the clowns! 🤡" > clowns.txt + + export BUILDKITE_BUILD_CHECKOUT_PATH=$tmp_dir + run $hook_path + + assert_failure + assert_output --partial "Detected clowns!" + + rm -rf "$tmp_dir" +}