Skip to content

Commit

Permalink
Merge branch 'main' of github.com:redwoodjs/redwood into try/dbauth-ssr
Browse files Browse the repository at this point in the history
* 'main' of github.com:redwoodjs/redwood: (26 commits)
  fix(api-server): copy fallback fix from redwoodjs#9272 (redwoodjs#9369)
  fix(deps): update dependency concurrently to v8.2.2 (redwoodjs#9361)
  chore(k6): Fix function context test (redwoodjs#9368)
  feat(cli): Setup command for mailer (redwoodjs#9335)
  feature: Support defer and stream GraphQL Directives in RedwoodRealtime (redwoodjs#9235)
  chore(deps): update dependency rimraf to v5.0.5 (redwoodjs#9360)
  chore(k6): Fix function context test (redwoodjs#9358)
  chore(deps): bump undici from 5.22.1 to 5.26.3 (redwoodjs#9307)
  fix(babel): Fix opentelemetry api wrapping and allow it to be disabled (redwoodjs#9298)
  chore(api-server): remove server survey tests in CI (redwoodjs#9348)
  chore(deps): update babel monorepo to v7.23.2 (redwoodjs#9344)
  chore(deps): bump @babel/traverse from 7.18.9 to 7.23.2 in /docs (redwoodjs#9311)
  chore(deps): update dependency @tsconfig/docusaurus to v2 (redwoodjs#9347)
  fix(deps): update dependency react-player to v2.13.0 (redwoodjs#9346)
  fix(deps): update docusaurus monorepo to v2.4.3 (redwoodjs#9345)
  fix(deps): update dependency @babel/traverse to v7.23.2 [security] (redwoodjs#9322)
  chore: increase server test timeout, fix `yarn build:clean` (redwoodjs#9336)
  feature: Adds utility functions to add envars and update Redwood toml for plugin packages to cli helpers for use in simplifying CLI setup commands (redwoodjs#9324)
  fix(cli): Tailwind setup updates `scaffold.css` when needed (redwoodjs#9290)
  fix(cli): Exit with non-zero exit code when `yarn rw g types` has errors (redwoodjs#9280)
  ...
  • Loading branch information
dac09 committed Nov 2, 2023
2 parents 5f1deed + 7ab07a2 commit bb0b36e
Show file tree
Hide file tree
Showing 292 changed files with 10,697 additions and 1,922 deletions.
67 changes: 67 additions & 0 deletions .github/actions/actionsLib.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-env node */
// @ts-check

import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

Expand Down Expand Up @@ -98,3 +99,69 @@ export async function createCacheKeys({ baseKeyPrefix, distKeyPrefix }) {
distKey
}
}

/**
* @callback ExecInProject
* @param {string} commandLine command to execute (can include additional args). Must be correctly escaped.
* @param {Omit<ExecOptions, "cwd">=} options exec options. See ExecOptions
* @returns {Promise<unknown>} exit code
*/

/**
* @param {string} testProjectPath
* @param {string} fixtureName
* @param {Object} core
* @param {(key: string, value: string) => void} core.setOutput
* @param {ExecInProject} execInProject
* @returns {Promise<void>}
*/
export async function setUpRscTestProject(
testProjectPath,
fixtureName,
core,
execInProject
) {
core.setOutput('test-project-path', testProjectPath)

console.log('rwPath', REDWOOD_FRAMEWORK_PATH)
console.log('testProjectPath', testProjectPath)

const fixturePath = path.join(
REDWOOD_FRAMEWORK_PATH,
'__fixtures__',
fixtureName
)
const rwBinPath = path.join(
REDWOOD_FRAMEWORK_PATH,
'packages/cli/dist/index.js'
)
const rwfwBinPath = path.join(
REDWOOD_FRAMEWORK_PATH,
'packages/cli/dist/rwfw.js'
)

console.log(`Creating project at ${testProjectPath}`)
console.log()
fs.cpSync(fixturePath, testProjectPath, { recursive: true })

console.log(`Adding framework dependencies to ${testProjectPath}`)
await projectDeps(testProjectPath)
console.log()

console.log(`Installing node_modules in ${testProjectPath}`)
await execInProject('yarn install')

console.log(`Building project in ${testProjectPath}`)
await execInProject(`node ${rwBinPath} build -v`)
console.log()

console.log(`Copying over framework files to ${testProjectPath}`)
await execInProject(`node ${rwfwBinPath} project:copy`, {
env: { RWFW_PATH: REDWOOD_FRAMEWORK_PATH },
})
console.log()

// await cache.saveCache([testProjectPath], dependenciesKey)
// console.log(`Cache saved with key: ${dependenciesKey}`)
}

3 changes: 1 addition & 2 deletions .github/actions/check_create_redwood_app/action.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Check create redwood app
description: Determines if the create redwood app JS template should be rebuilt
runs:
# `node18` isn't supported yet
using: node16
using: node20
main: check_create_redwood_app.mjs
inputs:
labels:
Expand Down
3 changes: 1 addition & 2 deletions .github/actions/check_test_project_fixture/action.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Check test project fixture
description: Determines if the test project fixture should be rebuilt
runs:
# `node18` isn't supported yet
using: node16
using: node20
main: check_test_project_fixture.mjs
inputs:
labels:
Expand Down
3 changes: 1 addition & 2 deletions .github/actions/only_doc_changes/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ outputs:
only-doc-changes:
description: If the PR only changes docs
runs:
# `node18` isn't supported yet
using: node16
using: node20
main: only_doc_changes.mjs
3 changes: 1 addition & 2 deletions .github/actions/require-milestone/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ name: Require milestone
description: Ensures that a PR has a valid milestone

runs:
# `node18` isn't supported yet
using: node16
using: node20
main: requireMilestone.mjs
3 changes: 1 addition & 2 deletions .github/actions/rsc_related_changes/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ outputs:
rsc-related-changes:
description: If the PR makes any RSC related changes
runs:
# `node18` isn't supported yet
using: node16
using: node20
main: rsc_related_changes.mjs
2 changes: 2 additions & 0 deletions .github/actions/rsc_related_changes/rsc_related_changes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ async function main() {
changedFile.startsWith('tasks/smoke-tests/rsc/') ||
changedFile.startsWith('tasks/smoke-tests/rsa/') ||
changedFile.startsWith('tasks/smoke-tests/basePlaywright.config.ts') ||
changedFile.startsWith('.github/actions/set-up-rsa-project/') ||
changedFile.startsWith('.github/actions/set-up-rsc-external-packages-project/') ||
changedFile.startsWith('.github/actions/set-up-rsc-project/') ||
changedFile.startsWith('github/actions/rsc_related_changes/') ||
changedFile.startsWith('packages/internal/') ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ Go into the github actions folder
`cd .github/actions`

Then run the following command to execute the action
`node set-up-rsc-from-fixture/setUpRscFixtureLocally.mjs`
`node set-up-rsa-project/setUpRsaProjectLocally.mjs`

## Design

The main logic of the action is in the `setUpRscFixture.mjs` file. To be able
to run that code both on GitHub and locally it uses dependency injection. The
injection is done by `setupRscFixtureLocally.mjs` for when you want to run
the action on your own machine and by `setupRscFixtureGitHib.mjs` when it's
The main logic of the action is in the `../actionsLib.mjs` file. To be able to
run that code both on GitHub and locally it uses dependency injection. The
injection is done by `setupRsaProjectLocally.mjs` for when you want to run the
action on your own machine and by `setupRsaProjectGitHib.mjs` when it's
triggered by GitHub CI.

When doing further changes to the code here it's very important to keep the
DI scripts as light on logic as possible. Ideally all logic is kept to
`setUpRscFixture.mjs` so that the same logic is used both locally and on
GitHub.
`../actionsLib.mjs` so that the same logic is used both locally and on GitHub.
Do note though that more actions share that code, so make sure not to break
the other actions when making changes there.
10 changes: 10 additions & 0 deletions .github/actions/set-up-rsa-project/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Set up RSA test project from fixture
description: Sets up an RSA project for smoke-tests

runs:
using: node20
main: 'setUpRsaProjectGitHub.mjs'

outputs:
test-project-path:
description: Path to the test project
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "set-up-rsc-fixture",
"name": "set-up-rsa-project",
"version": "0.0.0",
"private": true,
"type": "module"
Expand Down
22 changes: 22 additions & 0 deletions .github/actions/set-up-rsa-project/setUpRsaProjectGitHub.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-env node */
// @ts-check

import path from 'node:path'

import core from '@actions/core'

import { createExecWithEnvInCwd, setUpRscTestProject } from '../actionsLib.mjs'

const testProjectAndFixtureName = 'test-project-rsa'
const testProjectPath = path.join(
path.dirname(process.cwd()),
testProjectAndFixtureName
)
const execInProject = createExecWithEnvInCwd(testProjectPath)

setUpRscTestProject(
testProjectPath,
testProjectAndFixtureName,
core,
execInProject
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import path from 'node:path'

import execa from 'execa'

import { main } from './setUpRscFromFixture.mjs'
import { setUpRscTestProject } from '../actionsLib.mjs'

class ExecaError extends Error {
stdout
Expand Down Expand Up @@ -71,9 +71,12 @@ function getExecaOptions(cwd, env = {}) {
}
}

const rsaProjectPath = path.join(
const testProjectAndFixtureName = 'test-project-rsa'

const testProjectPath = path.join(
os.tmpdir(),
'redwood-rsa-project',
'redwood',
testProjectAndFixtureName,
// ":" is problematic with paths
new Date().toISOString().split(':').join('-')
)
Expand All @@ -96,8 +99,13 @@ function execInProject(commandLine, options) {
return exec(
commandLine,
undefined,
getExecaOptions(rsaProjectPath, options?.env)
getExecaOptions(testProjectPath, options?.env)
)
}

main(rsaProjectPath, core, execInProject)
setUpRscTestProject(
testProjectPath,
testProjectAndFixtureName,
core,
execInProject
)
29 changes: 29 additions & 0 deletions .github/actions/set-up-rsc-external-packages-project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# GitHub action to copy a template RSC project to use for testing

This action copies a RW project with Streaming SSR and RSC support already set
up. It's used for RSC smoke tests.

It copies the `__fixtures__/test-project-rsc-external-packages` project, runs
`yarn install` and `project:copy`. Finally it builds the rw app.

## Testing/running locally

Go into the github actions folder
`cd .github/actions`

Then run the following command to execute the action
`node set-up-rsc-external-packages-project/setUpRscExternalPackagesProjectLocally.mjs`

## Design

The main logic of the action is in the `../actionsLib.mjs` file. To be able to
run that code both on GitHub and locally it uses dependency injection. The
injection is done by `setupRscExternalPackagesProjectLocally.mjs` for when you
want to run the action on your own machine and by
`setupRscExternalPackagesProjectGitHib.mjs` when it's triggered by GitHub CI.

When doing further changes to the code here it's very important to keep the
DI scripts as light on logic as possible. Ideally all logic is kept to
`../actionsLib.mjs` so that the same logic is used both locally and on GitHub.
Do note though that more actions share that code, so make sure not to break
the other actions when making changes there.
10 changes: 10 additions & 0 deletions .github/actions/set-up-rsc-external-packages-project/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Set up RSC test project with external packages from fixture
description: Sets up an RSC project that imports external packages for smoke-tests

runs:
using: node20
main: 'setUpRscExternalPackagesProjectGitHub.mjs'

outputs:
test-project-path:
description: Path to the test project
11 changes: 11 additions & 0 deletions .github/actions/set-up-rsc-external-packages-project/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"noEmit": true,
"esModuleInterop": true,
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"skipLibCheck": false,
"jsx": "react-jsx"
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "set-up-rsc-external-packages-project",
"version": "0.0.0",
"private": true,
"type": "module"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-env node */
// @ts-check

import path from 'node:path'

import core from '@actions/core'

import { createExecWithEnvInCwd, setUpRscTestProject } from '../actionsLib.mjs'

const testProjectAndFixtureName = 'test-project-rsc-external-packages'
const testProjectPath = path.join(
path.dirname(process.cwd()),
testProjectAndFixtureName
)
const execInProject = createExecWithEnvInCwd(testProjectPath)

setUpRscTestProject(
testProjectPath,
testProjectAndFixtureName,
core,
execInProject
)
Loading

0 comments on commit bb0b36e

Please sign in to comment.