-
Notifications
You must be signed in to change notification settings - Fork 994
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into rc-delete-cache-key
- Loading branch information
Showing
973 changed files
with
32,848 additions
and
121,793 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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,36 @@ | ||
name: 🧶 Set up job | ||
description: | | ||
Set up node and yarn cache, then install. This sequence of steps appeared often enough | ||
in many of Redwood's jobs to make it worth abstracting. | ||
inputs: | ||
node-version: | ||
default: 18 | ||
github-token: | ||
default: ${{ github.token }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
|
||
# From https://github.com/actions/cache/blob/main/examples.md#node---yarn-2. | ||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
- uses: actions/cache@v3 | ||
id: yarn-cache | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', '.yarnrc.yml') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- run: yarn install | ||
shell: bash | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.github-token }} |
This file was deleted.
Oops, something went wrong.
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,105 @@ | ||
/* eslint-env node */ | ||
|
||
import http from 'http' | ||
|
||
import { exec } from '@actions/exec' | ||
|
||
console.log( | ||
`Telemetry is being redirected to ${process.env.REDWOOD_REDIRECT_TELEMETRY}` | ||
) | ||
|
||
// All the fields we expect inside a telemetry packet | ||
const expectedPacketFields = [ | ||
'type', | ||
'command', | ||
'duration', | ||
'uid', | ||
'ci', | ||
'redwoodCi', | ||
'NODE_ENV', | ||
'os', | ||
'osVersion', | ||
// "shell", // Not expected on windows | ||
'nodeVersion', | ||
'yarnVersion', | ||
'npmVersion', | ||
'redwoodVersion', | ||
'system', | ||
'complexity', | ||
'sides', | ||
'webBundler', | ||
] | ||
|
||
// Setup fake telemetry server | ||
const server = http.createServer((req, res) => { | ||
let data = '' | ||
req.on('data', (chunk) => { | ||
data += chunk | ||
}) | ||
req.on('end', () => { | ||
res.writeHead(200) | ||
res.end() | ||
|
||
const packet = JSON.parse(data) | ||
|
||
let hasAllFields = true | ||
for (const field of expectedPacketFields) { | ||
if (packet[field] === undefined) { | ||
hasAllFields = false | ||
console.error(`Telemetry packet is missing field "${field}"`) | ||
} | ||
} | ||
|
||
const isCI = packet.ci ?? false | ||
|
||
if (hasAllFields && isCI) { | ||
console.log('Valid telemetry received') | ||
process.exit(0) | ||
} else { | ||
console.error('Invalid telemetry received') | ||
console.error(packet) | ||
process.exit(1) | ||
} | ||
}) | ||
}) | ||
|
||
// Run the fake telemetry server at the redirected location | ||
const host = process.env.REDWOOD_REDIRECT_TELEMETRY.split(':')[1].slice(2) | ||
const port = parseInt(process.env.REDWOOD_REDIRECT_TELEMETRY.split(':')[2]) | ||
server.listen(port, host, () => { | ||
console.log(`Telemetry listener is running on http://${host}:${port}`) | ||
}) | ||
|
||
// Run a command and await output | ||
try { | ||
const mode = process.argv[process.argv.indexOf('--mode') + 1] | ||
let exitCode = 0 | ||
switch (mode) { | ||
case 'crwa': | ||
exitCode = await exec( | ||
`yarn node ./packages/create-redwood-app/dist/create-redwood-app.js ../project-for-telemetry --typescript false --git false --yarn-install true` | ||
) | ||
if (exitCode) { | ||
process.exit(1) | ||
} | ||
break | ||
case 'cli': | ||
exitCode = await exec( | ||
`yarn --cwd ../project-for-telemetry node ../redwood/packages/cli/dist/index.js info` | ||
) | ||
if (exitCode) { | ||
process.exit(1) | ||
} | ||
break | ||
default: | ||
console.error(`Unknown mode: ${mode}`) | ||
process.exit(1) | ||
} | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
|
||
// If we didn't hear the telemetry after 2 mins then let's fail | ||
await new Promise((r) => setTimeout(r, 120_000)) | ||
console.error('No telemetry response within 120 seconds. Failing...') | ||
process.exit(1) |
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
Oops, something went wrong.