Skip to content
Snippets Groups Projects
Unverified Commit 7a829e05 authored by Guilherme Gazzo's avatar Guilherme Gazzo Committed by GitHub
Browse files

ci: create reporter (#29662)

parent e846d873
No related branches found
No related tags found
No related merge requests found
......@@ -56,6 +56,10 @@ on:
required: true
QASE_API_TOKEN:
required: false
REPORTER_ROCKETCHAT_URL:
required: false
REPORTER_ROCKETCHAT_API_KEY:
required: false
env:
MONGO_URL: mongodb://localhost:27017/rocketchat?replicaSet=rs0&directConnection=true
......@@ -243,6 +247,11 @@ jobs:
env:
E2E_COVERAGE: ${{ inputs.release == 'ee' && 'true' || '' }}
IS_EE: ${{ inputs.release == 'ee' && 'true' || '' }}
REPORTER_ROCKETCHAT_API_KEY: ${{ secrets.REPORTER_ROCKETCHAT_API_KEY }}
REPORTER_ROCKETCHAT_URL: ${{ secrets.REPORTER_ROCKETCHAT_URL }}
REPORTER_ROCKETCHAT_REPORT: ${{ github.ref == 'refs/heads/develop' && 'true' || '' }}
REPORTER_ROCKETCHAT_BRANCH: ${{ github.ref }}
REPORTER_ROCKETCHAT_DRAFT: ${{ github.event.pull_request.draft }}
QASE_API_TOKEN: ${{ secrets.QASE_API_TOKEN }}
QASE_REPORT: ${{ github.ref == 'refs/heads/develop' && 'true' || '' }}
working-directory: ./apps/meteor
......
......@@ -259,6 +259,8 @@ jobs:
CR_USER: ${{ secrets.CR_USER }}
CR_PAT: ${{ secrets.CR_PAT }}
QASE_API_TOKEN: ${{ secrets.QASE_API_TOKEN }}
REPORTER_ROCKETCHAT_API_KEY: ${{ secrets.REPORTER_ROCKETCHAT_API_KEY }}
REPORTER_ROCKETCHAT_URL: ${{ secrets.REPORTER_ROCKETCHAT_URL }}
test-api-ee:
name: 🔨 Test API (EE)
......@@ -307,6 +309,8 @@ jobs:
CR_USER: ${{ secrets.CR_USER }}
CR_PAT: ${{ secrets.CR_PAT }}
QASE_API_TOKEN: ${{ secrets.QASE_API_TOKEN }}
REPORTER_ROCKETCHAT_API_KEY: ${{ secrets.REPORTER_ROCKETCHAT_API_KEY }}
REPORTER_ROCKETCHAT_URL: ${{ secrets.REPORTER_ROCKETCHAT_URL }}
tests-done:
name: ✅ Tests Done
......
......@@ -22,7 +22,15 @@ export default {
outputDir: 'tests/e2e/.playwright',
reporter: [
['list'],
// process.env.CI ? ['github'] : ['list'],
process.env.REPORTER_ROCKETCHAT_REPORT === 'true' && [
'./reporters/rocketchat.ts',
{
url: process.env.REPORTER_ROCKETCHAT_URL,
apiKey: process.env.REPORTER_ROCKETCHAT_API_KEY,
branch: process.env.REPORTER_ROCKETCHAT_BRANCH,
draft: process.env.REPORTER_ROCKETCHAT_DRAFT === 'true',
},
],
[
'playwright-qase-reporter',
{
......@@ -36,7 +44,7 @@ export default {
environmentId: '1',
},
],
],
].filter(Boolean),
testDir: 'tests/e2e',
testIgnore: 'tests/e2e/federation/**',
workers: 1,
......
import fetch from 'node-fetch';
import type { Reporter, TestCase, TestResult } from '@playwright/test/reporter';
class RocketChatReporter implements Reporter {
private url: string;
private apiKey: string;
private branch: string;
private draft: boolean;
constructor(options: { url: string; apiKey: string; branch: string; draft: boolean }) {
this.url = options.url;
this.apiKey = options.apiKey;
this.branch = options.branch;
this.draft = options.draft;
}
onTestEnd(test: TestCase, result: TestResult) {
if (process.env.REPORTER_ROCKETCHAT_REPORT !== 'true') {
console.log('REPORTER_ROCKETCHAT_REPORT is not true, skipping', {
draft: this.draft,
branch: this.branch,
});
return;
}
const payload = {
name: test.title,
status: result.status,
duration: result.duration,
branch: this.branch,
draft: this.draft,
};
console.log(`Sending test result to Rocket.Chat: ${JSON.stringify(payload)}`);
return fetch(this.url, {
method: 'POST',
body: JSON.stringify(payload),
headers: {
'Content-Type': 'application/json',
'X-Api-Key': this.apiKey,
},
});
}
}
export default RocketChatReporter;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment