-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·82 lines (66 loc) · 1.66 KB
/
run
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
#!/usr/bin/env bash
set -Eeo pipefail
shopt -s globstar
function version() {
export BRANCH=${CIRCLE_BRANCH-$(git rev-parse --abbrev-ref HEAD)}
export BUILD_NUMBER=${CIRCLE_BUILD_NUM-$(date -u +"%Y%m%d%H%M%S")}
export REVISIONS=$(git rev-list --count ${BRANCH})
export VERSION=0.${REVISIONS}.${BUILD_NUMBER}
echo version: ${VERSION}
}
function setup_asdf() {
if [[ ! $(command -v asdf) ]]; then
if [[ ! -f "$HOME/.asdf/asdf.sh" ]]; then
echo "* Downloading and installing asdf..."
git clone -c advice.detachedHead=false https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.12.0 > /dev/null 2>&1
fi
. "$HOME/.asdf/asdf.sh"
fi
}
function setup_deno() {
setup_asdf
if [[ ! $(asdf plugin list) =~ deno ]]; then
echo "* Downloading and installing deno plugin..."
asdf plugin add deno > /dev/null 2>&1
fi
asdf install
}
function tag() {
version
git config --global user.name "Server"
git config --global user.email "[email protected]"
git tag -a ${VERSION} -m "Release ${VERSION}"
git push origin ${VERSION}
}
function clean() {
rm -rf artifacts
}
function check() {
deno check {src,test}/**/*.ts
deno lint --compact
}
function test() {
deno test --parallel --allow-net "$@" ./test/
}
function test-with-coverage() {
mkdir -p artifacts/coverage
test --junit-path=artifacts/test-results --coverage=artifacts/coverage
deno coverage --lcov artifacts/coverage/ --output=artifacts/coverage.lcov
}
function dev() {
test --watch
}
function build() {
check
test
}
function ci() {
check
test-with-coverage
tag
}
setup_deno
clean
command="${1-build}"
set +e; shift; set -Eeo pipefail;
$command "$@"