# 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 vars: BASE_IMG: "docker.io/apache" RELEASE: sh: git -C oplugins-op rev-parse --short HEAD 2>/dev/null || echo '{{trimPrefix "openserverless-" (base .TASKFILE_DIR)}}' OPERATOR_TAG: "{{.RELEASE}}" OPERATOR_IMG: sh: awk -F= '/ARG OPERATOR_IMAGE_DEFAULT=/ { print $2 ; exit }' oplugins-op/Dockerfile OPERATOR_SRC: "{{.OPERATOR_IMG}}:{{.OPERATOR_TAG}}" STREAMER_TAG: "{{.OPERATOR_TAG}}" STREAMER_SRC: "docker.io/apache/openserverless-streamer:{{.STREAMER_TAG}}" ADMIN_API_TAG: "{{.OPERATOR_TAG}}" ADMIN_API_SRC: "docker.io/apache/openserverless-admin-api:{{.ADMIN_API_TAG}}" RUNTIMES_TAG: "all_{{.OPERATOR_TAG}}" OPENWHISK_TAG: "{{.OPERATOR_TAG}}" CONTROLLER_SRC: "docker.io/apache/openserverless-wsk-controller:{{.OPENWHISK_TAG}}" INVOKER_SRC: "docker.io/apache/openserverless-wsk-invoker:{{.OPENWHISK_TAG}}" DEVCONTAINER_TAG: "{{.OPERATOR_TAG}}" DEVCONTAINER_SRC: "docker.io/apache/openserverless-devcontainer:{{.DEVCONTAINER_TAG}}" OPS_BRANCH: "{{.OPERATOR_TAG}}" CMD: "check" TEST_TYPE: "kind" RAT_VERSION: 0.18 RAT: "apache-rat-{{.RAT_VERSION}}.jar" tasks: default: silent: true cmds: - task -l - echo release '{{.RELEASE}}' clean: desc: clean the intermediate artifacts cmds: - rm -vf ./ops ~/.ops/{{OS}}-{{ARCH}}/images/kind/* - rm -vf ./ops image-save: desc: save an a SRC image in the TGT file requires: { vars: [SRC]} env: TGT: sh: | B64="$(echo -n {{.SRC}} | /usr/bin/base64 -w0)" echo ~/.ops/{{OS}}-{{ARCH}}/images/kind/$B64 cmds: - echo Saving {{.SRC}} in "$TGT" - mkdir -p "$(dirname $TGT)" - docker save {{.SRC}} -o "$TGT" status: - ! test -e "$TGT" cli: desc: build the cli dir: cli cmds: - go build -o ../ops cmd/ops/main.go status: - ! test -e ../ops operator: desc: build the operator deps: - cli dir: oplugins-op cmds: - echo Building {{.OPERATOR_SRC}} - git tag -d $(git tag) && git tag {{.OPERATOR_TAG}} - task b:build - task: image-save vars: SRC: "{{.OPERATOR_SRC}}" streamer: desc: build the streamer deps: - cli dir: streamer cmds: - echo Building {{.STREAMER_SRC}} - git tag -d $(git tag) && git tag {{.STREAMER_TAG}} - echo -e "NAMESPACE=apache\nREGISTRY=dockerhub\n" >.env - task buildx - task: image-save vars: SRC: "{{.STREAMER_SRC}}" admin-api: desc: build the admin-api deps: - cli dir: admin-api cmds: - echo Building {{.ADMIN_API_SRC}} - git tag -d $(git tag) && git tag {{.STREAMER_TAG}} - echo -e "NAMESPACE=apache\nREGISTRY=dockerhub\n" >.env - task buildx - task: image-save vars: SRC: "{{.ADMIN_API_SRC}}" openwhisk: desc: build openwhisk dir: build env: PATH: "{{.TASKFILE_DIR}}:$PATH" OPS_ROOT: "{{.TASKFILE_DIR}}" cmds: - echo Building OpenServerless - git tag -d $(git tag) && git tag {{.OPENWHISK_TAG}} - | export PATH="{{.TASKFILE_DIR}}:$PATH" export OPS_ROOT="{{.TASKFILE_DIR}}/oplugins" task build-all - task: image-save vars: SRC: "{{.CONTROLLER_SRC}}" - task: image-save vars: SRC: "{{.INVOKER_SRC}}" runtimes: desc: build current runtimes.json dir: runtimes cmds: - git tag -d $(git tag) && git tag {{.RUNTIMES_TAG}} - task build - task render-runtimes - cp runtimes.json ../oplugins/runtimes.json - task: runtimes-save runtimes-save: desc: save runtimes images dir: runtimes vars: IMAGES: sh: jq -r '.runtimes[][] | select(.default == true or .kind == "python:sys") | "\(.image.prefix)/\(.image.name):\(.image.tag)"' runtimes.json | grep -v php cmds: - for: { var: IMAGES, split: "\n", as: IMG } task: image-save vars: SRC: "{{.IMG}}" TGT: sh: echo ~/.ops/{{OS}}-{{ARCH}}/images/kind/$(echo {{.IMG}} | /usr/bin/base64 -w0) opsroot: desc: build current opsroot.json dir: oplugins cmds: - test -e opsroot.orig || jq . opsroot.orig - > jq opsroot.json ' .config.images.operator = "{{.OPERATOR_SRC}}" | .config.images.streamer = "{{.STREAMER_SRC}}" | .config.images.systemapi = "{{.ADMIN_API_SRC}}" | .config.images.controller = "{{.CONTROLLER_SRC}}" | .config.images.invoker = "{{.INVOKER_SRC}}" | .config.images.devcontainer = "{{.DEVCONTAINER_SRC}}" ' - diff opsroot.orig opsroot.json || true opslink: desc: link ops cmds: - task: cli - mkdir -p ~/.local/bin ~/.ops/{{.OPS_BRANCH}} - ln -sf $(pwd)/ops ~/.local/bin/ops - test -d ~/.ops/{{.OPS_BRANCH}}/oplugins || ln -sf $(pwd)/oplugins ~/.ops/{{.OPS_BRANCH}}/oplugins - touch ~/.profile - | if ! grep -q OPS_BRANCH= ~/.profile then echo export OPS_BRANCH={{.OPS_BRANCH}} >>~/.profile fi - | if ! grep -q 'PATH=~/.local/bin' ~/.profile then echo 'export PATH=~/.local/bin:"$PATH"' >>~/.profile fi gitinit: desc: initialize git if missing cmds: - | for i in build cli oplugins-op runtimes streamer admin-api do cd "$i" if ! test -e .git then git init 2>/dev/null git commit -m "init" --allow-empty fi cd .. done build: desc: build all cmds: - task: gitinit - task: opslink - task: openwhisk - task: operator - task: runtimes - task: streamer - task: admin-api - task: opsroot test: desc: execute all the tests dir: testing/tests cmds: - | export PATH="{{.TASKFILE_DIR}}:$PATH" export OPS_ROOT="{{.TASKFILE_DIR}}/oplugins" export OPS_BRANCH="{{.OPS_BRANCH}}" which ops ops -info ops setup docker delete || true touch .secrets ./all.sh {{.TEST_TYPE}} test-one: desc: execute one test specified by TEST, empty valure to list tests requires: { vars: [TEST] } dir: testing/tests cmds: - | export PATH="{{.TASKFILE_DIR}}:$PATH" export OPS_ROOT="{{.TASKFILE_DIR}}/oplugins" export OPS_BRANCH="{{.OPS_BRANCH}}" which ops ops -info if test -e '{{.TEST}}' then echo "Running {{.TEST}}" if ./{{.TEST}} {{.TEST_TYPE}} then echo SUCCESS else echo FAIL fi else echo test not found, tests are ls *-*.sh | awk '{ print "- " $1 }' fi license: silent: true desc: check license headers cmds: - | license-eye header {{.CMD}} for i in */.licenserc.yaml do DIR="$(dirname $i)" echo "*** Checking license headers in $DIR" cd $DIR license-eye header {{.CMD}} cd {{.TASKFILE_DIR}} done rat-install: cmds: - | if ! java --version then echo install java 17 at least ; exit 1 fi - wget https://dlcdn.apache.org//creadur/apache-rat-{{.RAT_VERSION}}/apache-rat-{{.RAT_VERSION}}-bin.zip - unzip -j apache-rat-{{.RAT_VERSION}}-bin.zip apache-rat-{{.RAT_VERSION}}/apache-rat-{{.RAT_VERSION}}.jar - rm apache-rat-{{.RAT_VERSION}}-bin.zip - java -jar {{.RAT}} -help status: - test -e {{.RAT}} rat-check: desc: check ASF license compliance with Apache RAT cmds: - task: rat-install - java -jar {{.RAT}} --input-exclude-file .rat-excludes -- . rat-list: desc: list files RAT does not approve, one per line (T=all to list every file) vars: XML: .task/rat.xml cmds: - mkdir -p .task - defer: rm -f {{.XML}} - java -jar {{.RAT}} --input-exclude-file .rat-excludes --output-file {{.XML}} --output-style xml -- . >/dev/null 2>&1 || true - | python3 - {{.XML}} {{.T}} <<'EOF' import sys, xml.etree.ElementTree as ET xml = sys.argv[1] show_all = len(sys.argv) > 2 and sys.argv[2] == 'all' for res in ET.parse(xml).getroot().iter('resource'): approved = any(l.get('approval') == 'true' for l in res.findall('license')) if approved and not show_all: continue lic = ','.join(l.get('id') or '?' for l in res.findall('license')) or '-' print(f"{res.get('type'):9} {res.get('mediaType'):26} {lic:12} {res.get('name')}") EOF find-binaries: silent: true desc: find binary files cmds: # configurator.js is a false positive because of an embedded unicode character - > find . -name .git -prune -o -iname '*.png' -prune -o -iname '*.jpg' -prune -o -iname '*.ico' -prune -o -path './oplugins/util/config/configurator.js' -prune -o -type f -size +0 -print0 | xargs -0 file --mime-encoding | grep ':.*\bbinary$' | cut -d: -f1 sync-images: desc: synchronize runtimes.json and opsroot.json with the images published by the origin user, asking before writing cmds: - python3 syncimages.py rebuild-images: desc: rebuild all the images cmds: - | for i in build oplugins-op admin-api runtimes streamer do task -d $i tag ci done targz: requires: {vars: [FILE]} cmds: - > {{if eq OS "darwin"}}gtar{{else}}tar{{end}} -C .. --exclude-from={{.TASKFILE_DIR}}/no-release.txt --transform 's,^openserverless,apache-openserverless-{{.VER}}-incubating,' -czvf ../{{.FILE}} openserverless release: desc: release - the source must be in version folder and you need a gpg key to sign requires: vars: [ VER, RC, KEY ] vars: FILE: apache-openserverless-{{.VER}}-incubating-src.tar.gz TAG: v{{.VER}}-incubating{{.RC}} cmds: - test -d ../../{{.VER}}-incubating{{.RC}}/openserverless || { echo "parent dir does not match with version" ; exit 1; } - gpg --list-secret-keys | grep "{{or .KEY "missing" }}" || { echo "key not found in gpg" ; exit 1; } - rm -f -v ../apache-openserverless-* || true - git tag -d $(git tag) || true - git tag "{{.TAG}}" - task targz FILE={{.FILE}} - gpg --armor --detach-sign --local-user {{.KEY}} ../{{.FILE}} - cd .. && shasum -a 512 {{.FILE}} >{{.FILE}}.sha512 - python3 releasing.py {{.TAG}} >../../{{.VER}}-incubating{{.RC}}.txt