Skip to content

fix: update Cloudflare R2 upload paths for stonks.js files #9

fix: update Cloudflare R2 upload paths for stonks.js files

fix: update Cloudflare R2 upload paths for stonks.js files #9

Workflow file for this run

name: CI/CD
on:
push:
branches: [master, dev]
pull_request:
branches: [master, dev]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
# ── Setup ────────────────────────────────────────────────
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Install MPA test app dependencies
run: pnpm install --frozen-lockfile
working-directory: test/mpa
- name: Install SPA test app dependencies
run: pnpm install --frozen-lockfile
working-directory: test/spa
# ── Build tracker ────────────────────────────────────────
- name: Build tracker (test build)
run: pnpm bundle:test
# ── Unit tests ──────────────────────────────────────────
- name: Run unit tests
run: pnpm test:units
# ── Prepare integration tests ───────────────────────────
- name: Copy tracker to test apps
run: |
mkdir -p test/mpa/public test/spa/static
cp build/stonks.js test/mpa/public/stonks.js
cp build/stonks.js test/spa/static/stonks.js
- name: Build MPA test app
run: pnpm build
working-directory: test/mpa
- name: Build SPA test app
run: pnpm build
working-directory: test/spa
- name: Install Chromium for Puppeteer
run: npx puppeteer browsers install chrome
- name: Start servers and wait for readiness
run: |
(cd test/mpa && pnpm preview --host 0.0.0.0) &
(cd test/spa && pnpm preview --host 0.0.0.0) &
echo "Waiting for MPA server (port 4321)..."
timeout 30 bash -c 'until curl -sf http://127.0.0.1:4321 > /dev/null 2>&1; do sleep 1; done'
echo "MPA server is ready"
echo "Waiting for SPA server (port 5173)..."
timeout 30 bash -c 'until curl -s -o /dev/null http://127.0.0.1:5173 2>&1; do sleep 1; done'
echo "SPA server is ready"
# ── Integration tests ───────────────────────────────────
- name: Run integration tests
run: pnpm test:e2e
env:
SKIP_BUILD: "1"
SKIP_SERVERS: "1"
# ── Production build & deploy ───────────────────────────
- name: Build production bundle
if: github.event_name == 'push'
run: pnpm bundle
- name: Upload to Cloudflare R2 (master -> stonks.js)
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: npx wrangler r2 object put one-dollar-analytic/stonks.js --file=build/stonks.js --content-type=text/javascript --remote
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Upload to Cloudflare R2 (dev -> stonks-dev.js)
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
run: npx wrangler r2 object put one-dollar-analytic/stonks-dev.js --file=build/stonks.js --content-type=text/javascript --remote
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}