forked from vinland-technology/flict
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkflow.sh
More file actions
executable file
·143 lines (127 loc) · 3.08 KB
/
workflow.sh
File metadata and controls
executable file
·143 lines (127 loc) · 3.08 KB
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
#!/bin/bash
###################################################################
#
# SPDX-FileCopyrightText: 2021 Jens Erdmann
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
###################################################################
# Python revision to select the docker container
PYTHON_VERSION="${PYTHON_VERSION:-3.9.8}"
# default project directory
PROJECT_DIR="${PROJECT_DIR:-/project}"
# Project source directory
SRC_DIR="${SRC_DIR:-${PWD}}"
# directory to store virtual environment at
VENV_DIR="${VENV_DIR:-/tmp/venv}"
# option to install test dependencies
INSTALL_TEST="${INSTALL_TEST:-1}"
# Docker run arguments
DOCKERARGS="${DOCKERARGS:-\-\-rm}"
start_container()
{
docker run --rm -it \
--name flict-container \
-v ${SRC_DIR}:${PROJECT_DIR} \
--entrypoint="/bin/bash" \
python:${PYTHON_VERSION}
}
start_environment()
{
echo "Creating virtual environment at ${VENV_DIR} ..."
python3 -m venv ${VENV_DIR}
}
install_dependencies()
{
. ${VENV_DIR}/bin/activate
echo "Update python package feed ..."
python3 -m pip install --upgrade pip
echo "Install base dependencies ..."
python3 -m pip install -r ${PROJECT_DIR}/requirements.txt
if [ "${INSTALL_TEST}" -eq "1" ]; then
echo "Installing test dependencies ..."
python3 -m pip install -r ${PROJECT_DIR}/requirements-dev.txt
fi
}
build()
{
. ${VENV_DIR}/bin/activate
cd ${PROJECT_DIR}
python3 setup.py build
}
install()
{
. ${VENV_DIR}/bin/activate
cd ${PROJECT_DIR}
python3 setup.py install
}
run_tests()
{
. ${VENV_DIR}/bin/activate
pytest
}
build_and_install()
{
build && install
}
build_install_test()
{
build && install && run_tests
}
full_workflow()
{
start_environment && \
install_dependencies && \
build && \
install && \
run_tests
}
usage()
{
LAYOUT="\t%-20s\t%s\n"
printf "flict workflow script\n"
printf "Except 'container' all commands are expected to be run inside a container.\n"
printf "Usage: ${0} OPTION\n"
printf "Options:\n"
printf "${LAYOUT}" "build" "run build procedure"
printf "${LAYOUT}" "buildinstall" "run procedure to build and install"
printf "${LAYOUT}" "buildinstalltest" "run procedure to build, install, and test"
printf "${LAYOUT}" "container" "start a container to develop in"
printf "${LAYOUT}" "full" "setup development environment and run build, install, and test"
printf "${LAYOUT}" "install" "run install procedure"
printf "${LAYOUT}" "test" "run test procedure"
printf "${LAYOUT}" "venv" "create virtual environment (Python)"
}
case "${1}" in
build)
build
;;
buildinstall)
build_and_install
;;
buildinstalltest)
build_install_test
;;
container)
start_container
;;
dependencies)
install_dependencies
;;
full)
full_workflow
;;
install)
install
;;
test)
run_tests
;;
venv)
start_environment
;;
*)
usage ${0}
exit 1
;;
esac