Skip to content

Commit 85e76bd

Browse files
committed
Update invoke workflows
1 parent 1031248 commit 85e76bd

File tree

1 file changed

+33
-37
lines changed

1 file changed

+33
-37
lines changed

.github/workflows/invoke-all.yaml

Lines changed: 33 additions & 37 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,64 @@ 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+
local builder="pack"
72+
local request_type="GET"
73+
local container=true
74+
local 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'"
7984
8085
# This takes the array of paths, wraps it in single quotes for jq, then
8186
# selects only the value that matches with language to get current
8287
# language AND its full path (where the func template is)
8388
language_path=$(echo '${{env.language_paths}}' | jq -r ".[] | select(contains(\"${{matrix.language}}\"))")
89+
echo ">> language_path=$language_path"
8490
8591
## use the Pull request environment so that the changes are included in testing
8692
url="https://github.com/gauron99/func-templates#${{ env.HEADREF }}"
93+
echo ">> url=$url"
94+
8795
WORKDIR=$(mktemp -d)
8896
cd $WORKDIR
8997
for template_dir_abs in $(ls -d $language_path*/); do
98+
echo "template_dir_abs=$template_dir_abs"
9099
echo "ls -la ${GITHUB_WORKSPACE}"
91100
ls -la ${GITHUB_WORKSPACE}
92101
template=$(basename "$template_dir_abs")
93-
102+
94103
############################# FUNC CREATE #############################
95104
echo "> FUNC CREATE"
96105
97106
echo "f create $language-$template -r=$url -l=$language -t=$template"
98107
f create $language-$template -r "$url" -l "$language" -t "$template"
99108
109+
echo "cd $language-$template"
100110
cd $language-$template
101111
102112
############################## PRE-REQS ##############################
103113
echo "> PREREQS (if any)"
104114
### language & template specific prerequisites
105-
if [ ${{matrix.language}} == "go" ] && [ "$template" == "blog" ];then
115+
if [ ${{ matrix.language }} == "go" ] && [ "$template" == "blog" ];then
106116
make
107-
elif [ ${{matrix.language}} == "typescript" ];then
117+
elif [ ${{ matrix.language }} == "typescript" ];then
108118
npm install
109-
elif [ ${{matrix.language}} == "rust" ]; then
119+
elif [ ${{ matrix.language }} == "rust" ]; then
110120
cargo build
111121
fi
112122
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"
123+
########################## FUNC BUILD & RUN ##########################
124+
echo "> FUNC BUILD & RUN"
120125
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
126+
f run --builder=$builder --container=$container --build &
131127
132128
RUN_PID=$!
133129
@@ -147,7 +143,7 @@ jobs:
147143
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
148144
echo "Attempt $RETRY_COUNT of $MAX_RETRIES"
149145
echo "Invoking 'func invoke' with current PID $$"
150-
if f invoke; then
146+
if f invoke --request-type=GET; then
151147
echo "'func invoke' succeeded."
152148
SUCCESS=true
153149
break

0 commit comments

Comments
 (0)