-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QA 2857 changed yml, updated few steps in testPages
- Loading branch information
Showing
5 changed files
with
165 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,8 @@ on: | |
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
repository_dispatch: | ||
types: [ deploy_success ] | ||
schedule: | ||
- cron: '0 0 * * 0' | ||
|
||
workflow_dispatch: | ||
inputs: | ||
|
@@ -20,37 +20,32 @@ on: | |
type: choice | ||
options: | ||
- staging | ||
|
||
- production | ||
|
||
concurrency: | ||
group: tests-on-formplayer-${{ github.ref }} | ||
group: lookup-table-tests-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
set_matrix: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix-deploy.outputs.matrix || steps.set-matrix-manual.outputs.matrix || steps.set-matrix-default.outputs.matrix }} | ||
matrix: ${{ steps.set-matrix-manual.outputs.matrix || steps.set-matrix-default.outputs.matrix }} | ||
steps: | ||
- id: set-matrix-deploy | ||
if: ${{ github.event_name == 'repository_dispatch' }} | ||
run: | | ||
echo "::set-output name=matrix::{\"environment\": [\"${{ github.event.client_payload.environment }}\"]}" | ||
- id: set-matrix-manual | ||
if: ${{ github.event_name == 'workflow_dispatch' }} | ||
run: | | ||
echo "::set-output name=matrix::{\"environment\": [\"${{ inputs.environment }}\"]}" | ||
- id: set-matrix-default | ||
if: ${{ !contains(github.event_name , 'dispatch') }} | ||
run: | | ||
echo "::set-output name=matrix::{\"environment\": [\"staging\"]}" | ||
echo "::set-output name=matrix::{\"environment\": [\"production\", \"staging\"]}" | ||
build: | ||
needs: set_matrix | ||
strategy: | ||
fail-fast: false | ||
matrix: ${{ fromJSON(needs.set_matrix.outputs.matrix) }} | ||
name: Formplayer on '${{ matrix.environment }}' | ||
name: Lookup tests on '${{ matrix.environment }}' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
@@ -63,24 +58,21 @@ jobs: | |
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r Formplayer/requires.txt | ||
- name: Formplayer Test with pytest | ||
- name: Lookup table tests with pytest | ||
env: | ||
DIMAGIQA_ENV: ${{ matrix.environment }} #${{ secrets.DIMAGIQA_URL }} | ||
DIMAGIQA_ENV: ${{ matrix.environment }} | ||
DIMAGIQA_LOGIN_USERNAME: ${{ secrets.DIMAGIQA_LOGIN_USERNAME }} | ||
DIMAGIQA_LOGIN_PASSWORD: ${{ secrets.DIMAGIQA_LOGIN_PASSWORD }} | ||
DIMAGIQA_MAIL_USERNAME: ${{ secrets.DIMAGIQA_MAIL_USERNAME }} | ||
DIMAGIQA_MAIL_PASSWORD: ${{ secrets.DIMAGIQA_MAIL_PASSWORD }} | ||
DIMAGIQA_STAGING_AUTH_KEY: ${{ secrets.DIMAGIQA_STAGING_AUTH_KEY }} | ||
DIMAGIQA_PROD_AUTH_KEY: ${{ secrets.DIMAGIQA_PROD_AUTH_KEY }} | ||
|
||
run: | | ||
echo "client_payload: ${{ toJson(github.event.client_payload) }}" | ||
echo "matrix environment: ${{ matrix.environment }}" | ||
echo "NOW=$(date +'%m-%d %H:%M')" >> $GITHUB_ENV | ||
echo ${{env.NOW}} | ||
pytest -v --rootdir= Formplayer/testCases -n auto --dist=loadfile --html=report_${{ matrix.environment }}.html | ||
pytest -v --rootdir= Formplayer/testCases -n 3 --dist=loadfile --reruns 1 --html=formplayer_${{ matrix.environment }}.html | ||
- name: Set email vars | ||
if: ${{ success() || failure() }} | ||
id: configure_email | ||
|
@@ -91,39 +83,34 @@ jobs: | |
with: | ||
script: | | ||
const { promises: fs } = require('fs') | ||
const {JOB_STATUS, NOW, CC_ENV, GITHUB_HEAD_REF} = process.env | ||
const prefix = `[${CC_ENV}] Formplayer Tests - ${JOB_STATUS.toUpperCase()} - Run #${context.runNumber}` | ||
const prefix = `[${CC_ENV}] Lookuptable Tests - ${JOB_STATUS.toUpperCase()} - Run #${context.runNumber}` | ||
const suffix = `at ${NOW}` | ||
let subject = `${prefix} on branch "${GITHUB_HEAD_REF}" ${suffix}` | ||
let subject = `${prefix} on "deploy_success" ${suffix}` | ||
if (context.eventName !== "repository_dispatch") { | ||
subject = `${prefix} on branch "${GITHUB_HEAD_REF}" ${suffix}` | ||
} | ||
let bodyFile = './Formplayer/email_pass.md' | ||
let bodyFile = './common_utilities/mail_templates/email_pass.md' | ||
if (JOB_STATUS !== 'success') { | ||
bodyFile = './Formplayer/email_fail.md' | ||
bodyFile = './common_utilities/mail_templates/email_fail.md' | ||
} | ||
let actionRunLink = context.payload.repository.html_url + `/actions/runs/${context.runId}` | ||
let testSuite = 'Formplayer Regression' | ||
let bodyContent = await fs.readFile(bodyFile, 'utf8') | ||
bodyContent = bodyContent.replace(/{{actionRunLink}}/g, actionRunLink) | ||
.replace(/{{runNumber}}/g, context.runNumber) | ||
.replace(/{{environment}}/g, CC_ENV) | ||
.replace(/{{testSuite}}/g, testSuite) | ||
let receivers = '[email protected]' | ||
if (context.eventName !== "pull_request" || context.eventName !== "push") { | ||
receivers = 'qa@dimagi.com, sameena.shaik@fissionlabs.com' | ||
receivers = 'kbordoloi@dimagi.com' | ||
} | ||
return { | ||
"subject": subject, | ||
"body": bodyContent, | ||
"reference": Math.random().toString(36).substr(2), // used to prevent threading of similar emails | ||
"receivers": receivers | ||
} | ||
- name: Send Result Email | ||
if: ${{ success() || failure() }} | ||
uses: dawidd6/action-send-mail@v3 | ||
|
@@ -137,13 +124,126 @@ jobs: | |
from: <${{secrets.DIMAGIQA_MAIL_USERNAME}}> | ||
html_body: ${{ fromJSON(steps.configure_email.outputs.result).body }} | ||
convert_markdown: true | ||
attachments: ${{ github.workspace }}/report_${{ matrix.environment }}.html | ||
attachments: ${{ github.workspace }}/formplayer_${{ matrix.environment }}.html | ||
in_reply_to: ${{ fromJSON(steps.configure_email.outputs.result).reference }} | ||
|
||
- name: Post to Slack channel on Failure | ||
id: slack_fail | ||
uses: slackapi/[email protected] | ||
if: failure() | ||
with: | ||
payload: | | ||
{ | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": " Hey Folks!! :bye_boo: \n*${{ github.workflow }}* were just triggered!" | ||
} | ||
}, | ||
{ | ||
"type": "context", | ||
"elements": [ | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*Environment: *\n ${{ matrix.environment }} \n" | ||
}, | ||
{ | ||
"type": "mrkdwn", | ||
"text": " " | ||
}, | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*Status: *\n ${{ job.status }} :x:" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "Here's the corresponding workflow execution :arrow_right::arrow_right:" | ||
}, | ||
"accessory": { | ||
"type": "button", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "View on Github", | ||
"emoji": true | ||
}, | ||
"value": "click_me_123", | ||
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", | ||
"action_id": "button-action", | ||
"style": "danger" | ||
} | ||
} | ||
] | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_FEATURES }} | ||
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | ||
|
||
- name: Post to Slack channel on Success | ||
id: slack_pass | ||
uses: slackapi/[email protected] | ||
if: success() | ||
with: | ||
payload: | | ||
{ | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": " Hey Folks!! :bye_boo: \n*${{ github.workflow }}* were just triggered!" | ||
} | ||
}, | ||
{ | ||
"type": "context", | ||
"elements": [ | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*Environment: *\n ${{ matrix.environment }} \n" | ||
}, | ||
{ | ||
"type": "mrkdwn", | ||
"text": " " | ||
}, | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*Status: *\n ${{ job.status }} :white_check_mark:" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "Here's the corresponding workflow execution :arrow_right::arrow_right:" | ||
}, | ||
"accessory": { | ||
"type": "button", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "View on Github", | ||
"emoji": true | ||
}, | ||
"value": "click_me_123", | ||
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", | ||
"action_id": "button-action", | ||
"style": "primary" | ||
} | ||
} | ||
] | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_FEATURES }} | ||
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | ||
|
||
- name: Archive test results | ||
if: ${{ success() || failure() }} | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: test-result-reports-${{ matrix.environment }} | ||
path: ${{ github.workspace }}/report_${{ matrix.environment }}.html | ||
retention-days: 2 | ||
path: ${{ github.workspace }}/formplayer_${{ matrix.environment }}.html |
Oops, something went wrong.