| # 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: | |
| BASETAG: 0.9.0-incubating | |
| SUFFIX: "-snapshot" | |
| COMMIT_ID: | |
| sh: git rev-parse --short HEAD | |
| # taken from the tag - overridable with ADMINAPI_TAG env var | |
| TAG: | |
| sh: echo "${ADMINAPI_TAG:-$(git describe --tags --abbrev=0 2>/dev/null || git rev-parse --short HEAD)}" | |
| # taken from the Dockerfile - overridable with MY_ADMINAPI_IMAGE env var | |
| ADMINAPI_IMAGE: | |
| sh: echo "${MY_ADMINAPI_IMAGE:-$(awk -F= '/ARG ADMINAPI_IMAGE_DEFAULT=/ { print $2 ; exit }' Dockerfile)}" | |
| dotenv: | |
| - .env | |
| includes: | |
| builder: | |
| taskfile: TaskfileBuilder.yml | |
| dev: | |
| taskfile: TaskfileDev.yml | |
| tasks: | |
| docker-login-ghcr: | |
| silent: true | |
| cmds: | |
| - | | |
| echo "Logging in to ghcr.io as $GITHUB_USER" | |
| echo $GITHUB_TOKEN | docker login ghcr.io -u $GITHUB_USER --password-stdin | |
| docker-login-dockerhub: | |
| silent: true | |
| cmds: | |
| - | | |
| echo "Logging in to docker.io as $DOCKERHUB_USER" | |
| echo $DOCKERHUB_TOKEN | docker login docker.io -u $DOCKERHUB_USER --password-stdin | |
| docker-login: | |
| desc: | | |
| Login to the registry the image name points to: docker.io for apache images, | |
| ghcr.io otherwise. | |
| silent: true | |
| cmds: | |
| - | | |
| IMG="${MY_ADMINAPI_IMAGE:-{{.ADMINAPI_IMAGE}}}" | |
| case "$IMG" in | |
| ghcr.io/*) task docker-login-ghcr ;; | |
| *) task docker-login-dockerhub ;; | |
| esac | |
| image: | |
| desc: | | |
| Print the image name that would be built. | |
| silent: true | |
| cmds: | |
| - echo "AdminApi=${MY_ADMINAPI_IMAGE:-{{.ADMINAPI_IMAGE}}}:{{.TAG}}" | |
| # deprecated - use task tag | |
| image-tag: | |
| desc: "[deprecated] use task tag" | |
| silent: true | |
| cmds: | |
| - 'echo "deprecated, use task tag"' | |
| tag: | |
| desc: | | |
| Create a new snapshot tag for the current git commit. | |
| NOTE: this deletes the existing local tags first - snapshot tags are disposable. | |
| 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 -d $(git tag) 2>/dev/null || true | |
| - | | |
| TAG="{{.BASETAG}}.{{.TS}}{{.SUFFIX}}" | |
| git tag -f $TAG | |
| echo New tag $TAG | |
| ci: | |
| desc: | | |
| Push the tags, starting the GitHub Actions build on the repo that received them. | |
| This does not build anything locally. | |
| cmds: | |
| - git push --tags | |
| buildx: | |
| desc: | | |
| Build the docker image using buildx. Set PUSH=1 to push the image to the registry. | |
| silent: true | |
| cmds: | |
| - | | |
| IMG="${MY_ADMINAPI_IMAGE:-{{.ADMINAPI_IMAGE}}}:{{.TAG}}" | |
| if [ -n "{{.PUSH}}" ]; then | |
| {{.DRY}} docker buildx build -t "$IMG" \ | |
| --build-arg ADMINAPI_IMAGE_DEFAULT="${MY_ADMINAPI_IMAGE:-{{.ADMINAPI_IMAGE}}}" \ | |
| --build-arg ADMINAPI_TAG_DEFAULT="{{.TAG}}" \ | |
| --platform linux/amd64,linux/arm64 . --push | |
| else | |
| {{.DRY}} docker buildx build -t "$IMG" \ | |
| --build-arg ADMINAPI_IMAGE_DEFAULT="${MY_ADMINAPI_IMAGE:-{{.ADMINAPI_IMAGE}}}" \ | |
| --build-arg ADMINAPI_TAG_DEFAULT="{{.TAG}}" \ | |
| . --load | |
| fi | |
| echo "Built $IMG" | |
| build: | |
| silent: true | |
| desc: Build the docker image locally and load it into the local docker daemon. | |
| cmds: | |
| - uv lock --upgrade | |
| - task: buildx | |
| build-and-load: | |
| silent: true | |
| desc: Build the image and loads it to local Kind cluster | |
| cmds: | |
| - task: build | |
| - | | |
| IMG="${MY_ADMINAPI_IMAGE:-{{.ADMINAPI_IMAGE}}}:{{.TAG}}" | |
| kind load docker-image $IMG --name=openserverless | |
| utest: | |
| cmds: | |
| - | | |
| for test in openserverless/common/{{.T}}*.py | |
| do echo "*** [{{.KUBE}}] $test" | |
| uv run python3 -m doctest -o ELLIPSIS $test {{.CLI_ARGS}} | |
| done | |
| silent: true | |
| utest-sso: | |
| desc: test OIDC flows and legacy authentication compatibility without a cluster | |
| cmds: | |
| - uv run python3 -m unittest discover -s tests -v |