Skip to content

Commit

Permalink
fix reporting variables in the community report
Browse files Browse the repository at this point in the history
  • Loading branch information
yasserfaraazkhan committed Jun 7, 2024
1 parent 66d8e3f commit a0f405b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/e2e-detox-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ env:
ADMIN_EMAIL: ${{ secrets.MM_MOBILE_E2E_ADMIN_EMAIL }}
ADMIN_USERNAME: ${{ inputs.MM_TEST_USER_NAME || secrets.MM_MOBILE_E2E_ADMIN_USERNAME }}
ADMIN_PASSWORD: ${{ inputs.MM_TEST_PASSWORD || secrets.MM_MOBILE_E2E_ADMIN_PASSWORD }}
BRANCH: ${{ github.head_ref || github.ref_name }}
COMMIT_HASH: ${{ github.sha }}
DETOX_AWS_S3_BUCKET: "mattermost-detox-report"
HEADLESS: "true"
TYPE: ${{ inputs.run-type }}
Expand Down
13 changes: 6 additions & 7 deletions detox/save_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ const os = require('os');
const path = require('path');

const fse = require('fs-extra');
const { mergeFiles } = require('junit-report-merger');
const {mergeFiles} = require('junit-report-merger');
const shell = require('shelljs');

const { saveArtifacts } = require('./utils/artifacts');
const { ARTIFACTS_DIR } = require('./utils/constants');
const {saveArtifacts} = require('./utils/artifacts');
const {ARTIFACTS_DIR} = require('./utils/constants');
const {
generateJestStareHtmlReport,
mergeJestStareJsonFiles,
Expand All @@ -55,7 +55,7 @@ const {
readJsonFromFile,
writeJsonToFile,
} = require('./utils/report');
const { createTestCycle, createTestExecutions } = require('./utils/test_cases');
const {createTestCycle, createTestExecutions} = require('./utils/test_cases');

require('dotenv').config();

Expand All @@ -69,7 +69,6 @@ const saveReport = async () => {
WEBHOOK_URL,
ZEPHYR_ENABLE,
ZEPHYR_CYCLE_KEY,
REPORT_PATH,
} = process.env;

// Remove old generated reports
Expand Down Expand Up @@ -105,7 +104,7 @@ const saveReport = async () => {

// Read XML from a file
const xml = fse.readFileSync(combinedFilePath);
const { testsuites } = convertXmlToJson(xml);
const {testsuites} = convertXmlToJson(xml);

// Generate short summary, write to file and then send report via webhook
const allTests = getAllTests(testsuites);
Expand Down Expand Up @@ -133,7 +132,7 @@ const saveReport = async () => {
}
}
}
const result = await saveArtifacts(REPORT_PATH);
const result = await saveArtifacts();
if (result && result.success) {
console.log('Successfully uploaded artifacts to S3:', result.reportLink);
}
Expand Down
7 changes: 4 additions & 3 deletions detox/utils/artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const {
DETOX_AWS_ACCESS_KEY_ID,
DETOX_AWS_SECRET_ACCESS_KEY,
IOS,
REPORT_PATH,
} = process.env;
const platform = IOS === 'true' ? 'ios' : 'android';

Expand All @@ -35,7 +36,7 @@ function getFiles(dirPath) {
return fs.existsSync(dirPath) ? readdir(dirPath) : [];
}

async function saveArtifacts(s3Folder) {
async function saveArtifacts() {
if (!DETOX_AWS_S3_BUCKET || !DETOX_AWS_ACCESS_KEY_ID || !DETOX_AWS_SECRET_ACCESS_KEY) {
console.log('No AWS credentials found. Test artifacts not uploaded to S3.');

Expand All @@ -50,7 +51,7 @@ async function saveArtifacts(s3Folder) {
filesToUpload,
10,
async.asyncify(async (file) => {
const Key = file.replace(uploadPath, s3Folder);
const Key = file.replace(uploadPath, REPORT_PATH);
const contentType = mime.lookup(file);
const charset = mime.charset(contentType);

Expand All @@ -76,7 +77,7 @@ async function saveArtifacts(s3Folder) {
return reject(new Error(err));
}

const reportLink = `https://${DETOX_AWS_S3_BUCKET}.s3.amazonaws.com/${s3Folder}/jest-stare/${platform}-report.html`;
const reportLink = `https://${DETOX_AWS_S3_BUCKET}.s3.amazonaws.com/${REPORT_PATH}/jest-stare/${platform}-report.html`;
resolve({ success: true, reportLink });
},
);
Expand Down
3 changes: 2 additions & 1 deletion detox/utils/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,15 @@ function generateTitle() {
RELEASE_DATE,
RELEASE_VERSION,
TYPE,
REPORT_PATH
} = process.env;

const platform = IOS === 'true' ? 'iOS' : 'Android';
const lane = `${platform} Build`;
const appExtension = IOS === 'true' ? 'ipa' : 'apk';
const appFileName = `Mattermost_Beta.${appExtension}`;
const appBuildType = 'mattermost-mobile-beta';
const s3Folder = `${platform.toLocaleLowerCase()}/${BUILD_ID}-${COMMIT_HASH}-${BRANCH}`.replace(/\./g, '-');
const s3Folder = `${platform.toLocaleLowerCase()}/${REPORT_PATH}`;
const appFilePath = IOS === 'true' ? 'Mattermost-simulator-x86_64.app.zip' : 'android/app/build/outputs/apk/release/app-release.apk';
let buildLink = '';
let releaseDate = '';
Expand Down

0 comments on commit a0f405b

Please sign in to comment.