| # 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: |
| BASEVER: "0.1.0" |
| VARIANT: "dev" |
| VERSION: |
| sh: git describe --tags --abbrev=0 2>/dev/null || git rev-parse --short HEAD |
| DEBUG: "" |
| |
| tasks: |
| |
| default: task -l |
| setup: { silent:true } |
| |
| tag: |
| desc: tag the cli to generate the build |
| cmds: |
| - git tag -d $(git tag) |
| - echo "{{.BASEVER}}-$(date +%y%m%d%H%M).{{.VARIANT}}" >version.txt |
| - echo "{{.BASEVER}}" >branch.txt |
| - git add version.txt branch.txt |
| - git commit -m "$(cat version.txt)" || true |
| - git tag -f "v$(cat version.txt)" |
| |
| |
| trigger: |
| desc: create tag and push triggering a build |
| prompt: did you commit everyting? |
| cmds: |
| - git diff --exit-code |
| - task: tag |
| - git push origin main --tags |
| |
| rebuild: |
| - rm -f ops |
| - task: build |
| |
| build: |
| aliases: [b] |
| desc: build ops locally |
| cmds: |
| - echo building {{.VERSION}} |
| - go build {{.DEBUG}} ./cmd/ops/ |
| sources: |
| - "*.go" |
| - "*/*.go" |
| - version.txt |
| - branch.txt |
| generates: |
| - ops |
| |
| debug: |
| aliases: [d] |
| cmds: |
| - task: build |
| vars: |
| DEBUG: "-gcflags '-l -N'" |
| - dlv exec ./ops -- {{.CLI_ARGS}} |
| |
| install: |
| aliases: [i] |
| desc: install ops in ~./local/bin |
| deps: |
| - build |
| cmds: |
| - mkdir -p $HOME/.local/bin |
| - cp -v ops $HOME/.local/bin |
| - | |
| if ! which ops | grep $HOME/.local/bin |
| then |
| echo "$HOME/.local/bin is not in the path - adding it" |
| echo 'export PATH="$HOME/.local/bin:$PATH"' >>$HOME/.bashrc |
| echo 'export PATH="$HOME/.local/bin:$PATH"' >>$HOME/.zshrc |
| echo to find ops in the path, please either source your .bashrc or .zshrc or restart your terminal |
| else |
| echo installed ops v$(ops -version) |
| fi |
| |
| |
| tests: |
| desc: all tests |
| cmds: |
| - task: install |
| - task: utest |
| - task: itest |
| |
| utest: |
| aliases: [ut] |
| desc: unit test (use F=-v to verbose) |
| cmds: |
| - rm -Rf ~/.ops |
| - go clean -testcache -cache |
| - go test -count=1 {{.F}} github.com/apache/openserverless-cli |
| - go test -count=1 {{.F}} github.com/apache/openserverless-cli/config |
| - go test -count=1 {{.F}} github.com/apache/openserverless-cli/tools |
| - go test github.com/apache/openserverless-cli/auth |
| |
| |
| bats: |
| dir: tests |
| cmds: |
| - git clone https://github.com/bats-core/bats-core bats |
| - git clone https://github.com/bats-core/bats-support test_helper/bats-support |
| - git clone https://github.com/bats-core/bats-assert test_helper/bats-assert |
| status: |
| - test -d bats |
| |
| itest: |
| aliases: [it] |
| desc: integration tests for ops (T=<test-name> without .bats, empty run all, pass flags with F=) |
| dir: tests |
| cmds: |
| - task: bats |
| - rm -Rf ~/.ops/olaris |
| - | |
| if test -z "{{.T}}" |
| then bats/bin/bats {{.F}} . |
| else bats/bin/bats {{.F}} {{.T}}.bats |
| fi |
| |
| clean: |
| - rm ops || true |
| - go clean -cache -modcache -testcache -fuzzcache |
| |
| utestdiff: |
| cmds: |
| - |- |
| if test -z '{{.N}}' |
| then go test -v | tee _difftest |
| python3 difftest.py |
| else python3 difftest.py {{.N}} |
| fi |
| |