Skip to content

Commit

Permalink
feat: implement update script and build/push workflow (#99)
Browse files Browse the repository at this point in the history
Signed-off-by: a3hadi <[email protected]>
  • Loading branch information
ayildirim21 authored Mar 22, 2024
1 parent 684e113 commit f329e10
Show file tree
Hide file tree
Showing 5 changed files with 342 additions and 10 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Docker Publish

on:
push:
branches: [ main ]
tags:
- '*'

jobs:
docker_publish:
name: Build, Tag, and Push Image
runs-on: ubuntu-latest

strategy:
matrix:
execution_ids: [
"mapt-event-time-filter-function", "flat-map-stream", "map-flatmap",
"even-odd", "simple-sink", "reduce-sum", "reduce-stream-sum",
"map-forward-message", "reduce-counter", "sideinput-example",
"udf-sideinput-example", "source-simple-source", "session-reduce-count"
]

steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Quay.io registry
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.NUMAIO_USERNAME }}
password: ${{ secrets.NUMAIO_PASSWORD }}
- name: Build, tag, and push images
run: ./update_examples.sh --build-push-example ${{ matrix.execution_ids }}
File renamed without changes.
73 changes: 73 additions & 0 deletions development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Development

This document explains the development process for the Numaflow Java SDK.

### Testing

After you make certain changes to the Java SDK implementation, you would like to use it to build a
brand new UDF image, and run it on a pipeline to verify the image continues working well with the Numaflow platform.
In order to do this you can follow these steps:

1. Make the changes.
2. Update your local repository using maven, to reflect your latest changes. This can be done in the root
directory by running: `mvn clean install` (make sure that the version in the `pom.xml in the root and examples
directories match).
3. Build your test images, and test them in a pipeline.

There exists a script `update_examples.sh`, which you can also use while testing, for your convenience.

If you would like to build and push a specific example, you can run:

```shell
./update_examples -bpe <example-image> -t <tag>
```
The -bpe flag builds and pushes to the remote registry. <example-image> must be
the id tag used within the execution element of the desired example. It is recommended to specify a tag,
like `test`, as the default is `stable`, which is used by the Github Actions CI. For example, in order to push
the example, for the reducer SDK, specifically the sum function, you would run:
```shell
./update_examples -bpe reduce-sum -t test
```
If you would like to build and push all the examples at once, you can run:
```shell
./update_examples -bp -t test
```
Both `bpe` and `bp` first build a local image with the naming convention
`numaflow-java-examples/<example_id>:<tag>`, which then gets pushed as
`quay.io/numaio/numaflow-java/<example_id>:<tag>`. If while testing, you would like
to build your image locally, without pushing to quay.io, you can run the following in the
examples directory:

```shell
mvn jib:dockerBuild@<example_id> -Ddocker.tag=<tag>
```

If you would like to build all example images without pushing, in the examples directory you can also run:
```shell
mvn clean install -Ddocker.tag=<tag>
```

### Deploying

After confirming that your changes pass local testing:

1. Clean up testing artifacts.
2. Create a PR. Once your PR has been merged a Github Actions workflow will be triggered to build, tag (with `stable`), and push
all example images, so that they are using the most up-to-date version of the SDK, i.e. the one including your
changes.

### Before Release

Before releasing a new SDK version, make sure to update all references from the old version to the new one.
For example, the version in the `pom.xml` in the root and example directories. For [reference
](https://github.com/numaproj/numaflow-java/pull/89/files#diff-9c5fb3d1b7e3b0f54bc5c4182965c4fe1f9023d449017cece3005d3f90e8e4d8).

### Adding a New Example

If you add a new example, there are a few steps to follow in order for it to be used by the update script and the Docker
Publish workflow:

1. Add the example to the `pom.xml` file in the examples directory, within an execution element. Note that the
id tag you specify must be exactly the same as the quay.io repository name for the example.
2. Add the id tag you specified in step 1 to the executionIDs array in `update_examples.sh`.
3. Add the id tag you specified in step 1 to the execution_ids matrix in `build-push.yaml`.
106 changes: 96 additions & 10 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<docker.tag>stable</docker.tag>
</properties>

<dependencies>
Expand All @@ -34,7 +35,7 @@
<version>3.3.0</version>
<executions>
<execution>
<id>event-time-filter-function</id>
<id>mapt-event-time-filter-function</id>
<phase>package</phase>
<goals>
<goal>dockerBuild</goal>
Expand All @@ -46,7 +47,7 @@
</mainClass>
</container>
<to>
<image>numaflow-java-examples/event-time-filter</image>
<image>numaflow-java-examples/mapt-event-time-filter-function:${docker.tag}</image>
</to>
</configuration>
</execution>
Expand All @@ -63,12 +64,12 @@
</mainClass>
</container>
<to>
<image>numaflow-java-examples/flat-map-stream</image>
<image>numaflow-java-examples/flat-map-stream:${docker.tag}</image>
</to>
</configuration>
</execution>
<execution>
<id>flat-map</id>
<id>map-flatmap</id>
<phase>package</phase>
<goals>
<goal>dockerBuild</goal>
Expand All @@ -80,7 +81,7 @@
</mainClass>
</container>
<to>
<image>numaflow-java-examples/map-flatmap</image>
<image>numaflow-java-examples/map-flatmap:${docker.tag}</image>
</to>
</configuration>
</execution>
Expand All @@ -97,7 +98,7 @@
</mainClass>
</container>
<to>
<image>numaflow-java-examples/even-odd</image>
<image>numaflow-java-examples/even-odd:${docker.tag}</image>
</to>
</configuration>
</execution>
Expand All @@ -113,7 +114,7 @@
</mainClass>
</container>
<to>
<image>numaflow-java-examples/simple-sink</image>
<image>numaflow-java-examples/simple-sink:${docker.tag}</image>
</to>
</configuration>
</execution>
Expand All @@ -130,7 +131,7 @@
</mainClass>
</container>
<to>
<image>numaflow-java-examples/reduce-sum</image>
<image>numaflow-java-examples/reduce-sum:${docker.tag}</image>
</to>
</configuration>
</execution>
Expand All @@ -147,7 +148,92 @@
</mainClass>
</container>
<to>
<image>numaflow-java-examples/reduce-stream-sum</image>
<image>numaflow-java-examples/reduce-stream-sum:${docker.tag}</image>
</to>
</configuration>
</execution>
<execution>
<id>map-forward-message</id>
<phase>package</phase>
<goals>
<goal>dockerBuild</goal>
</goals>
<configuration>
<container>
<mainClass>
io.numaproj.numaflow.examples.map.forward.ForwardFunction
</mainClass>
</container>
<to>
<image>numaflow-java-examples/map-forward-message:${docker.tag}</image>
</to>
</configuration>
</execution>
<execution>
<id>reduce-counter</id>
<phase>package</phase>
<goals>
<goal>dockerBuild</goal>
</goals>
<configuration>
<container>
<mainClass>
io.numaproj.numaflow.examples.reduce.count.CounterFactory
</mainClass>
</container>
<to>
<image>numaflow-java-examples/reduce-counter:${docker.tag}</image>
</to>
</configuration>
</execution>
<execution>
<id>sideinput-example</id>
<phase>package</phase>
<goals>
<goal>dockerBuild</goal>
</goals>
<configuration>
<container>
<mainClass>
io.numaproj.numaflow.examples.sideinput.simple.SimpleSideInput
</mainClass>
</container>
<to>
<image>numaflow-java-examples/sideinput-example:${docker.tag}</image>
</to>
</configuration>
</execution>
<execution>
<id>udf-sideinput-example</id>
<phase>package</phase>
<goals>
<goal>dockerBuild</goal>
</goals>
<configuration>
<container>
<mainClass>
io.numaproj.numaflow.examples.sideinput.udf.SimpleMapWithSideInput
</mainClass>
</container>
<to>
<image>numaflow-java-examples/udf-sideinput-example:${docker.tag}</image>
</to>
</configuration>
</execution>
<execution>
<id>source-simple-source</id>
<phase>package</phase>
<goals>
<goal>dockerBuild</goal>
</goals>
<configuration>
<container>
<mainClass>
io.numaproj.numaflow.examples.source.simple.SimpleSource
</mainClass>
</container>
<to>
<image>numaflow-java-examples/source-simple-source:${docker.tag}</image>
</to>
</configuration>
</execution>
Expand All @@ -164,7 +250,7 @@
</mainClass>
</container>
<to>
<image>numaflow-java-examples/session-reduce-count</image>
<image>numaflow-java-examples/session-reduce-count:${docker.tag}</image>
</to>
</configuration>
</execution>
Expand Down
Loading

0 comments on commit f329e10

Please sign in to comment.