Skip to content

Commit

Permalink
ci: post daily update for Firefox as well (#12945)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightning00Blade authored Aug 12, 2024
1 parent 11ea036 commit cb42358
Show file tree
Hide file tree
Showing 3 changed files with 208 additions and 109 deletions.
109 changes: 0 additions & 109 deletions .github/workflows/canary.yml

This file was deleted.

170 changes: 170 additions & 0 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
name: Puppeteer Canary CI

# Declare default permissions as read only.
permissions: read-all

on:
schedule:
# Run everyday at: https://crontab.guru/#0_8_*_*_1-5.
- cron: '0 8 * * 1-5'
workflow_dispatch:

jobs:
chrome-canary-tests:
name: ${{ matrix.suite }} tests on ${{ matrix.os }} (${{ matrix.shard }}) ${{ matrix.configs }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
suite:
- chrome-headless
- chrome-headful
- chrome-headless-shell
- chrome-bidi
os:
- ubuntu-latest
- windows-latest
- macos-latest
shard:
- 1-2
- 2-2
configs:
- experimental
- stable
exclude:
- os: windows-latest
suite: chrome-bidi
- os: macos-latest
suite: chrome-headful
steps:
- name: Check out repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
cache: npm
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm ci
env:
PUPPETEER_SKIP_DOWNLOAD: true
# Set up GitHub Actions caching for Wireit.
- uses: google/wireit@4aad131006ea85c1e42af927534ebb13426dd730 # setup-github-actions-caching/v1.0.2
- name: Build packages
run: npm run build
- name: Install browsers
run: npm run postinstall
env:
PUPPETEER_CHROME_VERSION: canary
PUPPETEER_CHROME_HEADLESS_SHELL_VERSION: canary
PUPPETEER_FIREFOX_SKIP_DOWNLOAD: true
- name: Apply Canary expectations
run: node tools/merge-canary-test-expectations.mjs
- name: Run all tests (for non-Linux)
if: ${{ matrix.os != 'ubuntu-latest' }}
run: npm run test -- --shard '${{ matrix.shard }}' --test-suite ${{ matrix.suite }} --save-stats-to /tmp/artifacts/${{ github.event_name }}_INSERTID.json
env:
PUPPETEER_CHROME_VERSION: canary
PUPPETEER_CHROME_HEADLESS_SHELL_VERSION: canary
PUPPETEER_CHROME_HEADLESS_SHELL_SKIP_DOWNLOAD: true
PUPPETEER_TEST_EXPERIMENTAL_CHROME_FEATURES: ${{ matrix.configs == 'experimental' }}
- name: Run all tests (for Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: xvfb-run --auto-servernum npm run test -- --shard '${{ matrix.shard }}' --test-suite ${{ matrix.suite }} --save-stats-to /tmp/artifacts/${{ github.event_name }}_INSERTID.json
env:
PUPPETEER_CHROME_VERSION: canary
PUPPETEER_CHROME_HEADLESS_SHELL_VERSION: canary
PUPPETEER_TEST_EXPERIMENTAL_CHROME_FEATURES: ${{ matrix.configs == 'experimental' }}
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
if: always()
with:
name: test-results-${{ matrix.os }}-${{ matrix.suite }}-${{ matrix.shard }}-${{ matrix.configs }}
path: /tmp/artifacts/*.json

firefox-nightly-tests:
name: ${{ matrix.suite }} (${{ matrix.shard }}) on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
suite:
- firefox-headful
- firefox-headless
os:
- ubuntu-latest
- macos-latest
- windows-latest
shard:
- 1-4
- 2-4
- 3-4
- 4-4
steps:
- name: Check out repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
cache: npm
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm ci
env:
PUPPETEER_SKIP_DOWNLOAD: true
# Set up GitHub Actions caching for Wireit.
- uses: google/wireit@4aad131006ea85c1e42af927534ebb13426dd730 # setup-github-actions-caching/v1.0.2
- name: Build packages
run: npm run build
- name: Install browsers
run: npm run postinstall
env:
PUPPETEER_CHROME_SKIP_DOWNLOAD: true
PUPPETEER_CHROME_HEADLESS_SHELL_SKIP_DOWNLOAD: true
PUPPETEER_FIREFOX_VERSION: nightly
- name: Apply Canary expectations
run: node tools/merge-canary-test-expectations.mjs
- name: Run all tests (for non-Linux)
if: ${{ matrix.os != 'ubuntu-latest' }}
run: npm run test -- --shard '${{ matrix.shard }}' --test-suite ${{ matrix.suite }} --save-stats-to /tmp/artifacts/${{ github.event_name }}_INSERTID.json
- name: Run all tests (for Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: xvfb-run --auto-servernum npm run test -- --shard '${{ matrix.shard }}' --test-suite ${{ matrix.suite }} --save-stats-to /tmp/artifacts/${{ github.event_name }}_INSERTID.json
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
if: always()
with:
name: test-results-${{ matrix.os }}-${{ matrix.suite }}-${{ matrix.shard }}
path: /tmp/artifacts/*.json

report-results:
name: 'Report results'
needs: [chrome-canary-tests, firefox-nightly-tests]
runs-on: ubuntu-latest
permissions:
issues: write
if: ${{ always() }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
cache: npm
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm ci
env:
PUPPETEER_SKIP_DOWNLOAD: true
- name: Generate comment
id: genearate-comment-body
run: node tools/build_daily_comment.mjs
env:
CHROME_RUN_STATUS: ${{ needs.chrome-canary-tests.result }}
FIREFOX_RUN_STATUS: ${{ needs.firefox-nightly-tests.result }}

- name: Post comment
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
if: ${{ needs.chrome-canary-tests.result}}
with:
# https://github.com/puppeteer/puppeteer/issues/12379
issue-number: 12379
body: ${{ steps.genearate-comment-body.outputs.body }}
38 changes: 38 additions & 0 deletions tools/build_daily_comment.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @license
* Copyright 2024 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import actions from '@actions/core';

/**
*
* @param {string} env
* @returns {string}
*/
function getGitHubEnvVariable(env) {
return process.env[`GITHUB_${env.toUpperCase()}`];
}

function getStatus(result) {
if (result === 'success') {
return '✅ Tests succeeded';
}

return '❌ Tests failed';
}

const chromeStatus = getStatus(process.env.CHROME_RUN_STATUS);
const firefoxStatus = getStatus(process.env.FIREFOX_RUN_STATUS);
const body = `
| Browser | Status |
| ------- | ------ |
| Chrome Canary | ${chromeStatus} |
| Firefox Nightly | ${firefoxStatus} |
`;

const footer = `
---
[Link](${getGitHubEnvVariable('server_url')}/${getGitHubEnvVariable('repository')}/actions/runs/${getGitHubEnvVariable('run_id')})`;

actions.setOutput('body', `${body}${footer}`);

0 comments on commit cb42358

Please sign in to comment.