From a4235b25b56e8e721a3bc3eb4451206650f7c1cd Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 May 2020 16:14:34 +0100 Subject: [PATCH 01/24] Improves GHA workflows --- .github/workflows/docker.yml | 9 +++++---- .github/workflows/lint.yml | 14 ++++++++++++-- .github/workflows/tests-mql.yml | 12 ++++++++++-- .github/workflows/tests-shell.yml | 11 ++++++++--- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0591e468..444b7355 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,15 +4,16 @@ name: Docker on: pull_request: paths-ignore: - - '*.md' - - '*.txt' + - '**/*.md' + - '**/*.txt' push: branches: - "master" - "dev*" paths-ignore: - - '*.md' - - '*.txt' + - '**/*.md' + - '**/*.txt' + - '**/*.yml' release: types: - published diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e81bbb2d..40b242c7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,8 +1,18 @@ --- name: Lint + on: - - pull_request - - push + pull_request: + paths: + - '**/*.mq?' + - '**/*.sh' + - '*.y?ml' + push: + paths: + - '**/*.mq?' + - '**/*.sh' + - '**/*.y?ml' + jobs: YAML: runs-on: ubuntu-latest diff --git a/.github/workflows/tests-mql.yml b/.github/workflows/tests-mql.yml index f4ba32ad..47936c98 100644 --- a/.github/workflows/tests-mql.yml +++ b/.github/workflows/tests-mql.yml @@ -2,8 +2,16 @@ name: Tests-MQL on: - - pull_request - - push + pull_request: + paths: + - '**/docker-compose.yml' + - '**/*.mq?' + - '.github/workflows/tests-mql.yml' + push: + paths: + - '**/docker-compose.yml' + - '**/*.mq?' + - '.github/workflows/tests-mql.yml' jobs: Tests-MT4: diff --git a/.github/workflows/tests-shell.yml b/.github/workflows/tests-shell.yml index 4e5b388d..3eba4055 100644 --- a/.github/workflows/tests-shell.yml +++ b/.github/workflows/tests-shell.yml @@ -2,8 +2,14 @@ name: Tests-Shell on: - - pull_request - - push + pull_request: + paths: + - '**/*.sh' + - '.github/workflows/tests-shell.yml' + push: + paths: + - '**/*.sh' + - '.github/workflows/tests-shell.yml' jobs: Tests-Scripts: @@ -12,7 +18,6 @@ jobs: image: ea31337/ea-tester:dev steps: - uses: actions/checkout@v2 - - run: rm -fr /opt/scripts - run: ln -fs scripts /opt/scripts - name: Test .vars.inc.sh file working-directory: scripts/tests From 4007811ac9ec074eb6aa2485a4963ca6b19516ac Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 May 2020 16:38:21 +0100 Subject: [PATCH 02/24] Adds test_aliases.sh --- scripts/.funcs.inc.sh | 2 +- scripts/tests/test_aliases.sh | 19 +++++++++++++++++++ scripts/tests/test_vars.sh | 4 ++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 scripts/tests/test_aliases.sh diff --git a/scripts/.funcs.inc.sh b/scripts/.funcs.inc.sh index 3f763e4f..a7a17af8 100644 --- a/scripts/.funcs.inc.sh +++ b/scripts/.funcs.inc.sh @@ -326,7 +326,7 @@ kill_wine() { # Usage: kill_display kill_display() { ( - pkill -e Xvfb + pkill -e Xvfb || pkill Xvfb [ -w /tmp/.X0-lock ] && rm $VFLAG /tmp/.X0-lock ) || true } diff --git a/scripts/tests/test_aliases.sh b/scripts/tests/test_aliases.sh new file mode 100755 index 00000000..36c62be0 --- /dev/null +++ b/scripts/tests/test_aliases.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Test .aliases.inc.sh file. +set -e + +# Initialize. +. ../.funcs.inc.sh +initialize + +# Test code +. ../.aliases.inc.sh + +input="123" +input_encoded=$(printf "%s" "$input" | encode) +input_decoded=$(printf "%s" "$input_encoded" | decode) + +# Asserts. +[ "$input" -eq "$input_decoded" ] + +echo "${BASH_SOURCE[0]} done." diff --git a/scripts/tests/test_vars.sh b/scripts/tests/test_vars.sh index 9f4017d1..99b8b24b 100755 --- a/scripts/tests/test_vars.sh +++ b/scripts/tests/test_vars.sh @@ -2,6 +2,10 @@ # Test .vars.inc.sh file. set -ex +# Initialize. +. ../.funcs.inc.sh +initialize + # Test code . ../.vars.inc.sh From cf74cc10985ec5d65494603e931344b55ccc28cb Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 May 2020 16:49:54 +0100 Subject: [PATCH 03/24] Run all shell tests --- .github/workflows/tests-shell.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests-shell.yml b/.github/workflows/tests-shell.yml index 3eba4055..af32d77c 100644 --- a/.github/workflows/tests-shell.yml +++ b/.github/workflows/tests-shell.yml @@ -18,7 +18,8 @@ jobs: image: ea31337/ea-tester:dev steps: - uses: actions/checkout@v2 - - run: ln -fs scripts /opt/scripts - - name: Test .vars.inc.sh file + - name: Prepare folder + run: ln -fsv scripts /opt/scripts + - name: Run test scripts working-directory: scripts/tests - run: ./test_vars.sh + run: find . -name "*.sh" -print -exec {} ";" From 7c114ce6c0004d6b046b9eec3921b12ceeb74ccf Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 May 2020 17:19:24 +0100 Subject: [PATCH 04/24] Adds run alias --- scripts/.aliases.inc.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/.aliases.inc.sh b/scripts/.aliases.inc.sh index ac08888b..eebf6bb6 100644 --- a/scripts/.aliases.inc.sh +++ b/scripts/.aliases.inc.sh @@ -11,3 +11,4 @@ shopt -s expand_aliases # Define aliases. alias encode="base64" alias decode="base64 -d" +alias run="eval.sh" From e5abfdb9563f1e8aaa92a07ddf07438f9a074380 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 May 2020 17:19:47 +0100 Subject: [PATCH 05/24] Adds test_aliases.sh test --- .github/workflows/tests-shell.yml | 7 +++++-- scripts/tests/test_aliases.sh | 3 ++- scripts/tests/test_cmds.sh | 15 +++++++++++++++ scripts/tests/test_vars.sh | 4 +++- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100755 scripts/tests/test_cmds.sh diff --git a/.github/workflows/tests-shell.yml b/.github/workflows/tests-shell.yml index af32d77c..3e5ff731 100644 --- a/.github/workflows/tests-shell.yml +++ b/.github/workflows/tests-shell.yml @@ -20,6 +20,9 @@ jobs: - uses: actions/checkout@v2 - name: Prepare folder run: ln -fsv scripts /opt/scripts - - name: Run test scripts + - run: ./test_aliases.sh + working-directory: scripts/tests + - run: ./test_cmds.sh + working-directory: scripts/tests + - run: ./test_vars.sh working-directory: scripts/tests - run: find . -name "*.sh" -print -exec {} ";" diff --git a/scripts/tests/test_aliases.sh b/scripts/tests/test_aliases.sh index 36c62be0..30106ce7 100755 --- a/scripts/tests/test_aliases.sh +++ b/scripts/tests/test_aliases.sh @@ -6,9 +6,10 @@ set -e . ../.funcs.inc.sh initialize -# Test code +# Includes required code. . ../.aliases.inc.sh +# Test code input="123" input_encoded=$(printf "%s" "$input" | encode) input_decoded=$(printf "%s" "$input_encoded" | decode) diff --git a/scripts/tests/test_cmds.sh b/scripts/tests/test_cmds.sh new file mode 100755 index 00000000..f90ca832 --- /dev/null +++ b/scripts/tests/test_cmds.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# Test .funcs.cmds.inc.sh file. +set -e + +# Initialize. +. ../.funcs.inc.sh +initialize + +# Includes required code. +. ../.funcs.cmds.inc.sh + +# Asserts. +help + +echo "${BASH_SOURCE[0]} done." diff --git a/scripts/tests/test_vars.sh b/scripts/tests/test_vars.sh index 99b8b24b..cecaa472 100755 --- a/scripts/tests/test_vars.sh +++ b/scripts/tests/test_vars.sh @@ -6,7 +6,9 @@ set -ex . ../.funcs.inc.sh initialize -# Test code +# Includes required code. . ../.vars.inc.sh +# Test code + echo "${BASH_SOURCE[0]} done." From aee314ebf999d099d2ea0e105530f4459e7f5a1e Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 May 2020 17:57:32 +0100 Subject: [PATCH 06/24] Adds test_eval.sh --- .github/workflows/tests-shell.yml | 2 ++ scripts/tests/test_eval.sh | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100755 scripts/tests/test_eval.sh diff --git a/.github/workflows/tests-shell.yml b/.github/workflows/tests-shell.yml index 3e5ff731..8e12b2d6 100644 --- a/.github/workflows/tests-shell.yml +++ b/.github/workflows/tests-shell.yml @@ -24,5 +24,7 @@ jobs: working-directory: scripts/tests - run: ./test_cmds.sh working-directory: scripts/tests + - run: ./test_eval.sh + working-directory: scripts/tests - run: ./test_vars.sh working-directory: scripts/tests diff --git a/scripts/tests/test_eval.sh b/scripts/tests/test_eval.sh new file mode 100755 index 00000000..e8f50bc9 --- /dev/null +++ b/scripts/tests/test_eval.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Test eval.sh file. +set -e + +# Initialize. +. ../.funcs.inc.sh +initialize + +# Includes required code. +. ../.aliases.inc.sh + +# Asserts. +bc_4=$(run bc <<<"2+2") +[ "$bc_4" -eq 4 ] + +echo "${BASH_SOURCE[0]} done." From 8d6364456b6d9e69d525e82df1e48e6c72bd650b Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 May 2020 18:41:54 +0100 Subject: [PATCH 07/24] Adds test_backtest.sh --- .github/workflows/tests-shell.yml | 2 ++ scripts/tests/test_backtest.sh | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100755 scripts/tests/test_backtest.sh diff --git a/.github/workflows/tests-shell.yml b/.github/workflows/tests-shell.yml index 8e12b2d6..250224bf 100644 --- a/.github/workflows/tests-shell.yml +++ b/.github/workflows/tests-shell.yml @@ -22,6 +22,8 @@ jobs: run: ln -fsv scripts /opt/scripts - run: ./test_aliases.sh working-directory: scripts/tests + - run: ./test_backtest.sh + working-directory: scripts/tests - run: ./test_cmds.sh working-directory: scripts/tests - run: ./test_eval.sh diff --git a/scripts/tests/test_backtest.sh b/scripts/tests/test_backtest.sh new file mode 100755 index 00000000..da0f3f95 --- /dev/null +++ b/scripts/tests/test_backtest.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# Test run_backtest.sh file. +set -e + +# Initialize. +. ../.funcs.inc.sh +initialize + +# Includes required code. +. ../.aliases.inc.sh +. ../.funcs.cmds.inc.sh + +# Defines local variables. +file_stdout=/tmp/stdout +file_stderr=/tmp/stderr + +# Asserts. + +## Test script with missing parameters. +! run_backtest -_ 1>$file_stdout 2>$file_stderr +grep ^ERROR $file_stderr +wc -l "$file_stdout" +[ "$(wc -l "$file_stdout" | grep -o ^"[0-9]\+")" -eq 2 ] + +echo "${BASH_SOURCE[0]} done." From 407db433cb2f7d7d1b94d6c6279c9e1baaa77f5e Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 May 2020 18:47:19 +0100 Subject: [PATCH 08/24] Renames TestInitFail to scripts --- tests/{ => scripts}/TestInitFail.mq4 | 0 tests/{ => scripts}/TestInitFail.mq5 | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/{ => scripts}/TestInitFail.mq4 (100%) rename tests/{ => scripts}/TestInitFail.mq5 (100%) diff --git a/tests/TestInitFail.mq4 b/tests/scripts/TestInitFail.mq4 similarity index 100% rename from tests/TestInitFail.mq4 rename to tests/scripts/TestInitFail.mq4 diff --git a/tests/TestInitFail.mq5 b/tests/scripts/TestInitFail.mq5 similarity index 100% rename from tests/TestInitFail.mq5 rename to tests/scripts/TestInitFail.mq5 From d8086045761da8ece973d93cc77297c34ff2c630 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 May 2020 18:49:46 +0100 Subject: [PATCH 09/24] Adds Dummy script --- tests/docker-compose.yml | 7 +++++++ tests/scripts/Dummy.mq4 | 13 +++++++++++++ tests/scripts/Dummy.mq5 | 15 +++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 tests/scripts/Dummy.mq4 create mode 100644 tests/scripts/Dummy.mq5 diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index f2601e07..fc01b5a3 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -164,6 +164,13 @@ services: RUN_ON_START: clean_ea # MQL Scripts. + ScriptDummy: + command: run_backtest -s Dummy + image: ea31337/ea-tester:dev + volumes: + - .:/opt/tests + - ../scripts:/opt/scripts + - ../conf:/opt/conf ScriptPrintPaths: command: run_backtest -s PrintPaths image: ea31337/ea-tester:dev diff --git a/tests/scripts/Dummy.mq4 b/tests/scripts/Dummy.mq4 new file mode 100644 index 00000000..6f36cda7 --- /dev/null +++ b/tests/scripts/Dummy.mq4 @@ -0,0 +1,13 @@ +//+------------------------------------------------------------------+ +//| Dummy | +//| Copyright 2016-2020, 31337 Investments Ltd | +//| https://github.com/EA31337 | +//+------------------------------------------------------------------+ + +/** + * @file + * Dummy script to run OnInit(). + */ + +// Includes the main code. +#include "Dummy.mq5" diff --git a/tests/scripts/Dummy.mq5 b/tests/scripts/Dummy.mq5 new file mode 100644 index 00000000..7a9de2b1 --- /dev/null +++ b/tests/scripts/Dummy.mq5 @@ -0,0 +1,15 @@ +//+------------------------------------------------------------------+ +//| Dummy | +//| Copyright 2016-2020, 31337 Investments Ltd | +//| https://github.com/EA31337 | +//+------------------------------------------------------------------+ + +/** + * @file + * Dummy script to run OnInit(). + */ + +/** + * Initialization function. + */ +int OnInit() { return INIT_SUCCEEDED; } From 35786c7a3516e717bf07a83bbd80ec55a05c295e Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 May 2020 20:02:02 +0100 Subject: [PATCH 10/24] GHA: Adds ScriptDummy for testing --- .github/workflows/tests-mql.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests-mql.yml b/.github/workflows/tests-mql.yml index 47936c98..e189f85d 100644 --- a/.github/workflows/tests-mql.yml +++ b/.github/workflows/tests-mql.yml @@ -18,6 +18,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Run ScriptDummy + working-directory: tests + run: docker-compose run ScriptDummy - name: Run ScriptPrintPaths working-directory: tests run: docker-compose run ScriptPrintPaths From 324bf2e16658d5be376cbba2430c64c45720c550 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 May 2020 20:06:11 +0100 Subject: [PATCH 11/24] Improves to stdout/stderr handling Adds more tests --- scripts/.funcs.cmds.inc.sh | 89 ++++++++++---------- scripts/.funcs.inc.sh | 2 +- scripts/run_backtest.sh | 144 +++++++++++++++++---------------- scripts/tests/test_backtest.sh | 17 +++- 4 files changed, 128 insertions(+), 124 deletions(-) diff --git a/scripts/.funcs.cmds.inc.sh b/scripts/.funcs.cmds.inc.sh index cde1d6a2..2e3e1c9a 100644 --- a/scripts/.funcs.cmds.inc.sh +++ b/scripts/.funcs.cmds.inc.sh @@ -135,9 +135,8 @@ live_stats() { # Delete compiled EAs. # Usage: clean_ea clean_ea() { - exec 1>&2 - echo "Cleaning compiled EAs and scripts..." >&2 - find "$TERMINAL_DIR/$MQL_DIR" '(' -name '*.ex4' -or -name '*.ex5' ')' -type f $VPRINT -delete + echo "INFO: Cleaning compiled EAs and scripts..." + find "$TERMINAL_DIR/$MQL_DIR" '(' -name '*.ex4' -or -name '*.ex5' ')' -type f $VPRINT -delete >&2 } # Clean files (e.g. previous report and log files). @@ -145,7 +144,7 @@ clean_ea() { clean_files() { # Remove previous log, dat, txt and htm files. exec 1>&2 - echo "Cleaning previous test data..." + echo "INFO: Cleaning previous test data..." find "$TESTER_DIR" '(' -name "*.htm" -o -name "*.txt" ')' -type f $VPRINT -delete [ -d "$TESTER_DIR"/files ] && find "$TESTER_DIR"/files -type f $VPRINT -delete # Remove log files. @@ -159,9 +158,8 @@ clean_files() { # Usage: clean_bt clean_bt() { # Remove previous backtest files for the current symbol. - exec 1>&2 - echo "Cleaning backtest data for ${BT_SYMBOL}..." >&2 - find "$TERMINAL_DIR" '(' -name "${BT_SYMBOL}*.hst" -o -name "${BT_SYMBOL}*.fxt" ')' -type f $VPRINT -delete + echo "INFO: Cleaning backtest data for ${BT_SYMBOL}..." >&2 + find "$TERMINAL_DIR" '(' -name "${BT_SYMBOL}*.hst" -o -name "${BT_SYMBOL}*.fxt" ')' -type f $VPRINT -delete >&2 ini_del "bt_data" "$CUSTOM_INI" } @@ -228,8 +226,8 @@ install_mt() { print_ver() { MT_VER=$(filever $(basename "$TERMINAL_EXE")) MTE_VER=$(filever $(basename "$MTEDITOR_EXE")) - echo "Installed Terminal: $MT_VER" - echo "Installed MetaEditor: $MTE_VER" + echo "INFO: Installed Terminal: $MT_VER" + echo "INFO: Installed MetaEditor: $MTE_VER" } # Configure virtual display and wine. @@ -284,8 +282,7 @@ script_copy() { local dest="$SCRIPTS_DIR/$(basename "$file")" [ ! -s "$file" ] && file=$(ea_find "$file") [ "$(dirname "$file")" == "$(dirname "$dest")" ] && return - exec 1>&2 - cp $VFLAG "$file" "$SCRIPTS_DIR"/ + cp $VFLAG "$file" "$SCRIPTS_DIR"/ >&2 } # Copy library file (e.g. dll) given the file path. @@ -294,8 +291,7 @@ lib_copy() { local file="$1" local dest="$LIB_DIR/$(basename "$file")" [ "$(dirname "$file")" == "$(dirname "$dest")" ] && return - exec 1>&2 - cp $VFLAG "$file" "$LIB_DIR"/ + cp $VFLAG "$file" "$LIB_DIR"/ >&2 } # Copy a file given the file path. @@ -304,8 +300,7 @@ file_copy() { local file="$1" local dest="$FILES_DIR/$(basename "$file")" [ "$(dirname "$file")" == "$(dirname "$dest")" ] && return - exec 1>&2 - cp $VFLAG "$file" "$FILES_DIR"/ + cp $VFLAG "$file" "$FILES_DIR"/ >&2 } # Copy srv files into terminal dir. @@ -314,7 +309,7 @@ srv_copy() { local server="$(ini_get Server)" srv_file=$(find "$ROOT" -name "$server.srv" -type f -print -quit) if [ -n "$srv_file" ]; then - cp $VFLAG "$srv_file" "$TERMINAL_CNF"/ + cp $VFLAG "$srv_file" "$TERMINAL_CNF"/ >&2 fi } @@ -374,7 +369,6 @@ compile() { compiled_no=$? # Reset errexit to the previous value. [[ $errexit -eq 0 ]] && set -e - echo "Info: Number of files compiled: $compiled_no" >&2 ( [ ! -f "$log_file" ] && log_file="${log_file%.*}.log" if [ -f "$log_file" ]; then @@ -457,10 +451,9 @@ compile_and_test() { ini_copy() { # Copy the configuration file, so platform can find it. [ -d "$TESTER_DIR" ] || mkdir -p $VFLAG "$TESTER_DIR" - exec 1>&2 echo "Copying ini files..." >&2 - cp $VFLAG "$TPL_TEST" "$TESTER_INI" - cp $VFLAG "$TPL_TERM" "$TERMINAL_INI" + cp $VFLAG "$TPL_TEST" "$TESTER_INI" >&2 + cp $VFLAG "$TPL_TERM" "$TERMINAL_INI" >&2 } # Find the EA file. @@ -528,18 +521,19 @@ ea_copy() { } [ "$(dirname "$file")" == "$dir_dst" ] && return [ -d "$EXPERTS_DIR" ] || mkdir -p $VFLAG "$EXPERTS_DIR" - exec 1>&2 - mapfile -t includes < <(grep ^#include "$file" | grep -o '"[^"]\+"' | tr -d '"') - if [ ${#includes[@]} -eq 0 ]; then - # Copy a single file when no includes present. - cp $VFLAG "$file" "$dir_dst"/ - elif [[ "${includes[*]}" =~ .. ]]; then - # Copy the parent folder of EA, when relative includes are found. - cp -fr "$(dirname "$file")/.." "$dir_dst"/ | paste -sd';' - else - # Copy the whole EA folder, when includes are found. - cp -fr "$(dirname "$file")" "$dir_dst"/ | paste -sd';' - fi + ( + mapfile -t includes < <(grep ^#include "$file" | grep -o '"[^"]\+"' | tr -d '"') + if [ ${#includes[@]} -eq 0 ]; then + # Copy a single file when no includes present. + cp $VFLAG "$file" "$dir_dst"/ + elif [[ "${includes[*]}" =~ .. ]]; then + # Copy the parent folder of EA, when relative includes are found. + cp -fr "$(dirname "$file")/.." "$dir_dst"/ | paste -sd';' + else + # Copy the whole EA folder, when includes are found. + cp -fr "$(dirname "$file")" "$dir_dst"/ | paste -sd';' + fi + ) >&2 } # Copy script file to the platform scripts dir. @@ -556,18 +550,19 @@ script_copy() { [ "$(dirname "$file")" == "$dir_dst" ] && return [ "$(dirname "$file")" == "$(dirname "$dir_dst")" ] && return [ -d "$SCRIPTS_DIR" ] || mkdir -p $VFLAG "$SCRIPTS_DIR" - exec 1>&2 - mapfile -t includes < <(grep ^#include "$file" | grep -o '"[^"]\+"' | tr -d '"') - if [ ${#includes[@]} -eq 0 ]; then - # Copy a single file when no includes present. - cp $VFLAG "$file" "$dir_dst"/ - elif [[ "${includes[*]}" =~ .. ]]; then - # Copy the parent folder of EA, when relative includes are found. - cp -fr "$(dirname "$file")/.." "$dir_dst"/ | paste -sd';' - else - # Copy the whole EA folder, when includes are found. - cp -fr "$(dirname "$file")" "$dir_dst"/ | paste -sd';' - fi + ( + mapfile -t includes < <(grep ^#include "$file" | grep -o '"[^"]\+"' | tr -d '"') + if [ ${#includes[@]} -eq 0 ]; then + # Copy a single file when no includes present. + cp $VFLAG "$file" "$dir_dst"/ + elif [[ "${includes[*]}" =~ .. ]]; then + # Copy the parent folder of EA, when relative includes are found. + cp -fr "$(dirname "$file")/.." "$dir_dst"/ | paste -sd';' + else + # Copy the whole EA folder, when includes are found. + cp -fr "$(dirname "$file")" "$dir_dst"/ | paste -sd';' + fi + ) >&2 } # Copy library file (e.g. dll) to the platform lib dir. @@ -583,7 +578,6 @@ lib_copy() { } [ "$(dirname "$file")" == "$dir_dst" ] && return [ -d "$LIB_DIR" ] || mkdir -p $VFLAG "$LIB_DIR" - exec 1>&2 cp $VFLAG "$file" "$dir_dst"/ } @@ -593,8 +587,7 @@ file_copy() { local file="$1" local dest="$FILES_DIR/$(basename "$file")" [ "$(dirname "$file")" == "$(dirname "$dest")" ] && return - exec 1>&2 - cp $VFLAG "$file" "$FILES_DIR"/ + cp $VFLAG "$file" "$FILES_DIR"/ >&2 } # Copy server files into terminal dir. @@ -603,7 +596,7 @@ srv_copy() { local server="$(ini_get Server)" srv_file=$(find "$ROOT" -name "$server.srv" -type f -print -quit) if [ -n "$srv_file" ]; then - cp $VFLAG "$srv_file" "$TERMINAL_CNF"/ + cp $VFLAG "$srv_file" "$TERMINAL_CNF"/ >&2 fi } diff --git a/scripts/.funcs.inc.sh b/scripts/.funcs.inc.sh index a7a17af8..b2aae4b0 100644 --- a/scripts/.funcs.inc.sh +++ b/scripts/.funcs.inc.sh @@ -353,7 +353,7 @@ on_error() { local frame=0 # Invoke custom code on error. if [ -n "$RUN_ON_ERROR" ]; then - echo "Running code on error ($RUN_ON_ERROR)..." >&2 + echo "INFO: Running code on error ($RUN_ON_ERROR)..." eval "$RUN_ON_ERROR" fi kill_jobs diff --git a/scripts/run_backtest.sh b/scripts/run_backtest.sh index 76e2dc3f..e315a4d0 100755 --- a/scripts/run_backtest.sh +++ b/scripts/run_backtest.sh @@ -24,36 +24,36 @@ usage() { on_success() { # Fail on error in the logs. - echo "Checking logs for warnings and errors..." >&2 + echo "INFO: Checking logs for warnings and errors..." check_log_errors if [ $? -ne 0 ]; then - echo "ERROR: RUN failed with errors." >&2 + echo "ERROR: RUN failed with errors." on_fail on_error 1 fi check_log_warns if [ $? -ne 0 ]; then - echo "ERROR: RUN failed with warnings." >&2 + echo "ERROR: RUN failed with warnings." on_warn on_fail on_error 1 fi - echo "RUN succeeded." >&2 + echo "INFO: RUN succeeded." show_logs parse_results $@ on_finish local OPTIND # Invoke custom code on success. if [ -n "$RUN_ON_SUCCESS" ]; then - echo "Running code on success ($RUN_ON_SUCCESS)..." >&2 + echo "INFO: Running code on success ($RUN_ON_SUCCESS)..." eval "$RUN_ON_SUCCESS" fi while getopts $ARGS arg; do case $arg in X) # Invoke file on exit after the successful test. - echo "Invoking script file after test..." >&2 + echo "INFO: Invoking script file after test..." . "$OPTARG" ;; esac @@ -64,7 +64,7 @@ on_success() { # Invoke on test failure. on_failure() { - echo "FAIL?!" >&2 + echo "WARN: Something went wrong, a non-zero exit code returned." # Sometimes MT4 fails on success, therefore double checking. TEST_REPORT_BASE="$(basename "$(ini_get TestReport)" .htm)" @@ -83,9 +83,9 @@ on_failure() { } fi - echo "Printing logs..." >&2 + echo "INFO: Printing logs..." show_logs - echo "ERROR: RUN failed." >&2 + echo "ERROR: RUN failed." on_fail on_finish } @@ -94,7 +94,7 @@ on_failure() { parse_results() { TEST_REPORT_BASE="$(basename "$(ini_get TestReport)" .htm)" - echo "Checking the total time elapsed..." >&2 + echo "INFO: Checking the total time elapsed..." save_time # Ignore if no test results or test expert name is set (e.g. when running the script). @@ -108,17 +108,17 @@ parse_results() { if [ -n "$OPT_FORMAT_JSON" ]; then # Convert test report file into JSON format. - echo "Converting HTML report ($TEST_REPORT_DIR) into JSON file..." >&2 + echo "INFO: Converting HTML report ($TEST_REPORT_DIR) into JSON file..." convert_html2json "$TEST_REPORT_HTM" fi if [ -n "$OPT_OPTIMIZATION" ]; then # Parse and save the optimization test results. - echo "Sorting optimization test results..." >&2 + echo "INFO: Sorting optimization test results..." if [ "${MT_VER%%.*}" -ne 5 ]; then sort_opt_results "$TEST_REPORT_HTM" fi - echo "Saving optimization results..." + echo "INFO: Saving optimization results..." if [ -n "${param_list[*]}" ] || [ -n "$SET_PARAMS" ]; then if [ -z "${param_list[*]}" ]; then IFS=',' param_list=(${SET_PARAMS}) @@ -126,7 +126,7 @@ parse_results() { fi for input in ${param_list[@]}; do value=$(htm_get "$input" "$TEST_REPORT_HTM") - echo "Setting '$input' to '$value' in '$(basename $SETFILE)'" >&2 + echo "INFO: Setting '$input' to '$value' in '$(basename $SETFILE)'" ini_set "^$input" "$value" "$SETFILE" done fi @@ -135,19 +135,19 @@ parse_results() { if [ -n "$OPT_FORMAT_FULL" ]; then # Convert test report file to full detailed text format. TEST_REPORT_TXT="$TEST_REPORT_DIR/$TEST_REPORT_BASE.txt" - echo "Converting HTML report ($(basename "$TEST_REPORT_HTM")) into full text file ($(basename "$TEST_REPORT_TXT"))..." >&2 + echo "INFO: Converting HTML report ($(basename "$TEST_REPORT_HTM")) into full text file ($(basename "$TEST_REPORT_TXT"))..." convert_html2txt_full "$TEST_REPORT_HTM" "$TEST_REPORT_TXT" elif [ -n "$OPT_FORMAT_BRIEF" ]; then # Convert test report file into brief text format. TEST_REPORT_TXT="$TEST_REPORT_DIR/$TEST_REPORT_BASE.txt" - echo "Converting HTML report ($(basename "$TEST_REPORT_HTM")) into short text file ($(basename "$TEST_REPORT_TXT"))..." >&2 + echo "INFO: Converting HTML report ($(basename "$TEST_REPORT_HTM")) into short text file ($(basename "$TEST_REPORT_TXT"))..." convert_html2txt "$TEST_REPORT_HTM" "$TEST_REPORT_TXT" fi if [ -n "$OPT_GIF_ENHANCE" ]; then # Enhance gif report files. report_gif="$TEST_REPORT_DIR/$TEST_REPORT_BASE.gif" - echo "Enhancing report image ($TEST_REPORT_BASE.gif)..." >&2 + echo "INFO: Enhancing report image ($TEST_REPORT_BASE.gif)..." enhance_gif "$report_gif" ${GIF_ENHANCE:-"-n"} if [ -f "$TEST_REPORT_TXT" ]; then local gif_text=$(grep -wE '^\s*(Symbol|Period|Bars|Initial|Total|Profit|Absolute)' "$TEST_REPORT_TXT") @@ -157,14 +157,14 @@ parse_results() { if [ -n "$OPT_VERBOSE" ]; then # Print test results in plain text. - echo "Printing test report ($(basename "$TEST_REPORT_HTM"))..." >&2 + echo "INFO: Printing test report ($(basename "$TEST_REPORT_HTM"))..." grep -v mso-number "$TEST_REPORT_HTM" | html2text -nobs -width 180 | sed "/\[Graph\]/q" find "$TESTER_DIR/files" '(' -name "*.log" -o -name "*.txt" ')' $VPRINT -exec cat "{}" + fi if [ -d "$BT_DEST" ]; then # Copy the test results if the destination directory has been specified. - echo "Copying report files (${TEST_REPORT_HTM%.*}* into: $BT_DEST)..." >&2 + echo "INFO: Copying report files (${TEST_REPORT_HTM%.*}* into: $BT_DEST)..." cp $VFLAG "${TEST_REPORT_HTM%.*}"* "$BT_DEST" [ -f "$TESTER_LOGS/$(date +%Y%m%d).log" ] && cp $VFLAG "$TESTER_LOGS/$(date +%Y%m%d).log" "$BT_DEST/${TEST_REPORT_BASE}.log" find "$TESTER_DIR/files" -type f $VPRINT -exec cp $VFLAG "{}" "$BT_DEST" ';' @@ -248,13 +248,13 @@ if [ -n "$MT_VER" ] && [ ${#MT_VER} -gt 8 ]; then fi # Check if terminal is present, otherwise install it. -echo "Checking platform..." >&2 +echo "INFO: Checking platform..." if [ -f "$TERMINAL_EXE" ]; then # Check required directories. check_dirs else [ -n "$OPT_VERBOSE" ] && grep ^TERMINAL <(set) | xargs - echo "ERROR: Terminal not found, please specify -M parameter with version to install it." >&2 + echo "ERROR: Terminal not found, please specify -M parameter with version to install it." on_error 1 fi @@ -322,7 +322,7 @@ done # Apply settings. if [ -n "$INCLUDE_BOOT" ]; then - echo "Invoking include booting file(s) (${INCLUDE_BOOT[@]})..." >&2 + echo "INFO: Invoking include booting file(s) (${INCLUDE_BOOT[@]})..." for file in "${INCLUDE_BOOT[@]}"; do [ -f "$INCLUDE_BOOT" ] . <(cat "$file") @@ -331,7 +331,7 @@ fi # Invoke boot code. if [ -n "$RUN_ON_START" ]; then - echo "Running code on startup ($RUN_ON_START)..." >&2 + echo "INFO: Running code on startup ($RUN_ON_START)..." eval "$RUN_ON_START" fi @@ -357,9 +357,9 @@ if [ -n "$TEST_EXPERT" ]; then # Locate TestExpert if specified. cd "$EXPERTS_DIR" EA_PATH=$(ea_find "$TEST_EXPERT") - echo "Locating TestExpert file ("$TEST_EXPERT" => "$EA_PATH")..." >&2 + echo "INFO: Locating TestExpert file ("$TEST_EXPERT" => "$EA_PATH")..." [ -f "$EA_PATH" ] || { - echo "Error: TestExpert file ($TEST_EXPERT) not found!" >&2 + echo "ERROR: TestExpert file ($TEST_EXPERT) not found!" on_error 1 } if [ "${EA_PATH::1}" == '/' ]; then @@ -374,9 +374,9 @@ elif [ -n "$EXPERT" ]; then # Locate Expert if specified. cd "$EXPERTS_DIR" EA_PATH=$(ea_find "$EXPERT") - echo "Locating Expert file ("$EXPERT" => "$EA_PATH")..." >&2 + echo "INFO: Locating Expert file ("$EXPERT" => "$EA_PATH")..." [ -f "$EA_PATH" ] || { - echo "Error: Expert file ($EXPERT) not found!" >&2 + echo "ERROR: Expert file ($EXPERT) not found!" on_error 1 } if [ "${EA_PATH::1}" == '/' ]; then @@ -391,9 +391,9 @@ elif [ -n "$SCRIPT" ]; then # Locate Script if specified. cd "$SCRIPTS_DIR" SCR_PATH=$(script_find "$SCRIPT") - echo "Locating Script file ("$SCRIPT" => "$SCR_PATH")..." >&2 + echo "INFO: Locating Script file ("$SCRIPT" => "$SCR_PATH")..." [ -f "$SCR_PATH" ] || { - echo "Error: Script file ($SCRIPT) not found!" >&2 + echo "ERROR: Script file ($SCRIPT) not found!" on_error 1 } if [ "${SCR_PATH::1}" == '/' ]; then @@ -407,14 +407,14 @@ elif [ -n "$SCRIPT" ]; then fi if [ -n "$BT_START_DATE" ]; then - echo "Configuring start test period ($BT_START_DATE)..." >&2 + echo "INFO: Configuring start test period ($BT_START_DATE)..." ini_set "^TestFromDate" "$BT_START_DATE" "$TESTER_INI" else BT_START_DATE="$(ini_get TestFromDate)" BT_YEARS=(${BT_START_DATE%%.*}) fi if [ -n "$BT_END_DATE" ]; then - echo "Configuring end test period ($BT_END_DATE)..." >&2 + echo "INFO: Configuring end test period ($BT_END_DATE)..." ini_set "^TestToDate" "$BT_END_DATE" "$TESTER_INI" else BT_END_DATE="$(ini_get TestToDate)" @@ -426,7 +426,7 @@ fi # Configure symbol pair. if [ -n "$BT_SYMBOL" ]; then - echo "Configuring symbol pair ($BT_SYMBOL)..." >&2 + echo "INFO: Configuring symbol pair ($BT_SYMBOL)..." ini_set "^TestSymbol" "$BT_SYMBOL" "$TESTER_INI" else BT_SYMBOL="$(ini_get TestSymbol)" @@ -434,14 +434,14 @@ fi # Configure testing mode. if [ -n "$BT_TESTMODEL" ]; then - echo "Configuring test model ($BT_TESTMODEL)..." >&2 + echo "INFO: Configuring test model ($BT_TESTMODEL)..." ini_set "^TestModel" "$BT_TESTMODEL" "$TESTER_INI" else BT_TESTMODEL="$(ini_get TestModel)" fi if [ -n "$TEST_OPTS" ]; then - echo "Applying tester settings ($TEST_OPTS)..." >&2 + echo "INFO: Applying tester settings ($TEST_OPTS)..." IFS=',' test_options=($TEST_OPTS) restore_ifs @@ -466,18 +466,18 @@ SERVER="${SERVER:-$(ini_get Server)}" # Export SET file when SETFILE does not exist. if [ -n "$SETFILE" -a ! -s "$SETFILE" ]; then - echo "Specified SET file via -f param does not exist ($SETFILE), exporting from EA ..." >&2 + echo "ERROR: Specified SET file via -f param does not exist ($SETFILE), exporting from EA ..." exported_setfile=${TEST_EXPERT:-$EXPERT} exported_setfile=$(export_set "${exported_setfile##*/}" "$(basename "$SETFILE")") [ ! -s "$TESTER_DIR/$exported_setfile" ] && { - echo "ERROR: Export of SET file failed!" >&2 + echo "ERROR: Export of SET file failed!" ls "$TESTER_DIR"/*.set on_error 1 } cp -f $VFLAG "$TESTER_DIR/$exported_setfile" "$SETFILE" fi if [ -s "$SETFILE" -a ! -f "$TESTER_DIR/$EA_SETFILE" ]; then - echo "EA's SET file is missing ($EA_SETFILE), copying from $SETFILE..." >&2 + echo "INFO: EA's SET file is missing ($EA_SETFILE), copying from $SETFILE..." cp -f $VFLAG "$SETFILE" "$TESTER_DIR/$EA_SETFILE" fi @@ -581,9 +581,9 @@ while getopts $ARGS arg; do ;; X) - echo "Checking whether after test script exists..." >&2 + echo "INFO: Checking whether after test script exists..." [ -f "$OPTARG" ] || { - echo "ERROR: Script specified by -X parameter does no exist." >&2 + echo "ERROR: Script specified by -X parameter does no exist." on_error 1 } ;; @@ -604,7 +604,7 @@ while getopts $ARGS arg; do b | B | C | e | E | f | I | m | M | p | s | x | y) ;; *) - echo "Args: $@" >&2 + echo "WARN: Args: $@" >&2 usage on_error 1 ;; @@ -614,7 +614,7 @@ done # Apply settings. if [ -n "$INCLUDE" ]; then - echo "Invoking include file(s) (${INCLUDE[@]})..." >&2 + echo "INFO: Invoking include file(s) (${INCLUDE[@]})..." for file in ${INCLUDE[@]}; do [ -f "$INCLUDE" ] . <(cat "$file") @@ -623,19 +623,19 @@ fi # Configure test period. if [ -n "$BT_PERIOD" ]; then - echo "Configuring test period ($BT_PERIOD)..." >&2 + echo "INFO: Configuring test period ($BT_PERIOD)..." ini_set "^TestPeriod" "$BT_PERIOD" "$TESTER_INI" fi # Action(s) to evaluate. if [ -n "$RUN_ON_SET" ]; then for code in "${RUN_ON_SET[@]}"; do - echo "Running code on SET configuration ($code)..." >&2 + echo "INFO: Running code on SET configuration ($code)..." eval "$code" done fi if [ -n "$EA_OPTS" ]; then - echo "Applying EA backtest settings ($EA_OPTS)..." >&2 + echo "INFO: Applying EA backtest settings ($EA_OPTS)..." [ -f "$EA_INI" ] IFS=',' ea_options=($EA_OPTS) @@ -648,7 +648,7 @@ if [ -n "$EA_OPTS" ]; then done fi if [ -n "$SET_OPTS" ]; then - echo "Setting EA options ($SET_OPTS)..." >&2 + echo "INFO: Setting EA options ($SET_OPTS)..." if [ -f "$TESTER_DIR/$EA_SETFILE" ]; then # Append settings into the SET file. IFS=',' @@ -667,13 +667,13 @@ if [ -n "$SET_OPTS" ]; then fi if [ -n "$OPT_VERBOSE" ]; then # Print final version of the SET file. - echo "Final parameters: $(grep -v ,.= "$TESTER_DIR/$EA_SETFILE" | paste -sd,)" >&2 + echo "INFO: Final parameters: $(grep -v ,.= "$TESTER_DIR/$EA_SETFILE" | paste -sd,)" >&2 fi fi # Adds SET file into Terminal INI Configuration file. if [ -n "$SETFILE" -o -n "$SET_OPTS" ]; then - echo "Configuring SET parameters ($EA_SETFILE)..." >&2 + echo "INFO: Configuring SET parameters ($EA_SETFILE)..." if [ -f "$TESTER_DIR/$EA_SETFILE" ]; then if [ -n "$TEST_EXPERT" ]; then ini_set "^TestExpertParameters" "$EA_SETFILE" "$TESTER_INI" @@ -682,11 +682,11 @@ if [ -n "$SETFILE" -o -n "$SET_OPTS" ]; then elif [ -n "$SCRIPT" ]; then ini_set "^ScriptParameters" "$EA_SETFILE" "$TESTER_INI" fi - echo "Copying parameters from SET into INI file..." >&2 + echo "INFO: Copying parameters from SET into INI file..." ini_set_inputs "$TESTER_DIR/$EA_SETFILE" "$EA_INI" else if [ ! -s "$SETFILE" ]; then - echo "ERROR: Set file not found ($SETFILE)!" >&2 + echo "ERROR: Set file not found ($SETFILE)!" on_error 1 fi fi @@ -694,45 +694,45 @@ fi # Configure base currency if present. if [ -n "$BT_CURRENCY" ]; then - echo "Configuring base currency ($BT_CURRENCY)..." >&2 + echo "INFO: Configuring base currency ($BT_CURRENCY)..." ini_set "^currency" "$BT_CURRENCY" "$EA_INI" fi # Configure deposit if present. if [ -n "$BT_DEPOSIT" ]; then - echo "Configuring deposit ($BT_DEPOSIT)..." >&2 + echo "INFO: Configuring deposit ($BT_DEPOSIT)..." ini_set "^deposit" "$BT_DEPOSIT" "$EA_INI" fi # Sets a test report if present. if [ -n "$EA_FILE" ]; then TEST_REPORT_NAME="${TEST_REPORT_NAME:-tester/${EA_FILE##*/}-Report}.htm" - echo "Configuring test report ($TEST_REPORT_NAME)..." >&2 + echo "INFO: Configuring test report ($TEST_REPORT_NAME)..." ini_set "^TestReport" "$TEST_REPORT_NAME" "$TESTER_INI" fi # Sets the optimization mode if present. if [ -n "$OPT_OPTIMIZATION" ]; then - echo "Configuring optimization mode..." >&2 + echo "INFO: Configuring optimization mode..." ini_set "^TestOptimization" true "$TESTER_INI" fi # Sets the visual mode if present. if [ -n "$VISUAL_MODE" ]; then - echo "Enabling visual mode..." >&2 + echo "INFO: Enabling visual mode..." ini_set "^TestVisualEnable" true "$TESTER_INI" fi # Checks the destination folder (if run EA, not a script). if [ -n "$EA_FILE" -a -n "$BT_DEST" ]; then - echo "Checking destination directory ($BT_DEST)..." >&2 + echo "INFO: Checking destination directory ($BT_DEST)..." [ -d "$BT_DEST" ] || mkdir -p $VFLAG "$BT_DEST" [ -f /.dockerenv -a -w "$BT_DEST" ] || { - echo "Warning: No write access! Attempting fixing the destination directory permissions ($BT_DEST)..." >&2 + echo "WARN: No write access! Attempting fixing the destination directory permissions ($BT_DEST)..." timeout 1 sudo id && chmod $VFLAG a=rwx "$BT_DEST" || true } [ -w "$BT_DEST" ] || { - echo "Error: Destination directory ($BT_DEST) not writeable!" >&2 + echo "ERROR: Destination directory ($BT_DEST) not writeable!" stat "$BT_DEST" >&2 on_error 1 } @@ -743,7 +743,7 @@ BT_PERIOD=$(ini_get TestPeriod) BT_PERIOD_FXT=${BT_PERIOD_FXT:-$BT_PERIOD} BT_TESTMODEL_FXT=${BT_TESTMODEL_FXT:-0} if [ -n "$TEST_EXPERT" ]; then - echo "Checking backtest data (${BT_SRC:-DS})..." + echo "INFO: Checking backtest data (${BT_SRC:-DS})..." bt_key=$BT_SYMBOL-$(join_by - ${BT_YEARS[@]:-2018})-${BT_SRC:-DS} bt_data=$(ini_get "bt_data" "$CUSTOM_INI") # Download backtest files if not present. @@ -761,31 +761,31 @@ fi # Sets a spread in FXT files (if specified). if [ -n "$BT_SPREAD" ]; then - echo "Configuring spread ($BT_SPREAD)..." >&2 + echo "INFO: Configuring spread ($BT_SPREAD)..." set_spread $BT_SPREAD fi # Sets currency/volume digits and point size in symbol raw and FXT files (if specified). if [ -n "$BT_DIGITS" ]; then - echo "Configuring digits ($BT_DIGITS)..." >&2 + echo "INFO: Configuring digits ($BT_DIGITS)..." set_digits $BT_DIGITS fi # Sets a lot step in FXT files (if specified). if [ -n "$BT_LOTSTEP" ]; then - echo "Setting lot step in FXT files ($BT_LOTSTEP)..." >&2 + echo "INFO: Setting lot step in FXT files ($BT_LOTSTEP)..." set_lotstep $BT_LOTSTEP fi # Sets an account leverage in FXT files (if specified). if [ -n "$BT_LEVERAGE" ]; then - echo "Setting account leverage in FXT files ($BT_LEVERAGE)..." >&2 + echo "INFO: Setting account leverage in FXT files ($BT_LEVERAGE)..." set_leverage $BT_LEVERAGE fi # Sets white-listed web-request URLs (if specified). if [ -n "$EA_WHITELIST_URLS" ]; then - echo "Setting white-listed URLs ($EA_WHITELIST_URLS)..." >&2 + echo "INFO: Setting white-listed URLs ($EA_WHITELIST_URLS)..." add_url $EA_WHITELIST_URLS fi @@ -793,31 +793,33 @@ fi if [ -n "$TEST_EXPERT" ]; then [ -n "$(find "$TERMINAL_DIR" '(' -name "*.hst" -o -name "*.fxt" ')' -size +1 -print -quit)" ] || { - echo "ERROR: Missing backtest data files." >&2 + echo "ERROR: Missing backtest data files!" on_error 1 } fi if [ -z "$TEST_EXPERT" -a -z "$EXPERT" -a -z "$SCRIPT" ]; then - echo "ERROR: You need to specify TestExpert (-e), Expert (-E) or Script (-s)." >&2 + echo "ERROR: You need to specify TestExpert (-e), Expert (-E) or Script (-s)!" on_error 1 fi if [ -n "$EA_FILE" ] && [[ ${EA_PATH##*.} =~ 'mq' ]]; then # Compile EA when source code file is specified. - echo "Compiling EA ($EA_PATH)..." >&2 + echo "INFO: Compiling EA ($EA_PATH)..." compiled_no="$(compile_ea ${EA_PATH##*/})" + echo "INFO: Number of files compiled: $compiled_no" [ "${compiled_no}" -gt 0 ] elif [ -n "$SCRIPT" ] && [[ ${SCR_PATH##*.} =~ 'mq' ]]; then # Compile script when source code file is specified. - echo "Compiling script ($SCR_PATH)..." >&2 + echo "INFO: Compiling script ($SCR_PATH)..." compiled_no="$(compile_script ${SCR_PATH##*/})" + echo "INFO: Number of files compiled: $compiled_no" [ ${compiled_no} -gt 0 ] fi # Exit on dry run. if [ -n "$OPT_DRY_RUN" ]; then - echo "Dry run completed." >&2 + echo "INFO: Dry run completed." exit $? fi @@ -839,7 +841,7 @@ if [ -n "$OPT_VERBOSE" ]; then fi # Run the test in the platform. -echo "Starting..." >&2 +echo "INFO: Starting..." { time wine "$TERMINAL_EXE" $TERMINAL_ARG $TERMINAL_ARG_CFG } 2>>"$TERMINAL_LOG" && exit_status=$? || exit_status=$? @@ -849,9 +851,9 @@ echo "Starting..." >&2 # Invoke custom code on shutdown/final run. if [ -n "$RUN_ON_EXIT" ]; then - echo "Running code on exit ($RUN_ON_EXIT)..." >&2 + echo "INFO: Running code on exit ($RUN_ON_EXIT)..." eval "$RUN_ON_EXIT" fi -[ -n "$OPT_VERBOSE" ] && times >&2 && echo "$0 done" >&2 +[ -n "$OPT_VERBOSE" ] && times >&2 && echo "INFO: $0 done." exit $exit_status diff --git a/scripts/tests/test_backtest.sh b/scripts/tests/test_backtest.sh index da0f3f95..df169fcd 100755 --- a/scripts/tests/test_backtest.sh +++ b/scripts/tests/test_backtest.sh @@ -15,11 +15,20 @@ file_stdout=/tmp/stdout file_stderr=/tmp/stderr # Asserts. +set -x -## Test script with missing parameters. +## Checks backtest with missing parameters. ! run_backtest -_ 1>$file_stdout 2>$file_stderr -grep ^ERROR $file_stderr -wc -l "$file_stdout" -[ "$(wc -l "$file_stdout" | grep -o ^"[0-9]\+")" -eq 2 ] +grep ^ERROR $file_stdout + +## Checks backtest with dummy script. +#run_backtest -_ -s Dummy 1>$file_stdout 2>$file_stderr +#grep "compiled: 1" $file_stdout +#! grep ^ERROR $file_stderr + +## Checks backtest with dummy script as EA. +#run_backtest -_ -x -e Dummy 1>$file_stdout 2>$file_stderr +#grep "compiled: 1" $file_stdout +#! grep ^ERROR $file_stderr echo "${BASH_SOURCE[0]} done." From d828de6e5ba815ae5c3e500a8da4b81cd6d85b8d Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 May 2020 20:55:18 +0100 Subject: [PATCH 12/24] Adds more backtest tests Improves output handling --- .github/workflows/tests-shell.yml | 2 -- scripts/.funcs.cmds.inc.sh | 6 +++--- scripts/tests/test_backtest.sh | 22 +++++++++++++--------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests-shell.yml b/.github/workflows/tests-shell.yml index 250224bf..38549e28 100644 --- a/.github/workflows/tests-shell.yml +++ b/.github/workflows/tests-shell.yml @@ -18,8 +18,6 @@ jobs: image: ea31337/ea-tester:dev steps: - uses: actions/checkout@v2 - - name: Prepare folder - run: ln -fsv scripts /opt/scripts - run: ./test_aliases.sh working-directory: scripts/tests - run: ./test_backtest.sh diff --git a/scripts/.funcs.cmds.inc.sh b/scripts/.funcs.cmds.inc.sh index 2e3e1c9a..f5300fc6 100644 --- a/scripts/.funcs.cmds.inc.sh +++ b/scripts/.funcs.cmds.inc.sh @@ -205,7 +205,7 @@ install_mt() { if [[ " ${mt_releases_list[*]} " =~ ${mt_ver} ]]; then mt_release_url=$(jq -r '.[]|select(.tag_name == "'${mt_ver}'")["assets"][0]["browser_download_url"]' <<<"$mt_releases_json") wget -nv -c "$mt_release_url" - unzip -ou "mt-$mt_ver.zip" && rm $VFLAG "mt-$mt_ver.zip" + (unzip -ou "mt-$mt_ver.zip" && rm $VFLAG "mt-$mt_ver.zip") 1>&2 else echo "Error: Not supported platform version. Supported: ${mt_releases_list[@]}" >&2 fi @@ -239,13 +239,13 @@ set_display() { xdpyinfo &>/dev/null && return if command -v x11vnc &>/dev/null; then ! pgrep -a x11vnc && x11vnc -bg -forever -nopw -quiet -display WAIT$DISPLAY & - fi + fi 1>&2 ! pgrep -a Xvfb && Xvfb $DISPLAY -screen 0 1024x768x16 & sleep 1 if command -v fluxbox &>/dev/null; then ! pgrep -a fluxbox && fluxbox 2>/dev/null & fi - echo "IP: $(hostname -I) ($(hostname))" + echo "INFO: IP: $(hostname -I) ($(hostname))" } # Detect and configure proxy. diff --git a/scripts/tests/test_backtest.sh b/scripts/tests/test_backtest.sh index df169fcd..bc41f20a 100755 --- a/scripts/tests/test_backtest.sh +++ b/scripts/tests/test_backtest.sh @@ -17,18 +17,22 @@ file_stderr=/tmp/stderr # Asserts. set -x +# Install both platforms. +install_mt 4.0.0.1260 /opt 1>$file_stdout 2>$file_stderr +install_mt 5.0.0.2361 /opt 1>$file_stdout 2>$file_stderr + ## Checks backtest with missing parameters. ! run_backtest -_ 1>$file_stdout 2>$file_stderr -grep ^ERROR $file_stdout +grep ^"ERROR: You need to specify" $file_stdout -## Checks backtest with dummy script. -#run_backtest -_ -s Dummy 1>$file_stdout 2>$file_stderr -#grep "compiled: 1" $file_stdout -#! grep ^ERROR $file_stderr +# Checks backtest with dummy script. +run_backtest -_ -s Dummy 1>$file_stdout 2>$file_stderr +grep "compiled: 1" $file_stdout +! grep ^ERROR $file_stderr -## Checks backtest with dummy script as EA. -#run_backtest -_ -x -e Dummy 1>$file_stdout 2>$file_stderr -#grep "compiled: 1" $file_stdout -#! grep ^ERROR $file_stderr +# Checks backtest with dummy script as EA. +run_backtest -_ -e Dummy 1>$file_stdout 2>$file_stderr +grep "compiled: 1" $file_stdout +! grep ^ERROR $file_stderr echo "${BASH_SOURCE[0]} done." From c4701e9b74f47649170d8dcc09388161a24efcc1 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 May 2020 23:00:28 +0100 Subject: [PATCH 13/24] Adds test_bt_data_gen.sh --- .github/workflows/tests-shell.yml | 2 ++ scripts/tests/test_bt_data_gen.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 scripts/tests/test_bt_data_gen.sh diff --git a/.github/workflows/tests-shell.yml b/.github/workflows/tests-shell.yml index 38549e28..91996bb9 100644 --- a/.github/workflows/tests-shell.yml +++ b/.github/workflows/tests-shell.yml @@ -22,6 +22,8 @@ jobs: working-directory: scripts/tests - run: ./test_backtest.sh working-directory: scripts/tests + - run: ./test_bt_data_gen.sh + working-directory: scripts/tests - run: ./test_cmds.sh working-directory: scripts/tests - run: ./test_eval.sh diff --git a/scripts/tests/test_bt_data_gen.sh b/scripts/tests/test_bt_data_gen.sh new file mode 100755 index 00000000..df40b65c --- /dev/null +++ b/scripts/tests/test_bt_data_gen.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Test .funcs.cmds.inc.sh file. +set -e + +# Initialize. +. ../.funcs.inc.sh +initialize + +# Defines variables. +dst="/tmp" + +# Includes required code. +. ../.funcs.cmds.inc.sh + +# Asserts. + +## Test generation of data. +for type in none wave curve zigzag random; do + for spread in 10 20; do + for digits in 4 5; do + filename="${type}-s${spread}-d${digits}.csv" + bt_data_gen -p $type -o "$dst/$filename" -s $spread -D $digits 2020.01.01 2020.01.02 1.0 2.0 + done + done +done + +echo "${BASH_SOURCE[0]} done." From 840b53d8697499e2b6290bb5c947d9be61769437 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 May 2020 23:13:18 +0100 Subject: [PATCH 14/24] Adds test for conv_csv_to_mt --- scripts/tests/test_bt_data_gen.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/tests/test_bt_data_gen.sh b/scripts/tests/test_bt_data_gen.sh index df40b65c..2ccf9240 100755 --- a/scripts/tests/test_bt_data_gen.sh +++ b/scripts/tests/test_bt_data_gen.sh @@ -18,8 +18,15 @@ dst="/tmp" for type in none wave curve zigzag random; do for spread in 10 20; do for digits in 4 5; do - filename="${type}-s${spread}-d${digits}.csv" - bt_data_gen -p $type -o "$dst/$filename" -s $spread -D $digits 2020.01.01 2020.01.02 1.0 2.0 + file="$dst/${type}-s${spread}-d${digits}.csv" + # Convert to CSV. + bt_data_gen -p $type -o "$file" -s $spread -D $digits 2020.01.01 2020.01.02 1.0 2.0 + # Convert to binary format. + for format in fxt4 hst4 hcc; do + for tf in M1 M5 M15 M30 H1 H4 D1 W1 MN1; do + conv_csv_to_mt -i "$file" -d "$dst" -f $format -t $tf -s ${type^^} -v + done + done done done done From 2049f1804a99cacc2489306f54beb364ee711700 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sat, 23 May 2020 23:39:38 +0100 Subject: [PATCH 15/24] Test generated files --- scripts/tests/test_bt_data_gen.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/tests/test_bt_data_gen.sh b/scripts/tests/test_bt_data_gen.sh index 2ccf9240..e4828a83 100755 --- a/scripts/tests/test_bt_data_gen.sh +++ b/scripts/tests/test_bt_data_gen.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Test .funcs.cmds.inc.sh file. +# Test generation of backtest data. set -e # Initialize. @@ -24,11 +24,18 @@ for type in none wave curve zigzag random; do # Convert to binary format. for format in fxt4 hst4 hcc; do for tf in M1 M5 M15 M30 H1 H4 D1 W1 MN1; do - conv_csv_to_mt -i "$file" -d "$dst" -f $format -t $tf -s ${type^^} -v + conv_csv_to_mt -i "$file" -d "$dst" -f $format -t $tf -s ${type^^} done done done done done +## Test generated files. +for format in hst fxt hcc; do + find "$dst" -name "*.${format}" -print0 | while IFS= read -r -d '' file; do + mt_read -f "$file" -t "${format}-header" >/dev/null + done +done + echo "${BASH_SOURCE[0]} done." From 8ff81ec72d54e8555488bc8d830ddddb1e1fa3cf Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 24 May 2020 15:49:09 +0100 Subject: [PATCH 16/24] Installs dependencies when ran with act --- .github/workflows/tests-mql.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests-mql.yml b/.github/workflows/tests-mql.yml index e189f85d..7687ceeb 100644 --- a/.github/workflows/tests-mql.yml +++ b/.github/workflows/tests-mql.yml @@ -18,6 +18,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Check dependencies + if: github.actor == 'nektos/act' + run: apt-get update && apt-get -qq install python-pip && pip install docker-compose - name: Run ScriptDummy working-directory: tests run: docker-compose run ScriptDummy From 4f7f4d2f477dae42c7ab3739f3e14edae127d8fb Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 24 May 2020 15:51:19 +0100 Subject: [PATCH 17/24] Improves order of info messages when locating files --- scripts/run_backtest.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/run_backtest.sh b/scripts/run_backtest.sh index e315a4d0..1df57d9d 100755 --- a/scripts/run_backtest.sh +++ b/scripts/run_backtest.sh @@ -355,9 +355,9 @@ fi # Locate the main file to execute. if [ -n "$TEST_EXPERT" ]; then # Locate TestExpert if specified. + echo "INFO: Locating TestExpert file ("$TEST_EXPERT" => "$EA_PATH")..." cd "$EXPERTS_DIR" EA_PATH=$(ea_find "$TEST_EXPERT") - echo "INFO: Locating TestExpert file ("$TEST_EXPERT" => "$EA_PATH")..." [ -f "$EA_PATH" ] || { echo "ERROR: TestExpert file ($TEST_EXPERT) not found!" on_error 1 @@ -372,9 +372,9 @@ if [ -n "$TEST_EXPERT" ]; then cd - &>/dev/null elif [ -n "$EXPERT" ]; then # Locate Expert if specified. + echo "INFO: Locating Expert file ("$EXPERT" => "$EA_PATH")..." cd "$EXPERTS_DIR" EA_PATH=$(ea_find "$EXPERT") - echo "INFO: Locating Expert file ("$EXPERT" => "$EA_PATH")..." [ -f "$EA_PATH" ] || { echo "ERROR: Expert file ($EXPERT) not found!" on_error 1 @@ -389,9 +389,9 @@ elif [ -n "$EXPERT" ]; then cd - &>/dev/null elif [ -n "$SCRIPT" ]; then # Locate Script if specified. + echo "INFO: Locating Script file ("$SCRIPT" => "$SCR_PATH")..." cd "$SCRIPTS_DIR" SCR_PATH=$(script_find "$SCRIPT") - echo "INFO: Locating Script file ("$SCRIPT" => "$SCR_PATH")..." [ -f "$SCR_PATH" ] || { echo "ERROR: Script file ($SCRIPT) not found!" on_error 1 From 9b51236102b4e6f3ca7cf0663b2ba9c1d364a868 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 24 May 2020 16:07:13 +0100 Subject: [PATCH 18/24] Specifies extension when running Dummy --- tests/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index fc01b5a3..d1cec7f9 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -165,7 +165,7 @@ services: # MQL Scripts. ScriptDummy: - command: run_backtest -s Dummy + command: run_backtest -s Dummy.mq4 image: ea31337/ea-tester:dev volumes: - .:/opt/tests From c21e60d1cc71ece027b3397562cd1b9231a9d76b Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 24 May 2020 16:12:02 +0100 Subject: [PATCH 19/24] YAML: Fixes line too long --- .github/workflows/tests-mql.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests-mql.yml b/.github/workflows/tests-mql.yml index 7687ceeb..3397ca6e 100644 --- a/.github/workflows/tests-mql.yml +++ b/.github/workflows/tests-mql.yml @@ -20,7 +20,10 @@ jobs: - uses: actions/checkout@v2 - name: Check dependencies if: github.actor == 'nektos/act' - run: apt-get update && apt-get -qq install python-pip && pip install docker-compose + run: > + apt-get update + && apt-get -qq install python-pip + && pip install docker-compose - name: Run ScriptDummy working-directory: tests run: docker-compose run ScriptDummy From 0dcb757a33f86287ed5e324bb865f29d951fadaa Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 24 May 2020 16:12:34 +0100 Subject: [PATCH 20/24] Disables ScriptDummy job --- .github/workflows/tests-mql.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests-mql.yml b/.github/workflows/tests-mql.yml index 3397ca6e..94a9603c 100644 --- a/.github/workflows/tests-mql.yml +++ b/.github/workflows/tests-mql.yml @@ -27,6 +27,8 @@ jobs: - name: Run ScriptDummy working-directory: tests run: docker-compose run ScriptDummy + # @fixme + if: false - name: Run ScriptPrintPaths working-directory: tests run: docker-compose run ScriptPrintPaths From 12961e2b9e76c4be042796f79bbe3bae3c710ad1 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 24 May 2020 16:33:23 +0100 Subject: [PATCH 21/24] GHA: More fixes to push condition [GH-180] --- .github/workflows/docker.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 444b7355..283b54ad 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,6 +6,7 @@ on: paths-ignore: - '**/*.md' - '**/*.txt' + - '.*' push: branches: - "master" @@ -13,7 +14,7 @@ on: paths-ignore: - '**/*.md' - '**/*.txt' - - '**/*.yml' + - '.*' release: types: - published @@ -40,8 +41,10 @@ jobs: --build-arg VERSION=${GITHUB_REF} --target ea-tester . - run: docker images + - name: Prints GitHub actor and repository + run: echo "${{ github.actor }} @ ${{ github.repository }}" - name: Push to Docker Hub - if: github.actor == 'ea31337' + if: github.repository == 'EA31337/EA-Tester' uses: docker/build-push-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} @@ -49,9 +52,10 @@ jobs: repository: ea31337/ea-tester tag_with_ref: true - name: Push to GitHub Packages - if: github.actor == 'ea31337' + if: github.repository == 'EA31337/EA-Tester' uses: docker/build-push-action@v1 with: + add_git_labels: true username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} registry: docker.pkg.github.com From c4b4300e05f8c9bd846fa0119f844c896ef445cf Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 24 May 2020 16:53:35 +0100 Subject: [PATCH 22/24] GHA: Uses actions/checkout@v2 --- .github/workflows/docker.yml | 2 +- .github/workflows/lint.yml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 283b54ad..58773967 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -23,7 +23,7 @@ jobs: Docker: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Build ubuntu-base run: docker build --target ubuntu-base -t ubuntu-base . - name: Build ubuntu-provisioned diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 40b242c7..e3c7247e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,7 +17,7 @@ jobs: YAML: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: YAML check (yamllint) uses: ibiqlik/action-yamllint@master with: @@ -25,7 +25,7 @@ jobs: Markdown: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: markdownlint-cli uses: nosborn/github-action-markdown-cli@v1.1.1 env: @@ -36,7 +36,7 @@ jobs: ShellCheck: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Shell Check uses: luizm/action-sh-checker@master env: @@ -47,14 +47,14 @@ jobs: MQL: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - uses: DoozyX/clang-format-lint-action@v0.5 with: extensions: 'h' Syntax: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Run RunCompileMql run: docker-compose run RunCompileMql - name: Run TestSyntaxBash From 07612fc334d507b07379a7ca75582a143e98a192 Mon Sep 17 00:00:00 2001 From: kenorb Date: Sun, 24 May 2020 17:12:40 +0100 Subject: [PATCH 23/24] GHA: Do not push image on pull requests [GH-180] --- .github/workflows/docker.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 58773967..ce230935 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -44,7 +44,9 @@ jobs: - name: Prints GitHub actor and repository run: echo "${{ github.actor }} @ ${{ github.repository }}" - name: Push to Docker Hub - if: github.repository == 'EA31337/EA-Tester' + if: > + github.repository == 'EA31337/EA-Tester' + && github.event_name != 'pull_request' uses: docker/build-push-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} @@ -52,7 +54,9 @@ jobs: repository: ea31337/ea-tester tag_with_ref: true - name: Push to GitHub Packages - if: github.repository == 'EA31337/EA-Tester' + if: > + github.repository == 'EA31337/EA-Tester' + && github.event_name != 'pull_request' uses: docker/build-push-action@v1 with: add_git_labels: true From 48adc9300517ee2a4b3cc77e6bc06e8fe80a6331 Mon Sep 17 00:00:00 2001 From: kenorb Date: Tue, 26 May 2020 18:51:46 +0100 Subject: [PATCH 24/24] GHA: Adds Hadolint workflow --- .github/workflows/docker.yml | 9 +++++++++ Dockerfile | 7 +++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ce230935..e3c75b7a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -20,8 +20,16 @@ on: - published jobs: + Hadolint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: brpaz/hadolint-action@master + with: + dockerfile: Dockerfile Docker: runs-on: ubuntu-latest + needs: Hadolint steps: - uses: actions/checkout@v2 - name: Build ubuntu-base @@ -67,6 +75,7 @@ jobs: tag_with_ref: true Test-Docker: runs-on: ubuntu-latest + needs: Docker container: image: ea31337/ea-tester:dev volumes: diff --git a/Dockerfile b/Dockerfile index 853c328f..b1ef6851 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ # Set the base Ubuntu image. FROM ubuntu:xenial AS ubuntu-base -MAINTAINER kenorb ENV DEBIAN_FRONTEND noninteractive # Setup the default user. @@ -23,7 +22,7 @@ ARG PROVISION_SUDO=1 ARG PROVISION_VNC=1 # Provision container image. -ADD scripts /opt/scripts +COPY scripts /opt/scripts ENV PATH $PATH:/opt/scripts:/opt/scripts/py ENV PROVISION_HASH KwFCBBn659lGNLNiIGd5131XnknI RUN provision.sh @@ -39,8 +38,8 @@ USER ubuntu FROM ubuntu-provisioned AS ea-tester-base # Add files. -ADD conf /opt/conf -ADD tests /opt/tests +COPY conf /opt/conf +COPY tests /opt/tests # Setup results directory. ARG BT_DEST=/opt/results