| # Licensed to the Apache Software Foundation (ASF) under one | |
| # or more contributor license agreements. See the NOTICE file | |
| # distributed with this work for additional information | |
| # regarding copyright ownership. The ASF licenses this file | |
| # to you under the Apache License, Version 2.0 (the | |
| # "License"); you may not use this file except in compliance | |
| # with the License. You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, | |
| # software distributed under the License is distributed on an | |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| # KIND, either express or implied. See the License for the | |
| # specific language governing permissions and limitations | |
| # under the License. | |
| version: "3" | |
| dotenv: [.env] | |
| vars: | |
| DRY: "" | |
| DRY2: "" | |
| PUSH: "" | |
| BASETAG: "" | |
| FILTER: "" | |
| J: "{}" | |
| COMMIT_ID: | |
| sh: git rev-parse --short HEAD | |
| SUFFIX: "-snapshot" | |
| # register | |
| REGISTRY: ${DOCKERHUB_REGISTRY:-docker.io} | |
| REPO_PATH: ${DOCKERHUB_USER:-apache} | |
| BASEIMG: '{{.REGISTRY}}/{{.REPO_PATH}}' | |
| # if you change this, change also the task build FILTER=common:1.18.4 in workflow image.yml | |
| COMMON_VER: 1.18.4 | |
| # Builder used for local (non-PUSH) builds. It must use the "docker" driver so | |
| # that images loaded with --load land in the docker daemon store and are then | |
| # visible as a FROM base to subsequent builds. The "docker-container" driver | |
| # (mybuilder) keeps its own isolated store and would try to pull the | |
| # not-yet-pushed common image from the registry. Multi-arch PUSH builds are | |
| # unaffected and keep using the current builder (mybuilder). | |
| # The docker-driver builder is named after the active docker context | |
| # ("default" on plain Linux, "desktop-linux" on Docker Desktop), so derive it | |
| # instead of hardcoding. Override with LOCAL_BUILDER in the environment. | |
| LOCAL_BUILDER: | |
| sh: echo "${LOCAL_BUILDER:-$(docker context show 2>/dev/null || echo default)}" | |
| # pick the most recently created tag (tags are annotated, so they carry their | |
| # own creation date and sort correctly even when they share a commit) | |
| FULLTAG: | |
| sh: git for-each-ref --sort=-creatordate --count=1 --format='%(refname:short)' refs/tags 2>/dev/null | grep . || echo snapshot | |
| TAG: | |
| sh: FULL="{{.FULLTAG}}" ; echo ${FULL##*_} | |
| COMMON: "{{.BASEIMG}}/openserverless-runtime-common:{{.COMMON_VER}}-{{.TAG}}" | |
| # if you cahange this change also the filter in workflow image.yml | |
| #RUNTIMES: "go,nodejs,php,python,java" temp disabled php | |
| RUNTIMES: "go,nodejs,python,java" | |
| includes: | |
| x: | |
| TaskfileExperimental.yml | |
| tasks: | |
| default: | |
| - task --list-all | |
| setup: | |
| # check we are running in ubuntu | |
| - grep '^ID=' /etc/os-release | grep -i ubuntu | |
| - if ! which python3 | grep python3 ; then echo "python3 not found" ; exit 1; fi | |
| - sudo apt-get -y install python3-pip python3-virtualenv | |
| - python3 -m pip install ipython watchdog requests cram | |
| tag: | |
| desc: 'tag to build, specify RT to restrict to <language> or common, experimental' | |
| silent: true | |
| vars: | |
| TS: | |
| sh: date '+%y %m %d %H %M' | awk '{printf "%s%s%02d%s%02d\n", $1, substr("abcdefghijkl",$2+0,1), $3, substr("abcdefghijklmnopqrstuvwx",$4+1,1), $5}' | |
| cmds: | |
| - git tag | xargs -L1 git tag -d | |
| - | | |
| if test -z "{{.RT}}" | |
| then RT=all | |
| else RT="{{.RT}}" | |
| fi | |
| TAG="${RT}_{{.TS}}{{.SUFFIX}}" | |
| git tag -a -m "build $TAG" "$TAG" | |
| echo Tag $TAG, you can now 'task build' | |
| ci: | |
| - git push --tags | |
| compile: go build -o proxy | |
| test-prep: ln -sf $(which python3) /usr/local/bin/python | |
| test: | |
| dir: openwhisk | |
| cmds: | |
| - | | |
| if ! /usr/local/bin/python --version | grep 'Python 3' | |
| then echo 'you need to link a python 3 to /usr/local/bin/python to run the tests (do not ask why)' | |
| echo tast test-init does it for you if you have a python3 and sudo | |
| exit 1 | |
| fi | |
| - go test -v | |
| docker-login: | |
| ignore_error: true | |
| cmds: | |
| - > | |
| echo ${$DOCKERHUB_TOKEN} | |
| | docker login -u $DOCKERHUB_USER | |
| --password-stdin {{.REGISTRY}} | |
| - > | |
| {{.DRY}} | |
| docker run -it --rm --privileged tonistiigi/binfmt:qemu-v7.0.0-28 --install all | |
| - > | |
| {{.DRY}} | |
| docker buildx create --name mybuilder --bootstrap --use | |
| clean-images: | |
| - docker images -a | grep openserverless | awk '{print $3}' | xargs docker rmi -f | |
| - yes | docker buildx prune | |
| build-common: | |
| silent: true | |
| # use the toplevel for common | |
| # dir: "runtime/common/{{.COMMON_VER}}" | |
| cmds: | |
| - | | |
| if echo '{{.COMMON}}' | grep '{{.FILTER}}' | |
| then | |
| if test -n "{{.PUSH}}" | |
| then | |
| echo ">>> Building arm/amd and pushing {{.COMMON}}" | |
| {{.DRY2}} docker buildx build -t "{{.COMMON}}" --platform linux/amd64,linux/arm64 . --push | |
| else | |
| echo ">>> Building {{.COMMON}} (local, docker driver)" | |
| {{.DRY2}} docker buildx build --builder {{.LOCAL_BUILDER}} -t "{{.COMMON}}" . --load | |
| fi | |
| echo "<<< Built {{.COMMON}}" | |
| fi | |
| build-runtime: | |
| silent: true | |
| requires: { vars: [RT, VER] } | |
| vars: | |
| RUNTIME: "{{.BASEIMG}}/openserverless-runtime-{{.RT}}:{{.VER}}-{{.TAG}}" | |
| dir: "runtime/{{.RT}}/{{.VER}}" | |
| cmds: | |
| - | | |
| if echo '{{.RUNTIME}}' | grep '{{.FILTER}}' | |
| then | |
| if test -n "{{.PUSH}}" | |
| then | |
| echo ">>> Building arm/amd and pushing {{.RUNTIME}}" | |
| {{.DRY2}} docker buildx build -t "{{.RUNTIME}}" --build-arg COMMON="{{.COMMON}}" --platform linux/amd64,linux/arm64 . --push | |
| else | |
| echo ">>> Building {{.RUNTIME}} (local, docker driver)" | |
| {{.DRY2}} docker buildx build --builder {{.LOCAL_BUILDER}} -t "{{.RUNTIME}}" --build-arg COMMON="{{.COMMON}}" . --load | |
| fi | |
| echo "<<< Built {{.RUNTIME}}" | |
| fi | |
| build-lang: | |
| silent: true | |
| desc: build images for one runtime | |
| requires: { vars: [RT] } | |
| vars: | |
| DIRS: | |
| sh: ls -d runtime/{{.RT}}/* || echo "" | |
| cmds: | |
| - for: { var: DIRS } | |
| task: build-runtime | |
| vars: | |
| VER: "{{base .ITEM}}" | |
| # build all | |
| build: | |
| silent: true | |
| desc: build the runtimes selected by task tag | |
| cmds: | |
| - | | |
| T="{{.FULLTAG}}" | |
| TS="${T#*_}" | |
| RT="${T%%_*}" | |
| echo Building: $T | |
| case "$T" in | |
| all_*) | |
| {{.DRY}} task build-common TAG="$TS" PUSH="{{.PUSH}}" DRY2={{.DRY2}} FILTER={{.FILTER}} | |
| for runtime in $(echo {{.RUNTIMES}} | tr ',' ' ') | |
| do {{.DRY}} task build-lang RT="$runtime" TAG="$TS" PUSH="{{.PUSH}}" DRY2={{.DRY2}} FILTER={{.FILTER}} | |
| done | |
| ;; | |
| common_*) | |
| {{.DRY}} task build-common TAG="$TS" PUSH="{{.PUSH}}" DRY2={{.DRY2}} FILTER={{.FILTER}} | |
| ;; | |
| experimental_*) | |
| {{.DRY}} task x:build-experimental-runtimes TAG="$TS" PUSH="{{.PUSH}}" | |
| ;; | |
| *_*) | |
| TS="${T#*_}" | |
| {{.DRY}} task build-common TAG="$TS" PUSH="{{.PUSH}}" DRY2={{.DRY2}} FILTER={{.FILTER}} | |
| {{.DRY}} task build-lang RT="$RT" TAG="$TS" PUSH="{{.PUSH}}" DRY2={{.DRY2}} FILTER={{.FILTER}} | |
| ;; | |
| *) | |
| echo this should not happen - did you read the README | |
| ;; | |
| esac | |
| buildx: | |
| desc: build and push the runtimes selected by task tag | |
| silent: false | |
| cmds: | |
| - task build PUSH=y FILTER="{{.FILTER}}" DRY2='{{.DRY2}}' | |
| run: | |
| desc: run a runtime | |
| requires: { vars: [RT, VER] } | |
| dir: "runtime/{{.RT}}/{{.VER}}" | |
| cmds: | |
| - > | |
| {{.DRY}} docker run -p 8080:8080 -ti "{{.BASEIMG}}/openserverless-runtime-{{.RT}}:{{.VER}}-{{.TAG}}" | |
| debug: | |
| desc: debug a runtime | |
| requires: { vars: [RT, VER] } | |
| dir: "runtime/{{.RT}}/{{.VER}}" | |
| cmds: | |
| - > | |
| {{.DRY}} docker run -p 8080:8080 -ti | |
| --entrypoint=/bin/bash -v $PWD:/mnt | |
| -e OW_COMPILER=/mnt/bin/compile | |
| "{{.BASEIMG}}/openserverless-runtime-{{.RT}}:{{.VER}}-{{.TAG}}" | |
| init: | |
| desc: intialize a runtime with a test | |
| requires: { vars: [RT, VER, T] } | |
| cmds: | |
| - python3 packages/invoke.py init packages/{{.RT}}/{{.T}}.zip | |
| invoke: | |
| desc: invoke a runtime listening in port 8080, optionally with J=<json> | |
| cmds: | |
| - python3 packages/invoke.py run '{{.J}}' | |
| render-runtimes: | |
| silent: true | |
| desc: generate a runtimes.json file with all the runtime corresponding to the current TAG | |
| cmds: | |
| - echo "creating runtimes.json" | |
| - python3 runtimes.py {{.TAG}} >runtimes.json |