forked from apache/openserverless-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yml
150 lines (131 loc) · 3.91 KB
/
Taskfile.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# 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