testrail-api-tests #975
This file contains hidden or 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
| 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 }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| 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/slack-github-action@v2.1.1 | |
| with: | |
| webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| webhook-type: incoming-webhook | |
| payload: | | |
| { | |
| "text": "TestRail API tests failed!", | |
| "attachments": [ | |
| { | |
| "color": "danger", | |
| "blocks": [ | |
| { | |
| "type": "header", | |
| "text": { | |
| "type": "plain_text", | |
| "text": "TestRail API Tests Failed", | |
| "emoji": true | |
| } | |
| }, | |
| { | |
| "type": "section", | |
| "fields": [ | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Workflow:*\n${{ github.workflow }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Job:*\n${{ github.job }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Status:*\n${{ job.status }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Test Results:*\nFailed" | |
| } | |
| ] | |
| }, | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Results>" | |
| } | |
| } | |
| ] | |
| } | |
| ] | |
| } |