-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nathan Hammond
authored and
Nathan Hammond
committed
May 17, 2023
1 parent
165a33b
commit deee5f0
Showing
3 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Turborepo Compare Cache Item | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: Turborepo release to test. | ||
type: string | ||
default: "canary" | ||
|
||
jobs: | ||
generate_cache_artifact: | ||
strategy: | ||
matrix: | ||
os: [macos-latest, ubuntu-latest, windows-latest] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: create-turbo | ||
run: | | ||
npm install -g pnpm turbo@${{ inputs.version }} | ||
pnpm dlx create-turbo@${{ inputs.version }} my-turborepo pnpm | ||
- name: Run build | ||
run: | | ||
cd my-turborepo | ||
turbo run build --filter=docs --filter=web --summarize --skip-infer -vvv | ||
- name: Grab Turborepo artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: cache-item-${{ matrix.os }}-${{ inputs.version }} | ||
path: | | ||
my-turborepo/node_modules/.cache/turbo | ||
my-turborepo/.turbo/runs | ||
retention-days: 1 | ||
|
||
use_cache_artifact: | ||
needs: generate_cache_artifact | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [macos-latest, ubuntu-latest, windows-latest] | ||
cache_os: [macos-latest, ubuntu-latest, windows-latest] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: create-turbo | ||
run: | | ||
npm install -g pnpm turbo@${{ inputs.version }} | ||
pnpm dlx create-turbo@${{ inputs.version }} my-turborepo pnpm | ||
- name: Download cache artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: cache-item-${{ matrix.cache_os }}-${{ inputs.version }} | ||
path: my-turborepo | ||
|
||
- name: Check for cache hit | ||
run: | | ||
cd my-turborepo | ||
rm .turbo/runs/*.json | ||
turbo run build --filter=docs --filter=web --summarize --skip-infer -vvv | ||
cat .turbo/runs/*.json | jq -e '.execution.cached == 2' | ||
- name: Check for functional server | ||
run: | | ||
curl https://raw.githubusercontent.com/vercel/turbo/main/scripts/server.js -O | ||
node server.js my-turborepo/apps/docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env node | ||
|
||
const { spawn } = require("child_process"); | ||
const { platform } = require("process"); | ||
|
||
const path = process.argv[2]; | ||
|
||
async function main() { | ||
let errored = false; | ||
|
||
await new Promise((resolve) => { | ||
const command = platform === "win32" ? "pnpm.cmd" : "pnpm"; | ||
const server = spawn(command, ["run", "start"], { cwd: path }); | ||
|
||
server.stdout.on("data", (data) => { | ||
console.log("stdout:"); | ||
console.log(`${data}`); | ||
|
||
// Stable for 5s. | ||
setTimeout(() => { | ||
server.kill(); | ||
}, 5000); | ||
}); | ||
|
||
server.stderr.on("data", (data) => { | ||
console.log("stderr:"); | ||
console.log(`${data}`); | ||
|
||
errored = true; | ||
server.kill(); | ||
}); | ||
|
||
server.on("exit", () => { | ||
console.log(`exit: ${+errored}`); | ||
resolve(); | ||
}); | ||
}); | ||
|
||
process.exit(errored); | ||
} | ||
|
||
main(); |