92 lines
3.2 KiB
YAML
92 lines
3.2 KiB
YAML
# This workflow is designed to test Zebra configuration files using Docker containers.
|
|
# - Runs a specified Docker image with the provided test variables and network settings.
|
|
# - Monitors and analyzes container logs for specific patterns to determine test success.
|
|
# - Provides flexibility in testing various configurations and networks by dynamically adjusting input parameters.
|
|
name: Test Zebra Config Files
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
# Status and logging
|
|
test_id:
|
|
required: true
|
|
type: string
|
|
description: 'Unique identifier for the test'
|
|
grep_patterns:
|
|
required: true
|
|
type: string
|
|
description: 'Patterns to grep for in the logs'
|
|
|
|
# Test selection and parameters
|
|
docker_image:
|
|
required: true
|
|
type: string
|
|
description: 'Docker image to test'
|
|
test_variables:
|
|
required: true
|
|
type: string
|
|
description: 'Environmental variables used to select and configure the test'
|
|
network:
|
|
required: false
|
|
type: string
|
|
default: Mainnet
|
|
description: 'Zcash network to test against'
|
|
|
|
jobs:
|
|
test-docker-config:
|
|
name: Test ${{ inputs.test_id }} in Docker
|
|
timeout-minutes: 30
|
|
runs-on: ubuntu-latest-m
|
|
steps:
|
|
- uses: actions/checkout@v4.1.6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Inject slug/short variables
|
|
uses: rlespinasse/github-slug-action@v4
|
|
with:
|
|
short-length: 7
|
|
|
|
- uses: r7kamura/rust-problem-matchers@v1.5.0
|
|
|
|
- name: Run ${{ inputs.test_id }} test
|
|
run: |
|
|
docker pull ${{ inputs.docker_image }}
|
|
docker run ${{ inputs.test_variables }} --detach --name ${{ inputs.test_id }} -t ${{ inputs.docker_image }} zebrad start
|
|
# Use a subshell to handle the broken pipe error gracefully
|
|
(
|
|
trap "" PIPE;
|
|
docker logs \
|
|
--tail all \
|
|
--follow \
|
|
${{ inputs.test_id }} | \
|
|
tee --output-error=exit /dev/stderr | \
|
|
grep --max-count=1 --extended-regexp --color=always \
|
|
${{ inputs.grep_patterns }}
|
|
) || true
|
|
LOGS_EXIT_STATUS=$?
|
|
|
|
docker stop ${{ inputs.test_id }}
|
|
|
|
EXIT_STATUS=$(docker wait ${{ inputs.test_id }} || echo "Error retrieving exit status");
|
|
echo "docker exit status: $EXIT_STATUS";
|
|
|
|
# If grep found the pattern, exit with the Docker container exit status
|
|
if [ $LOGS_EXIT_STATUS -eq 0 ]; then
|
|
# We can't diagnose or fix these errors, so we're just ignoring them for now.
|
|
# They don't actually impact the test because they happen after it succeeds.
|
|
# See ticket #7898 for details.
|
|
if [ $EXIT_STATUS -eq 137 ] || [ $EXIT_STATUS -eq 139 ]; then
|
|
echo "Warning: ignoring docker exit status $EXIT_STATUS";
|
|
exit 0;
|
|
else
|
|
exit $EXIT_STATUS;
|
|
fi
|
|
fi
|
|
|
|
# Handle other potential errors here
|
|
echo "An error occurred while processing the logs.";
|
|
exit 1;
|
|
env:
|
|
NETWORK: '${{ inputs.network }}'
|