Skip to content

Commit

Permalink
Add baseURL env
Browse files Browse the repository at this point in the history
  • Loading branch information
ltthienn committed Sep 11, 2023
1 parent e86f030 commit 1801ff9
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 85 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ jobs:
env:
DISPLAY: :0.0

- name: Create env file
run: |
touch .env
echo ENV=${ENV} > .env
echo CYPRESS_BASE_URL='http://127.0.0.1:4173/' > .env
- name: Run Cypress Test
run: |+
#!/bin/bash
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
echo ENV=${ENV} > .env
echo GITHUB_RUN_ID=${GITHUB_RUN_ID} > .env
echo CORE_PUSH_GATEWAY_URL=${{ secrets.CORE_PUSH_GATEWAY_URL }} > .env
echo CYPRESS_BASE_URL='https://kyberswap.com/' > .env
- name: Run Cypress Test
run: |+
Expand Down
173 changes: 88 additions & 85 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,117 +24,120 @@ 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 suite = new client.Counter({
name: `${prefix}_suite`,
help: `${prefix}_suite`,
labelNames: ['buildId', 'result', 'baseName', 'duration', 'chain'] as const,
})
suite.reset()
const { totalPassed, totalFailed, totalTests, totalDuration, runs } = results
runs.forEach(run => {
const { stats, spec } = run
const { tests, passes, pending, failures, duration } = stats
const { baseName } = spec
suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'failed',
baseName: baseName,
duration: duration,
chain: config.env.NETWORK,
})
.inc(failures)
if (process.env.CYPRESS_BASE_URL === 'https://kyberswap.com/') {
on('after:run', async results => {
if (results) {
const register = new client.Registry()
const prefix = 'e2e_cypress'
const suite = new client.Counter({
name: `${prefix}_suite`,
help: `${prefix}_suite`,
labelNames: ['buildId', 'result', 'baseName', 'duration', 'chain'] as const,
})
suite.reset()
const { totalPassed, totalFailed, totalTests, totalDuration, runs } = results
runs.forEach(run => {
const { stats, spec } = run
const { tests, passes, pending, failures, duration } = stats
const { baseName } = spec
suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'failed',
baseName: baseName,
duration: duration,
chain: config.env.NETWORK,
})
.inc(failures)

suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'passed',
baseName: baseName,
duration: duration,
chain: config.env.NETWORK,
})
.inc(passes)

suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'pending',
baseName: baseName,
duration: duration,
chain: config.env.NETWORK,
})
.inc(pending)
suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'tests',
baseName: baseName,
duration: duration,
chain: config.env.NETWORK,
})
.inc(tests)
})

suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'passed',
baseName: baseName,
duration: duration,
baseName: 'All Specs',
duration: totalDuration,
chain: config.env.NETWORK,
})
.inc(passes)
.inc(totalPassed)

suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'pending',
baseName: baseName,
duration: duration,
result: 'failed',
baseName: 'All Specs',
duration: totalDuration,
chain: config.env.NETWORK,
})
.inc(pending)
.inc(totalFailed)
suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'tests',
baseName: baseName,
duration: duration,
result: 'total',
baseName: 'All Specs',
duration: totalDuration,
chain: config.env.NETWORK,
})
.inc(tests)
})
.inc(totalTests)

suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'passed',
baseName: 'All Specs',
duration: totalDuration,
chain: config.env.NETWORK,
const testPass = new client.Counter({
name: `${prefix}_test_passed`,
help: `${prefix}_pass`,
labelNames: ['buildId', 'chain'] as const,
})
.inc(totalPassed)

suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'failed',
baseName: 'All Specs',
duration: totalDuration,
chain: config.env.NETWORK,
const testFail = new client.Counter({
name: `${prefix}_test_failed`,
help: `${prefix}_fail`,
labelNames: ['buildId', 'chain'] as const,
})
.inc(totalFailed)
suite
.labels({
buildId: `${process.env.GITHUB_RUN_ID}`,
result: 'total',
baseName: 'All Specs',
duration: totalDuration,
chain: config.env.NETWORK,
})
.inc(totalTests)

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

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

testPass.reset()
testFail.reset()
testPass.reset()
testFail.reset()

testFail.labels({ buildId: `${process.env.GITHUB_RUN_ID}`, chain: config.env.NETWORK }).inc(totalFailed)
testPass.labels({ buildId: `${process.env.GITHUB_RUN_ID}`, chain: config.env.NETWORK }).inc(totalPassed)
testFail.labels({ buildId: `${process.env.GITHUB_RUN_ID}`, chain: config.env.NETWORK }).inc(totalFailed)
testPass.labels({ buildId: `${process.env.GITHUB_RUN_ID}`, chain: config.env.NETWORK }).inc(totalPassed)

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

const gateway = new client.Pushgateway(`${process.env.CORE_PUSH_GATEWAY_URL}`, [], register)
await gateway.push({ jobName: 'ui-automation' })
}
})
const gateway = new client.Pushgateway(`${process.env.CORE_PUSH_GATEWAY_URL}`, [], register)
await gateway.push({ jobName: 'ui-automation' })
}
})
}
},
specPattern: 'cypress/e2e/specs/*.e2e.cy.ts',
baseUrl: process.env.CYPRESS_BASE_URL,
specPattern: 'cypress/e2e/specs/farm-page.e2e.cy.ts',
},
})

0 comments on commit 1801ff9

Please sign in to comment.