Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/preview-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
fetch(request, env) {
return env.ASSETS.fetch(request);
},
};
23 changes: 23 additions & 0 deletions .github/scripts/__tests__/preview-worker.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { describe, expect, it } from "vitest";

import worker from "../../preview-worker.js";

describe("documentation preview worker", () => {
it("forwards requests and responses to the static asset binding", async () => {
const request = new Request("https://example.com/docs");
const response = new Response("missing", { status: 404 });

const result = await worker.fetch(request, {
ASSETS: {
fetch: (received) => {
expect(received).toBe(request);

return response;
},
},
});

expect(result).toBe(response);
expect(result.status).toBe(404);
});
});
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ matrix.task == 'build' && github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
Expand All @@ -46,6 +47,20 @@ jobs:
run: bun install --frozen-lockfile
- name: Run task
run: bun run ${{ matrix.task }}
- name: Prepare documentation preview artifact
if: matrix.task == 'build' && github.event_name == 'pull_request'
run: |
test -f apps/web/dist/index.html
mkdir -p "$RUNNER_TEMP/alchemy-worker"
cp .github/preview-worker.js "$RUNNER_TEMP/alchemy-worker/index.js"
cp -R apps/web/dist "$RUNNER_TEMP/alchemy-worker/site"
- name: Upload documentation preview artifact
if: matrix.task == 'build' && github.event_name == 'pull_request'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: alchemy-worker
path: ${{ runner.temp }}/alchemy-worker/
if-no-files-found: error
- name: Upload force-input coverage to Codecov
if: matrix.task == 'test' && env.CODECOV_TOKEN_AVAILABLE == 'true'
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ jobs:
production-stage: prod
production-url: https://opencode-plugins.mynameistito.com
use-adopt: false
preview-assets-directory: site
preview-assets-config: '{"htmlHandling":"drop-trailing-slash","notFoundHandling":"404-page"}'
pull-request-number: ${{ needs.resolve.outputs.pull_request_number }}
allow-fork-commits: true

Expand Down Expand Up @@ -149,4 +151,6 @@ jobs:
production-stage: prod
production-url: https://opencode-plugins.mynameistito.com
use-adopt: false
preview-assets-directory: site
preview-assets-config: '{"htmlHandling":"drop-trailing-slash","notFoundHandling":"404-page"}'
pull-request-number: ${{ needs.resolve.outputs.pull_request_number }}