Skip to content

Commit

Permalink
initial working version
Browse files Browse the repository at this point in the history
  • Loading branch information
ca-johnson committed Jul 24, 2019
1 parent 9216a62 commit 42dc60b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 10 deletions.
9 changes: 9 additions & 0 deletions .buildkite/local-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
steps:
- label: "Test"
command: echo "Hello World"
plugins:
- ./.buildkite/plugins/metahook:
pre-command: echo "pre-command hook"
command: echo "command hook"
post-command: echo "post-command hook"
pre-exit: echo "pre-exit hook"
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
__pycache__/
*.py[cod]

.buildkite/plugins
.vscode
.pytest_cache
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
local_run: vendorize
bk local run .buildkite/local-pipeline.yml

vendorize:
mkdir .buildkite/plugins/metahook -p
cp hooks python plugin.yml .buildkite/plugins/metahook/ -rf
2 changes: 2 additions & 0 deletions hooks/environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
python "${BASH_SOURCE%/*}/../python/setup-hooks.py"
3 changes: 0 additions & 3 deletions hooks/environment.sh

This file was deleted.

13 changes: 8 additions & 5 deletions python/setup-hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@

def cleanup_metahooks():
"""Remove the temporary hooks"""
hooks = [os.path.join(HOOKDIR, hook) for hook in os.listdir(HOOKDIR)]
hooks = [os.path.join(HOOKDIR, hook) for hook in os.listdir(HOOKDIR) if hook != 'environment']
for hook in hooks:
if hook == 'environment.sh':
continue # skip the geniuine plugin hook
os.remove(hook)

def create_metahooks():
with open(os.path.join(HOOKDIR, 'pre-checkout.sh'), 'w') as outfile:
outfile.write("ls")
for hook in hooks:
content = os.environ.get("BUILDKITE_PLUGIN_METAHOOK_%s" % hook.replace('-', '_').upper())
if not content:
continue
with open(os.path.join(HOOKDIR, hook), 'w') as outfile:
outfile.write(content)


def main():
cleanup_metahooks()
create_metahooks()

if __name__ == "__main__":
Expand Down
3 changes: 1 addition & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ steps:

- label: "Test"
command: "scripts/test.sh"
<<: *common

<<: *common
```

0 comments on commit 42dc60b

Please sign in to comment.