Skip to content

@Desktop • Test App (external) triggered by Sheng-Long on ref forked/fd6792eb0a9041df17da7ff544b1cad5a365a0a9 #212

@Desktop • Test App (external) triggered by Sheng-Long on ref forked/fd6792eb0a9041df17da7ff544b1cad5a365a0a9

@Desktop • Test App (external) triggered by Sheng-Long on ref forked/fd6792eb0a9041df17da7ff544b1cad5a365a0a9 #212

name: "@Desktop • Test App (external)"
run-name: "@Desktop • Test App (external) triggered by ${{ inputs.login }} ${{ format('on ref {0}', github.ref_name) }}"
on:
workflow_dispatch:
inputs:
ref:
description: the branch which triggered this workflow
required: false
login:
description: The GitHub username that triggered the workflow
required: true
base_ref:
description: The base branch to merge the head into when checking out the code
required: false
draft:
description: true if the PR is in draft
required: false
default: "false"
concurrency:
# See: https://github.com/orgs/community/discussions/35341
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref_name != 'develop' }}
jobs:
# typecheck:
# name: "Ledger Live Desktop TypeCheck"
# env:
# NODE_OPTIONS: "--max-old-space-size=7168"
# FORCE_COLOR: 3
# CI_OS: ubuntu-latest
# runs-on: ubuntu-latest
# steps:
# - uses: LedgerHQ/ledger-live/tools/actions/composites/checkout-merge@develop
# with:
# ref: ${{ github.ref_name }}
# base: ${{ inputs.base_ref }}
# - uses: ./tools/actions/composites/setup-test-desktop
# id: setup-test-desktop
# with:
# skip_builds: true
# - name: lint
# run: pnpm desktop lint
# - name: prettier
# run: pnpm desktop prettier:check
# - name: typecheck
# run: pnpm desktop typecheck
unit-tests:
name: "Ledger Live Desktop Unit Tests"
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
CI_OS: ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: LedgerHQ/ledger-live/tools/actions/composites/checkout-merge@develop
with:
ref: ${{ github.ref_name }}
base: ${{ inputs.base_ref }}
- uses: ./tools/actions/composites/setup-test-desktop
id: setup-test-desktop
with:
skip_builds: true
- name: Run unit tests
run: pnpm desktop test:jest
e2e-tests-linux:
name: "Live Desktop Tests (Ubuntu)"
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
CI_OS: ubuntu-latest
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
# DEBUG: "pw:browser*"
# DEBUG_LOGS: 1
runs-on: ubuntu-latest
outputs:
status: ${{ steps.tests.outcome }}
steps:
- uses: LedgerHQ/ledger-live/tools/actions/composites/checkout-merge@develop
with:
ref: ${{ github.ref_name }}
base: ${{ inputs.base_ref }}
- uses: ./tools/actions/composites/setup-test-desktop
id: setup-test-desktop
with:
skip_python: true
skip_ruby: true
install_playwright: true
- name: Run playwright tests [Linux => xvfb-run]
id: tests
run: |
if [[ "${{ inputs.draft }}" == true ]]; then
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- pnpm desktop test:playwright
else
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- pnpm desktop test:playwright
fi
- name: upload diffs to imgur
if: always() && !cancelled()
uses: ./tools/actions/upload-images
id: imgur
with:
path: apps/ledger-live-desktop/tests/artifacts/test-results
workspace: ${{ github.workspace }}
os: linux
- name: upload ci suggested screenshots
if: always() && !cancelled()
uses: actions/upload-artifact@v3
with:
name: images
path: images-linux.json
- name: Upload playwright test results [On Failure]
uses: actions/upload-artifact@v3
if: failure() && !cancelled()
with:
name: playwright-results-linux
path: |
apps/ledger-live-desktop/tests/artifacts/test-results
apps/ledger-live-desktop/tests/artifacts/html-report
apps/ledger-live-desktop/tests/artifacts/coverage
apps/ledger-live-desktop/tests/artifacts/videos
apps/ledger-live-desktop/tests/artifacts/logs
- name: Upload Allure Report
if: always()
uses: actions/upload-artifact@v3
with:
name: allure-results-linux
path: apps/ledger-live-desktop/allure-results
e2e-tests-mac:
name: "Live Desktop Tests (macOS X)"
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
CI_OS: macos-latest
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
# DEBUG: "pw:browser*"
# DEBUG_LOGS: 1
runs-on: macos-latest
outputs:
status: ${{ steps.tests.outcome }}
steps:
- uses: LedgerHQ/ledger-live/tools/actions/composites/checkout-merge@develop
with:
ref: ${{ github.ref_name }}
base: ${{ inputs.base_ref }}
- uses: ./tools/actions/composites/setup-test-desktop
id: setup-test-desktop
with:
skip_python: true
skip_ruby: true
install_playwright: true
- name: Run playwright tests
id: tests
run: |
if [[ "${{ inputs.draft }}" == true ]]; then
pnpm desktop test:playwright
else
pnpm desktop test:playwright
fi
- name: upload diffs to imgur
if: always() && !cancelled()
uses: ./tools/actions/upload-images
id: imgur
with:
path: apps/ledger-live-desktop/tests/artifacts/test-results
workspace: ${{ github.workspace }}
os: macos
- name: upload ci suggested screenshots
if: always() && !cancelled()
uses: actions/upload-artifact@v3
with:
name: images
path: images-macos.json
- name: Upload playwright test results [On Failure]
uses: actions/upload-artifact@v3
if: failure() && !cancelled()
with:
name: playwright-results-macos
path: |
apps/ledger-live-desktop/tests/artifacts/test-results
apps/ledger-live-desktop/tests/artifacts/html-report
apps/ledger-live-desktop/tests/artifacts/coverage
apps/ledger-live-desktop/tests/artifacts/videos
apps/ledger-live-desktop/tests/artifacts/logs
- name: Upload Allure Report
if: always()
uses: actions/upload-artifact@v3
with:
name: allure-results-macos
path: apps/ledger-live-desktop/allure-results
e2e-tests-windows:
name: "Live Desktop Tests (Windows)"
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
CI_OS: windows-latest
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
# DEBUG: "pw:browser*"
# DEBUG_LOGS: 1
runs-on: windows-latest
outputs:
status: ${{ steps.tests.outcome }}
steps:
- uses: LedgerHQ/ledger-live/tools/actions/composites/checkout-merge@develop
with:
ref: ${{ github.ref_name }}
base: ${{ inputs.base_ref }}
- uses: ./tools/actions/composites/setup-test-desktop
id: setup-test-desktop
with:
install_node_gyp: true
install_playwright: true
upgrade_npm: true
- name: Run playwright tests
id: tests
run: |
if [[ "${{ inputs.draft }}" == true ]]; then
pnpm desktop test:playwright
else
pnpm desktop test:playwright
fi
shell: bash
- name: upload diffs to imgur
if: always() && !cancelled()
uses: ./tools/actions/upload-images
id: imgur
with:
path: apps/ledger-live-desktop/tests/artifacts/test-results
workspace: ${{ github.workspace }}
os: windows
- name: upload ci suggested screenshots
if: always() && !cancelled()
uses: actions/upload-artifact@v3
with:
name: images
path: images-windows.json
- name: Upload playwright test results [On Failure]
uses: actions/upload-artifact@v3
if: failure() && !cancelled()
with:
name: playwright-results-windows
path: |
apps/ledger-live-desktop/tests/artifacts/test-results
apps/ledger-live-desktop/tests/artifacts/html-report
apps/ledger-live-desktop/tests/artifacts/coverage
apps/ledger-live-desktop/tests/artifacts/videos
apps/ledger-live-desktop/tests/artifacts/logs
- name: Upload Allure Report
if: always()
uses: actions/upload-artifact@v3
with:
name: allure-results-windows
path: apps/ledger-live-desktop/allure-results
report:
needs: [
# typecheck,
unit-tests,
e2e-tests-linux,
e2e-tests-mac,
e2e-tests-windows,
]
runs-on: ubuntu-latest
if: always() && !cancelled() && github.event_name == 'workflow_dispatch'
steps:
- uses: LedgerHQ/ledger-live/tools/actions/composites/checkout-merge@develop
with:
ref: ${{ github.ref_name }}
base: ${{ inputs.base_ref }}
- name: download images artifacts
uses: actions/download-artifact@v3
with:
name: images
- name: parse images
uses: actions/github-script@v6
with:
script: |
const fs = require("fs");
const files = ["images-linux", "images-windows", "images-macos"];
let result = {};
for (const file of files) {
try {
const raw = JSON.parse(fs.readFileSync("${{github.workspace}}/" + file + ".json"));
const key = file.replace("images-", "").replace("-latest", "").trim()
result[key] = raw;
} catch (err) {
console.log(err);
}
}
fs.writeFileSync("./images.json", JSON.stringify(result, null, 2));
- name: prepare comment with screenshots
id: comment
uses: ./tools/actions/prepare-comment-screenshots
with:
images: images.json
no-actor: true
- uses: actions/github-script@v6
name: prepare status
id: status
with:
script: |
const fs = require("fs");
const [ owner, repo ] = "${{ github.repository }}".split("/");
const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRunAttempt, {
owner,
repo,
run_id: "${{ github.run_id }}",
attempt_number: "${{ github.run_attempt }}",
});
const findJobUrl = os =>
jobs.find(job => job.name == `Live Desktop Tests (${os})`)?.html_url;
const keys = {
mac: {
symbol: "🍏",
name: "macOS",
jobUrl: findJobUrl("macOS X")
},
windows: {
symbol: "🪟",
name: "Windows",
jobUrl: findJobUrl("Windows")
},
linux: {
symbol: "🐧",
name: "Linux",
jobUrl: findJobUrl("Ubuntu")
},
};
/*
const typecheck = {
pass: ${{ needs.typecheck.result == 'success' }},
status: "${{ needs.typecheck.result }}",
};
*/
const unitTests = {
pass: ${{ needs.unit-tests.result == 'success' }},
status: "${{ needs.unit-tests.result }}",
};
const report = {
mac: {
pass: ${{ needs.e2e-tests-mac.outputs.status == 'success' }},
status: "${{ needs.e2e-tests-mac.outputs.status }}",
},
linux: {
pass: ${{ needs.e2e-tests-linux.outputs.status == 'success' }},
status: "${{ needs.e2e-tests-linux.outputs.status }}",
},
windows: {
pass: ${{ needs.e2e-tests-windows.outputs.status == 'success' }},
status: "${{ needs.e2e-tests-windows.outputs.status }}",
},
};
let summary = `### TypeCheck
DISABLED (ts migration in progress)
### Unit Tests (Jest)
${unitTests.pass ? "Unit tests are fine" : "Unit tests did not pass"}
- ${unitTests.pass ? "✅" : "❌"} **Unit tests** ended with status \`${unitTests.status}\`
### Screenshot Tests (Playwright)
`
summary += `|`
const reportKeys = Object.keys(report);
reportKeys.forEach((k) => {
summary += ` [${keys[k].symbol} ${keys[k].name}](${keys[k].jobUrl}) |`;
});
summary += `
|`;
for (let i = 0; i < reportKeys.length; i++) {
summary += ` :--: |`;
}
summary += `
|`;
Object.entries(report).forEach(([os, values]) => {
summary += ` ${values.pass ? "✅" : "❌"} (${values.status}) |`;
});
summary += `
${{ steps.comment.outputs.body }}
`
const output = {
summary,
actions: [{
// 20 chars max
label: "Regen. Screenshots",
// 20 chars max
identifier: "regen_screenshots",
// 40 chars max
description: "Will regenerate playwright screenshots",
}],
};
fs.writeFileSync("summary.json", JSON.stringify(output), "utf-8");
- uses: actions/upload-artifact@v3
name: upload summary
with:
name: summary.json
path: ${{ github.workspace }}/summary.json
allure-report:
name: "Allure Reports Export on Server"
needs: [e2e-tests-windows, e2e-tests-linux, e2e-tests-mac]
runs-on: [ledger-live-medium-linux]
if: ${{ always() && !cancelled() && github.ref_name == 'develop' }}
steps:
- name: checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- name: Download Allure Report - Windows
uses: actions/download-artifact@v3
with:
name: allure-results-windows
path: allure-results-windows
- name: Download Allure Report - MacOS
uses: actions/download-artifact@v3
with:
name: allure-results-macos
path: allure-results-macos
- name: Download Allure Report - Linux
uses: actions/download-artifact@v3
with:
name: allure-results-linux
path: allure-results-linux
- name: Send Results and Generate Allure Report - Windows
uses: ./tools/actions/composites/upload-allure-report
if: always()
with:
platform: windows
login: ${{ secrets.ALLURE_LOGIN }}
password: ${{ secrets.ALLURE_PASSWORD }}
path: allure-results-windows
- name: Send Results and Generate Allure Report - MacOS
uses: ./tools/actions/composites/upload-allure-report
if: always()
with:
platform: macos
login: ${{ secrets.ALLURE_LOGIN }}
password: ${{ secrets.ALLURE_PASSWORD }}
path: allure-results-macos
- name: Send Results and Generate Allure Report - Linux
uses: ./tools/actions/composites/upload-allure-report
if: always()
with:
platform: linux
login: ${{ secrets.ALLURE_LOGIN }}
password: ${{ secrets.ALLURE_PASSWORD }}
path: allure-results-linux