-
Notifications
You must be signed in to change notification settings - Fork 1
Repo Dispatch Setup
This guide explains how to implement repository dispatch to trigger integration tests in testviper when there are merges to the main branches of toolviper, xradio, graphviper, or astroviper.
The solution consists of:
- Dispatch Sender: Modified workflows in source repositories (toolviper, xradio, graphviper, astroviper)
- Dispatch Receiver: Modified workflow in testviper that listens for dispatch events
- Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
- Create a new token with the following permissions:
-
repo(Full control of private repositories) -
workflow(Update GitHub Action workflows)
-
- Copy the token value
For each source repository (toolviper, xradio, graphviper, astroviper):
- Go to repository Settings → Secrets and variables → Actions
- Add a new repository secret:
- Name:
TESTVIPER_DISPATCH_TOKEN - Value: The PAT created above
- Name:
For testviper repository:
- Go to repository Settings → Secrets and variables → Actions
- Add the same repository secret:
- Name:
TESTVIPER_DISPATCH_TOKEN - Value: The same PAT
- Name:
Replace or modify the existing python-testing-integration-template.yml in the nrao organization in GitHub, gh-actions-template-public workflows. Follow up with adding the
repository dispatch token to the source repository (toolviper, xradio, graphviper, astroviper) (TBC) to send the token across organizations. This might change in the near future after all projects move to the same nrao organization.
File path: .github/workflows/python-testing-integration-template.yml
Key features of the sender workflow:
- Runs existing tests as before
- Adds a new job
dispatch-integration-teststhat only runs on main branch pushes - Sends repository dispatch event to testviper with metadata about the triggering event
Replace or modify the existing python-tests-allure-report.yml in testviper repository with the dispatch receiver workflow.
File path: .github/workflows/python-tests-allure-report.yml
Key features of the receiver workflow:
- Listens for
repository_dispatchevents with typeintegration-test-trigger - Runs integration tests with Allure reporting
- Uploads Allure reports as artifacts
- Optionally deploys reports to GitHub Pages
- Sends status updates back to the source repository
To automatically publish Allure reports:
- Go to testviper repository Settings → Pages
- Set Source to "GitHub Actions"
- Reports will be available at:
https://casangi.github.io/testviper/allure-report/
- Developer pushes to main branch of toolviper, xradio, graphviper, or astroviper
- Source repository workflow runs and completes its tests
-
Dispatch event is sent to testviper with metadata:
{ "repository": "casangi/toolviper", "ref": "refs/heads/main", "sha": "abc123...", "actor": "developer-username", "workflow": "Python Integration Testing with Dispatch", "run_id": "123456789", "run_number": "42" } - testviper workflow is triggered automatically
- Integration tests run with Allure reporting
- Status is reported back to the source repository as a commit status
- Allure reports are generated and uploaded
The system responds to:
-
pushevents to main branch of source repositories -
repository_dispatchevents in testviper -
workflow_dispatchfor manual triggering -
schedulefor periodic integration tests (daily at 2 AM UTC)
- Trigger manually: Go to testviper → Actions → Select the workflow → "Run workflow"
- Test dispatch: Push a change to main branch of any source repository
- Check logs: Verify the dispatch event details appear in testviper workflow logs
- DISPATCH_TOKEN secret is set in all repositories
- Source repositories have updated workflows
- testviper has updated workflow
- GitHub Pages is configured (if using report deployment)
- Test push to source repository triggers testviper workflow
- Allure reports are generated and accessible
- Status checks appear on source repository commits
-
Dispatch not triggering:
- Check TESTVIPER_DISPATCH_TOKEN is valid and has correct permissions
- Verify the token is added to both source and target repositories
- Ensure workflow files are in the correct paths
- Check validity of token as it has a limited duration.
-
Tests failing:
- Check test dependencies are properly installed
- Verify test files exist in expected locations
- Review pytest configuration
-
Allure reports not generating:
- Ensure Java is installed (required for Allure CLI)
- Check allure-results directory is created
- Verify pytest-allure-adaptor is installed
-
Status checks not appearing:
- Confirm DISPATCH_TOKEN has repo permissions
- Check the notify-completion job is running
- Verify repository and SHA information in dispatch payload
The workflows include comprehensive logging:
- Dispatch event details are logged in testviper
- Client payload information is displayed
- Status updates include links back to test runs
To change when dispatch events are sent, modify the if condition in the dispatch job:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'Extend the client payload to include additional information:
client-payload: |
{
"repository": "${{ github.repository }}",
"custom_field": "custom_value"
}Modify the event type to categorize different dispatch sources:
event-type: integration-test-trigger-toolviper # for toolviper
event-type: integration-test-trigger-xradio # for xradio- The TESTVIPER_DISPATCH_TOKEN has significant permissions - store securely
- Consider using fine-grained PATs for better security
- Regularly rotate the token
- Monitor dispatch events for unexpected usage
- Ensure the token belongs to a service account rather than personal account
- Update Allure CLI version periodically in the receiver workflow
- Review and update Python versions in the matrix
- Monitor workflow run times and optimize as needed
- Update dependencies regularly for security patches