Skip to content

Commit

Permalink
Merge pull request #125 from crazy-max/container-logs-check
Browse files Browse the repository at this point in the history
test: use composite container-logs-check action
  • Loading branch information
crazy-max committed Jun 18, 2023
2 parents 50e07a1 + 5e68e9c commit b60ff63
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ on:
env:
BUILD_TAG: test
CONTAINER_NAME: nextcloud
RUNNING_TIMEOUT: 120
RUNNING_LOG_CHECK: ready to handle connections

jobs:
test:
Expand Down Expand Up @@ -66,26 +64,11 @@ jobs:
-e "DB_PASSWORD=asupersecretpassword" \
${{ env.BUILD_TAG }}
-
name: Test run
run: |
TIMEOUT=$((SECONDS + ${{ env.RUNNING_TIMEOUT }}))
while read LOGLINE; do
echo ${LOGLINE}
if [[ ${LOGLINE} == *"${{ env.RUNNING_LOG_CHECK }}"* ]]; then
echo "Container up!"
break
fi
if [[ $SECONDS -gt ${TIMEOUT} ]]; then
>&2 echo "Failed to run ${{ env.CONTAINER_NAME }} container"
exit 1
fi
done < <(docker logs -f ${{ env.CONTAINER_NAME }} 2>&1)
CONTAINER_STATUS=$(docker container inspect --format "{{.State.Status}}" ${{ env.CONTAINER_NAME }})
if [[ ${CONTAINER_STATUS} != "running" ]]; then
>&2 echo "Container ${{ env.CONTAINER_NAME }} returned status '$CONTAINER_STATUS'"
exit 1
fi
name: Check container logs
uses: crazy-max/.github/.github/actions/container-logs-check@main
with:
container_name: ${{ env.CONTAINER_NAME }}
log_check: "ready to handle connections"
-
name: Container logs
if: always()
Expand Down

0 comments on commit b60ff63

Please sign in to comment.