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

fix reporting variables in the community report #7997

Merged
merged 34 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e67270a
feat: Refactor e2e detox workflows for simplicity
toninis Jun 5, 2024
46f2b88
fix: Missed outputs job name
toninis Jun 7, 2024
66d8e3f
fix: Generate S3 path once per run
toninis Jun 7, 2024
a0f405b
fix reporting variables in the community report
yasserfaraazkhan Jun 7, 2024
3f55c77
fix lint
yasserfaraazkhan Jun 7, 2024
8108448
fix lint
yasserfaraazkhan Jun 7, 2024
c9db15e
fix lint
yasserfaraazkhan Jun 7, 2024
f865f27
Merge remote-tracking branch 'origin/main' into fix/cmt-report
yasserfaraazkhan Jun 10, 2024
75edd3a
add zephyr reporting
yasserfaraazkhan Jun 10, 2024
bee2f17
spelling
yasserfaraazkhan Jun 10, 2024
b59fd7f
lint
yasserfaraazkhan Jun 10, 2024
ef0eb44
Update .github/workflows/e2e-detox-scheduled.yml
yasserfaraazkhan Jun 11, 2024
fee4ffa
Update .github/workflows/e2e-detox-template.yml
yasserfaraazkhan Jun 11, 2024
cb0e802
test if Username & Password secrets are working
yasserfaraazkhan Jun 11, 2024
4b33514
run time device override
yasserfaraazkhan Jun 11, 2024
9b2412a
set default device to iphone 14
yasserfaraazkhan Jun 11, 2024
0d92287
fix env reference
yasserfaraazkhan Jun 12, 2024
7a2cd90
Merge remote-tracking branch 'origin/main' into fix/cmt-report
yasserfaraazkhan Jun 12, 2024
6685ae6
test urls
yasserfaraazkhan Jun 14, 2024
4e8290e
new servers
yasserfaraazkhan Jun 14, 2024
cf39b01
testing new server
yasserfaraazkhan Jun 14, 2024
ad1a8d1
fix branch reference
yasserfaraazkhan Jun 14, 2024
2c6998b
remove console statements, test for different device and OS
yasserfaraazkhan Jun 20, 2024
c4b62ce
fix detox config to pick device
yasserfaraazkhan Jun 20, 2024
6baa04d
fix eslint
yasserfaraazkhan Jun 20, 2024
1da1c11
fix lint
yasserfaraazkhan Jun 20, 2024
fb36b56
Merge branch 'main' into fix/cmt-report
mattermost-build Jun 21, 2024
38308b9
Merge branch 'fix/cmt-report' of https://github.com/mattermost/matter…
yasserfaraazkhan Jun 21, 2024
7835408
update package.json
yasserfaraazkhan Jun 21, 2024
79f1284
macos-12
yasserfaraazkhan Jun 21, 2024
e6d0ccd
final fixes
yasserfaraazkhan Jun 21, 2024
8a5b664
final fixes
yasserfaraazkhan Jun 21, 2024
a2da904
final fixes
yasserfaraazkhan Jun 21, 2024
1170827
fix review comments
yasserfaraazkhan Jun 26, 2024
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
1 change: 0 additions & 1 deletion .github/workflows/compatibility-matrix-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ jobs:
secrets: inherit
with:
run-ios-tests: true
run-android-tests: false
run-type: "RELEASE"
MM_TEST_SERVER_URL: ${{ matrix.server.url }}
MOBILE_VERSION: ${{ inputs.MOBILE_VERSION }}
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/e2e-detox-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ jobs:
- build-ios-simulator
with:
run-ios-tests: true
run-android-tests: false
run-type: "PR"
MOBILE_VERSION: ${{ github.event.pull_request.head.sha }}
secrets: inherit
Expand Down Expand Up @@ -99,11 +98,3 @@ jobs:
});
}

if (labels.includes(androidLabel)) {
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: androidLabel,
});
}
2 changes: 1 addition & 1 deletion .github/workflows/e2e-detox-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ jobs:
- build-ios-simulator
with:
run-ios-tests: true
run-android-tests: false
run-type: "RELEASE"
record_tests_in_zephyr: 'true'
MOBILE_VERSION: ${{ github.ref }}
secrets: inherit

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-detox-scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Detox E2E Tests (Scheduled)

on:
schedule:
- cron: "0 0 * * *" # every day at midnight
- cron: "0 0 * * 4,5" # Wednesday and Thursday midnight

jobs:
update-initial-status:
Expand Down Expand Up @@ -51,8 +51,8 @@ jobs:
- build-ios-simulator
with:
run-ios-tests: true
run-android-tests: false
run-type: "MAIN"
record_tests_in_zephyr: 'true'
MOBILE_VERSION: ${{ github.ref }}
secrets: inherit

Expand Down
66 changes: 37 additions & 29 deletions .github/workflows/e2e-detox-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ on:
description: "Run iOS tests"
required: true
type: boolean
run-android-tests:
description: "Run Android tests"
required: true
type: boolean
run-type:
type: string
required: false
Expand All @@ -37,6 +33,21 @@ on:
required: false
type: boolean
default: false
record_tests_in_zephyr:
description: "Record test results in Zephyr, typically for nightly and release runs"
required: false
type: string
default: 'false'
ios_device_name:
description: "iPhone simulator name"
required: false
type: string
default: "iPhone 14"
ios_device_os_name:
description: "iPhone simulator OS version"
required: false
type: string
default: "iOS 17.0"
outputs:
STATUS:
value: ${{ jobs.generate-report.outputs.STATUS }}
Expand All @@ -48,16 +59,20 @@ on:
env:
AWS_REGION: "us-east-1"
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 }}
ADMIN_USERNAME: ${{ secrets.MM_MOBILE_E2E_ADMIN_USERNAME }}
ADMIN_PASSWORD: ${{ secrets.MM_MOBILE_E2E_ADMIN_PASSWORD }}
# BRANCH: ${{ github.head_ref || github.ref_name }}
# COMMIT_HASH: ${{ github.sha }}
DEVICE_NAME: ${{ inputs.ios_device_name }}
DEVICE_OS_VERSION: ${{ inputs.ios_device_os_name }}
DETOX_AWS_S3_BUCKET: "mattermost-detox-report"
HEADLESS: "true"
TYPE: ${{ inputs.run-type }}
PULL_REQUEST: "https://github.com/mattermost/mattermost-mobile/pull/${{ github.event.number }}"
SITE_1_URL: ${{ inputs.MM_TEST_SERVER_URL || secrets.MM_MOBILE_E2E_SITE_1_URL }}
SITE_2_URL: ${{ secrets.MM_MOBILE_E2E_SITE_2_URL }}
SITE_3_URL: ${{ secrets.MM_MOBILE_E2E_SITE_3_URL }}
ZEPHYR_ENABLE: false
SITE_1_URL: ${{ inputs.MM_TEST_SERVER_URL || 'https://mobile-e2e-site-1.test.mattermost.cloud' }}
SITE_2_URL: "https://mobile-e2e-site-2.test.mattermost.cloud"
SITE_3_URL: "https://mobile-e2e-site-3.test.mattermost.cloud"
ZEPHYR_ENABLE: ${{ inputs.record_tests_in_zephyr }}
JIRA_PROJECT_KEY: "MM"
ZEPHYR_API_KEY: ${{ secrets.MM_MOBILE_E2E_ZEPHYR_API_KEY }}
ZEPHYR_FOLDER_ID: "3233873"
Expand All @@ -68,12 +83,10 @@ env:
jobs:
generate-specs:
runs-on: ubuntu-22.04
if: ${{ inputs.run-ios-tests || inputs.run-android-tests }}
if: ${{ inputs.run-ios-tests }}
outputs:
specs: ${{ steps.generate-specs.outputs.specs }}
build_id: ${{ steps.resolve-device.outputs.BUILD_ID }}
device_name: ${{ steps.resolve-device.outputs.DEVICE_NAME }}
device_os_version: ${{ steps.resolve-device.outputs.DEVICE_OS_VERSION }}
mobile_sha: ${{ steps.resolve-device.outputs.MOBILE_SHA }}
mobile_ref: ${{ steps.resolve-device.outputs.MOBILE_REF }}
workflow_hash: ${{ steps.resolve-device.outputs.WORKFLOW_HASH }}
Expand All @@ -86,18 +99,13 @@ jobs:
- name: Set Build ID
id: resolve-device
run: |
cd detox
DEVICE_NAME=$(node -p "require('./.detoxrc').devices['ios.simulator'].device.type")
DEVICE_OS_VERSION=$(node -p "require('./.detoxrc').devices['ios.simulator'].device.os")
BUILD_ID="${{ github.run_id }}-${{ env.DEVICE_NAME }}-${{ env.DEVICE_OS_VERSION}}"
WORKFLOW_HASH=$(tr -dc a-z0-9 </dev/urandom | head -c 10)
BUILD_ID="${{ github.run_id }}-${DEVICE_NAME}-${DEVICE_OS_VERSION}-${WORKFLOW_HASH}"

## We need that hash to separate the artifacts
echo "WORKFLOW_HASH=${WORKFLOW_HASH}" >> ${GITHUB_OUTPUT}

echo "BUILD_ID=$(echo ${BUILD_ID} | sed 's/ /_/g')" >> ${GITHUB_OUTPUT}
echo "DEVICE_NAME=${DEVICE_NAME}" >> ${GITHUB_OUTPUT}
echo "DEVICE_OS_VERSION=${DEVICE_OS_VERSION}" >> ${GITHUB_OUTPUT}
echo "MOBILE_SHA=$(git rev-parse HEAD)" >> ${GITHUB_OUTPUT}
echo "MOBILE_REF=$(git rev-parse --abbrev-ref HEAD)" >> ${GITHUB_OUTPUT}

Expand All @@ -107,8 +115,8 @@ jobs:
with:
parallelism: 10
search_path: detox/e2e/test
device_name: ${{ steps.resolve-device.outputs.DEVICE_NAME }}
device_os_version: ${{ steps.resolve-device.outputs.DEVICE_OS_VERSION }}
device_name: ${{ env.DEVICE_NAME }}
device_os_version: ${{ env.DEVICE_OS_VERSION }}

e2e-ios:
name: ios-detox-e2e-${{ matrix.runId }}-${{ matrix.deviceName }}-${{ matrix.deviceOsVersion }}
Expand Down Expand Up @@ -154,7 +162,13 @@ jobs:

- name: Run Detox E2E Tests
continue-on-error: true # Label might have been removed manually
run: cd detox && npm run e2e:ios-test -- ${{ matrix.specs }}
run: |
cd detox
npm run detox:config-gen
npm run e2e:ios-test -- ${{ matrix.specs }}
env:
DETOX_DEVICE_TYPE: ${{ env.DEVICE_NAME }}
DETOX_OS_VERSION: ${{ env.DEVICE_OS_VERSION }}

- name: Upload iOS Test Report
if: always()
Expand All @@ -165,7 +179,7 @@ jobs:

generate-report:
runs-on: ubuntu-22.04
if: ${{ inputs.run-ios-tests || inputs.run-android-tests }}
if: ${{ inputs.run-ios-tests}}
needs:
- generate-specs
- e2e-ios
Expand Down Expand Up @@ -205,8 +219,6 @@ jobs:
DETOX_AWS_SECRET_ACCESS_KEY: ${{ secrets.MM_MOBILE_DETOX_AWS_SECRET_ACCESS_KEY }}
IOS: ${{ inputs.run-ios-tests }}
BUILD_ID: ${{ needs.generate-specs.outputs.build_id }}
DEVICE_NAME: ${{ needs.generate-specs.outputs.device_name }}
DEVICE_OS_VERSION: ${{ needs.generate-specs.outputs.device_os_version }}
REPORT_PATH: ${{ steps.s3.outputs.path }}
## These are needed for the MM Webhook report
COMMIT_HASH: ${{ needs.generate-specs.outputs.mobile_sha }}
Expand All @@ -225,11 +237,7 @@ jobs:
- name: Set Target URL
id: set-url
run: |
if ${{ inputs.run-ios-tests }}; then
echo "TARGET_URL=https://${{ env.DETOX_AWS_S3_BUCKET }}.s3.amazonaws.com/${{ steps.s3.outputs.path }}/jest-stare/ios-report.html" >> ${GITHUB_OUTPUT}
else
echo "TARGET_URL=https://${{ env.DETOX_AWS_S3_BUCKET }}.s3.amazonaws.com/${{ steps.s3.outputs.path }}/jest-stare/android-report.html" >> ${GITHUB_OUTPUT}
fi

- name: Determine Status
id: determine-status
Expand Down
4 changes: 2 additions & 2 deletions detox/.detoxrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"ios.simulator": {
"type": "ios.simulator",
"device": {
"type": "iPhone 15 Pro",
"os": "iOS 17.4"
"type": "__DEVICE_TYPE__",
"os": "__DEVICE_OS__"
}
},
"android.emulator": {
Expand Down
2 changes: 1 addition & 1 deletion detox/e2e/support/server_api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const getCookiesFromConfig = (config: AxiosRequestConfig<any>) => {
export const getResponseFromError = (err: any) => {
const {response} = err;
if (!response) {
const message = `No response from server at "${err.config.baseURL}".
const message = `No response from server at "${err}".
If testing against a server other than the default local instance, you may set the server URL via "SITE_URL" environment variable.
`;

Expand Down
1 change: 1 addition & 0 deletions detox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"e2e:ios-test": "IOS=true detox test -c ios.sim.debug",
"e2e:ios-build-release": "detox build -c ios.sim.release",
"e2e:ios-test-release": "IOS=true detox test -c ios.sim.release --record-logs failing --take-screenshots failing",
"detox:config-gen": "cd utils && node generate_detox_config_ci.js",
"check": "npm run lint && npm run tsc",
"clean-detox": "detox clean",
"lint": "eslint --ignore-pattern node_modules --quiet .",
Expand Down
15 changes: 7 additions & 8 deletions detox/save_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -100,7 +99,7 @@ const saveReport = async () => {
// Merge all XML reports into one single XML report
const platform = process.env.IOS === 'true' ? 'ios' : 'android';
const combinedFilePath = `${ARTIFACTS_DIR}/${platform}-combined.xml`;
await mergeFiles(path.join(__dirname, combinedFilePath), [`${ARTIFACTS_DIR}/ios-results*/${platform}-junit*.xml`]);
await mergeFiles(path.join(__dirname, combinedFilePath), [`${ARTIFACTS_DIR}/${platform}-results*/${platform}-junit*.xml`]);
console.log(`Merged, check ${combinedFilePath}`);

// Read XML from a file
Expand All @@ -120,27 +119,27 @@ const saveReport = async () => {
fs.mkdirSync(jestStareOutputDir, {recursive: true});
}

// 'ios-results-*' is the path in CI where the parallel detox jobs save artifacts
await mergeJestStareJsonFiles(jestStareCombinedFilePath, [`${ARTIFACTS_DIR}/ios-results*/jest-stare/${platform}-data*.json`]);
// "ios-results-*" or "android-results-*" is the path in CI where the parallel detox jobs save the artifacts
await mergeJestStareJsonFiles(jestStareCombinedFilePath, [`${ARTIFACTS_DIR}/${platform}-results*/jest-stare/${platform}-data*.json`]);
generateJestStareHtmlReport(jestStareOutputDir, `${platform}-report.html`, jestStareCombinedFilePath);

if (process.env.CI) {
// Delete folders starting with "iOS-results-" only in CI environment
// Delete folders starting with "ios-results-" or "android-results-" only in CI environment
const entries = fs.readdirSync(ARTIFACTS_DIR, {withFileTypes: true});
for (const entry of entries) {
if (entry.isDirectory() && entry.name.startsWith('ios-results-')) {
if (entry.isDirectory() && entry.name.startsWith(`${platform}-results-`)) {
fs.rmSync(path.join(ARTIFACTS_DIR, entry.name), {recursive: true});
}
}
}
const result = await saveArtifacts(REPORT_PATH);
const result = await saveArtifacts();
if (result && result.success) {
console.log('Successfully uploaded artifacts to S3:', result.reportLink);
}

// Create or use an existing test cycle
let testCycle = {};
if (ZEPHYR_ENABLE === 'true') {
if (ZEPHYR_ENABLE === true) {
const {start, end} = summary.stats;
testCycle = ZEPHYR_CYCLE_KEY ? {key: ZEPHYR_CYCLE_KEY} : await createTestCycle(start, end);
}
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
14 changes: 14 additions & 0 deletions detox/utils/generate_detox_config_ci.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

/* eslint-disable no-process-env */
/* eslint-disable no-console */
const fs = require('fs');
const deviceType = process.env.DETOX_DEVICE_TYPE || 'iPhone 15 Pro';
const deviceOS = process.env.DETOX_DEVICE_OS || 'iOS 17.4';
const detoxConfigTemplate = fs.readFileSync('../.detoxrc.json', 'utf8');
const detoxConfig = detoxConfigTemplate.replace('__DEVICE_TYPE__', deviceType).replace('__DEVICE_OS__', deviceOS);

fs.writeFileSync('../.detoxrc.json', detoxConfig);

console.log('Detox configuration generated successfully');
4 changes: 2 additions & 2 deletions detox/utils/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ function generateTestReport(summary, isUploadedToS3, reportLink, environment, te
function generateTitle() {
const {
BRANCH,
DETOX_AWS_S3_BUCKET,
COMMIT_HASH,
DETOX_AWS_S3_BUCKET,
IOS,
PULL_REQUEST,
RELEASE_BUILD_NUMBER,
Expand All @@ -324,7 +324,7 @@ function generateTitle() {
const appExtension = IOS === 'true' ? 'ipa' : 'apk';
const appFileName = `Mattermost_Beta.${appExtension}`;
const appBuildType = 'mattermost-mobile-beta';
const s3Folder = `${platform.toLocaleLowerCase()}/${REPORT_PATH}`.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
Loading