Skip to content

testrail-api-tests #209

testrail-api-tests

testrail-api-tests #209

name: testrail-api-tests
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *" # Run every day at midnight
push:
paths:
- "testrail/**" # Run on changes to testrail directory
pull_request:
paths:
- "testrail/**" # Run on changes to testrail directory
jobs:
test:
name: Run unit tests
runs-on: ubuntu-latest
env:
TESTRAIL_HOST: ${{ secrets.TESTRAIL_HOST }}
TESTRAIL_USERNAME: ${{ secrets.TESTRAIL_USERNAME }}
TESTRAIL_PASSWORD: ${{ secrets.TESTRAIL_PASSWORD }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_TEST_ALERTS_SANDBOX }}
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Set up Python
uses: actions/[email protected]
with:
python-version: 3.11
- name: Install dependencies
run: |
pip install -r testrail/requirements.txt
- name: Run tests
run: |
python -m unittest discover -s testrail/tests -p '*tests.py'
- name: Send Slack message on test failure
if: ${{ failure() }}
id: slack-failure
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_MOBILE_ALERTS_SANDBOX_CHANNEL }}
payload: |
{
"type": "mrkdwn",
"text": "TestRail API tests failed! :tada:\n\n*Workflow:* ${{ github.workflow }}\n*Job:* ${{ github.job }}\n\n*Status:* ${{ job.status }}\n*Test results:* Failed\n\nLink to results: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View results>"
}
- name: Send Slack message on test success
if: ${{ success() }}
id: slack-success
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_MOBILE_ALERTS_SANDBOX_CHANNEL }}
payload: |
{
"type": "mrkdwn",
"text": "TestRail API tests passed! :tada:\n\n*Workflow:* ${{ github.workflow }}\n*Job:* ${{ github.job }}\n\n*Status:* ${{ job.status }}\n*Test results:* Passed\n\nLink to results: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View results>"
}