This repository was archived by the owner on Mar 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJustfile
executable file
·157 lines (133 loc) · 5.26 KB
/
Justfile
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
150
151
152
153
154
155
156
#!/usr/bin/env bash
source "${VSI_COMMON_DIR}/linux/just_env" "$(dirname "${BASH_SOURCE[0]}")"/'just'.env
# Plugins
source "${VSI_COMMON_DIR}/linux/docker_functions.bsh"
source "${VSI_COMMON_DIR}/linux/just_docker_functions.bsh"
source "${VSI_COMMON_DIR}/linux/just_git_functions.bsh"
source "${VSI_COMMON_DIR}/linux/colors.bsh"
cd "${JUST_CWD}"
# Main function
function caseify()
{
local just_arg=$1
shift 1
case ${just_arg} in
build) # Build Docker image
if [ "$#" -gt "0" ]; then
Docker-compose "${just_arg}" ${@+"${@}"}
extra_args=$#
else
(justify build_recipes vsi gosu)
Docker-compose build
fi
;;
build_local) # Build local environment (for testing)
mkdir -p "${JUST_CWD}/build"
pushd "${JUST_CWD}/build"
curl -LO "https://github.com/megastep/makeself/archive/${JUST_MAKESELF_VERSION}/makeself.tar.gz"
tar xf makeself.tar.gz --strip-components=1; \
rm makeself.tar.gz
sed '1,/^while true/s|^while true|while false|; 1,/^quiet="n"/s|^quiet="n"|quiet="y"|' "${JUST_CWD}/build/makeself-header.sh" > "${JUST_CWD}/build/makeself-header_just.sh"
popd &> /dev/null
;;
run_make) # Run makeself
Just-docker-compose run makeself ${@+"${@}"}
extra_args=$#
;;
compile_make) # Compile the sh binary
Just-docker-compose run makeself
;;
compile_local) # Compile the binary locally (for testing)
mkdir -p "${JUST_CWD}/dist"
${DRYRUN} "${JUST_CWD}/build/makeself.sh" --tar-extra "--exclude=.git --exclude=docs ../.juste_wrapper" --noprogress --nomd5 --nocrc --nox11 --keep-umask --header "${JUST_CWD}/build/makeself-header_just.sh" vsi_common/ "${JUST_CWD}/dist/juste" juste_label ./.juste_wrapper
;;
compile_darwin) # Compile the binary locally (for testing on darwin)
mkdir -p "${JUST_CWD}/dist"
cp "${JUST_CWD}/.juste_wrapper" "${JUST_CWD}/vsi_common/"
${DRYRUN} "${JUST_CWD}/build/makeself.sh" --tar-extra "--exclude=.git --exclude=docs" --noprogress --nomd5 --nocrc --nox11 --keep-umask --header "${JUST_CWD}/build/makeself-header_just.sh" vsi_common/ "${JUST_CWD}/dist/juste" juste_label ./.juste_wrapper
rm "${JUST_CWD}/vsi_common/.juste_wrapper"
;;
sync) # Synchronize the many aspects of the project when new code changes \
# are applied e.g. after "git checkout"
justify _sync
# Add any extra steps run when syncing when not installing
;;
_sync)
Docker-compose down
if [ ! -e "${JUST_CWD}/.just_synced" ]; then
# Add any commands here, like initializing a database, etc... that need
# to be run the first time sync is run.
touch "${JUST_CWD}/.just_synced"
fi
justify git_submodule-update # For those users who don't remember!
justify build
;;
clean) # Remove all binary artifacts
if [ -x "${JUST_CWD}/dist" ]; then
rm -r "${JUST_CWD}/dist"
fi
if [ -x "${JUST_CWD}/build" ]; then
rm -r "${JUST_CWD}/build"
fi
;;
## upload_release) # Upload a new release to github - $1 - release name
# ${DRYRUN} hub release create -a "${JUST_CWD}/juste" "${1}"
# extra_args=1
# ;;
release) # Stamp a new release. $1 - release version (e.g. "0.0.1")
local version=$1
if ! git diff-index --quiet HEAD &> /dev/null; then
echo "${RED}Repo is dirty${NC}, please commit uncommited changes"
exit 1
fi
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then
echo "${RED}Current just branch is not master${NC}, please fix and try again"
exit 1
fi
# TODO: Make BSD compatible
sed -i 's|export JUST_VERSION=.*|export JUST_VERSION='"${version}"'|' vsi_common/linux/just_common.bsh
pushd vsi_common &> /dev/null
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then
echo "${RED}Current vsi_common branch is not master${NC}, please fix and try again"
exit 1
fi
git add linux/just_common.bsh
git commit -m "Just $version" || :
git push origin master
git tag "just_${version}"
echo "Waiting for CI to pass..."
local rv=2
while [ "${rv}" = "2" ]; do
echo -n .
sleep 10
rv=0
hub ci-status "$(git rev-parse HEAD)" &> /dev/null || rv=$?
done
if [ "${rv}" != "0" ]; then
echo "${RED}CI Tests failed${NC}, please fix and try again"
exit 1
fi
git push origin "just_${version}"
popd &> /dev/null
git add vsi_common
git commit -m "Just ${version}"
git tag "${version}"
git push origin master "${version}"
sed -i 's|export JUST_VERSION=.*|export JUST_VERSION='"${version}+1dev"'|' vsi_common/linux/just_common.bsh
pushd vsi_common &> /dev/null
git add linux/just_common.bsh
git commit -m "Just $version+1dev"
git push origin master
popd &> /dev/null
extra_args=1
;;
test) # Run integration tests
TESTS_DIR="${JUST_CWD}/tests" "${VSI_COMMON_DIR}/tests/run_tests.bsh" ${@+"${@}"}
extra_args=$#
;;
*)
defaultify "${just_arg}" ${@+"${@}"}
;;
esac
}
if ! command -v justify &> /dev/null; then caseify ${@+"${@}"};fi