5
2
mirror of https://github.com/getbible/v2_builder.git synced 2024-11-25 20:17:32 +00:00

Added github workflow action behaviour for testing, and build (in progress).

This commit is contained in:
Llewellyn van der Merwe 2021-04-23 05:50:33 +02:00
parent c776fb9435
commit a6464f3c55
Signed by: Llewellyn
GPG Key ID: EFC0C720A240551C
5 changed files with 164 additions and 44 deletions

33
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,33 @@
name: "Build getBible static JSON API files"
on:
# run once per/day
schedule:
- cron: '7 7 * * *'
# also run if we merge staging into master
push:
branches:
- master
# so we can manually run a build
workflow_dispatch:
jobs:
build:
runs-on: [ubuntu-20.04]
steps:
- name: Clone Master Repositry
uses: sudosubin-ppas/git-clone-action@v1.0.0
with:
repository: getbible/v2_builder
ref: master
- name: Install Dependancies
run: |
sudo apt install python3.8 python3-pip python3-requests
sudo pip3 install future
sudo pip3 install pysword
# not ready....
# - name: Build the JSON Bible files
# run: |
# /bin/bash ./run.sh --github --push

30
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,30 @@
name: "Test getBible static JSON API build"
on:
# run a test when pushing to master, and when pull request is made to staging
push:
branches:
- staging
pull_request:
branches:
- staging
# so we can manually run a test also
workflow_dispatch:
jobs:
build:
runs-on: [ubuntu-20.04]
steps:
- name: Clone Staging Repositry
uses: sudosubin-ppas/git-clone-action@v1.0.0
with:
repository: getbible/v2_builder
ref: staging
- name: Install Dependancies
run: |
sudo apt install python3.8 python3-pip python3-requests
sudo pip3 install future
sudo pip3 install pysword
- name: Build the JSON Bible files
run: |
/bin/bash ./run.sh --github --test

View File

@ -27,13 +27,14 @@ Should you like to contribute any improvements either in code or conduct, just o
Install Python3.8+ Install Python3.8+
```bash ```bash
$ sudo apt-get update $ sudo apt update
$ sudo apt-get install python3.8 python3-pip $ sudo apt install python3.8 python3-pip python3-requests
``` ```
> make sure the [python3 version is 3.8](https://askubuntu.com/a/892322/379265) or higher so that the JSON order remains the same as found on [our API](https://github.com/getbible/v2), else your hash values will not be the same. > make sure the [python3 version is 3.8](https://askubuntu.com/a/892322/379265) or higher so that the JSON order remains the same as found on [our API](https://github.com/getbible/v2), else your hash values will not be the same.
Install [pysword](https://gitlab.com/tgc-dk/pysword) (A native Python reader of the SWORD Project Bible Modules) Install [pysword](https://gitlab.com/tgc-dk/pysword) (A native Python reader of the SWORD Project Bible Modules)
```bash ```bash
$ sudo pip3 install future
$ sudo pip3 install pysword $ sudo pip3 install pysword
``` ```
@ -135,6 +136,11 @@ You are able to change a few default behaviours in the getBible API builder
example: ./run.sh --hashonly example: ./run.sh --hashonly
====================================================== ======================================================
--github
Trigger github workflow behaviour
example: ./run.sh --github
======================================================
--test --test
Run a test with only three Bibles Run a test with only three Bibles

51
run.sh
View File

@ -101,6 +101,14 @@ function getModules() {
# we first delete the old modules # we first delete the old modules
rm -fr "${modules_path}" rm -fr "${modules_path}"
mkdir -p "${modules_path}" mkdir -p "${modules_path}"
# run in github action workflow... ¯\_(ツ)_/¯
if (("$GITHUB" == 1)); then
echo "Start download of modules..."
python3 "${DIR_src}/download.py" \
--output_path "${modules_path}" \
--bible_conf "${DIR_bible}" >>/dev/null
echo "Done downloading modules..."
else
# then we get the current modules # then we get the current modules
{ {
sleep 1 sleep 1
@ -113,6 +121,7 @@ function getModules() {
echo -e "XXX\n100\nDone downloading modules... \nXXX" echo -e "XXX\n100\nDone downloading modules... \nXXX"
sleep 2 sleep 2
} | showProgress "Get Crosswire Modules | ${HEADERTITLE}" "Please wait while we download all modules" } | showProgress "Get Crosswire Modules | ${HEADERTITLE}" "Please wait while we download all modules"
fi
} }
# prep the Scripture Main Git Folder # prep the Scripture Main Git Folder
@ -143,6 +152,23 @@ function setStaticJsonFiles() {
local modules_path="$2" local modules_path="$2"
local each="$3" local each="$3"
local counter=0 local counter=0
# run in github action workflow... ¯\_(ツ)_/¯
if (("$GITHUB" == 1)); then
echo "Start Building..."
for filename in $modules_path/*.zip; do
# give notice
echo "Building ${filename} static json files"
# run script
python3 "${DIR_src}/sword_to_json.py" \
--source_file "${filename}" \
--output_path "${scripture_path}" \
--conf_dir "${DIR_conf}" \
--bible_conf "${DIR_bible}" >>/dev/null
# give notice
echo "Done building ${filename} static json files..."
done
echo "Done Building..."
else
# build the files # build the files
{ {
sleep 1 sleep 1
@ -169,6 +195,7 @@ function setStaticJsonFiles() {
echo -e "XXX\n100\nDone Building... \nXXX" echo -e "XXX\n100\nDone Building... \nXXX"
sleep 1 sleep 1
} | showProgress "Build Static JSON Files | ${HEADERTITLE}" "Please wait while build the static json API" } | showProgress "Build Static JSON Files | ${HEADERTITLE}" "Please wait while build the static json API"
fi
} }
# Remove Empty Folder & Static Files # Remove Empty Folder & Static Files
@ -225,6 +252,15 @@ function hashingMethod() {
local w_end_ms="$5" local w_end_ms="$5"
local w_initial_ms="$6" local w_initial_ms="$6"
local each="$7" local each="$7"
# run in github action workflow... ¯\_(ツ)_/¯
if (("$GITHUB" == 1)); then
echo "$w_title | ${HEADERTITLE}"
echo "$w_initial_ms"
echo "${w_start_ms}..."
# now run the hashing
. "${DIR_src}/${script_name}.sh" "${scripture_path}" "$each" >>/dev/null
echo "${w_end_ms}..."
else
# now run the hashing # now run the hashing
{ {
sleep 1 sleep 1
@ -235,6 +271,7 @@ function hashingMethod() {
echo -e "XXX\n100\n${w_end_ms}... \nXXX" echo -e "XXX\n100\n${w_end_ms}... \nXXX"
sleep 1 sleep 1
} | showProgress "$w_title | ${HEADERTITLE}" "$w_initial_ms" } | showProgress "$w_title | ${HEADERTITLE}" "$w_initial_ms"
fi
} }
# set any/all default config property # set any/all default config property
@ -247,6 +284,7 @@ function setDefaults() {
DOWNLOAD=$(getDefault "getbible.download" "$DOWNLOAD") DOWNLOAD=$(getDefault "getbible.download" "$DOWNLOAD")
PUSH=$(getDefault "getbible.push" "$PUSH") PUSH=$(getDefault "getbible.push" "$PUSH")
HASHONLY=$(getDefault "getbible.hashonly" "$HASHONLY") HASHONLY=$(getDefault "getbible.hashonly" "$HASHONLY")
GITHUB=$(getDefault "getbible.github" "$GITHUB")
QUIET=$(getDefault "getbible.quiet" "$QUIET") QUIET=$(getDefault "getbible.quiet" "$QUIET")
fi fi
} }
@ -332,6 +370,11 @@ You are able to change a few default behaviours in the getBible API builder
example: ${0##*/:-} --hashonly example: ${0##*/:-} --hashonly
====================================================== ======================================================
--github
Trigger github workflow behaviour
example: ${0##*/:-} --github
======================================================
--test --test
Run a test with only three Bibles Run a test with only three Bibles
@ -380,6 +423,8 @@ DRYRUN=0
HASHONLY=0 HASHONLY=0
# kill all messages # kill all messages
QUIET=0 QUIET=0
# trigger github workflow behaviour
GITHUB=0
# check if we have options # check if we have options
while :; do while :; do
@ -406,6 +451,11 @@ while :; do
--dry) --dry)
DRYRUN=1 DRYRUN=1
;; ;;
--github)
# github actions workflow behaviour... ¯\_(ツ)_/¯
GITHUB=1
QUIET=1
;;
--push) --push)
PUSH=1 PUSH=1
;; ;;
@ -493,6 +543,7 @@ if (("$DRYRUN" == 1)); then
echo "DIR_bible: ${DIR_bible}" echo "DIR_bible: ${DIR_bible}"
echo "QUIET: ${QUIET}" echo "QUIET: ${QUIET}"
echo "HASHONLY: ${HASHONLY}" echo "HASHONLY: ${HASHONLY}"
echo "GITHUB: ${GITHUB}"
echo "DOWNLOAD: ${DOWNLOAD}" echo "DOWNLOAD: ${DOWNLOAD}"
echo "PUSH: ${PUSH}" echo "PUSH: ${PUSH}"
echo "CONFIGFILE: ${CONFIGFILE}" echo "CONFIGFILE: ${CONFIGFILE}"

View File

@ -15,8 +15,8 @@ parser = argparse.ArgumentParser()
# get the arguments # get the arguments
parser.add_argument('--source_file') parser.add_argument('--source_file')
parser.add_argument('--output_path') parser.add_argument('--output_path')
parser.add_argument('--counter') parser.add_argument('--counter', default=0)
parser.add_argument('--next') parser.add_argument('--next', default=90)
parser.add_argument('--conf_dir') parser.add_argument('--conf_dir')
parser.add_argument('--bible_conf') parser.add_argument('--bible_conf')
# set to args # set to args