Skip to content

test(perf): verify route-profile stylesheets load [Codex] #883

test(perf): verify route-profile stylesheets load [Codex]

test(perf): verify route-profile stylesheets load [Codex] #883

Workflow file for this run

name: Deploy to Cloudflare Pages
on:
push:
branches:
- master
workflow_dispatch:
inputs:
environment:
description: "Choose an environment to deploy to: <preview|production>"
required: true
default: "preview"
pull_request:
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false }}
concurrency:
group: docs-deploy-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
permissions:
contents: read
deployments: write
pull-requests: write
steps:
- uses: actions/checkout@v6.0.2
- name: Install Corepack
run: npm install --global corepack
- name: Enable Corepack
run: corepack enable
- name: Setup Node.js environment
uses: actions/setup-node@v6.3.0
with:
node-version-file: ".node-version"
cache: "yarn"
- name: Install dependencies
run: yarn install
- name: Sync playground bundles
run: yarn build:sync-bundles
- name: Set VITE_DEPLOYMENT_URL
env:
RAW_BRANCH: ${{ github.head_ref || github.ref_name }}
shell: bash
run: bash .github/scripts/deployment-environment.sh
- name: Build
run: yarn build
env:
VITE_DEPLOYMENT_URL: ${{ env.VITE_DEPLOYMENT_URL }}
VITE_ALGOLIA_APP_ID: ${{ secrets.VITE_ALGOLIA_APP_ID }}
VITE_ALGOLIA_INDEX_NAME: ${{ secrets.VITE_ALGOLIA_INDEX_NAME }}
VITE_ALGOLIA_SEARCH_API_KEY: ${{ secrets.VITE_ALGOLIA_SEARCH_API_KEY }}
- name: Deploy
if: ${{ github.actor != 'dependabot[bot]' }}
id: deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: apps/docs
command: pages deploy out --project-name=rescript-lang-org --branch=${{ env.SAFE_BRANCH }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
wranglerVersion: 4.130.0
env:
FORCE_COLOR: 0
- name: Comment with docs preview link
if: ${{ github.event_name == 'pull_request' && steps.deploy.outcome == 'success' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
recreate: true
header: docs-deployment
message: |
[Docs preview](${{ steps.deploy.outputs.deployment-url }})
lighthouse:
runs-on: ubuntu-latest
name: Lighthouse
needs: deploy
if: ${{ github.actor != 'dependabot[bot]' }}
concurrency:
group: docs-lighthouse-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
permissions:
actions: write
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v6.0.2
- name: Setup Node.js environment
uses: actions/setup-node@v6.3.0
with:
node-version-file: ".node-version"
- name: Set deployment URL
env:
RAW_BRANCH: ${{ github.head_ref || github.ref_name }}
shell: bash
run: bash .github/scripts/deployment-environment.sh
- name: Set Lighthouse environment
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RAW_BRANCH: ${{ github.head_ref || github.ref_name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: bash .github/scripts/lighthouse-environment.sh
- name: Restore target branch Lighthouse baseline
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: bash .github/scripts/lighthouse-restore.sh
- name: Set Lighthouse route profiles
shell: bash
run: node apps/docs/scripts/route-profiles.mjs lighthouse-urls "$DOCS_DEPLOYMENT_URL" >> "$GITHUB_ENV"
- name: Audit homepage with Lighthouse
uses: treosh/lighthouse-ci-action@v12
with:
urls: ${{ env.LIGHTHOUSE_URLS }}
configPath: ./apps/docs/lighthouserc.json
- name: Create Lighthouse baseline
run: node apps/docs/scripts/lighthouse-report.mjs baseline
env:
LIGHTHOUSE_URL: ${{ env.DOCS_DEPLOYMENT_URL }}
- name: Upload Lighthouse reports
id: lighthouse-artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.LIGHTHOUSE_ARTIFACT_NAME }}
path: .lighthouseci/
if-no-files-found: error
include-hidden-files: true
overwrite: true
retention-days: 90
- name: Summarize Lighthouse baseline
run: |
node apps/docs/scripts/lighthouse-report.mjs comment
cat .lighthouseci/comment.md >> "$GITHUB_STEP_SUMMARY"
env:
LIGHTHOUSE_ARTIFACT_URL: ${{ steps.lighthouse-artifact.outputs.artifact-url }}
- name: Comment PR with Lighthouse baseline
if: ${{ github.event_name == 'pull_request' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: lighthouse-baseline
path: .lighthouseci/comment.md
- name: Remove superseded Lighthouse artifacts
env:
CURRENT_ARTIFACT_ID: ${{ steps.lighthouse-artifact.outputs.artifact-id }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: bash .github/scripts/lighthouse-cleanup.sh
deploy-guide:
runs-on: ubuntu-latest
name: Deploy Guide Worker
if: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false) && github.actor != 'dependabot[bot]' }}
permissions:
contents: read
deployments: write
steps:
- uses: actions/checkout@v6.0.2
- name: Install Corepack
run: npm install --global corepack
- name: Enable Corepack
run: corepack enable
- name: Setup Node.js environment
uses: actions/setup-node@v6.3.0
with:
node-version-file: ".node-version"
cache: "yarn"
- name: Install dependencies
run: yarn install
- name: Build guide
run: yarn build:guide
- name: Set guide deployment command
shell: bash
run: |
RAW_BRANCH="${{ github.head_ref || github.ref_name }}"
SAFE_BRANCH=$(echo "$RAW_BRANCH" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9-]+/-/g; s/^-+//; s/-+$//; s/-+/-/g')
SAFE_BRANCH="${SAFE_BRANCH:0:28}"
if [[ "${{ github.event_name }}" == "push" && "$RAW_BRANCH" == "master" ]] || [[ "${{ inputs.environment }}" == "production" ]]; then
echo "GUIDE_DEPLOY_COMMAND=deploy" >> "$GITHUB_ENV"
echo "GUIDE_DEPLOYMENT_ENVIRONMENT=guide-production" >> "$GITHUB_ENV"
echo "GUIDE_PRODUCTION_ENVIRONMENT=true" >> "$GITHUB_ENV"
else
echo "GUIDE_DEPLOY_COMMAND=versions upload --preview-alias=$SAFE_BRANCH" >> "$GITHUB_ENV"
echo "GUIDE_DEPLOYMENT_ENVIRONMENT=guide-preview" >> "$GITHUB_ENV"
echo "GUIDE_PRODUCTION_ENVIRONMENT=false" >> "$GITHUB_ENV"
fi
- name: Deploy guide
id: deploy-guide
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: apps/guide
command: ${{ env.GUIDE_DEPLOY_COMMAND }}
wranglerVersion: 4.130.0
env:
FORCE_COLOR: 0
- name: Publish guide deployment to GitHub
uses: actions/github-script@v9.0.0
with:
script: |
const environment = process.env.GUIDE_DEPLOYMENT_ENVIRONMENT;
const productionEnvironment = process.env.GUIDE_PRODUCTION_ENVIRONMENT === "true";
const ref = context.payload.pull_request?.head.ref ?? context.ref;
const deployment = await github.rest.repos.createDeployment({
owner: context.repo.owner,
repo: context.repo.repo,
ref,
auto_merge: false,
required_contexts: [],
environment,
production_environment: productionEnvironment,
transient_environment: !productionEnvironment,
description: "Cloudflare Guide",
});
await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: deployment.data.id,
state: "success",
environment,
environment_url: process.env.GUIDE_DEPLOYMENT_URL,
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
description: "Cloudflare Guide deployed",
auto_inactive: false,
});
env:
GUIDE_DEPLOYMENT_ENVIRONMENT: ${{ env.GUIDE_DEPLOYMENT_ENVIRONMENT }}
GUIDE_DEPLOYMENT_URL: ${{ steps.deploy-guide.outputs.deployment-url }}
GUIDE_PRODUCTION_ENVIRONMENT: ${{ env.GUIDE_PRODUCTION_ENVIRONMENT }}
e2e:
runs-on: ubuntu-latest
name: E2E Tests
needs: deploy
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- uses: actions/checkout@v6.0.2
- name: Install Corepack
run: npm install --global corepack
- name: Enable Corepack
run: corepack enable
- name: Setup Node.js environment
uses: actions/setup-node@v6.3.0
with:
node-version-file: ".node-version"
cache: "yarn"
- name: Install dependencies
run: yarn install
- name: Build ReScript
run: yarn build:res
- name: Set deployment URL
env:
RAW_BRANCH: ${{ github.head_ref || github.ref_name }}
shell: bash
run: bash .github/scripts/deployment-environment.sh
- name: Cypress E2E tests
uses: cypress-io/github-action@v7
with:
install: false
working-directory: apps/docs
browser: chrome
config: baseUrl=${{ env.DOCS_DEPLOYMENT_URL }}
- name: Route profile Cypress tests
uses: cypress-io/github-action@v7
with:
install: false
working-directory: apps/docs
browser: chrome
config-file: cypress.route-profiles.config.mjs
config: baseUrl=${{ env.DOCS_DEPLOYMENT_URL }}