Skip to content

Commit

Permalink
add test.command.direct to run test command directly against container.
Browse files Browse the repository at this point in the history
  • Loading branch information
wildone committed Apr 5, 2023
1 parent 9f18290 commit 2c23f83
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 14 additions & 2 deletions scripts/github/github_container_verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,20 @@ fi
echo ">>> VERIFY BUILD CONTAINER <<<"
DIR=$(mktemp -d)
echo "TEST_COMMAND:${TEST_COMMAND}"
echo "TEST:docker run --env TEST_COMMAND ${IMAGE}:${IMAGE_VERSION} bash -c 'eval \${TEST_COMMAND} 2>&1 | grep -q -e ${TEST_COMMAND_VERIFY} && echo true || echo false'"
export CONTAINER_OUTPUT=$(docker run --env TEST_COMMAND ${IMAGE}:${IMAGE_VERSION} bash -c "eval \${TEST_COMMAND} 2>&1 | grep -q -e \"${TEST_COMMAND_VERIFY}\" && echo true || echo false")
if [[ -z "${TEST_COMMAND_DIRECT}" ]]; then
echo "TEST_COMMAND_DIRECT is not empty"
echo "TEST:docker run --env TEST_COMMAND ${IMAGE}:${IMAGE_VERSION} ${TEST_COMMAND}"
CONTAINER_RESULT=$(docker run --env TEST_COMMAND ${IMAGE}:${IMAGE_VERSION} ${TEST_COMMAND})
if [[ "${CONTAINER_RESULT}" == "${TEST_COMMAND_VERIFY}" ]]; then
export CONTAINER_OUTPUT=true
else
export CONTAINER_OUTPUT=false
fi
else
echo "TEST_COMMAND_DIRECT is empty"
echo "TEST:docker run --env TEST_COMMAND ${IMAGE}:${IMAGE_VERSION} bash -c 'eval \${TEST_COMMAND} 2>&1 | grep -q -e ${TEST_COMMAND_VERIFY} && echo true || echo false'"
export CONTAINER_OUTPUT=$(docker run --env TEST_COMMAND ${IMAGE}:${IMAGE_VERSION} bash -c "eval \${TEST_COMMAND} 2>&1 | grep -q -e \"${TEST_COMMAND_VERIFY}\" && echo true || echo false")
fi
echo "CONTAINER_OUTPUT=${CONTAINER_OUTPUT}" >> $GITHUB_ENV
echo "CONTAINER_OUTPUT=${CONTAINER_OUTPUT}" >> $GITHUB_OUTPUT

Expand Down
4 changes: 4 additions & 0 deletions scripts/github/github_get_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export TEST_COMMAND_VERIFY=$(grep test.command.verify= Dockerfile | sed -e 's/.*
echo "TEST_COMMAND_VERIFY=${TEST_COMMAND_VERIFY}" >> $GITHUB_ENV
echo "TEST_COMMAND_VERIFY=${TEST_COMMAND_VERIFY}" >> $GITHUB_OUTPUT

export TEST_COMMAND_DIRECT=$(grep test.command.direct= Dockerfile | sed -e 's/.*test.command.direct="\(.*\)".*/\1/')
echo "TEST_COMMAND_DIRECT=${TEST_COMMAND_DIRECT}" >> $GITHUB_ENV
echo "TEST_COMMAND_DIRECT=${TEST_COMMAND_DIRECT}" >> $GITHUB_OUTPUT

export IMAGE_VERSION=$(grep version= Dockerfile | sed -e 's/.*version="\(.*\)".*/\1/')
echo "IMAGE_VERSION=${IMAGE_VERSION}" >> $GITHUB_ENV
echo "IMAGE_VERSION=${IMAGE_VERSION}" >> $GITHUB_OUTPUT
Expand Down

0 comments on commit 2c23f83

Please sign in to comment.