Skip to content

Commit

Permalink
Feature: Workflow now Invokes Functions + some edits (#22)
Browse files Browse the repository at this point in the history
* redo some workflows, func invoke instead of deploy because its easier

Signed-off-by: David Fridrich <[email protected]>

* fix triggering, remove old wf

* fix

* synchronize on push

* trigger on pull_request_target

* trigger on pull_request_target

* testing trigger on pull_request_target

* testing trigger on pull_request_target

* testing filtered list

* add hack

Signed-off-by: David Fridrich <[email protected]>

* install binaries init, filter list to only languages

Signed-off-by: David Fridrich <[email protected]>

* dont deploy, just invoke, chmod stuff

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* func run in bg and invoke

* fix

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* fix

* fix

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* rename, we invoke now instead of deploy

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* remove unnecessary

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

---------

Signed-off-by: David Fridrich <[email protected]>
  • Loading branch information
gauron99 authored Jan 9, 2025
1 parent 79b404f commit f36c78f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Build All Functions
name: Invoke All Functions

on:
pull_request:
paths-ignore:
- '.github/**'

jobs:
prepare:
runs-on: ubuntu-latest
Expand All @@ -28,7 +29,7 @@ jobs:
echo language_paths=$language_paths >> $GITHUB_OUTPUT
echo languages=$languages >> $GITHUB_OUTPUT
deploy:
run:
needs: prepare
runs-on: ubuntu-latest
strategy:
Expand All @@ -51,14 +52,12 @@ jobs:
version: ${{ env.FUNC_VERSION }}
name: f

- name: Deploy Function
- name: Build & Invoke Function
run: |
# series of commands to build & deploy the Function (with specifics per language)
# series of commands to build & invoke the Function (with specifics per language)
# Might change this to <one "run" per language> scenario because then
# I would just need to check the matrix language for which one to run
# DETERMINE IF HOST BUILDER SHOULD BE USED
## NOTE: HOST_ENABLED_LANGUAGES MUST BE UP TO DATE
if echo '${{env.HOST_ENABLED_LANGUAGES}}' | jq -r ".[] | select(. == \"${{matrix.language}}\")" | grep -q .; then
Expand All @@ -85,29 +84,70 @@ jobs:
ls -la ${GITHUB_WORKSPACE}
template=$(basename "$template_dir_abs")
############################## FUNC CREATE ##############################
############################# FUNC CREATE #############################
echo "> FUNC CREATE"
echo "f create $language-$template -r=$url -l=$language -t=$template"
f create $language-$template -r "$url" -l "$language" -t "$template"
cd $language-$template
############################## FUNC BUILD ##############################
############################# FUNC BUILD #############################
echo "> FUNC BUILD"
if $HOST_ENABLED; then
if [ "$HOST_ENABLED" == "true" ]; then
echo "build with host"
FUNC_ENABLE_HOST_BUILDER=1 FUNC_BUILDER=host FUNC_CONTAINER=false FUNC_REGISTRY=docker.io/4141gauron3268 f build
else
echo "build with pack"
echo "build with pack"
#TODO this might be moved up above the if statement for HOSTBUILDER?
if [ ${{matrix.language}} == "typescript" ];then
npm install
fi
if [ ${{matrix.language}} == "rust"]; then
elif [ ${{matrix.language}} == "rust" ]; then
cargo build
fi
FUNC_REGISTRY=docker.io/4141gauron3268 f build --builder=pack
FUNC_REGISTRY=docker.io/4141gauron3268 f build
fi
############################## FUNC RUN ##############################
if [ "$HOST_ENABLED" == "true" ]; then
FUNC_ENABLE_HOST_BUILDER=1 FUNC_CONTAINER=false f run &
else
FUNC_CONTAINER=true f run &
fi
RUN_PID=$!
if ps -p $RUN_PID > /dev/null; then
echo "'func run' is running with PID $RUN_PID"
else
echo "Failed to start 'func run'. Exiting"
exit 1
fi
sleep 5
############################# FUNC INVOKE #############################
MAX_RETRIES=5
RETRY_COUNT=0
SUCCESS=false
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
echo "Attempt $RETRY_COUNT of $MAX_RETRIES"
echo "Invoking 'func invoke' with current PID $$"
if f invoke; then
echo "'func invoke' succeeded."
SUCCESS=true
break
else
echo "'func invoke' failed."
RETRY_COUNT=$((RETRY_COUNT + 1))
sleep 2
fi
done
kill $RUN_PID
if [ "$SUCCESS" = true ]; then
echo "all good"
else
echo "'func invoke' failed."
exit 1
fi
done
42 changes: 0 additions & 42 deletions .github/workflows/main-build-all.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build All](https://github.com/gauron99/func-templates/actions/workflows/main-build-all.yaml/badge.svg?branch=main&event=push)](https://github.com/gauron99/func-templates/actions/workflows/main-build-all.yaml)
[![Deploy All](https://github.com/gauron99/func-templates/actions/workflows/deploy-all.yaml/badge.svg?branch=main&event=push)](https://github.com/gauron99/func-templates/actions/workflows/deploy-all.yaml)
# WELCOME To Knative Function Templates!

### Quick search
Expand Down

0 comments on commit f36c78f

Please sign in to comment.