Skip to content

Commit b1dc74d

Browse files
committed
Add basic local usage testing
1 parent 0f6a568 commit b1dc74d

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

examples/basic-event.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
steps:
2+
- plugins:
3+
- envato/create-datadog-event#main:
4+
api_key: $DATADOG_API_KEY
5+
title: "Hello, world!"
6+
text: Testing the create-datadog-event-buildkite-plugin
7+
tags:
8+
- debug:true

examples/run-example-locally

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
# a crude way to run the example using the current version of the code, including changes that haven't been committed
6+
7+
if [[ "$#" -lt 1 ]] || ! [[ -f "$1" ]]; then
8+
echo "usage: $0 <example-path> [...bk local run args]"
9+
echo
10+
echo " e.g. $0 examples/basic-event.yml -E DATADOG_API_KEY="'"$DATADOG_API_KEY"'
11+
exit 1
12+
fi
13+
14+
example="$1"
15+
shift
16+
bk_args=( "$@" )
17+
18+
run_dir="$(mktemp -d)"
19+
20+
cleanup() {
21+
echo "Removing ${run_dir}"
22+
rm -rf -- "$run_dir"
23+
}
24+
trap 'cleanup' EXIT
25+
26+
cp -r . "${run_dir}/create-datadog-event-buildkite-plugin"
27+
cp -r ./.git "${run_dir}/.git"
28+
29+
sed -Ee "s%envato/create-datadog-event#main%file://./create-datadog-event-buildkite-plugin%" "$example" > "${run_dir}/pipeline.yml" # ./tmp/pipeline.yml
30+
31+
cd "$run_dir"
32+
echo "Running pipeline in $(pwd)"
33+
34+
bk local run ./pipeline.yml "$@"

0 commit comments

Comments
 (0)