Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286# Credit for fingerprint action https://github.com/expo/expo# https://github.com/expo/expo/blob/main/.github/workflows/pr-labeler.yml---name: PR Tests
on: push: branches: [main] pull_request: types: [opened, synchronize]
concurrency: group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} cancel-in-progress: true
# Permissions are granted per-job below; anything unlisted defaults to none.# pull-requests: write is needed by sticky-pull-request-comment to post the# bundle-size and fingerprint diffspermissions: {}
env: NODE_OPTIONS: --max-old-space-size=4096
jobs: # Populate this from main so every PR can restore the same trusted baseline. bundle-analyzer-base: runs-on: ubuntu-24.04 if: ${{ github.event_name == 'push' }} permissions: contents: read steps: # Temporary until fixed runner images roll out: # https://github.com/actions/runner-images/issues/15018 - name: Update Ubuntu CA certificates run: | sudo apt-get update -qq sudo apt-get install --only-upgrade --no-install-recommends -y ca-certificates
- name: ⬇️ Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- name: 🔧 Setup Node uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version-file: package.json cache: pnpm
- name: ⬇️ Get base bundle size from cache id: get-base-size uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: base-bundle-size.json key: base-bundle-size-v2-main-${{ github.sha }}
- name: 🔦 Build and measure base bundle if: ${{ !steps.get-base-size.outputs.cache-hit }} run: | pnpm install pnpm intl:build pnpm build-web node scripts/measure-web-bundle.js --json > base-bundle-size.json
- name: ⬆️ Save base bundle size to cache if: ${{ !steps.get-base-size.outputs.cache-hit }} uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: base-bundle-size.json key: base-bundle-size-v2-main-${{ github.sha }}
bundle-analyzer: name: Web bundle size and browser support runs-on: ubuntu-24.04 if: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.event_name == 'pull_request'}} permissions: contents: read pull-requests: write steps: # Temporary until fixed runner images roll out: # https://github.com/actions/runner-images/issues/15018 - name: Update Ubuntu CA certificates run: | sudo apt-get update -qq sudo apt-get install --only-upgrade --no-install-recommends -y ca-certificates
- name: ⬇️ Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- name: 🔧 Setup Node uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version-file: package.json cache: pnpm
- name: 🌿 Ensure tracking relevant branches and checkout base env: HEAD_REF: ${{ github.head_ref }} BASE_REF: ${{ github.base_ref }} run: | git checkout $HEAD_REF git checkout $BASE_REF
- name: 🔍 Get the base commit id: base-commit env: BASE_REF: ${{ github.base_ref }} run: echo base-commit=$(git log -n 1 $BASE_REF --pretty=format:'%H') >> "$GITHUB_OUTPUT"
- name: 🔀 Merge PR commit env: HEAD_REF: ${{ github.head_ref }} run: | # Have to set a git config for the merge to work git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" git merge --no-edit $HEAD_REF pnpm install pnpm intl:build
- name: 🔦 Build and measure PR bundle run: | pnpm build-web node scripts/measure-web-bundle.js --json > ../pr-bundle-size.json cp scripts/measure-web-bundle.js "$RUNNER_TEMP/measure-web-bundle.js"
- name: 🔎 Check web browser support run: pnpm check-web-browser-support
- name: ⬇️ Get base bundle size from cache id: get-base-size # Restore-only prevents PR-scoped fallback builds from creating caches. uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: base-bundle-size.json key: base-bundle-size-v2-main-${{ steps.base-commit.outputs.base-commit }}
- name: ⏪ Restore to base commit if: ${{ !steps.get-base-size.outputs.cache-hit }} env: BASE_COMMIT: ${{ steps.base-commit.outputs.base-commit }} run: | git reset "$BASE_COMMIT" git restore . # Files the PR added are left behind untracked by the reset, and a # platform-specific one (`*.web.ts`) would shadow the base's module. git clean -fd # Measure both builds with the PR's script, even when the base # predates support for gzip measurements. cp "$RUNNER_TEMP/measure-web-bundle.js" scripts/measure-web-bundle.js # Drop the PR-side export so the measure script's output-dir # auto-detection can't pick it up: a webpack base exports to # web-build/ while the PR's Metro build left dist/ behind. rm -rf dist web-build
- name: 🔦 Build and measure base bundle if: ${{ !steps.get-base-size.outputs.cache-hit }} run: | pnpm install pnpm intl:build pnpm build-web node scripts/measure-web-bundle.js --allow-missing --json > base-bundle-size.json
- name: % Get diff id: get-diff run: | node -e ' const fs = require("node:fs") const base = JSON.parse(fs.readFileSync("base-bundle-size.json", "utf8")) const pr = JSON.parse(fs.readFileSync("../pr-bundle-size.json", "utf8")) const fmt = bytes => { const abs = Math.abs(bytes) if (abs >= 1024 * 1024) return `${(bytes / 1024 / 1024).toFixed(2)} MB` if (abs >= 1024) return `${(bytes / 1024).toFixed(2)} KB` return `${bytes} B` } const out = [] for (const metric of ["raw", "gzip"]) { const baseSize = base[metric] const prSize = pr[metric] if (!Number.isFinite(baseSize) || !Number.isFinite(prSize) || baseSize <= 0 || prSize < 0) { console.error(`Bad ${metric} measurements: base=${baseSize} pr=${prSize}`) process.exit(1) } const diff = prSize - baseSize out.push( `${metric}_base_file_string=${fmt(baseSize)}`, `${metric}_pr_file_string=${fmt(prSize)}`, `${metric}_diff_file_string=${diff > 0 ? "+" : ""}${fmt(diff)}`, `${metric}_percent=${((diff / baseSize) * 100).toFixed(2)}`, ) } console.log(out.join("\n")) fs.appendFileSync(process.env.GITHUB_OUTPUT, out.join("\n") + "\n") '
- name: 💬 Drop a comment uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 with: header: bundle-diff message: | | Size | Old size | New size | Diff | |------|----------|----------|------| | Uncompressed | ${{ steps.get-diff.outputs.raw_base_file_string }} | ${{ steps.get-diff.outputs.raw_pr_file_string }} | ${{ steps.get-diff.outputs.raw_diff_file_string }} (${{ steps.get-diff.outputs.raw_percent }}%) | | Gzip | ${{ steps.get-diff.outputs.gzip_base_file_string }} | ${{ steps.get-diff.outputs.gzip_pr_file_string }} | ${{ steps.get-diff.outputs.gzip_diff_file_string }} (${{ steps.get-diff.outputs.gzip_percent }}%) | ---
fingerprint-native: runs-on: ubuntu-22.04 if: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.event_name == 'pull_request'}} permissions: contents: read pull-requests: write outputs: # Empty when the native surface is unchanged, 'true' when it changed. includes-changes: ${{ steps.fingerprint.outputs.includes-changes }} steps: # Temporary until fixed runner images roll out: # https://github.com/actions/runner-images/issues/15018 - name: Update Ubuntu CA certificates run: | sudo apt-get update -qq sudo apt-get install --only-upgrade --no-install-recommends -y ca-certificates
- name: ⬇️ Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 100
- name: ⬇️ Fetch commits from base branch run: git fetch origin main:main --depth 100 if: github.event_name == 'pull_request'
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- name: 🔧 Setup Node uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version-file: package.json cache: pnpm
- name: 📷 Check fingerprint and install dependencies id: fingerprint timeout-minutes: 5 uses: bluesky-social/github-actions/fingerprint-native@b8aac187f297a2cb3e84434d1e8dedd907918c9d # v0.5.1 with: profile: pull-request
- name: 💬 Drop a comment uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 if: ${{ steps.fingerprint.outputs.includes-changes }} with: header: fingerprint-diff message: | The Pull Request introduced native fingerprint changes against the base commit.
--- *Generated by [PR labeler](https://github.com/expo/expo/actions/workflows/pr-labeler.yml) 🤖*
- name: 💬 Delete comment uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 if: ${{ !steps.fingerprint.outputs.includes-changes }} with: header: fingerprint-diff delete: true
- name: 🏷️ Label as fingerprint changed if: ${{ steps.fingerprint.outputs.includes-changes }} env: GH_TOKEN: ${{ github.token }} PR_NUMBER: ${{ github.event.pull_request.number }} run: | gh pr edit "$PR_NUMBER" --add-label "bot: fingerprint changed" || true
- name: 🏷️ Remove fingerprint changed label if: ${{ !steps.fingerprint.outputs.includes-changes }} env: GH_TOKEN: ${{ github.token }} PR_NUMBER: ${{ github.event.pull_request.number }} run: | gh pr edit "$PR_NUMBER" --remove-label "bot: fingerprint changed" || true