Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 1546 CI testing #2029

Merged
merged 147 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
7461330
use env var to set MET_PYTHON_EXE in unit tests instead of using hard…
georgemccabe Jan 18, 2022
ca71c58
ignore log file created in Docker image
georgemccabe Jan 18, 2022
760afd0
rename output file from test to no longer contain + character that ca…
georgemccabe Jan 18, 2022
a06a71f
wrote script that contains all commands that are needed to install wh…
georgemccabe Jan 18, 2022
e337b08
split script to build and push MET docker image into 2 scripts
georgemccabe Jan 19, 2022
303ab44
removed echo commands to group log output to allow script/job to fail…
georgemccabe Jan 19, 2022
d3a0487
Per #1546, move steps to install external libraries needed to install…
georgemccabe Jan 19, 2022
d07fcb0
per #1546, moved logic to build MET in Docker into a script to call f…
georgemccabe Jan 20, 2022
5cd2afb
Per #1546, added Dockerfile that copies local MET source code into Do…
georgemccabe Jan 20, 2022
04c72a3
Per #1546, fixed path to build script
georgemccabe Jan 20, 2022
d787dbb
rename file to match DockerHub image name
georgemccabe Jan 20, 2022
f9b2a19
Per #1546, set env var MET_REPO_DIR to easily get directory that repo…
georgemccabe Jan 20, 2022
2a1579c
Per #1546, changed script to run unit tests and comparison, writing t…
georgemccabe Jan 20, 2022
0ab6fd7
Per #1546, check return code of commands and exit non-zero if failure…
georgemccabe Jan 20, 2022
c0d233f
added readme file to describe how to use each Dockerfile in the direc…
georgemccabe Jan 20, 2022
e85c79c
Per #1546, added error checking and reporting to unit test script
georgemccabe Jan 20, 2022
f2dbb7d
Per #1546, moved time_command function into a file to be sourced by e…
georgemccabe Jan 20, 2022
3c55389
Per #1546, changed build docker script to use Dockerfile.copy to use …
georgemccabe Jan 20, 2022
6de4ac5
Per #1546, renamed jobs and steps to be more clear
georgemccabe Jan 20, 2022
0b70c80
Per #1546, fixed logic to get branch name
georgemccabe Jan 20, 2022
d19ccfa
Per #1546, fixed logic to get branch name in other workflow
georgemccabe Jan 20, 2022
06c4527
changed event rules to trigger on push to feature and bugfix branches…
georgemccabe Jan 20, 2022
0327436
Per #1546, to test automation logic, make change to file in met/src t…
georgemccabe Jan 20, 2022
2bdefad
per #1546, pipe docker build output to log file and make log availabl…
georgemccabe Jan 20, 2022
ed8e212
Per #1546, testing: another change under met/src to trigger compilati…
georgemccabe Jan 20, 2022
f1525cc
fix path to file to upload as artifact
georgemccabe Jan 20, 2022
e511cdc
test again
georgemccabe Jan 20, 2022
ac13a16
fix sending output to logfile while keeping timing information in stdout
georgemccabe Jan 20, 2022
5dc9419
another change to test broken compilation
georgemccabe Jan 20, 2022
21f6505
remove line that causes error
georgemccabe Jan 20, 2022
78bb8c7
last test for compilation failure
georgemccabe Jan 20, 2022
c4ef297
fixed error catching when log file is set
georgemccabe Jan 20, 2022
07bd039
test failed compilation one more time
georgemccabe Jan 20, 2022
0679504
formatting
georgemccabe Jan 20, 2022
3b75672
always upload build log artifact so it can be easily reviewed on a su…
georgemccabe Jan 20, 2022
aadefd8
fixed intentional bug used for testing
georgemccabe Jan 20, 2022
98327f4
minor change to trigger workflow on push
georgemccabe Jan 20, 2022
40dcd22
Per #1546, add option to skip MET compilation test by setting ci-skip…
georgemccabe Jan 20, 2022
fc442b7
trigger compilation test
georgemccabe Jan 20, 2022
ba2ed67
fixed logic to skip compile test by setting ci-skip-compile
georgemccabe Jan 20, 2022
5721ece
always run upload artifact step regardless of failure or success
georgemccabe Jan 20, 2022
c97258c
test once again
georgemccabe Jan 20, 2022
de40002
change code back to original state
georgemccabe Jan 20, 2022
a390ca1
added workflow to run unit tests, compare output to truth data, and c…
georgemccabe Jan 20, 2022
b8c6099
changed name of job, fixed typo
georgemccabe Jan 20, 2022
286c00d
fixed command run inside docker
georgemccabe Jan 20, 2022
0cd00a5
pass GITHUB_WORKSPACE env var into docker container
georgemccabe Jan 20, 2022
16a1ae8
fixed reference to runner workspace from workflow file
georgemccabe Jan 20, 2022
455dab0
remove GITHUB_WORKSPACE from docker run command and refer to script r…
georgemccabe Jan 20, 2022
0383320
change again to trigger compile test to check that changes work as ex…
georgemccabe Jan 20, 2022
d6fe01b
run step to copy build log to log directory even if build fails
georgemccabe Jan 20, 2022
f090976
changed code back to original state after confirmed behavior in autom…
georgemccabe Jan 20, 2022
41d4040
Per #1546, added function to get branch name depending on if event is…
georgemccabe Jan 20, 2022
192b0d3
set MET_FONT_DIR with ENV so it is avaiable for test runs
georgemccabe Jan 20, 2022
c554789
catch error if copy script fails
georgemccabe Jan 21, 2022
e3ec594
fix typo in shebang line
georgemccabe Jan 21, 2022
7a592a9
Per #1546, fixed incorrect directory to mount diff output
georgemccabe Jan 21, 2022
6def40f
fix bad path that causes diff artifact upload to fail
georgemccabe Jan 21, 2022
f4a15ca
Per #1546, many changes including adding new job control rules, build…
georgemccabe Jan 21, 2022
979de4b
fix typo in script
georgemccabe Jan 21, 2022
ca246ba
don't run unit tests unless job control specifies to
georgemccabe Jan 21, 2022
346517e
echo job control settings so they can be seen in the logs, trigger un…
georgemccabe Jan 21, 2022
71fc960
added always() to unit test if so that it will still run even if comp…
georgemccabe Jan 21, 2022
7c6552f
added escaped quotes around tests argument to prevent failure, ci-ski…
georgemccabe Jan 21, 2022
ce2a635
unit tests do not run if compile is skipped, so removing always() fro…
georgemccabe Jan 21, 2022
f060c0a
fix check for empty diff dir
georgemccabe Jan 21, 2022
ec44bb9
temporarily remove unit test dependency on compile for testing, ci-sk…
georgemccabe Jan 21, 2022
df1d3e0
pass in list of tests via env var instead of argument, ci-skip-compil…
georgemccabe Jan 21, 2022
dd476b9
try exporting env var so it is passed into docker container, ci-skip-…
georgemccabe Jan 21, 2022
9d38763
testing to debug issues in automation, ci-skip-compile, ci-run-unit
georgemccabe Jan 21, 2022
9a4f7da
need to compile to get changes, ci-run-unit
georgemccabe Jan 21, 2022
875a90e
fixed typo in var name, ci-run-unit
georgemccabe Jan 21, 2022
9ec546c
split unit test runs and diff logic into separate steps so it is easi…
georgemccabe Jan 21, 2022
3d1b8ce
try mounting all volumes in unit test docker run, then docker exec to…
georgemccabe Jan 22, 2022
94f7283
start docker container then run separate commands in container, ci-ru…
georgemccabe Jan 24, 2022
96c62b3
create container with ID to use to run commands, ci-run-unit
georgemccabe Jan 24, 2022
c1ddd15
try running docker with --name, ci-run-unit
georgemccabe Jan 24, 2022
ec6896c
try starting container then using docker exec to run commands inside,…
georgemccabe Jan 24, 2022
a14b920
try running docker with -d (detach) to run in background with volumes…
georgemccabe Jan 24, 2022
4574861
temporary skip compile to test running docker, ci-skip-compile, ci-ru…
georgemccabe Jan 24, 2022
ffadbe8
append to logfile if it already exists
georgemccabe Jan 24, 2022
1e0aa8a
add first test in group to log file name for copying diff files
georgemccabe Jan 24, 2022
ee76465
consolidate functions calls into fewer steps, copy unit test job into…
georgemccabe Jan 24, 2022
4f46e49
instead of failing if a diff is found in a unit test, run a job at th…
georgemccabe Jan 24, 2022
ada5b32
fixed name of dependent jobs, remove checkout action since we don't n…
georgemccabe Jan 24, 2022
3504df9
set unit test groups based on dependencies and length of run, ci-run-…
georgemccabe Jan 24, 2022
806bb02
fixed logic parsing missing file section to get correct full path to …
georgemccabe Jan 25, 2022
3d02253
print which comp_dir log file is being parsed, ci-run-unit
georgemccabe Jan 25, 2022
b321d56
added _group to log file name that contains first test name to make i…
georgemccabe Jan 25, 2022
b79bf7e
merged develop after #2021
georgemccabe Jan 25, 2022
8d74b48
Per #1546, rearrange use case group dependencies, save output as arti…
georgemccabe Jan 25, 2022
dd26457
copy all output data artifact content into output directory, ci-run-unit
georgemccabe Jan 25, 2022
f37e09c
Per #1546, change output filename to use underscore instead of colon …
georgemccabe Jan 25, 2022
24ad533
Per #1546, changed output filenames that include colon to use undersc…
georgemccabe Jan 25, 2022
0bb89d8
Per #1546, update name of grib_tables unit test group from test_grib_…
georgemccabe Jan 25, 2022
0664680
use vars to set local and docker dirs to mount, create local dirs
georgemccabe Jan 25, 2022
3a7436c
added job_control to needs list for unit test jobs so they can get th…
georgemccabe Jan 25, 2022
14669d7
Per #1546, remove check of content of output directory in unit tests …
georgemccabe Jan 25, 2022
3dc9673
added missing checkout action before running diff script, ci-run-unit
georgemccabe Jan 25, 2022
0989ea3
add diff logs to artifact, ci-run-unit
georgemccabe Jan 25, 2022
fb6cd8d
print contents of log file on failure for easier debugging
georgemccabe Jan 25, 2022
3ed5015
fixed variable that contains log file to parse, ci-run-unit
georgemccabe Jan 25, 2022
33dbae7
removed import that is no longer used
georgemccabe Jan 25, 2022
ffeffad
added logic to set job control variables to run diff and update truth…
georgemccabe Jan 25, 2022
6d1c585
added logic to set job control variables to run diff and update truth…
georgemccabe Jan 25, 2022
8f783d2
Per #1546, fix copy of data into dir that is mounted to Docker so dif…
georgemccabe Jan 25, 2022
088bcb1
Per #1546, added logic to update truth data volume on DockerHub for -…
georgemccabe Jan 25, 2022
2620aa4
remove dir listing for output and trigger ci-run-unit to test with da…
georgemccabe Jan 25, 2022
0fc5bd5
Per #1546, split output independent ascii2nc tests into unit_ascii2nc…
JohnHalleyGotway Jan 26, 2022
46d8785
Per #1546, split output independent pb2nc test into unit_pb2nc_indy.xml.
JohnHalleyGotway Jan 26, 2022
2e37e4f
change event/job rules so workflow is triggered on push to feature,bu…
georgemccabe Jan 26, 2022
b69407c
Testing: temporarily change settings to test running all unit tests a…
georgemccabe Jan 26, 2022
6f68825
test running diff logic using dtcenter/met-base:unit_test and buildin…
georgemccabe Jan 26, 2022
e4bffe9
revert back to using full MET image for diff test since unit_test bas…
georgemccabe Jan 26, 2022
5c833c8
revert back to using full MET image for diff test since unit_test bas…
georgemccabe Jan 26, 2022
4f92d45
added docker push for creating new truth data volume
georgemccabe Jan 26, 2022
740cbf0
set DOCKERHUB_REPO as global env var for workflow instead of making i…
georgemccabe Jan 26, 2022
29d71d7
Do not fail diff test if there are differences when updating the -ref…
georgemccabe Jan 26, 2022
13dc7dd
Testing: attempt 2 to update truth data
georgemccabe Jan 26, 2022
00cee88
reset default job controls after running test
georgemccabe Jan 26, 2022
a4cff20
rearrange job rules to force behavior for -ref branches, set required…
georgemccabe Jan 26, 2022
c6954e0
log into docker to push truth data
georgemccabe Jan 26, 2022
d2b3010
if truth data is not yet available for version (when first run of mai…
georgemccabe Jan 26, 2022
685eead
set truth data version based on -ref branch to allow diff tests and t…
georgemccabe Jan 26, 2022
01cab47
Testing: 3rd try - temporarily set to update truth and write to test …
georgemccabe Jan 26, 2022
1415b51
changed defaults back
georgemccabe Jan 26, 2022
d2d8a11
set truth data version to main_vX.Y if running on main_vX.Y push
georgemccabe Jan 26, 2022
dc5efea
added input data version variable that can be used to change the inpu…
georgemccabe Jan 26, 2022
16184c8
Per #1546, break unit_ref_config.xml out into 6 different XML's so th…
JohnHalleyGotway Jan 26, 2022
e22d755
Merge branch 'feature_1546_ci_testing' into feature_1546_unit_xmls
JohnHalleyGotway Jan 26, 2022
1c75983
Per #1543, update job control for splitting up the ascii2nc, pb2nc, a…
JohnHalleyGotway Jan 26, 2022
0280c3e
Per #1546, rename unit_test.yml file.
JohnHalleyGotway Jan 26, 2022
a931c0b
Per #1546 ci-run-unit, group short running unit tests together in the…
JohnHalleyGotway Jan 26, 2022
5624ec7
Per #1546, re-group the ref_config lead times from 2 to 3. Leads 00, …
JohnHalleyGotway Jan 26, 2022
d4bba5d
Per #1546, split unit_stat_analysis.xml out into 4 separate XML's wit…
JohnHalleyGotway Jan 26, 2022
1b842c2
Per #1543, ci-run-unit split unit_climatology.xml up into 3 pieces wh…
JohnHalleyGotway Jan 26, 2022
002b22c
Per #1546, ci-run-unit fix typo in the climatology_2.0deg name which …
JohnHalleyGotway Jan 26, 2022
fcef721
added option to skip obtaining input data volume if it is not needed,…
georgemccabe Jan 26, 2022
c47c35d
fixed typo in xml file name
georgemccabe Jan 26, 2022
fec3d3d
fixed typo, ci-run-unit
georgemccabe Jan 26, 2022
f9a6384
Merge branch 'develop' into feature_1546_unit_xmls
georgemccabe Jan 27, 2022
2547f99
remove workflow because unit_tests.yml performs the compilation test …
georgemccabe Jan 27, 2022
e3cc7e9
Per #1546, added requirement to test XML
georgemccabe Jan 27, 2022
5af8ded
changed script timing info to use datetime instead of time to fix err…
georgemccabe Jan 27, 2022
38e7bdd
Per #1546, echo value of MET_PYTHON_EXE in tests that use the env var…
georgemccabe Jan 27, 2022
c2688b5
Per #1546, fix typo in echo statements.
JohnHalleyGotway Jan 27, 2022
cafe079
Per #1546, update unit tests to trigger on pull_request synchronize.
JohnHalleyGotway Jan 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/jobs/Dockerfile.truth
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM centos:7
MAINTAINER George McCabe <[email protected]>

ENV OUTPUT_DIR /data/output
RUN mkdir -p ${OUTPUT_DIR}

ARG TRUTH_DIR

COPY ${TRUTH_DIR} ${OUTPUT_DIR}/

ARG TRUTH_DIR

# Define the volume mount point
VOLUME ${OUTPUT_DIR}/${TRUTH_DIR}

USER root
CMD ["true"]
27 changes: 27 additions & 0 deletions .github/jobs/bash_functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#! /bin/bash

# utility function to run command get log the time it took to run
# if CMD_LOGFILE is set, send output to that file and unset var
function time_command {
local start_seconds=$SECONDS
echo "RUNNING: $*"

local error
# pipe output to log file if set
if [ "x$CMD_LOGFILE" == "x" ]; then
"$@"
error=$?
else
echo "Logging to ${CMD_LOGFILE}"
"$@" &>> $CMD_LOGFILE
error=$?
unset CMD_LOGFILE
fi

local duration=$(( SECONDS - start_seconds ))
echo "TIMING: Command took `printf '%02d' $(($duration / 60))`:`printf '%02d' $(($duration % 60))` (MM:SS): '$*'"
if [ ${error} -ne 0 ]; then
echo "ERROR: '$*' exited with status = ${error}"
fi
return $error
}
40 changes: 0 additions & 40 deletions .github/jobs/build_and_push_docker_image.sh

This file was deleted.

14 changes: 14 additions & 0 deletions .github/jobs/build_docker_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /bin/bash

source ${GITHUB_WORKSPACE}/.github/jobs/bash_functions.sh

DOCKERHUB_TAG=${DOCKERHUB_REPO}:${SOURCE_BRANCH}

DOCKERFILE_PATH=${GITHUB_WORKSPACE}/scripts/docker/Dockerfile.copy

CMD_LOGFILE=${GITHUB_WORKSPACE}/docker_build.log

time_command docker build -t ${DOCKERHUB_TAG} \
--build-arg SOURCE_BRANCH \
--build-arg MET_BASE_IMAGE \
-f $DOCKERFILE_PATH ${GITHUB_WORKSPACE}
80 changes: 80 additions & 0 deletions .github/jobs/copy_diff_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#! /usr/bin/env python3

import os
import shutil

OUTPUT_DIR = os.environ['MET_TEST_OUTPUT']
TRUTH_DIR = os.environ['MET_TEST_TRUTH']
DIFF_DIR = os.environ['MET_TEST_DIFF']

LOG_DIR = '/met/logs'

def get_files_with_diffs(log_file):
files_to_copy = set()

with open(log_file, 'r') as file_handle:
file_content = file_handle.read()

missing_section, *test_sections = file_content.split(
'\n# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #\n'
)

# parse list of missing files
if 'ERROR:' in missing_section:
for missing_group in missing_section.split('ERROR:')[1:]:
dir_str, *rel_paths = missing_group.splitlines()
dir_str = dir_str.split()[1]
if OUTPUT_DIR in dir_str:
top_dir = dir_str.replace(OUTPUT_DIR, TRUTH_DIR)
elif TRUTH_DIR in dir_str:
top_dir = dir_str.replace(TRUTH_DIR, OUTPUT_DIR)
else:
print("ERROR: SOMETHING WENT WRONG PARSING COMP_DIR OUTPUT")
continue
for rel_path in rel_paths:
files_to_copy.add(os.path.join(top_dir, rel_path.strip()))

# parse file paths out of sections that have errors
error_sections = [item for item in test_sections if 'ERROR:' in item]
for error_section in error_sections:
for line in error_section.splitlines():
for item in line.split():
if OUTPUT_DIR in item or TRUTH_DIR in item:
files_to_copy.add(item)

return files_to_copy

def copy_files_to_diff_dir(files_to_copy):

print(f"Found {len(files_to_copy)} diff files")

# add extension for output/truth and copy files to diff directory
for filename in files_to_copy:
output_path, extension = os.path.splitext(filename)
if OUTPUT_DIR in output_path:
output_path = f'{output_path}_OUTPUT{extension}'
output_path = output_path.replace(OUTPUT_DIR, DIFF_DIR)
elif TRUTH_DIR in output_path:
output_path = f'{output_path}_TRUTH{extension}'
output_path = output_path.replace(TRUTH_DIR, DIFF_DIR)
else:
continue

# change bad char - this can be removed once test output is changed
output_path = output_path.replace(':', '_')

print(f"Copy {filename} to {output_path}")
output_dir = os.path.dirname(output_path)
if not os.path.exists(output_dir):
os.makedirs(output_dir)
shutil.copyfile(filename, output_path)

def main():
log_file = os.path.join(LOG_DIR, 'comp_dir.log')
print(f"Parsing {log_file}")
all_files_to_copy = get_files_with_diffs(log_file)

copy_files_to_diff_dir(all_files_to_copy)

if __name__ == "__main__":
main()
18 changes: 18 additions & 0 deletions .github/jobs/create_docker_truth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#! /bin/bash

source ${GITHUB_WORKSPACE}/.github/jobs/bash_functions.sh

image_name=dtcenter/met-data-output:${TRUTH_DATA_VERSION}

time_command docker build -t ${image_name} \
--build-arg TRUTH_DIR=met_test_truth \
-f ${GITHUB_WORKSPACE}/.github/jobs/Dockerfile.truth \
${RUNNER_WORKSPACE}
if [ $? != 0 ]; then
echo "ERROR: Docker build failed"
exit 1
fi

echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin

time_command docker push ${image_name}
15 changes: 15 additions & 0 deletions .github/jobs/get_branch_name.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /bin/bash

# If pull request, use GitHub head ref and add -PR to end
# Otherwise use GitHub ref

if [ "${GITHUB_EVENT_NAME}" == "pull_request" ] ; then
branch_name=${GITHUB_HEAD_REF}-PR
else
branch_name=${GITHUB_REF}
fi

branch_name=${branch_name#"refs/heads/"}

echo ::set-output name=branch_name::$branch_name
echo branch_name: $branch_name
7 changes: 7 additions & 0 deletions .github/jobs/get_test_input_data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/bash

source ${GITHUB_WORKSPACE}/.github/jobs/bash_functions.sh

DATA_VERSION=$1

time_command docker create --name met_input dtcenter/met-data-dev:${DATA_VERSION}
11 changes: 11 additions & 0 deletions .github/jobs/get_test_truth_data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /bin/bash

source ${GITHUB_WORKSPACE}/.github/jobs/bash_functions.sh

DATA_VERSION=$1

time_command docker create --name met_truth dtcenter/met-data-output:${DATA_VERSION}
if [ $? != 0 ]; then
echo "Image tag ${DATA_VERSION} does not exist. Using develop..."
time_command docker create --name met_truth dtcenter/met-data-output:develop
fi
7 changes: 7 additions & 0 deletions .github/jobs/pull_docker_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/bash

source ${GITHUB_WORKSPACE}/.github/jobs/bash_functions.sh

DOCKERHUB_TAG=$1

time_command docker pull ${DOCKERHUB_TAG}
15 changes: 15 additions & 0 deletions .github/jobs/push_docker_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /bin/bash

source ${GITHUB_WORKSPACE}/.github/jobs/bash_functions.sh

DOCKERHUB_TAG=${DOCKERHUB_REPO}:${SOURCE_BRANCH}

# skip docker push if credentials are not set
if [ -z ${DOCKER_USERNAME+x} ] || [ -z ${DOCKER_PASSWORD+x} ]; then
echo "DockerHub credentials not set. Skipping docker push"
exit 0
fi

echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin

time_command docker push ${DOCKERHUB_TAG}
48 changes: 48 additions & 0 deletions .github/jobs/run_diff_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#! /bin/bash

source ${GITHUB_WORKSPACE}/.github/jobs/bash_functions.sh

DOCKERHUB_TAG=${DOCKERHUB_REPO}:${SOURCE_BRANCH}

# Get truth output data
${GITHUB_WORKSPACE}/.github/jobs/get_test_truth_data.sh ${TRUTH_DATA_VERSION}

# Set up directories to mount
LOCAL_OUTPUT_DIR=${RUNNER_WORKSPACE}/output
DOCKER_OUTPUT_DIR=/data/output/met_test_output

LOCAL_DIFF_DIR=${RUNNER_WORKSPACE}/diff
DOCKER_DIFF_DIR=/data/output/met_test_diff

LOCAL_LOG_DIR=${RUNNER_WORKSPACE}/logs
DOCKER_LOG_DIR=/met/logs

# Create local directories to store output
mkdir -p ${LOCAL_LOG_DIR}
mkdir -p ${LOCAL_DIFF_DIR}

# mount output and log dirs, mount GitHub files into MET_REPO_DIR
mount_args="-v ${LOCAL_OUTPUT_DIR}:${DOCKER_OUTPUT_DIR} -v ${LOCAL_DIFF_DIR}:${DOCKER_DIFF_DIR} -v ${LOCAL_LOG_DIR}:${DOCKER_LOG_DIR}"

# Set up data volumes
volumes_from="--volumes-from met_truth"

# run unit test script inside Docker, mount MET output and truth data
# set MET_REPO_DIR env var in Docker to mounted directory
cmd="\${MET_REPO_DIR}/.github/jobs/run_diff_tests.sh"
time_command docker run ${volumes_from} ${mount_args} ${DOCKERHUB_TAG} bash -c \"${cmd}\"
if [ $? != 0 ]; then
exit 1
fi

if [ "$(ls -A ${LOCAL_DIFF_DIR})" ]; then
echo "ERROR: Differences exist in the output"

# only exit non-zero (job fails) if not updating truth data
# this makes difference output available when updating truth data
# so it is easier to see what changed with the update
if [ "${RUN_UPDATE_TRUTH}" != "true" ]; then
exit 1
fi

fi
33 changes: 33 additions & 0 deletions .github/jobs/run_diff_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#! /bin/bash

source ${MET_REPO_DIR}/.github/jobs/bash_functions.sh

###
# Set environment variables needed to run unit tests
###

source ${MET_REPO_DIR}/.github/jobs/test_env_vars.sh

###
# Run comparison of MET unit test output
###

echo "Running comparison on test output"
CMD_LOGFILE=/met/logs/comp_dir.log
time_command ${MET_TEST_BASE}/bin/comp_dir.sh ${MET_TEST_TRUTH} ${MET_TEST_OUTPUT}
if [ $? != 0 ]; then
echo "ERROR: Test output comparison failed"
cat /met/logs/comp_dir.log
exit 1
fi

echo "Running copy_diff_files.py"
CMD_LOGFILE=/met/logs/copy_diff_files.log
time_command ${MET_REPO_DIR}/.github/jobs/copy_diff_files.py
if [ $? != 0 ]; then
echo "ERROR: Copy diff files script failed"
cat /met/logs/copy_diff_files.log
exit 1
fi

echo "Success"
37 changes: 37 additions & 0 deletions .github/jobs/run_unit_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /bin/bash

source ${GITHUB_WORKSPACE}/.github/jobs/bash_functions.sh

DOCKERHUB_TAG=${DOCKERHUB_REPO}:${SOURCE_BRANCH}

# Pull MET Image from DockerHub
${GITHUB_WORKSPACE}/.github/jobs/pull_docker_image.sh ${DOCKERHUB_TAG}

# Get test input data if needed
volumes_from=""
if [ "${INPUT_DATA_VERSION}" != "none" ]; then
${GITHUB_WORKSPACE}/.github/jobs/get_test_input_data.sh ${INPUT_DATA_VERSION}
volumes_from=${volumes_from}"--volumes-from met_input"
fi

# Set up directories to mount
LOCAL_OUTPUT_DIR=${RUNNER_WORKSPACE}/output
DOCKER_OUTPUT_DIR=/data/output/met_test_output

LOCAL_LOG_DIR=${RUNNER_WORKSPACE}/logs
DOCKER_LOG_DIR=/met/logs

# Create local directories to store output
mkdir -p ${LOCAL_LOG_DIR}
mkdir -p ${LOCAL_OUTPUT_DIR}

mount_args="-v ${LOCAL_OUTPUT_DIR}:${DOCKER_OUTPUT_DIR} -v ${LOCAL_LOG_DIR}:${DOCKER_LOG_DIR}"

export TESTS_TO_RUN=$TESTS

# run unit test script inside Docker, mount MET input and truth data
cmd="\${MET_REPO_DIR}/.github/jobs/run_unit_tests.sh"
time_command docker run -e TESTS_TO_RUN ${volumes_from} ${mount_args} ${DOCKERHUB_TAG} bash -c \"${cmd}\"
if [ $? != 0 ]; then
exit 1
fi
Loading