-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: test config file in CI and CD with a reusable workflow
- Loading branch information
1 parent
97e7a14
commit 43ae06e
Showing
3 changed files
with
148 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,122 +214,47 @@ jobs: | |
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: r7kamura/[email protected] | ||
|
||
- name: Inject slug/short variables | ||
uses: rlespinasse/github-slug-action@v4 | ||
- name: Test Zebra with default config file | ||
uses: ./.github/workflows/test-zebra-config-files.yml | ||
with: | ||
short-length: 7 | ||
|
||
- name: Run tests using the default config | ||
run: | | ||
docker pull ${{ vars.GAR_BASE }}/${{ vars.CI_IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} | ||
docker run -e NETWORK --detach --name default-conf-tests -t ${{ vars.GAR_BASE }}/${{ vars.CI_IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} zebrad start | ||
# Use a subshell to handle the broken pipe error gracefully | ||
( | ||
trap "" PIPE; | ||
docker logs \ | ||
--tail all \ | ||
--follow \ | ||
default-conf-tests | \ | ||
tee --output-error=exit /dev/stderr | \ | ||
grep --max-count=1 --extended-regexp --color=always \ | ||
-e "net.*=.*Main.*estimated progress to chain tip.*BeforeOverwinter" | ||
) || true | ||
LOGS_EXIT_STATUS=$? | ||
docker stop default-conf-tests | ||
EXIT_STATUS=$(docker wait default-conf-tests || echo "Error retrieving exit status"); | ||
echo "docker exit status: $EXIT_STATUS"; | ||
test_id: 'default-conf-tests' | ||
test_description: 'Test Zebra default Docker config file' | ||
grep_patterns: '-e "net.*=.*Main.*estimated progress to chain tip.*BeforeOverwinter"' | ||
test_variables: '-e NETWORK' | ||
network: 'Mainnet' | ||
|
||
# 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: Mainnet | ||
|
||
# Test reconfiguring the docker image for testnet. | ||
# Test reconfiguring the the docker image for tesnet. | ||
test-configuration-file-testnet: | ||
name: Test Zebra testnet Docker config file | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: r7kamura/[email protected] | ||
|
||
- name: Inject slug/short variables | ||
uses: rlespinasse/github-slug-action@v4 | ||
with: | ||
short-length: 7 | ||
|
||
# Make sure Zebra can sync the genesis block on testnet | ||
- name: Run tests using a testnet config | ||
run: | | ||
docker pull ${{ vars.GAR_BASE }}/${{ vars.CI_IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} | ||
docker run -e NETWORK -e ZEBRA_CONF_PATH -e ENTRYPOINT_FEATURES='' --detach --name testnet-conf-tests -t ${{ vars.GAR_BASE }}/${{ vars.CI_IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} zebrad start | ||
# Use a subshell to handle the broken pipe error gracefully | ||
( | ||
trap "" PIPE; | ||
docker logs \ | ||
--tail all \ | ||
--follow \ | ||
testnet-conf-tests | \ | ||
tee --output-error=exit /dev/stderr | \ | ||
grep --max-count=1 --extended-regexp --color=always \ | ||
-e "net.*=.*Test.*estimated progress to chain tip.*Genesis" \ | ||
-e "net.*=.*Test.*estimated progress to chain tip.*BeforeOverwinter"; | ||
) || true | ||
LOGS_EXIT_STATUS=$? | ||
docker stop testnet-conf-tests | ||
EXIT_STATUS=$(docker wait testnet-conf-tests || 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: | ||
ZEBRA_CONF_PATH: '/etc/zebrad/zebrad.toml' | ||
NETWORK: Testnet | ||
- name: Test Zebra with Testnet config file | ||
uses: ./.github/workflows/test-zebra-config-files.yml | ||
with: | ||
test_id: 'testnet-conf-tests' | ||
test_description: 'Test Zebra testnet Docker config file' | ||
grep_patterns: '-e "net.*=.*Test.*estimated progress to chain tip.*Genesis" -e "net.*=.*Test.*estimated progress to chain tip.*BeforeOverwinter"' | ||
test_variables: '-e NETWORK -e ZEBRA_CONF_PATH="/etc/zebrad/zebrad.toml"' | ||
network: 'Testnet' | ||
|
||
# Test that Zebra works using the $ZEBRA_CONF_PATH config | ||
# Test that Zebra works using $ZEBRA_CONF_PATH config | ||
test-zebra-conf-path: | ||
name: Test Zebra custom Docker config file | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: r7kamura/[email protected] | ||
|
||
- name: Inject slug/short variables | ||
uses: rlespinasse/github-slug-action@v4 | ||
- name: Test Zebra with $ZEBRA_CONF_PATH config file | ||
uses: ./.github/workflows/test-zebra-config-files.yml | ||
with: | ||
short-length: 7 | ||
|
||
- name: Run tests using the $ZEBRA_CONF_PATH | ||
run: | | ||
set -ex | ||
docker pull ${{ vars.GAR_BASE }}/${{ vars.CI_IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} | ||
docker run -e NETWORK --detach -e ZEBRA_CONF_PATH --name variable-conf-tests -t ${{ vars.GAR_BASE }}/${{ vars.CI_IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} zebrad start | ||
EXIT_STATUS=$(docker logs --tail all --follow variable-conf-tests 2>&1 | grep -q --extended-regexp --max-count=1 -e 'v1.0.0-rc.2.toml'; echo $?; ) | ||
docker stop variable-conf-tests | ||
docker logs variable-conf-tests | ||
exit "$EXIT_STATUS" | ||
env: | ||
ZEBRA_CONF_PATH: 'zebrad/tests/common/configs/v1.0.0-rc.2.toml' | ||
NETWORK: ${{ inputs.network || vars.ZCASH_NETWORK }} | ||
test_id: 'variable-conf-tests' | ||
test_description: 'Test Zebra custom Docker config file' | ||
grep_patterns: '-e "v1.0.0-rc.2.toml"' | ||
test_variables: '-e NETWORK -e ZEBRA_CONF_PATH="zebrad/tests/common/configs/v1.0.0-rc.2.toml"' | ||
network: ${{ inputs.network || vars.ZCASH_NETWORK }} | ||
|
||
failure-issue: | ||
name: Open or update issues for main branch failures | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Test Zebra Config Files | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
# Status and logging | ||
test_id: | ||
required: true | ||
type: string | ||
description: 'Unique identifier for the test' | ||
test_description: | ||
required: true | ||
type: string | ||
description: 'Explains what the test does' | ||
grep_patterns: | ||
required: true | ||
type: string | ||
description: 'Patterns to grep for in the logs' | ||
|
||
# Test selection and parameters | ||
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-zebra-config: | ||
name: Test Zebra Docker Config | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: r7kamura/[email protected] | ||
|
||
- name: Inject slug/short variables | ||
uses: rlespinasse/github-slug-action@v4 | ||
with: | ||
short-length: 7 | ||
|
||
- name: Run ${{ inputs.test_id }} config test | ||
run: | | ||
Check warning on line 45 in .github/workflows/sub-test-zebra-config.yml GitHub Actions / actionlint[actionlint] .github/workflows/sub-test-zebra-config.yml#L45
Raw output
|
||
docker pull ${{ vars.GAR_BASE }}/${{ vars.CI_IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} | ||
docker run ${{ inputs.test_variables }} --detach --name ${{ inputs.test_id }} -t ${{ vars.GAR_BASE }}/${{ vars.CI_IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} 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 }}' |