Skip to content

Commit

Permalink
Update environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Limych committed Mar 9, 2021
1 parent 16e5ef8 commit b67e180
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ tab_width = 4

[*.{yml,yaml}]
indent_size = 2

[*.json]
indent_size = 2
36 changes: 18 additions & 18 deletions bin/devcontainer
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cd "${ROOT}"
# Load common functions
source ./bin/_common

dk=$(which docker) || die "ERROR: Docker not found."
docker=$(which docker) || die "ERROR: Docker not found."

workspace=${PWD##*/}
workdir="/workspaces/${workspace}"
Expand All @@ -21,26 +21,26 @@ volume="${ROOT}:${workdir}"

cmd="${1:-menu}"

dk_start() {
docker_start() {
tmp=$(echo "${port}" | cut -d":" -f-2)
tmp=$(${dk} ps | grep "${tmp}" | awk "{print \$NF}")
tmp=$(${docker} ps | grep "${tmp}" | awk "{print \$NF}")
if [ -n "${tmp}" ] ; then
log.info "Stop container ${tmp}..."
${dk} stop "${tmp}"
${docker} stop "${tmp}"
fi

log.info "Start container..."
${dk} start "${container}"
${docker} start "${container}"
}

if ! ${dk} ps -a | grep -wq ${container} && [[ "${cmd}" != "down" ]]; then
if ! ${docker} ps -a | grep -wq ${container} && [[ "${cmd}" != "down" ]]; then
log.info "Create container..."
${dk} create -it --name "${container}" -p "${port}" -v "${volume}" "${image}"
${docker} create -it --name "${container}" -p "${port}" -v "${volume}" "${image}"

dk_start
docker_start

log.info "Initialize container..."
${dk} exec -it -w "${workdir}" "${container}" container install
${docker} exec -it -w "${workdir}" "${container}" container install
fi

if [[ "${cmd}" == "menu" ]]; then
Expand Down Expand Up @@ -74,28 +74,28 @@ fi
case "${cmd}" in
"stop" )
log.info "Stop container..."
${dk} stop "${container}"
${docker} stop "${container}"
;;
"down" )
log.info "Destroy container..."
${dk} stop -t 10 "${container}" >/dev/null
${dk} rm "${container}"
${docker} stop -t 10 "${container}" >/dev/null
${docker} rm "${container}"
;;
"bash" )
if ! ${dk} ps | grep -wq ${container}; then
dk_start
if ! ${docker} ps | grep -wq ${container}; then
docker_start
fi
log.info "Interactive mode..."
${dk} exec -it "${container}" bash
${docker} exec -it "${container}" bash
;;
* )
if ! ${dk} ps | grep -wq ${container}; then
dk_start
if ! ${docker} ps | grep -wq ${container}; then
docker_start
fi
log.info "Send command '${cmd}' to container..."
if [[ "${cmd}" == "start" ]]; then
log.info "After Home Assistant initialization you can access to system on http://localhost:9123/"
fi
${dk} exec -it -w "${workdir}" "${container}" container "${cmd}"
${docker} exec -it -w "${workdir}" "${container}" container "${cmd}"
;;
esac
6 changes: 5 additions & 1 deletion bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ git commit -a --no-verify -m "Bump version"
git tag -a "$new" -m "v$new"
log.info "Commit tagged as v$new"

dev="$(echo "${new}" | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.).dev0"
if echo "${new}" | grep -Eq "[0-9](a|b|rc)"; then
dev="$(echo "${version}" | awk -F. '/[0-9]+\./{$NF="dev"($NF+1);print}' OFS=.)"
else
dev="$(echo "${new}" | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.).dev0"
fi

log.info "Patch files to version '${dev}'..."
sed -i -E "s/(^VERSION = \")[^\"]*/\\1${dev}/" ${const_path}
Expand Down
11 changes: 7 additions & 4 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,25 @@ set -e
ROOT="$( cd "$( dirname "$(readlink -f "$0")" )/.." >/dev/null 2>&1 && pwd )"
cd "${ROOT}"

python=$(which python3)
pip="${python} -m pip"

# Load common functions
source ./bin/_common

if [ ! -d "venv" ]; then
log.info "Initializing the virtual environment..."
/usr/bin/python3 -m venv venv
${python} -m venv venv
source ./venv/bin/activate
fi

log.info "Updating PIP..."
/usr/bin/python3 -m pip install --upgrade pip
${pip} install --upgrade pip

log.info "Installing development dependencies..."
pip3 install colorlog pre-commit $(grep mypy requirements-dev.txt)
${pip} install colorlog pre-commit $(grep mypy requirements-dev.txt)

pre-commit install
pip3 install -r requirements-dev.txt
${pip} install -r requirements-dev.txt

echo '"""Custom components module."""' >custom_components/__init__.py

0 comments on commit b67e180

Please sign in to comment.