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

run only fixture tests of files deployed #77

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 16 additions & 2 deletions .gitlab/ci_cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ variables:
interruptible: true
before_script:
- apt-get update && apt-get install -y --no-install-recommends git
artifacts:
paths:
- $CI_PROJECT_DIR/$DATA_PROJECT_DIR/deploy.env
script:
- *validate_input
# set envvars
- |
touch $CI_PROJECT_DIR/$DATA_PROJECT_DIR/deploy.env
_ENV_FLAGS="${ENV_FLAGS:=--last-partition --wait}"
cd $CI_PROJECT_DIR/$DATA_PROJECT_DIR
_NORMALIZED_BRANCH_NAME=$(echo $DATA_PROJECT_DIR | rev | cut -d "/" -f 1 | rev | tr '.-' '_')
Expand Down Expand Up @@ -81,7 +85,12 @@ variables:
DEPLOY_FILE=./deploy/${VERSION}/deploy.sh
if [ ! -f "$DEPLOY_FILE" ]; then
echo "$DEPLOY_FILE not found, running default tb deploy command"
tb --semver ${VERSION} deploy ${CI_FLAGS}
DEPLOY_OUTPUT=$(tb --semver ${VERSION} deploy ${CI_FLAGS})
echo "$DEPLOY_OUTPUT"
DEPLOY_RESOURCE_NAMES=$(echo "$DEPLOY_OUTPUT" | grep -o 'Running .*' | awk '{print $2}' | tr -d "'")
echo "$DEPLOY_RESOURCE_NAMES" > $CI_PROJECT_DIR/$DATA_PROJECT_DIR/deploy.env
echo "cat $CI_PROJECT_DIR/$DATA_PROJECT_DIR/deploy.env"
cat $CI_PROJECT_DIR/$DATA_PROJECT_DIR/deploy.env
tb release ls
fi

Expand Down Expand Up @@ -113,6 +122,11 @@ variables:
cd $CI_PROJECT_DIR/$DATA_PROJECT_DIR
_NORMALIZED_BRANCH_NAME=$(echo $DATA_PROJECT_DIR | rev | cut -d "/" -f 1 | rev | tr '.-' '_')
source .tinyenv
if [ -f deploy.env ]; then
export DEPLOY_RESOURCE_NAMES=$(cat deploy.env)
else
echo "deploy.env not found"
fi

# Create Python Virtual Environment
- |
Expand Down Expand Up @@ -182,7 +196,7 @@ variables:

- |
if [ -f ./scripts/exec_test.sh ]; then
./scripts/exec_test.sh $VERSION
./scripts/exec_test.sh $VERSION $DEPLOY_RESOURCE_NAMES
fi

# Run data quality tests
Expand Down
9 changes: 8 additions & 1 deletion scripts/exec_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set -euxo pipefail

export TB_VERSION_WARNING=0
export VERSION=$1
export RESOURCE_NAMES=$2

run_test() {
t=$1
Expand Down Expand Up @@ -55,7 +56,13 @@ run_test() {
export -f run_test

fail=0
find ./tests -name "*.test" -print0 | xargs -0 -I {} -P 4 bash -c 'run_test "$@"' _ {} $VERSION || fail=1
if [ -v RESOURCE_NAMES ]; then
for name in $RESOURCE_NAMES; do
find ./tests -type f -name "*.test" -exec grep -q "$name" {} \; -print0 | xargs -0 -I {} -P 4 bash -c 'run_test "$@"' _ {} $VERSION || fail=1
done
else
find ./tests -name "*.test" -print0 | xargs -0 -I {} -P 4 bash -c 'run_test "$@"' _ {} $VERSION || fail=1
fi

if [ $fail == 1 ]; then
exit -1;
Expand Down