Skip to content
Draft
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
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ jobs:
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository == 'voidzero-dev/void' && 'blacksmith-4vcpu-ubuntu-2404' || matrix.os }}
permissions:
contents: read
# Remote cache uploads authenticate with a GitHub Actions OIDC token.
id-token: write
env:
# Remote task cache, on when the repository variable is set. Pushes and pull requests from
# this repository upload results; fork pull requests get no OIDC token and only download.
VP_REMOTE_CACHE_URL: ${{ vars.VP_REMOTE_CACHE_URL }}
VP_REMOTE_CACHE: ${{ !vars.VP_REMOTE_CACHE_URL && 'off' || (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && 'read-write' || 'read' }}
strategy:
fail-fast: false
matrix:
Expand All @@ -32,7 +39,7 @@ jobs:
- uses: ./.github/actions/test-setup
# Build every playground once per OS for complete build/type coverage.
# Integration tests build their own selected fixtures in separate checkouts.
- run: vp run build:all
- run: vp run --cache build:all
- run: vp run build:docs
- run: node test/check-playground-build-artifacts.mjs
- run: vp run check
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
uses: ./.github/workflows/ci.yml
permissions:
contents: read
# ci.yml's build job uploads to the remote task cache with an OIDC token.
id-token: write

platform-ci:
needs: validate-release
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry-bridge.viteplus.dev/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"type": "module",
"scripts": {
"build": "vp run --filter './packages/**' --parallel build",
"build": "vp run --filter './packages/**' --filter '!./packages/md' build && vp run --filter ./packages/md build",
"build:core": "vp run --filter ./packages/deploy-core --filter ./packages/deploy-cloudflare --filter ./packages/edge --filter ./packages/isr --filter ./packages/platform --filter ./packages/void build",
"build:docs": "vp run --filter ./docs build",
"build:platform": "vp run --filter './platform/packages/**' build",
Expand Down
3 changes: 2 additions & 1 deletion packages/platform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"access": "public"
},
"scripts": {
"build": "vp pack && node scripts/build-runtime.mjs",
"build": "vp pack && node scripts/build-runtime.mjs && vp run build:stamp",
"dev": "vp pack --watch",
"typecheck": "tsc --noEmit"
},
Expand All @@ -51,6 +51,7 @@
},
"devDependencies": {
"@types/node": "catalog:",
"@void/isr": "workspace:*",
"typescript": "catalog:",
"vite-plus": "catalog:",
"wrangler": "catalog:"
Expand Down
5 changes: 2 additions & 3 deletions packages/platform/scripts/build-runtime.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { tmpdir } from 'node:os';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { basename, dirname, join } from 'pathslash';
import { buildSandboxController } from '../../../platform/packages/api/scripts/build-sandbox-controller.mjs';
import { resolvePlatformSourceRevision } from './source-revision.mjs';

const packageRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
const repositoryRoot = join(packageRoot, '..', '..');
Expand Down Expand Up @@ -139,7 +138,6 @@ try {
});
const packageJson = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf8'));
const database = buildDatabaseManifest();
const sourceRevision = resolvePlatformSourceRevision({ repositoryRoot });
const manifest = parsePlatformRuntimeManifest({
artifacts,
assets: {
Expand All @@ -164,7 +162,8 @@ try {
platformVersion: packageJson.version,
safetyProtocols: { sandboxDrain: 3 },
schemaVersion: 2,
sourceRevision,
// scripts/stamp-source-revision.mjs records the revision after this cached build.
sourceRevision: null,
usageProtocolVersion: PLATFORM_USAGE_PROTOCOL_VERSION,
});
writeFileSync(join(runtimeRoot, 'manifest.json'), `${JSON.stringify(manifest, null, 2)}\n`);
Expand Down
19 changes: 19 additions & 0 deletions packages/platform/scripts/stamp-source-revision.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { readFileSync, writeFileSync } from 'node:fs';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { dirname, join } from 'pathslash';
import { resolvePlatformSourceRevision } from './source-revision.mjs';

// Records the source revision in the manifest that scripts/build-runtime.mjs wrote, so a new
// revision reruns only this step and not the cached runtime build.
const packageRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
const repositoryRoot = join(packageRoot, '..', '..');
const manifestPath = join(packageRoot, 'dist', 'runtime', 'manifest.json');
const { parsePlatformRuntimeManifest } = await import(
pathToFileURL(join(packageRoot, 'dist', 'installer.mjs')).href
);

const manifest = parsePlatformRuntimeManifest({
...JSON.parse(readFileSync(manifestPath, 'utf8')),
sourceRevision: resolvePlatformSourceRevision({ repositoryRoot }),
});
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
11 changes: 11 additions & 0 deletions packages/platform/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { defineConfig } from 'vite-plus';

export default defineConfig({
run: {
tasks: {
// The last step of the `build` script: records the source revision in the runtime manifest.
// It isn't cached, so a new revision reruns only this step, and it gets the full
// environment, including VOID_PLATFORM_SOURCE_REVISION.
'build:stamp': {
command: 'node scripts/stamp-source-revision.mjs',
cache: false,
},
},
},
pack: {
entry: [
'src/index.ts',
Expand Down
2 changes: 1 addition & 1 deletion playground/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"type": "module",
"scripts": {
"build": "astro build",
"build": "NODE_USE_SYSTEM_CA=1 astro build",
"dev": "astro dev"
},
"dependencies": {
Expand Down
Loading
Loading