2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-11-09 14:50:58 +00:00

ci: check shell script format

This commit is contained in:
Revant Nandgaonkar 2021-06-24 16:54:17 +05:30
parent 391ee4c74e
commit 86a2fcc1fa
5 changed files with 58 additions and 35 deletions

View File

@ -156,8 +156,9 @@ jobs:
- sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- sudo chmod +x /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose
- sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose - sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
- sudo apt-get update && sudo apt-get -y install w3m - sudo apt-get update && sudo apt-get -y install w3m shellcheck
script: script:
- ./tests/check-format.sh
- docker build -t frappe/frappe-socketio:edge -f build/frappe-socketio/Dockerfile . - docker build -t frappe/frappe-socketio:edge -f build/frappe-socketio/Dockerfile .
- docker build -t frappe/frappe-worker:develop -f build/frappe-worker/Dockerfile . - docker build -t frappe/frappe-worker:develop -f build/frappe-worker/Dockerfile .
- docker build -t frappe/erpnext-worker:edge -f build/erpnext-worker/Dockerfile . - docker build -t frappe/erpnext-worker:edge -f build/erpnext-worker/Dockerfile .

View File

@ -36,3 +36,33 @@ Place relevant markdown file(s) in the `docs` directory and index them in README
# Wiki # Wiki
Add alternatives that can be used optionally along with frappe_docker. Add articles to list on home page as well. Add alternatives that can be used optionally along with frappe_docker. Add articles to list on home page as well.
# Prerequisites to pass CI
### Check shell script format
Use the following script
```shell
./tests/check-format.sh
```
### Build images locally
Use the following commands
```shell
docker build -t frappe/frappe-socketio:edge -f build/frappe-socketio/Dockerfile .
docker build -t frappe/frappe-worker:develop -f build/frappe-worker/Dockerfile .
docker build -t frappe/erpnext-worker:edge -f build/erpnext-worker/Dockerfile .
docker build -t frappe/frappe-nginx:develop -f build/frappe-nginx/Dockerfile .
docker build -t frappe/erpnext-nginx:edge -f build/erpnext-nginx/Dockerfile .
```
### Test running docker containers
Use the following script
```shell
./tests/docker-test.sh
```

View File

@ -44,8 +44,7 @@ function configureEnv() {
} }
function checkConnection() { function checkConnection() {
. /home/frappe/frappe-bench/env/bin/activate /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/commands/check_connection.py
python /home/frappe/frappe-bench/commands/check_connection.py
} }
function checkConfigExists() { function checkConfigExists() {
@ -88,12 +87,10 @@ case "$1" in
LOAD_CONFIG_FILE="-c /home/frappe/frappe-bench/commands/gevent_patch.py" LOAD_CONFIG_FILE="-c /home/frappe/frappe-bench/commands/gevent_patch.py"
if [[ -n "${AUTO_MIGRATE}" ]]; then if [[ -n "${AUTO_MIGRATE}" ]]; then
. /home/frappe/frappe-bench/env/bin/activate /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/commands/auto_migrate.py
python /home/frappe/frappe-bench/commands/auto_migrate.py
fi fi
. /home/frappe/frappe-bench/env/bin/activate /home/frappe/frappe-bench/env/bin/gunicorn ${LOAD_CONFIG_FILE} -b 0.0.0.0:${FRAPPE_PORT} \
gunicorn ${LOAD_CONFIG_FILE} -b 0.0.0.0:${FRAPPE_PORT} \
--worker-tmp-dir /dev/shm \ --worker-tmp-dir /dev/shm \
--threads=4 \ --threads=4 \
--workers ${WORKERS} \ --workers ${WORKERS} \
@ -107,16 +104,14 @@ case "$1" in
checkConnection checkConnection
# default WORKER_TYPE=default # default WORKER_TYPE=default
. /home/frappe/frappe-bench/env/bin/activate /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/commands/worker.py
python /home/frappe/frappe-bench/commands/worker.py
;; ;;
schedule) schedule)
checkConfigExists checkConfigExists
checkConnection checkConnection
. /home/frappe/frappe-bench/env/bin/activate /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/commands/background.py
python /home/frappe/frappe-bench/commands/background.py
;; ;;
@ -124,8 +119,7 @@ case "$1" in
checkConfigExists checkConfigExists
checkConnection checkConnection
. /home/frappe/frappe-bench/env/bin/activate /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/commands/new.py
python /home/frappe/frappe-bench/commands/new.py
exit exit
;; ;;
@ -133,27 +127,23 @@ case "$1" in
checkConfigExists checkConfigExists
checkConnection checkConnection
. /home/frappe/frappe-bench/env/bin/activate /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/commands/drop.py
python /home/frappe/frappe-bench/commands/drop.py
exit exit
;; ;;
migrate) migrate)
. /home/frappe/frappe-bench/env/bin/activate /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/commands/migrate.py
python /home/frappe/frappe-bench/commands/migrate.py
exit exit
;; ;;
doctor) doctor)
. /home/frappe/frappe-bench/env/bin/activate /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/commands/doctor.py "${@:2}"
python /home/frappe/frappe-bench/commands/doctor.py "${@:2}"
exit exit
;; ;;
backup) backup)
. /home/frappe/frappe-bench/env/bin/activate /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/commands/backup.py
python /home/frappe/frappe-bench/commands/backup.py
exit exit
;; ;;
@ -164,20 +154,17 @@ case "$1" in
exit 1 exit 1
fi fi
. /home/frappe/frappe-bench/env/bin/activate /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/commands/console.py "$2"
python /home/frappe/frappe-bench/commands/console.py "$2"
exit exit
;; ;;
push-backup) push-backup)
. /home/frappe/frappe-bench/env/bin/activate /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/commands/push_backup.py
python /home/frappe/frappe-bench/commands/push_backup.py
exit exit
;; ;;
restore-backup) restore-backup)
. /home/frappe/frappe-bench/env/bin/activate /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/commands/restore_backup.py
python /home/frappe/frappe-bench/commands/restore_backup.py
exit exit
;; ;;
*) *)

View File

@ -4,13 +4,7 @@ APP_NAME=${1}
APP_REPO=${2} APP_REPO=${2}
APP_BRANCH=${3} APP_BRANCH=${3}
cd /home/frappe/frappe-bench/
. env/bin/activate
cd ./apps
[[ -n "${APP_BRANCH}" ]] && BRANCH="-b ${APP_BRANCH}" [[ -n "${APP_BRANCH}" ]] && BRANCH="-b ${APP_BRANCH}"
git clone --depth 1 -o upstream ${APP_REPO} ${BRANCH} ${APP_NAME} git clone --depth 1 -o upstream ${APP_REPO} ${BRANCH} /home/frappe/frappe-bench/apps/${APP_NAME}
pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/${APP_NAME} /home/frappe/frappe-bench/env/bin/pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/${APP_NAME}

11
tests/check-format.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
echo "Checking bash scripts with shellcheck" >&2
shellcheck --check-sourced --severity=style --color=always --exclude=SC2164,SC2086,SC2012,SC2016 \
build/common/worker/docker-entrypoint.sh \
build/common/worker/healthcheck.sh \
build/common/worker/install_app.sh \
build/erpnext-nginx/install_app.sh \
build/frappe-nginx/docker-entrypoint.sh \
build/frappe-socketio/docker-entrypoint.sh