restrict max-failtures #347
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build And Test Extensions | |
on: | |
schedule: | |
- cron: '0 20 1 * *' | |
push: | |
branches: [develop] | |
paths: | |
- 'src/**' | |
- 'tests/**' | |
- 'playwright.config.ts' | |
pull_request: | |
branches: [develop, master] | |
types: | |
- opened | |
- reopened | |
- ready_for_review | |
- review_requested | |
paths: | |
- 'src/**' | |
- 'tests/**' | |
- 'playwright.config.ts' | |
- 'pnpm-lock.yaml' | |
- '.github/workflows/build-test.yml' | |
workflow_dispatch: | |
inputs: | |
debug: | |
description: 'Enable debug logging' | |
required: false | |
default: 'false' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
browser: [chrome, edge, chromium] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v3 | |
with: | |
version: 9 | |
- name: Setup Node.js | |
uses: actions/[email protected] | |
with: | |
node-version: 20 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Build And Package Extensions | |
run: pnpm build --zip --target=${{ matrix.browser }}-mv3 | |
env: | |
DEBUG: true | |
# upload to github artifacts for each browser with matrix | |
- name: Upload to GitHub Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.browser }}-mv3 | |
path: build/ | |
test: # non-e2e test no need upload to r2 | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
project: [integrations, units] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Ensure No @Scoped Test | |
run: grep -r --include "*.spec.ts" "@scoped" && echo "please remove @scoped from tests" && exit 1 || echo "No @scoped tests found" | |
- uses: pnpm/action-setup@v3 | |
with: | |
version: 9 | |
- name: Setup Node.js | |
uses: actions/[email protected] | |
with: | |
node-version: 20 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Cache playwright binaries | |
uses: actions/cache@v3 | |
id: playwright-cache | |
with: | |
path: ~/.cache/ms-playwright | |
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }} | |
- name: Install Playwright Browsers | |
run: pnpm exec playwright install --with-deps | |
if: steps.playwright-cache.outputs.cache-hit != 'true' | |
- name: Test | |
id: test | |
run: | | |
if [ "${{ inputs.debug }}" == "true" ]; then | |
echo "Enabled Debug Mode" | |
export DEBUG=true | |
fi | |
pnpm test -- --project=${{ matrix.project }} --max-failures=2 | |
- name: Upload Test Results | |
if: always() && steps.test.conclusion != 'skipped' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.project }}-test-results | |
path: | | |
test-results/ | |
playwright-report/ | |
if-no-files-found: ignore | |
e2e-test: | |
runs-on: ubuntu-latest | |
if: ${{ contains(fromJSON('["schedule", "pull_request", "workflow_dispatch"]'), github.event_name) || (github.event_name == 'push' && contains(github.event.head_commit.message, '[run ci]')) }} | |
needs: [build, test] | |
strategy: | |
fail-fast: false | |
matrix: | |
browser: [chrome, edge] | |
theme: ['', '-theme'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Ensure No @Scoped Test | |
run: grep -r --include "*.spec.ts" "@scoped" && echo "please remove @scoped from tests" && exit 1 || echo "No @scoped tests found" | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
id: download | |
with: | |
name: ${{ matrix.browser }}-mv3 | |
path: build/ | |
- name: Unzip artifacts | |
run: unzip build/${{ matrix.browser }}-mv3-prod.zip -d build/extension | |
- uses: pnpm/action-setup@v3 | |
with: | |
version: 9 | |
- name: Setup Node.js | |
uses: actions/[email protected] | |
with: | |
node-version: 20 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Cache playwright binaries | |
uses: actions/cache@v3 | |
id: playwright-cache | |
with: | |
path: ~/.cache/ms-playwright | |
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }} | |
- name: Install Playwright Browsers | |
run: pnpm exec playwright install --with-deps | |
if: steps.playwright-cache.outputs.cache-hit != 'true' | |
- name: Setup Project | |
id: project | |
run: | | |
# set output variable | |
echo "project=${{ matrix.browser }}${{ matrix.theme}}" >> $GITHUB_OUTPUT | |
- name: Test | |
id: test | |
run: | | |
if [ "${{ inputs.debug }}" == "true" ]; then | |
echo "Enabled Debug Mode" | |
export DEBUG=true | |
fi | |
pnpm test -- --project=${{ steps.project.outputs.project }} | |
- name: Upload Test Results | |
if: always() && steps.test.conclusion != 'skipped' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.project.outputs.project }}-test-results | |
path: | | |
test-results/ | |
playwright-report/ | |
if-no-files-found: ignore | |
- name: Upload Results To R2 | |
if: failure() && steps.test.conclusion == 'failure' | |
uses: eric2788/r2-upload-action@concurrent | |
id: upload | |
continue-on-error: true | |
with: | |
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} | |
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
r2-bucket: ${{ secrets.R2_BUCKET }} | |
source-dir: ./playwright-report | |
destination-dir: ${{ github.event.repository.name }}/${{ github.run_number }}/${{ steps.project.outputs.project }} | |
output-file-url: 'true' | |
multipart-size: 100 | |
max-retries: 5 | |
env: | |
NODE_OPTIONS: '--max-old-space-size=6144' | |
- name: Print Report URL | |
if: failure() && steps.upload.outcome == 'success' | |
run: echo "::notice title=Report URL for ${{ steps.project.outputs.project }}::https://reports.ericlamm.xyz/${{ github.event.repository.name }}/${{ github.run_number }}/${{ steps.project.outputs.project }}/" |