diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml new file mode 100644 index 0000000..99ee258 --- /dev/null +++ b/.buildkite/pipeline.yml @@ -0,0 +1,17 @@ + +steps: + - label: ":shell: Shellcheck" + plugins: + shellcheck#v1.1.2: + files: + - hooks/** + + - label: ":rocket: Test" + plugins: + docker-compose#v3.7.0: + run: tests + + - label: ":sparkles: Lint" + plugins: + plugin-linter#v2.0.0: + id: docker-login \ No newline at end of file diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..7b80650 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +# * @equinixmetal-buildkite/team \ No newline at end of file diff --git a/README.md b/README.md index e2789d5..f1942ee 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,29 @@ -# template-buildkite-plugin -A template repo that can help bootstrap a new buildkite plugin +# Buildkite Plugin Template + +Check the [buildkite organization](https://github.com/buildkite-plugins) or [website](https://buildkite.com/plugins) to see if your plugin already exists or we can contribute to it ! + +Be sure to update this readme with your plugin information after using the template repository. + +## Example + +Provide an example of using this plugin, like so: + +Add the following to your `pipeline.yml`: + +```yml +steps: + - command: ls + plugins: + - a-github-user/file-counter#v1.0.0: + pattern: '*.md' +``` + +## Developing + +Provide examples on how to modify and test, e.g.: + +To run the tests: + +```shell +docker-compose run --rm tests +``` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d7ca5a5 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +--- +version: '3.8' +services: + tests: + image: buildkite/plugin-tester + volumes: + - ".:/plugin" \ No newline at end of file diff --git a/hooks/post-checkout b/hooks/post-checkout new file mode 100644 index 0000000..bfbf482 --- /dev/null +++ b/hooks/post-checkout @@ -0,0 +1,6 @@ +#!/bin/bash + +set -o errexit # script exits when a command fails == set -e +set -o nounset # script exits when tries to use undeclared variables == set -u +set -o xtrace # trace what's executed == set -x (useful for debugging) +set -o pipefail # causes pipelines to retain / set the last non-zero status \ No newline at end of file diff --git a/plugin.yml b/plugin.yml new file mode 100644 index 0000000..4f50026 --- /dev/null +++ b/plugin.yml @@ -0,0 +1,14 @@ +--- +name: your name +description: what your plugin does +author: Equinix Metal +requirements: + - if you have requirements +configuration: + properties: + propertyname: + type: string + required: + - if any properties are required + dependencies: + dependencyname: [dep] \ No newline at end of file diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..a78e667 --- /dev/null +++ b/renovate.json @@ -0,0 +1,5 @@ +{ + "extends": [ + "config:base" + ] + } \ No newline at end of file diff --git a/scripts/test b/scripts/test new file mode 100644 index 0000000..4422bb0 --- /dev/null +++ b/scripts/test @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cd "$(dirname "$0")/.." + +if [[ "${DEBUG:-}" -gt 0 ]] +then + set -x +fi + +echo "--- BATS" +docker-compose run --rm tests + +echo "--- Plugin Lint" +docker-compose run --rm lint + +echo "--- Shellcheck" +docker run --rm -v "${PWD}:/mnt" --workdir /mnt koalaman/shellcheck:stable hooks/** scripts/** + +echo "--- Checking Markdown files (meta)..." +./hooks/command \ No newline at end of file diff --git a/tests/post-checkout.bats b/tests/post-checkout.bats new file mode 100644 index 0000000..ac06ce7 --- /dev/null +++ b/tests/post-checkout.bats @@ -0,0 +1,3 @@ +#!/usr/bin/env bats + +PROJECT_DIR=$(cd "${BATS_TEST_DIRNAME}/.." && pwd) \ No newline at end of file