Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build workflow - test host enabling #16

Closed
wants to merge 19 commits into from
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CODEOWNERS file -- gauron99

* @gauron99
101 changes: 74 additions & 27 deletions .github/workflows/build-all.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,90 @@
name: Create all functions
name: Build All Functions

on: [pull_request]
on: pull_request

jobs:
builds:
prepare:
runs-on: ubuntu-latest
outputs:
languages: ${{ steps.prep-matrix.outputs.languages }}
language_paths: ${{ steps.prep-matrix.outputs.language_paths }}
env:
VERSION: "v1.15.1"
FUNC_VERSION: "knative-v1.16.1"
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install func
- name: Prep Matrix
id: prep-matrix
run: |
echo "Installing func ${{env.VERSION}}"
program_url="https://github.com/knative/func/releases/download/knative-${{env.VERSION}}/func_linux_amd64"
curl -SLO $program_url && mv func_linux_amd64 f && chmod +x f
cp f /usr/local/bin
f version
## NOTE: ls -d returns absolute path
## GITHUB_WORKSPACE is the root directory
language_paths="$(ls -d ${GITHUB_WORKSPACE}/*/ | jq -R -s 'split("\n")[:-1]')"
languages="$(ls -d ${GITHUB_WORKSPACE}/*/ | xargs -n 1 basename | jq -R -s 'split("\n")[:-1]')"

# set output
echo language_paths=$language_paths >> $GITHUB_OUTPUT
echo languages=$languages >> $GITHUB_OUTPUT

deploy:
needs: prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: ${{ fromJSON(needs.prepare.outputs.languages) }}
env:
ACTIONS_STEP_DEBUG: true
language_paths: ${{needs.prepare.outputs.language_paths}}
HOST_ENABLED_LANGUAGES: '["go"]'
HEADREF: ${{github.head_ref}}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build Functions
- name: Install func
uses: gauron99/knative-func-action@main
with:
version: ${{ env.FUNC_VERSION }}
name: f

- name: Deploy Function
run: |
HOST_ENABLED=$(contains(fromJSON('${{env.HOST_ENABLED_LANGUAGES}}'),'${{matrix.language}}'))

language=${{matrix.language}}
echo "Current language is $language"
echo "host enabled? $HOST_ENABLED"

# This takes the array of paths, wraps it in single quotes for jq, then
# selects only the value that matches with language to get current
# language AND its full path (where the func template is)
language_path=$(echo '${{env.language_paths}}' | jq -r ".[] | select(contains(\"${{matrix.language}}\"))")

## use the Pull request environment so that the changes are included in testing
url="https://github.com/gauron99/func-templates#${{ env.HEADREF }}"
WORKDIR=$(mktemp -d)
cd $WORKDIR
## NOTE: ls -d returns absolute path
## GITHUB_WORKSPACE is the root directory
#cycle through all languages
echo ">> head ref: ${{ github.head_ref }}"
url="http://github.com/gauron99/func-templates#${{ github.head_ref }}"
echo ">> full url is: $url"
for lang_dir_abs in $(ls -d ${GITHUB_WORKSPACE}/*/); do
lang=$(basename "$lang_dir_abs")
echo "Building funcs in language $lang"
for template_dir_abs in $(ls -d $lang_dir_abs*/); do
template=$(basename "$template_dir_abs")
echo "f create $lang-$template -r=$url -l=$lang -t=$template"
f create $lang-$template -r "$url" -l "$lang" -t "$template"
#FUNC_ENABLE_HOST_BUILDER=1 FUNC_BUILDER=host FUNC_CONTAINER=false FUNC_REGISTRY=docker.io/4141gauron3268 f
done
done
echo "Building funcs in language ${{matrix.language}}"
for template_dir_abs in $(ls -d $language_path*/); do
echo "ls -la ${GITHUB_WORKSPACE}"
ls -la ${GITHUB_WORKSPACE}
template=$(basename "$template_dir_abs")

## 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
echo "> FUNC BUILD"
if ${{env.HOST_ENABLED}}; 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"
FUNC_REGISTR=docker.io/4141gauron3268 f build --builder=pack
fi
done
12 changes: 5 additions & 7 deletions .github/workflows/main-build-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ jobs:
builds:
runs-on: ubuntu-latest
env:
VERSION: "v1.15.1"
FUNC_VERSION: "knative-v1.16.1"
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install func
run: |
echo "Installing func ${{env.VERSION}}"
program_url="https://github.com/knative/func/releases/download/knative-${{env.VERSION}}/func_linux_amd64"
curl -SLO $program_url && mv func_linux_amd64 f && chmod +x f
cp f /usr/local/bin
f version
uses: gauron99/knative-func-action@main
with:
version: ${{env.FUNC_VERSION}}
name: f

- name: Build Functions
run: |
Expand Down
87 changes: 51 additions & 36 deletions .github/workflows/manual-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,67 @@ name: Manual Flow Testing
on: workflow_dispatch

jobs:
builds:
prepare:
runs-on: ubuntu-latest
outputs:
languages: ${{ steps.prep-matrix.outputs.languages }}
language_paths: ${{ steps.prep-matrix.outputs.language_paths }}
env:
FUNC_VERSION: "knative-v1.16.1"
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Prep Matrix
id: prep-matrix
run: |
## NOTE: ls -d returns absolute path
## GITHUB_WORKSPACE is the root directory
language_paths="$(ls -d ${GITHUB_WORKSPACE}/*/ | jq -R -s 'split("\n")[:-1]')"
languages="$(ls -d ${GITHUB_WORKSPACE}/*/ | xargs -n 1 basename | jq -R -s 'split("\n")[:-1]')"

# set output
echo language_paths=$language_paths >> $GITHUB_OUTPUT
echo languages=$languages >> $GITHUB_OUTPUT

deploy:
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix:
language: ${{ fromJSON(needs.prepare.outputs.languages) }}
env:
VERSION: "v1.15.1"
ACTIONS_STEP_DEBUG: true
language_paths: ${{needs.prepare.outputs.language_paths}}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install func
run: |
echo "Installing func ${{env.VERSION}}"
program_url="https://github.com/knative/func/releases/download/knative-${{env.VERSION}}/func_linux_amd64"
curl -SLO $program_url && mv func_linux_amd64 f && chmod +x f
cp f /usr/local/bin
f version
uses: gauron99/knative-func-action@main
with:
version: ${{ env.FUNC_VERSION }}
name: f

- name: Build Functions
run: |
language=${{matrix.language}}
echo "Current language: $language"

# This takes the array of paths, wraps it in single quotes for jq, then
# selects only the value that matches with language to get current
# language AND its full path (where the func template is)
language_path=$(echo '${{env.language_paths}}' | jq -r ".[] | select(contains(\"${{matrix.language}}\"))")

url="https://github.com/gauron99/func-templates"
WORKDIR=$(mktemp -d)
cd $WORKDIR
echo "did the cd work?"
pwd
## NOTE: ls -d returns absolute path
## GITHUB_WORKSPACE is the root directory
#cycle through all languages
url="http://github.com/gauron99/func-templates"
for lang_dir_abs in $(ls -d ${GITHUB_WORKSPACE}/*/); do
lang=$(basename "$lang_dir_abs")
echo "Building funcs in language $lang"
for template_dir_abs in $(ls -d $lang_dir_abs*/); do
echo "ls -la"
ls -la
echo "pwd"
pwd
echo "ls -la ${GITHUB_WORKSPACE}"
ls -la ${GITHUB_WORKSPACE}
template=$(basename "$template_dir_abs")
echo "f create $lang-$template -r=$url -l=$lang -t=$template"
if [ $lang = "python" ];then
f create $lang-$template -r "$url"
else
f create $lang-$template -r "$url" -l "$lang" -t "$template"
fi
#FUNC_ENABLE_HOST_BUILDER=1 FUNC_BUILDER=host FUNC_CONTAINER=false FUNC_REGISTRY=docker.io/4141gauron3268 f
done
done


echo "Building funcs in language ${{matrix.language}}"
for template_dir_abs in $(ls -d $language_path*/); do
echo "ls -la ${GITHUB_WORKSPACE}"
ls -la ${GITHUB_WORKSPACE}
template=$(basename "$template_dir_abs")
echo "f create $language-$template -r=$url -l=$language -t=$template"
f create $language-$template -r "$url" -l "$language" -t "$template"
#FUNC_ENABLE_HOST_BUILDER=1 FUNC_BUILDER=host FUNC_CONTAINER=false FUNC_REGISTRY=docker.io/4141gauron3268 f
done
Loading