Skip to content

Commit

Permalink
Clean up codebase (#2)
Browse files Browse the repository at this point in the history
This makes a pass over the entire repository to clean it up a bit so
that we can comfortably publish it.
  • Loading branch information
dominiklohmann authored Apr 11, 2024
1 parent f240833 commit e4c5adc
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 19 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
/.git/
/Dockerfile
/LICENSE
/README.md
/docker-compose.yaml
/integration/data/reference/
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ jobs:
docker compose build --build-arg TENZIR_VERSION=${{ matrix.version }}
- name: Test
run: |
docker compose run tests
docker compose run --build tests
git diff --exit-code
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
File renamed without changes.
11 changes: 3 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
ARG TENZIR_VERSION=main
FROM ghcr.io/tenzir/tenzir-dev:${TENZIR_VERSION} AS example-builder-untested
FROM ghcr.io/tenzir/tenzir-dev:${TENZIR_VERSION} AS example-builder

COPY example /plugins/example
COPY . /plugins/example/

RUN cmake -S /plugins/example -B build-example -G Ninja -D CMAKE_INSTALL_PREFIX:STRING="$PREFIX"
RUN cmake --build build-example --parallel
RUN cmake --install build-example --strip --component Runtime --prefix /plugin/example

FROM example-builder-untested AS example-test
FROM example-builder AS example-test

ENV BATS_LIB_PATH=/tmp/tenzir/tenzir/integration/lib
# TODO: Use the update-integration target instead
ENV UPDATE=1

ENTRYPOINT cmake --build build-example --target integration

FROM example-builder-untested AS example-builder

ENV BATS_LIB_PATH=/tmp/tenzir/tenzir/integration/lib
RUN cmake --build build-example --target integration

FROM ghcr.io/tenzir/tenzir:${TENZIR_VERSION}

COPY --from=example-builder --chown=tenzir:tenzir /plugin/example /opt/tenzir
38 changes: 31 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,42 @@
# Tenzir Example Plugin

This is an example plugin for Tenzir. Simply run `docker compose up` to build
and start a Tenzir node with your additional plugin. Use `docker compose run
tenzir '<pipeline>'` to interact with the node, or set the following
environment variables and to connect your node to app.tenzir.com:
This is an example plugin for Tenzir.

## Build and run

Simply run `docker compose up` to build and start a Tenzir node with your
additional plugin.

Use `docker compose run tenzir '<pipeline>'` to interact with the node. Set the
following environment variables and to connect your node to app.tenzir.com:

```
export TENZIR_PLUGINS__PLATFORM__API_KEY='<api-key>'
export TENZIR_PLUGINS__PLATFORM__TENANT_ID='<tenant-id>'
```

## Write Tests
## Learn how to write a plugin

We think that learning how to build a plugin is best done by example. Tenzir
ships with a variety of [plugins][plugins-source] and
[builtins][builtins-source] to get inspired by and to learn from.

If you have any questions, feel free to reach out in the [#developers channel
on Discord][discord].

## Run tests

Every plugin defines additional tests using
[BATS](https://bats-core.readthedocs.io/en/stable/writing-tests.html). Use
`docker compose run tests` to execute your tests and update the reference files
automatically.
`docker compose run --build tests` to execute your tests and update the
reference files automatically.

## Contribute your plugin

If you want to upstream your plugin so that it is bundled with every Tenzir
installation, open a PR that adds it to the [`plugins/` directory in the
`tenzir/tenzir` repository][plugins-source].

[plugins-source]: https://github.com/tenzir/tenzir/tree/main/plugins
[builtins-source]: https://github.com/tenzir/tenzir/tree/main/libtenzir/builtins
[discord]: https://docs.tenzir.com/discord
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ services:
profiles:
- donotstart
volumes:
- ./example/integration/data/reference/:/plugins/example/integration/data/reference/
- ./integration/data/reference/:/plugins/example/integration/data/reference/

volumes:
tenzir-node:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "example", "types": ["operator"], "dependencies": []}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ teardown() {
}

@test "Check plugin availability" {
check tenzir 'show plugins | where name == "example"'
check tenzir 'show plugins | where name == "example" | drop version, kind'
}
File renamed without changes.

0 comments on commit e4c5adc

Please sign in to comment.