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: preview-web can't be run on forks #84

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
198 changes: 198 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
name: Build

on:
workflow_run:
workflows:
- Tests
types:
- completed

jobs:
build-and-test-app:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ${{ matrix.os }}
env:
DISPLAY: :0

strategy:
fail-fast: false
max-parallel: 3
matrix:
os: [macos-latest, ubuntu-20.04, windows-latest]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"

- name: Install
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true"
run: yarn --immutable

- name: Fetch compiled source
uses: dawidd6/action-download-artifact@v5
with:
run_id: ${{ github.event.workflow_run.id }}
name: compiled-${{ matrix.os }}
path: build

- name: Build
run: yarn run pack

- name: Upload build
uses: actions/upload-artifact@v4
with:
name: app-builds-${{ matrix.os }}
retention-days: 15
if-no-files-found: error
path: |
dist/*.snap
dist/*.AppImage
dist/*.msi
dist/*.dmg
dist/latest-mac.yml
dist/latest-linux.yml

- run: yarn playwright install --with-deps chromium chromium

- name: Setup xvfb (Linux)
if: runner.os == 'Linux'
run: |
# start xvfb in the background
sudo /usr/bin/Xvfb $DISPLAY -screen 0 1280x1024x24 &

- name: Run tests
run: yarn e2e:app
env:
CI: "true"
PWTEST_VIDEO: "true"
HEADFUL: "true"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload test results
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: electron-${{ matrix.os }}-test-results
path: playwright-report

- name: Upload video recordings
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: electron-${{ matrix.os }}-recordings
path: e2e-recordings

# - name: Setup xvfb (Linux)
# if: runner.os == 'Linux'
# run: |
# sudo apt-get install -y xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0
# # start xvfb in the background
# sudo /usr/bin/Xvfb $DISPLAY -screen 0 1280x1024x24 &
# - name: E2E
# run: yarn e2e:production

# - name: Upload failure artifacts
# if: ${{ failure() }}
# uses: actions/upload-artifact@v2-preview
# with:
# name: diff
# path: |
# packages/configurator/e2e/output/*.png
# packages/configurator/e2e/output/*.webm
# packages/configurator/e2e/output/trace/*.zip
# - name: Preview demo

e2e-web:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"

- name: Install
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: yarn --immutable --mode=skip-build

- name: Install browsers
run: yarn playwright install --with-deps

- name: Fetch compiled source
uses: dawidd6/action-download-artifact@v5
with:
run_id: ${{ github.event.workflow_run.id }}
name: compiled-ubuntu-20.04
path: build

- name: Run tests
run: yarn e2e:web
env:
CI: "true"
PWTEST_VIDEO: "true"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: video-web-linux-test-results
path: playwright-report

preview-web:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Fetch compiled source
uses: dawidd6/action-download-artifact@v5
with:
run_id: ${{ github.event.workflow_run.id }}
name: compiled-ubuntu-20.04
path: build

- name: Fetch storybook build
uses: dawidd6/action-download-artifact@v5
with:
run_id: ${{ github.event.workflow_run.id }}
name: storybook-static
path: build/renderer/storybook

- name: Deploy preview
id: cloudflare-preview
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy build/renderer --project-name=buddy

- name: Find preview comment if present
uses: peter-evans/find-comment@v3
id: find-preview-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: Buddy has been automatically deployed to Cloudflare

- name: Create or update preview URL comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-preview-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
EdgeTX Buddy has been automatically deployed to Cloudflare.
✅ Preview: ${{ steps.cloudflare-preview.outputs.deployment-url }}
✅ Storybook: ${{ steps.cloudflare-preview.outputs.deployment-url }}/storybook
edit-mode: replace
Loading
Loading