Skip to content

Commit

Permalink
Merge branch 'main' into rc-delete-cache-key
Browse files Browse the repository at this point in the history
  • Loading branch information
cannikin authored Mar 2, 2023
2 parents 1cf27d7 + 8996510 commit 7a7a12c
Show file tree
Hide file tree
Showing 973 changed files with 32,848 additions and 121,793 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ module.exports = {
'packages/eslint-config/*.js',
'packages/record/src/**',
'packages/telemetry/src/**',
'packages/vite/bins/**',
],
env: {
node: true,
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/check_test_project_fixture/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"@actions/core": "1.10.0",
"@actions/exec": "1.1.1"
},
"packageManager": "yarn@3.3.1"
"packageManager": "yarn@3.4.1"
}
8 changes: 0 additions & 8 deletions .github/actions/get_publish_flags/action.yml

This file was deleted.

57 changes: 0 additions & 57 deletions .github/actions/get_publish_flags/get_publish_flags.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion .github/actions/message_slack_publishing/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ runs:
steps:
- name: Get status emoji
id: get-status-emoji
uses: sergeysova/jq-action@v2.2.1
uses: sergeysova/jq-action@v2.3.0
with:
cmd: 'echo "{ \"success\": \"✅\", \"failure\": \"🚨\" }" | jq .${{ inputs.status }} -r'

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/only_doc_changes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"@actions/core": "1.10.0",
"@actions/exec": "1.1.1"
},
"packageManager": "yarn@3.3.1"
"packageManager": "yarn@3.4.1"
}
36 changes: 36 additions & 0 deletions .github/actions/set-up-job/action.yml
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 }}
32 changes: 0 additions & 32 deletions .github/actions/setup_job/action.yml

This file was deleted.

105 changes: 105 additions & 0 deletions .github/actions/telemetry_check/check.mjs
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)
6 changes: 6 additions & 0 deletions .github/workflows/check-test-project-fixture.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]

# Cancel in-progress runs of this workflow.
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check-test-project-fixture:
name: Check test project fixture
Expand Down
Loading

0 comments on commit 7a7a12c

Please sign in to comment.