80 lines
2.3 KiB
YAML
80 lines
2.3 KiB
YAML
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
|
|
steps:
|
|
- uses: actions/checkout@v4.1.1
|
|
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.4.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
|
|
exit $EXIT_STATUS;
|
|
fi
|
|
|
|
# Handle other potential errors here
|
|
echo "An error occurred while processing the logs.";
|
|
exit 1;
|
|
env:
|
|
NETWORK: '${{ inputs.network }}'
|