Skip to content

Commit 37653f9

Browse files
committed
Update invoke workflows
1 parent 1031248 commit 37653f9

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

.github/workflows/invoke-all.yaml

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
name: Invoke All Functions
22

3-
on:
3+
on:
44
pull_request:
55
paths-ignore:
66
- '.github/**'
77
push:
88
branches:
99
- main
10+
11+
env:
12+
FUNC_VERSION: 'knative-v1.19.0'
13+
1014
jobs:
1115
prepare:
1216
runs-on: ubuntu-latest
1317
outputs:
1418
languages: ${{ steps.prep-matrix.outputs.languages }}
1519
language_paths: ${{ steps.prep-matrix.outputs.language_paths }}
16-
env:
17-
FUNC_VERSION: 'knative-v1.18.0'
1820
steps:
1921
- name: Checkout code
2022
uses: actions/checkout@v4
@@ -24,9 +26,9 @@ jobs:
2426
run: |
2527
## NOTE: ls -d returns absolute path
2628
## GITHUB_WORKSPACE is the root directory
27-
language_paths="$(ls -d ${GITHUB_WORKSPACE}/*/ | jq -R -s 'split("\n")[:-1]')"
28-
languages="$(ls -d ${GITHUB_WORKSPACE}/*/ | xargs -n 1 basename | jq -R -s 'split("\n")[:-1]')"
29+
language_paths="$(ls -d ${GITHUB_WORKSPACE}/*/ | jq -R -s 'split("\n")[:-1]')"
2930
31+
languages=$(find . -maxdepth 1 -type d -not -name ".*" -exec basename {} \; | jq -R -s -c 'split("\n")'[:-1])
3032
# set output
3133
echo language_paths=$language_paths >> $GITHUB_OUTPUT
3234
echo languages=$languages >> $GITHUB_OUTPUT
@@ -39,11 +41,10 @@ jobs:
3941
matrix:
4042
language: ${{ fromJSON(needs.prepare.outputs.languages) }}
4143
env:
42-
FUNC_VERSION: "knative-v1.18.0"
4344
ACTIONS_STEP_DEBUG: true
4445
language_paths: ${{needs.prepare.outputs.language_paths}}
4546
HEADREF: ${{github.head_ref}}
46-
# UPDATE THIS IF HOST BUILDER IS ENABLED FOR MORE LANGUAGES
47+
# TODO: UPDATE THIS IF HOST BUILDER IS ENABLED FOR MORE LANGUAGES
4748
HOST_ENABLED_LANGUAGES: '["go","python"]'
4849
steps:
4950
- name: Checkout code
@@ -56,7 +57,7 @@ jobs:
5657
name: f
5758
- name: Setup Hugo
5859
uses: peaceiris/actions-hugo@v3
59-
with:
60+
with:
6061
hugo-version: '0.142.0'
6162
extended: true
6263
- name: Build & Invoke Function
@@ -65,69 +66,68 @@ jobs:
6566
# Might change this to <one "run" per language> scenario because then
6667
# I would just need to check the matrix language for which one to run
6768
68-
# DETERMINE IF HOST BUILDER SHOULD BE USED
69+
set -euo pipefail
70+
71+
builder="pack"
72+
request_type="GET"
73+
container=true
74+
language=${{ matrix.language }}
75+
76+
## DETERMINE IF HOST BUILDER SHOULD BE USED
6977
## NOTE: HOST_ENABLED_LANGUAGES MUST BE UP TO DATE
7078
if echo '${{env.HOST_ENABLED_LANGUAGES}}' | jq -r ".[] | select(. == \"${{matrix.language}}\")" | grep -q .; then
71-
HOST_ENABLED=true
72-
else
73-
HOST_ENABLED=false
79+
builder="host"
7480
fi
7581
76-
language=${{matrix.language}}
77-
echo "Current language is $language"
78-
echo "host enabled? $HOST_ENABLED"
82+
echo "Using language '$language'"
83+
echo "Using builder '$builder'"
84+
if [[ "$builder" == "host" ]];then
85+
container=false
86+
fi
87+
echo "Using container '$container'"
7988
8089
# This takes the array of paths, wraps it in single quotes for jq, then
8190
# selects only the value that matches with language to get current
8291
# language AND its full path (where the func template is)
8392
language_path=$(echo '${{env.language_paths}}' | jq -r ".[] | select(contains(\"${{matrix.language}}\"))")
93+
echo ">> language_path=$language_path"
8494
8595
## use the Pull request environment so that the changes are included in testing
8696
url="https://github.com/gauron99/func-templates#${{ env.HEADREF }}"
97+
echo ">> url=$url"
98+
8799
WORKDIR=$(mktemp -d)
88100
cd $WORKDIR
89101
for template_dir_abs in $(ls -d $language_path*/); do
102+
echo "template_dir_abs=$template_dir_abs"
90103
echo "ls -la ${GITHUB_WORKSPACE}"
91104
ls -la ${GITHUB_WORKSPACE}
92105
template=$(basename "$template_dir_abs")
93-
106+
94107
############################# FUNC CREATE #############################
95108
echo "> FUNC CREATE"
96109
97110
echo "f create $language-$template -r=$url -l=$language -t=$template"
98111
f create $language-$template -r "$url" -l "$language" -t "$template"
99112
113+
echo "cd $language-$template"
100114
cd $language-$template
101115
102116
############################## PRE-REQS ##############################
103117
echo "> PREREQS (if any)"
104118
### language & template specific prerequisites
105-
if [ ${{matrix.language}} == "go" ] && [ "$template" == "blog" ];then
119+
if [ ${{ matrix.language }} == "go" ] && [ "$template" == "blog" ];then
106120
make
107-
elif [ ${{matrix.language}} == "typescript" ];then
121+
elif [ ${{ matrix.language }} == "typescript" ];then
108122
npm install
109-
elif [ ${{matrix.language}} == "rust" ]; then
123+
elif [ ${{ matrix.language }} == "rust" ]; then
110124
cargo build
111125
fi
112126
113-
############################# FUNC BUILD #############################
114-
echo "> FUNC BUILD"
115-
if [ "$HOST_ENABLED" == "true" ]; then
116-
echo "build with host"
117-
FUNC_ENABLE_HOST_BUILDER=1 FUNC_BUILDER=host FUNC_CONTAINER=false FUNC_REGISTRY=docker.io/4141gauron3268 f build
118-
else
119-
echo "build with pack"
120-
121-
FUNC_REGISTRY=quay.io/dfridric f build
122-
fi
123-
124-
############################## FUNC RUN ##############################
125-
echo "> FUNC RUN"
126-
if [ "$HOST_ENABLED" == "true" ]; then
127-
FUNC_ENABLE_HOST_BUILDER=1 FUNC_CONTAINER=false f run &
128-
else
129-
FUNC_CONTAINER=true f run &
130-
fi
127+
########################## FUNC BUILD & RUN ##########################
128+
echo "> FUNC BUILD & RUN"
129+
FUNC_REGISTRY=quay.io/dfridric f build --builder=$builder
130+
f run --container=$container --build=false &
131131
132132
RUN_PID=$!
133133
@@ -137,7 +137,7 @@ jobs:
137137
echo "Failed to start 'func run'. Exiting"
138138
exit 1
139139
fi
140-
140+
# wait for run just in case
141141
sleep 5
142142
############################# FUNC INVOKE #############################
143143
echo "> FUNC INVOKE"
@@ -147,7 +147,7 @@ jobs:
147147
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
148148
echo "Attempt $RETRY_COUNT of $MAX_RETRIES"
149149
echo "Invoking 'func invoke' with current PID $$"
150-
if f invoke; then
150+
if f invoke --request-type=GET; then
151151
echo "'func invoke' succeeded."
152152
SUCCESS=true
153153
break

0 commit comments

Comments
 (0)