Skip to content

Commit

Permalink
add reporting after screenshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
valpinkman committed May 2, 2022
1 parent acc9fd4 commit 9e7ed3b
Show file tree
Hide file tree
Showing 13 changed files with 270 additions and 110 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build-mobile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,29 @@ jobs:
with:
name: ${{ steps.version.outputs.version }}-release
path: ${{ github.workspace }}/apps/ledger-live-mobile/android/app/build/outputs/apk/release

ios:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.event.push.head.sha }}
- name: set git user
run: |
git config user.email "team-live@ledger.fr"
git config user.name "Team Live"
- uses: pnpm/action-setup@v2.0.1
with:
version: latest
- uses: actions/setup-node@v3
with:
node-version: 14.x
cache: pnpm
cache-dependency-path: "**/pnpm-lock.yaml"
- name: bump npm
run: npm i -g npm
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: install dependencies
run: pnpm i --filter="live-mobile..." --no-frozen-lockfile --unsafe-perm
2 changes: 1 addition & 1 deletion .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
cache-dependency-path: "**/pnpm-lock.yaml"
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.8 # Not needed with a .ruby-version file
ruby-version: 2.7 # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- uses: ledgerhq/ledger-live/tools/actions/get-package-infos@monorepo-setup
id: desktop-version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
cache-dependency-path: "**/pnpm-lock.yaml"
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.8
ruby-version: 2.7
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: install dependencies
run: pnpm i -F "ledger-live" -F "{libs}..." --frozen-lockfile
Expand Down
175 changes: 175 additions & 0 deletions .github/workflows/test-desktop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
name: Test Desktop App

on:
push:
branches:
- main
- develop
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
env:
NODE_OPTIONS: "--max-old-space-size=7168"
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
INSTRUMENT_BUILD: true
# DEBUG: "pw:browser*"
# DEBUG_LOGS: 1
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
# - macos-latest
- windows-latest

runs-on: ${{ matrix.os }}
steps:
- name: format os name
id: os
uses: actions/github-script@v6
with:
result-encoding: string
script: |
if ("${{ matrix.os }}" === "ubuntu-latest") {
return "linux"
} else if ("${{ matrix.os }}" === "macos-latest") {
return "macos"
} else if ("${{ matrix.os }}" === "windows-latest") {
return "windows"
}
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.0.1
with:
version: latest
- uses: actions/setup-node@v2
with:
node-version: 14
cache: pnpm
cache-dependency-path: "**/pnpm-lock.yaml"
- uses: actions/setup-python@v2
with:
python-version: "2.7.x"
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- name: Bump npm to latest
run: npm i -g npm
- name: Install dependencies
run: pnpm i --filter="ledger-live-desktop..." --filter="ledger-live" --frozen-lockfile --unsafe-perm
- name: Install playwright dependencies
run: npx playwright install-deps
- name: Build dependencies
run: pnpm turbo run ledger-live-desktop#build:testing
- name: Run code checkers [Linux]
if: matrix.os == 'ubuntu-latest'
run: pnpm desktop test:codecheck
- name: Run unit tests [Linux]
if: matrix.os == 'ubuntu-latest'
run: pnpm desktop test:jest
- name: Run playwright tests [Linux => xvfb-run]
if: matrix.os == 'ubuntu-latest'
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- pnpm desktop test:playwright
shell: bash
- name: Run playwright tests
if: matrix.os != 'ubuntu-latest'
run: pnpm desktop test:playwright
shell: bash
- name: upload diffs to imgur
if: always() && !cancelled()
uses: ledgerhq/ledger-live/tools/actions/upload-images@monorepo-setup
id: imgur
with:
path: apps/ledger-live-dekstop/tests/artifacts/test-results
workspace: ${{ github.workspace }}
os: ${{ steps.os.outputs.result }}
- name: upload ci suggested screenshots
if: always() && !cancelled()
uses: actions/upload-artifact@v3
with:
name: images
path: images-${{steps.os.outputs.result}}.json
- name: Upload playwright test results [On Failure]
uses: actions/upload-artifact@v2
if: failure() && !cancelled()
with:
name: ${{ format('playwright-results-{0}', matrix.os) }}
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
report:
needs: [test]
runs-on: ubuntu-latest
if: ${{ always() && !cancelled() && github.event.pull_request != '' }}
steps:
- name: check if comment already exists exists
uses: actions/github-script@v6
id: exists
with:
result-encoding: string
script: |
const comments = await github.rest.issues.listComments({
owner: github.actor,
repo: github.repo.repo,
issue_number: github.event.number,
});
const exists = comments.data.find(comment => comment.user.login === 'github-actions[bot]');
return exists?.id ?? 'false';
- 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"];
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: ledgerhq/ledger-live/tools/actions/prepare-comment-screenshots@monorepo-setup
with:
images: images.json
- name: edit comment
uses: actions/github-script@v6
if: ${{ steps.exists.outputs.result != 'false' }}
with:
script: |
await github.rest.issues.updateComment({
owner: github.actor,
repo: github.repo.repo,
comment_id: ${{ steps.exists.outputs.result }},
body: ${{ steps.comment.outputs.body }}
});
- name: create comment
if: ${{ steps.exists.outputs.result == 'false' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr comment ${{ github.event.number }} --body "${{ steps.comment.outputs.body }}"
83 changes: 0 additions & 83 deletions .github/workflows/test_desktop.yml

This file was deleted.

2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions tools/actions/prepare-comment-body/main.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: prepare-comment-body
description: gets a list of images and return a formatted markdown body for comment
name: prepare-comment-screenshots
description: returns a formatted comment to be added to the PR
author: valpinkman
outputs:
body:
Expand All @@ -8,6 +8,10 @@ inputs:
images:
description: array of images to include in body of comment
required: true
actor:
description: creator of the pull request
required: false
default: ${{ github.actor }}
runs:
using: node12
main: build/index.js
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit 9e7ed3b

Please sign in to comment.