Skip to content

Commit

Permalink
ci_runs
Browse files Browse the repository at this point in the history
  • Loading branch information
tauqirsarwar1 committed Mar 22, 2024
1 parent 36cf3ae commit e0229ef
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 149 deletions.
266 changes: 133 additions & 133 deletions .github/workflows/api_workflow.yml
Original file line number Diff line number Diff line change
@@ -1,140 +1,140 @@
name: API Workflow

env:
TAGS: "api"
BROWSERSTACK_USER: ${{secrets.BROWSERSTACK_API_USERNAME}}
BROWSERSTACK_ACCESS_KEY: ${{secrets.BROWSERSTACK_ACCESS_KEY}}
TAGS: "api"
BROWSERSTACK_USER: ${{secrets.BROWSERSTACK_API_USERNAME}}
BROWSERSTACK_ACCESS_KEY: ${{secrets.BROWSERSTACK_ACCESS_KEY}}

on:
schedule:
- cron: '0 21 * * *'
workflow_dispatch:
inputs:
tags:
description: 'Tags'
required: true
default: 'api'
schedule:
- cron: '0 21 * * *'
workflow_dispatch:
inputs:
tags:
description: 'Tags'
required: true
default: 'api'

jobs:
run-api-test-schedule:
if: github.event_name == 'schedule'
name: API Regression
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.9'

- name: Check out code
uses: actions/checkout@v4

- name: Setup dependencies
run: |
sh setup_install.sh
- name: Run tests
run: |
if [ "${{ github.event.inputs.tags }}" != "" ]
then
TAGS="${{ github.event.inputs.tags }}"
fi
source $HOME/.bp-venv/bin/activate
sh local_run_api.sh "$TAGS" "${{secrets.SLACK_WEBHOOK_URL}}" "${{secrets.TEAMS_WEBHOOK_URL}}"
- name: Get Allure history
uses: actions/checkout@v4
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages

- name: Allure Report
uses: simple-elf/[email protected]
if: always()
with:
gh_pages: gh-pages
allure_results: allure-results
allure_history: allure-history

- name: Deploy report to Github Pages
if: always()
uses: peaceiris/actions-gh-pages@v3
with:
PERSONAL_TOKEN: ${{ secrets.PYTEST_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: allure-history

- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
name: pytest-results
path: |
./*.html
./output/
./assets/
if: ${{ always() }}

run-api-test-on-local:
if: github.event_name != 'schedule'
name: API Regression
runs-on: ubuntu-latest
steps:

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.9'

- name: Check out code
uses: actions/checkout@v4

- name: Setup dependencies
run: |
sh setup_install.sh
- name: Run tests
run: |
if [ "${{ github.event.inputs.tags }}" != "" ]
then
TAGS="${{ github.event.inputs.tags }}"
fi
source $HOME/.bp-venv/bin/activate
sh local_run_api.sh "$TAGS" "${{secrets.SLACK_WEBHOOK_URL}}" "${{secrets.TEAMS_WEBHOOK_URL}}"
- name: Get Allure history
uses: actions/checkout@v4
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages

- name: Allure Report
uses: simple-elf/[email protected]
if: always()
with:
gh_pages: gh-pages
allure_results: allure-results
allure_history: allure-history

- name: Deploy report to Github Pages
if: always()
uses: peaceiris/actions-gh-pages@v3
with:
PERSONAL_TOKEN: ${{ secrets.PYTEST_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: allure-history

- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
name: pytest-results
path: |
./*.html
./output/
./assets/
if: ${{ always() }}
run-api-test-schedule:
if: github.event_name == 'schedule'
name: API Regression
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.9'

- name: Check out code
uses: actions/checkout@v4

- name: Setup dependencies
run: |
sh setup_install.sh
- name: Run tests
run: |
if [ "${{ github.event.inputs.tags }}" != "" ]
then
TAGS="${{ github.event.inputs.tags }}"
fi
source $HOME/.bp-venv/bin/activate
sh ci_run_api.sh "$TAGS" "${{secrets.SLACK_WEBHOOK_URL}}" "${{secrets.TEAMS_WEBHOOK_URL}}"
- name: Get Allure history
uses: actions/checkout@v4
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages

- name: Allure Report
uses: simple-elf/[email protected]
if: always()
with:
gh_pages: gh-pages
allure_results: allure-results
allure_history: allure-history

- name: Deploy report to Github Pages
if: always()
uses: peaceiris/actions-gh-pages@v3
with:
PERSONAL_TOKEN: ${{ secrets.PYTEST_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: allure-history

- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
name: pytest-results
path: |
./*.html
./output/
./assets/
if: ${{ always() }}

run-api-test-on-local:
if: github.event_name != 'schedule'
name: API Regression
runs-on: ubuntu-latest
steps:

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.9'

- name: Check out code
uses: actions/checkout@v4

- name: Setup dependencies
run: |
sh setup_install.sh
- name: Run tests
run: |
if [ "${{ github.event.inputs.tags }}" != "" ]
then
TAGS="${{ github.event.inputs.tags }}"
fi
source $HOME/.bp-venv/bin/activate
sh ci_run_api.sh "$TAGS" "${{secrets.SLACK_WEBHOOK_URL}}" "${{secrets.TEAMS_WEBHOOK_URL}}"
- name: Get Allure history
uses: actions/checkout@v4
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages

- name: Allure Report
uses: simple-elf/[email protected]
if: always()
with:
gh_pages: gh-pages
allure_results: allure-results
allure_history: allure-history

- name: Deploy report to Github Pages
if: always()
uses: peaceiris/actions-gh-pages@v3
with:
PERSONAL_TOKEN: ${{ secrets.PYTEST_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: allure-history

- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
name: pytest-results
path: |
./*.html
./output/
./assets/
if: ${{ always() }}
66 changes: 50 additions & 16 deletions .github/workflows/ui_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,8 @@ jobs:
- name: Run All Tests
run: |
env
source $HOME/.bp-venv/bin/activate
python -m pytest -v --driver Remote --selenium-host '${{secrets.BROWSERSTACK_API_USERNAME}}:${{secrets.BROWSERSTACK_ACCESS_KEY}}@hub-cloud.browserstack.com' \
--variables ${{ matrix.config_file }} --tags="${{ matrix.tags }}" \
--base-url="${{ matrix.baseurl }}" \
--capability headless False \
--reruns 1 --reruns-delay 5 \
--html=report.html \
--self-contained-html -n ${{ matrix.concurrent_thread }} \
source $HOME/.bp-venv/bin/activate
sh ci_run_web.sh ${{secrets.BROWSERSTACK_API_USERNAME}} ${{secrets.BROWSERSTACK_ACCESS_KEY}} "${{ matrix.config_file }}" "$TAGS" "${{secrets.SLACK_WEBHOOK_URL}}" "${{secrets.TEAMS_WEBHOOK_URL}}" "$BASE_URL" $concurrent_thread
# --pytest-testrail-export-test-results \
# --testrail-project-id "${{ env.TESTRAIL_PROJECT_ID }}" \
# --pytest-testrail-test-plan-id "${{ env.TEST_PLAN_ID }}" \
Expand All @@ -183,6 +176,29 @@ jobs:
with:
local-testing: stop
if: ${{ always() }}
- name: Get Allure history
uses: actions/checkout@v4
if: always()
continue-on-error: true
with:
ref: gh-pages-1
path: gh-pages-1

- name: Allure Report
uses: simple-elf/[email protected]
if: always()
with:
gh_pages: gh-pages-1
allure_results: allure-results
allure_history: allure-history

- name: Deploy report to Github Pages
if: always()
uses: peaceiris/actions-gh-pages@v3
with:
PERSONAL_TOKEN: ${{ secrets.PYTEST_TOKEN }}
PUBLISH_BRANCH: gh-pages-1
PUBLISH_DIR: allure-history

- name: Upload HTML run report in the Artifacts Folder
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -302,20 +318,38 @@ jobs:
env
source $HOME/.bp-venv/bin/activate
python -m pytest -v --driver Remote \
--selenium-host '${{secrets.BROWSERSTACK_API_USERNAME}}:${{secrets.BROWSERSTACK_ACCESS_KEY}}@hub-cloud.browserstack.com' \
--variables "$BROWSER" \
--capability headless False \
--reruns 1 --reruns-delay 5 \
--tags="$TAGS" --base-url="$BASE_URL" --html=report.html \
--self-contained-html -n $concurrent_thread
sh ci_run_web.sh ${{secrets.BROWSERSTACK_API_USERNAME}} ${{secrets.BROWSERSTACK_ACCESS_KEY}} "$BROWSER" "$TAGS" "${{secrets.SLACK_WEBHOOK_URL}}" "${{secrets.TEAMS_WEBHOOK_URL}}" "$BASE_URL" $concurrent_thread
- name: BrowserStackLocal Stop
uses: browserstack/github-actions/setup-local@master
with:
local-testing: stop
if: ${{ always() }}

- name: Get Allure history
uses: actions/checkout@v4
if: always()
continue-on-error: true
with:
ref: gh-pages-1
path: gh-pages-1

- name: Allure Report
uses: simple-elf/[email protected]
if: always()
with:
gh_pages: gh-pages-1
allure_results: allure-results
allure_history: allure-history

- name: Deploy report to Github Pages
if: always()
uses: peaceiris/actions-gh-pages@v3
with:
PERSONAL_TOKEN: ${{ secrets.PYTEST_TOKEN }}
PUBLISH_BRANCH: gh-pages-1
PUBLISH_DIR: allure-history

- name: Upload HTML run report in the Artifacts Folder
uses: actions/upload-artifact@v4
with:
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions ci_run_web.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# Run Web tests
python -m pytest -v -s --gherkin-terminal-reporter --driver=Remote --selenium-host $1':'$2'@hub-cloud.browserstack.com' --variables=$3 --html="./output/reports/" \
--tags=$4 --reruns 1 --reruns-delay 2 --self-contained-html --capability headless False --slack-webhook-url=$5 --slack-channel=pytest-test-automation \
--slack-results-url=https://tweag.github.io/pytest-automation-boilerplate --teams-webhook-url=$6 \
--teams-results-url=https://tweag.github.io/pytest-automation-boilerplate --base-url=$7 -n=$8

0 comments on commit e0229ef

Please sign in to comment.