Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QA-52] - Push results to Grafana #2224

Merged
merged 25 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions .github/workflows/schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
network: ['Ethereum', 'Arbitrum','Optimism', 'Avalanche', 'BNB']
network: ['Ethereum', 'Arbitrum', 'Optimism', 'Avalanche', 'BNB']
steps:
- name: Trigger Code Checkout
uses: actions/checkout@v3
Expand All @@ -30,9 +30,9 @@ jobs:

- name: Install linux deps
run: |
sudo apt-get install --no-install-recommends -y \
fluxbox \
xvfb
sudo apt-get install --no-install-recommends -y \
fluxbox \
xvfb

- name: Install cypress
run: yarn cypress install --force
Expand All @@ -43,31 +43,26 @@ jobs:
env:
DISPLAY: :0.0

- name: Create env file
run: |
touch .env
echo ENV=${ENV} > .env
echo GITHUB_RUN_ID=${GITHUB_RUN_ID} > .env
echo CORE_PUSH_GATEWAY_URL=${{ secrets.CORE_PUSH_GATEWAY_URL }} > .env

- name: Run Cypress Test
run: |+
#!/bin/bash
yarn test-schedule -e grepTags=regression,NETWORK=${{ matrix.network }}
env:
DISPLAY: :0.0

- name: Notify on failure
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANEL: automation-test-bot
SLACK_COLOR: ${{ job.status }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://icon-library.com/images/star-wars-icon-png/star-wars-icon-png-16.jpg?size=48
SLACK_TITLE: E2E Test ${{inputs.BASE_URL}}
SLACK_USERNAME: autoBot
SLACK_LINK_NAMES: true
DISPLAY: :0.0

- name: Archive e2e artifacts
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8
if: always()
with:
name: e2e-artifacts
path: |
cypress/videos
cypress/screenshots
name: e2e-artifacts
path: |
cypress/videos
cypress/screenshots
continue-on-error: true
58 changes: 57 additions & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import synpressPlugins from '@synthetixio/synpress/plugins'
import { defineConfig } from 'cypress'
import client from 'prom-client'

require('dotenv').config()

export default defineConfig({
projectId: '4x4jf8',
component: {
devServer: {
framework: 'create-react-app',
Expand All @@ -22,6 +24,60 @@ export default defineConfig({
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('@cypress/grep/src/plugin')(config)
synpressPlugins(on, config)
on('after:run', async results => {
if (results) {
const register = new client.Registry()
const prefix = 'e2e_cypress'

const { totalPassed, totalFailed, totalTests } = results

const suite = new client.Counter({
name: `${prefix}_suite`,
help: `${prefix}_suite`,
labelNames: ['buildId', 'status', 'duration'] as const,
})

const testPass = new client.Counter({
name: `${prefix}_test_passed`,
help: `${prefix}_pass`,
labelNames: ['buildId'] as const,
})

const testFail = new client.Counter({
name: `${prefix}_test_failed`,
help: `${prefix}_fail`,
labelNames: ['buildId'] as const,
})

testPass.reset()
testFail.reset()

register.registerMetric(testPass)
register.registerMetric(testFail)
register.registerMetric(suite)

testFail.labels({ buildId: `${process.env.GITHUB_RUN_ID}` }).inc(totalFailed)
testPass.labels({ buildId: `${process.env.GITHUB_RUN_ID}` }).inc(totalPassed)
suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
})
.inc(totalTests)

const gateway = new client.Pushgateway(`${process.env.CORE_PUSH_GATEWAY_URL}`, [], register)

console.log('gateway: ', gateway)
await gateway
.push({ jobName: 'ui-automation' })
.then(({ resp, body }) => {
console.log(`Body: ${body}`)
console.log(`Response status: ${resp}`)
})
.catch((err: any) => {
console.log('err: ', err)
})
}
})
},
specPattern: 'cypress/e2e/specs/*.e2e.cy.ts',
},
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"polished": "^3.7.2",
"postinstall-postinstall": "^2.1.0",
"process": "^0.11.10",
"prom-client": "^14.2.0",
ltthienn marked this conversation as resolved.
Show resolved Hide resolved
"react": "^18.2.0",
"react-date-picker": "^9.1.0",
"react-device-detect": "^1.17.0",
Expand Down Expand Up @@ -149,7 +150,7 @@
"@cypress/grep": "^3.1.5",
"@lingui/cli": "~3.14.0",
"@lingui/vite-plugin": "~3.16.1",
"@synthetixio/synpress": "^3.7.0",
"@synthetixio/synpress": "^3.7.2-beta.7",
"@trivago/prettier-plugin-sort-imports": "^3.3.1",
"@types/aos": "^3.0.4",
"@types/big.js": "^6.0.0",
Expand Down Expand Up @@ -205,4 +206,4 @@
"@lingui/core": "3.14.0",
"@lingui/conf": "3.16.0"
}
}
}
Loading
Loading