Files
webstudio/.github/workflows/cli-r2.yaml
T
Oleg Isonen b9319a3891 perf: share CLI startup for user-site publishing (#6704)
This PR reduces user-site publish time by sharing CLI startup between
sync and build, reducing asset downloads when hosted builds do not need
them, and testing smaller publish artifacts. The paired [SaaS PR
#685](https://github.com/webstudio-is/webstudio-saas/pull/685) uses the
combined CLI path when the Builder artifact advertises support; older
artifacts keep the existing split path.

The paired staging publish served HTML and JavaScript successfully. The
combined CLI step took 4 s versus about 8 s for the previous split steps
in that run; total publish time remained about 40 s. This is one
observation, not a controlled benchmark or a large-site measurement.
Local artifact pruning reduced the compressed archive from 119 MiB to
111 MiB (6.7%); it was not adopted. The full artifact is still
downloaded and extracted on every publish.

## Checklist

- [x] Preserve standalone sync/build behavior and gate combined
sync/build with an artifact capability marker.
- [x] Skip hosted asset downloads only when content indexing does not
need them; preserve static and MDX-required downloads.
- [x] Test CLI startup, synthetic build, and artifact-size
opportunities; record why no riskier change was adopted.
- [x] Verify the paired staging publish and review Builder
documentation.
- [x] Keep only the E2E schema snapshot matching current inputs; no
migration source or migration was added.
- [x] Retry the failing `pages-drag` shard: all 17 tests passed,
including the drag-and-nest test.
- [x] Resolve the two outdated review threads; current code retains
finding details and closes diagnostics on element navigation.
- [x] Required CI on the cleanup commit passed, including all Builder
E2E shards, visual regression, and the existing migration-chain check.
- [ ] Run the agent evaluation suite only after separate approval;
remind the user before merging.

No large-site publish or production release has been tested.
2026-11-17 14:04:00 +01:00

140 lines
4.3 KiB
YAML

name: CLI R2
on:
push:
branches:
- "*.staging"
# cancel in-progress runs on new commits to same PR (gitub.event.number)
concurrency:
group: vercel-cli-r2-${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
statuses: write # This is required for the GitHub Script createCommitStatus to work
packages: write
deployments: write
env:
COMPATIBILITY_DATE: "2024-04-10"
jobs:
build:
environment:
name: "staging"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }} # HEAD commit instead of merge commit
# We need submodules here as this is used for the cloudflare build
- uses: ./.github/actions/submodules-checkout
with:
submodules-ssh-key: ${{ secrets.PRIVATE_GITHUB_DEPLOY_TOKEN }}
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
# TRY FIX cloudlare incident
- uses: unfor19/install-aws-cli-action@v1
with:
version: "2.22.35"
verbose: false
arch: amd64
- name: pnpm instal
run: pnpm install --ignore-scripts
- name: pnpm build
run: pnpm --filter 'webstudio-cloudflare-template^...' run build
- name: pnpm deploy
run: |
pnpm --filter 'webstudio-cloudflare-template' deploy --prod "${{ github.workspace }}/../cloudflare-template"
touch "${{ github.workspace }}/../cloudflare-template/.webstudio-cli-sync-build-v1"
- name: Verify optional Assets build dependency is omitted
run: test ! -e node_modules/@webstudio-is/content-engine/package.json
working-directory: ${{ github.workspace }}/../cloudflare-template
- name: Make archive
run: |
tar --use-compress-program="zstd -19" -cf cloudflare-template.tar.zst cloudflare-template
working-directory: ${{ github.workspace }}/..
- name: Copy artifact
run: |
# For staging
aws s3 cp cloudflare-template.tar.zst "s3://${ARTEFACT_BUCKET_NAME}/public/cloudflare-template/${{ github.ref_name }}.tar.zst"
# For production can be cached forever
aws s3 cp \
--metadata-directive REPLACE --cache-control "public,max-age=31536102,immutable" \
cloudflare-template.tar.zst "s3://${ARTEFACT_BUCKET_NAME}/public/cloudflare-template/${{ github.sha }}.tar.zst"
working-directory: ${{ github.workspace }}/..
env:
AWS_ENDPOINT_URL_S3: ${{ secrets.AWS_ENDPOINT_URL_S3 }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
ARTEFACT_BUCKET_NAME: ${{ secrets.ARTEFACT_BUCKET_NAME }}
checks:
environment:
name: "staging"
runs-on: ubuntu-latest
needs: build
steps:
- uses: pnpm/action-setup@v4
with:
version: "9"
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Copy atrifact via http
run: curl -o cloudflare-template.tar.zst ${{ secrets.ARTEFACT_BUCKET_URL }}/public/cloudflare-template/${{ github.ref_name }}.tar.zst
- name: Extract archive
run: tar --use-compress-program="zstd -d" -xf cloudflare-template.tar.zst -C .
- name: Webstudio Build
run: pnpm webstudio build --template internal --template saas-helpers --template cloudflare --assets false
working-directory: ${{ github.workspace }}/cloudflare-template
- name: Remix Build
run: pnpm build
working-directory: ${{ github.workspace }}/cloudflare-template
- name: WRANGLER Build
run: |
NODE_ENV=production pnpm wrangler deploy \
--name build \
--compatibility-date "${COMPATIBILITY_DATE}" \
--minify true \
--logpush true \
--dry-run \
--outdir dist \
'./functions/[[path]].ts'
working-directory: ${{ github.workspace }}/cloudflare-template
delete-github-deployments:
needs: checks
uses: ./.github/workflows/delete-github-deployments.yml
with:
ref: ${{ github.ref_name }}