media/metrics: Avoid reporting preloadTime as 0 (#406) #1140
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: Main | |
on: | |
pull_request: | |
push: | |
branches: [main, next] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
install: | |
name: Install | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16] | |
pnpm-version: [7] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/[email protected] | |
with: | |
version: ${{ matrix.pnpm-version }} | |
- name: Set up Node ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
cache: 'pnpm' | |
node-version: ${{ matrix.node-version }} | |
- name: Cache pnpm | |
uses: actions/cache@v3 | |
with: | |
path: ~/.pnpm-store | |
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }} | |
restore-keys: pnpm- | |
- name: Cache node_modules | |
uses: actions/cache@v3 | |
id: cache-node-modules | |
with: | |
path: | | |
node_modules | |
examples/*/node_modules | |
packages/*/node_modules | |
packages/**/dist | |
key: modules-${{ hashFiles('pnpm-lock.yaml') }} | |
- name: Install Dependencies | |
if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
run: | | |
pnpm i --ignore-scripts | |
pnpm postinstall | |
- name: Link Dependencies | |
if: steps.cache-node-modules.outputs.cache-hit == 'true' | |
run: pnpm dev | |
lint: | |
name: Lint | |
needs: install | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16] | |
pnpm-version: [7] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/[email protected] | |
with: | |
version: ${{ matrix.pnpm-version }} | |
- name: Set up Node ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
cache: 'pnpm' | |
node-version: ${{ matrix.node-version }} | |
- name: Cache node_modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules | |
examples/*/node_modules | |
packages/*/node_modules | |
packages/**/dist | |
key: modules-${{ hashFiles('pnpm-lock.yaml') }} | |
- name: Lint code | |
run: pnpm lint | |
- name: Check types | |
run: pnpm lint:types | |
build: | |
name: Build | |
needs: install | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16] | |
pnpm-version: [7] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/[email protected] | |
with: | |
version: ${{ matrix.pnpm-version }} | |
- name: Set up Node ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
cache: 'pnpm' | |
node-version: ${{ matrix.node-version }} | |
- name: Cache node_modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules | |
examples/*/node_modules | |
packages/*/node_modules | |
packages/**/dist | |
key: modules-${{ hashFiles('pnpm-lock.yaml') }} | |
- name: Build | |
run: pnpm build | |
- name: Build Examples | |
run: pnpm build:examples | |
test: | |
name: Test | |
needs: install | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16] | |
pnpm-version: [7] | |
react-version: [18] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/[email protected] | |
with: | |
version: ${{ matrix.pnpm-version }} | |
- name: Set up Node ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
cache: 'pnpm' | |
node-version: ${{ matrix.node-version }} | |
- name: Cache node_modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules | |
examples/*/node_modules | |
packages/*/node_modules | |
packages/**/dist | |
key: modules-${{ hashFiles('pnpm-lock.yaml') }} | |
- name: Test React 18 | |
run: pnpm test:coverage | |
env: | |
REACT_VERSION: ${{ matrix.react-version }} | |
STUDIO_API_KEY: ${{ secrets.STUDIO_API_KEY }} | |
security-codeql: | |
name: Security (CodeQL) | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
security-events: write | |
strategy: | |
matrix: | |
node-version: [16] | |
pnpm-version: [7] | |
react-version: [18] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/[email protected] | |
with: | |
version: ${{ matrix.pnpm-version }} | |
- name: Set up Node ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
cache: 'pnpm' | |
node-version: ${{ matrix.node-version }} | |
- name: Cache node_modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules | |
examples/*/node_modules | |
packages/*/node_modules | |
packages/**/dist | |
key: modules-${{ hashFiles('pnpm-lock.yaml') }} | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v2 | |
with: | |
languages: typescript | |
queries: security-extended,security-and-quality | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v2 | |
security-dependency-review: | |
name: Security (Dependency Review) | |
needs: build | |
if: github.ref != 'refs/heads/main' && github.ref != 'refs/heads/next' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
strategy: | |
matrix: | |
node-version: [16] | |
pnpm-version: [7] | |
react-version: [18] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/[email protected] | |
with: | |
version: ${{ matrix.pnpm-version }} | |
- name: Set up Node ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
cache: 'pnpm' | |
node-version: ${{ matrix.node-version }} | |
- name: Cache node_modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules | |
examples/*/node_modules | |
packages/*/node_modules | |
packages/**/dist | |
key: modules-${{ hashFiles('pnpm-lock.yaml') }} | |
- name: Dependency Review | |
uses: actions/dependency-review-action@v3 |