Skip to content

Commit

Permalink
modify workflow to use matrix strategy
Browse files Browse the repository at this point in the history
Signed-off-by: a3hadi <[email protected]>
  • Loading branch information
ayildirim21 committed Mar 11, 2024
1 parent e7d0854 commit dfe4935
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/build-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ on:
jobs:
docker_publish:
runs-on: ubuntu-latest

strategy:
max-parallel: 6
matrix:
dockerfile_path: [
"pkg/mapper/examples/even_odd", "pkg/mapper/examples/flatmap", "pkg/mapper/examples/forward_message",
"pkg/mapper/examples/retry", "pkg/mapper/examples/tickgen", "pkg/mapstreamer/examples/flatmap_stream",
"pkg/reducer/examples/counter", "pkg/reducer/examples/sum", "pkg/reducestreamer/examples/counter",
"pkg/reducestreamer/examples/sum", "pkg/sessionreducer/examples/counter", "pkg/sideinput/examples/simple-sideinput/udf",
"pkg/sideinput/examples/simple-sideinput", "pkg/sinker/examples/log", "pkg/sourcer/examples/simple_source",
"pkg/sourcetransformer/examples/assign_event_time", "pkg/sourcetransformer/examples/event_time_filter"
]

steps:
- name: Check out repository
uses: actions/checkout@v3
Expand All @@ -23,4 +36,4 @@ jobs:
username: ${{ secrets.NUMAIO_USERNAME }}
password: ${{ secrets.NUMAIO_PASSWORD }}
- name: Build, tag, and push images
run: ./update_examples.sh --build-push
run: ./update_examples.sh --build-push-example ${{ matrix.dockerfile_path }}
33 changes: 27 additions & 6 deletions update_examples.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash

function show_help () {
echo "Usage: $0 [-h|--help] (-bp|--build-push | -u|--update <SDK-version>)"
echo " -h, --help Display help message and exit"
echo " -bp, --build-push Build the docker images of all the examples and push them to the quay.io registry (with tag: stable)"
echo " -u, --update Update all of the examples to depend on the numaflow-go version with the specified SHA or version"
echo "Usage: $0 [-h|--help] (-bp|--build-push | -bpe|--build-push-example | -u|--update <SDK-version>)"
echo " -h, --help Display help message and exit"
echo " -bp, --build-push Build the Dockerfiles of all the examples and push them to the quay.io registry (with tag: stable)"
echo " -bpe, --build-push-example Build the Dockerfile of the given example directory path, and push it to the quay.io registry (with tag: stable)"
echo " -u, --update Update all of the examples to depend on the numaflow-go version with the specified SHA or version"
}

function traverse_examples () {
Expand Down Expand Up @@ -33,8 +34,10 @@ fi

usingHelp=0
usingBuildPush=0
usingBuildPushExample=0
usingVersion=0
version=""
directoryPath=""

function handle_options () {
while [ $# -gt 0 ]; do
Expand All @@ -45,6 +48,17 @@ function handle_options () {
-bp | --build-push)
usingBuildPush=1
;;
-bpe | --build-push-example)
usingBuildPushExample=1
if [ -z "$2" ]; then
echo "Directory path not specified." >&2
show_help
exit 1
fi

directoryPath=$2
shift
;;
-u | --update)
usingVersion=1
if [ -z "$2" ]; then
Expand All @@ -68,8 +82,8 @@ function handle_options () {

handle_options "$@"

if (( usingBuildPush + usingVersion + usingHelp > 1 )); then
echo "Only one of '-h', '-bp', '-u' is allowed at a time" >&2
if (( usingBuildPush + usingBuildPushExample + usingVersion + usingHelp > 1 )); then
echo "Only one of '-h', '-bp', '-bpe, or, '-u' is allowed at a time" >&2
show_help
exit 1
fi
Expand All @@ -78,8 +92,15 @@ if [ -n "$version" ]; then
echo "Will update to: $version"
fi

if [ -n "$directoryPath" ]; then
echo "Dockerfile path to use: $directoryPath"
fi

if (( usingBuildPush )); then
traverse_examples "make image"
elif (( usingBuildPushExample )); then
cd "./$directoryPath" || exit
make image
elif (( usingVersion )); then
traverse_examples "go get github.com/numaproj/numaflow-go@$version" "go mod tidy"
elif (( usingHelp )); then
Expand Down

0 comments on commit dfe4935

Please sign in to comment.