Skip to content

Commit

Permalink
Merge branch 'main' into renovate/envelop-core-5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jtoar committed Jan 2, 2024
2 parents d9b91eb + 1075258 commit 9eb1f19
Show file tree
Hide file tree
Showing 526 changed files with 39,268 additions and 33,934 deletions.
2 changes: 1 addition & 1 deletion .github/actions/check_create_redwood_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"@actions/core": "1.10.1",
"@actions/exec": "1.1.1"
},
"packageManager": "yarn@3.7.0"
"packageManager": "yarn@4.0.2"
}
28 changes: 14 additions & 14 deletions .github/actions/check_create_redwood_app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,57 @@
# Manual changes might be lost - proceed with caution!

__metadata:
version: 6
cacheKey: 8c0
version: 8
cacheKey: 10c0

"@actions/core@npm:1.10.1":
version: 1.10.1
resolution: "@actions/core@npm:1.10.1"
dependencies:
"@actions/http-client": ^2.0.1
uuid: ^8.3.2
checksum: 7a61446697a23dcad3545cf0634dedbdedf20ae9a0ee6ee977554589a15deb4a93593ee48a41258933d58ce0778f446b0d2c162b60750956fb75e0b9560fb832
"@actions/http-client": "npm:^2.0.1"
uuid: "npm:^8.3.2"
checksum: 8c0/7a61446697a23dcad3545cf0634dedbdedf20ae9a0ee6ee977554589a15deb4a93593ee48a41258933d58ce0778f446b0d2c162b60750956fb75e0b9560fb832
languageName: node
linkType: hard

"@actions/exec@npm:1.1.1":
version: 1.1.1
resolution: "@actions/exec@npm:1.1.1"
dependencies:
"@actions/io": ^1.0.1
checksum: 4a09f6bdbe50ce68b5cf8a7254d176230d6a74bccf6ecc3857feee209a8c950ba9adec87cc5ecceb04110182d1c17117234e45557d72fde6229b7fd3a395322a
"@actions/io": "npm:^1.0.1"
checksum: 8c0/4a09f6bdbe50ce68b5cf8a7254d176230d6a74bccf6ecc3857feee209a8c950ba9adec87cc5ecceb04110182d1c17117234e45557d72fde6229b7fd3a395322a
languageName: node
linkType: hard

"@actions/http-client@npm:^2.0.1":
version: 2.0.1
resolution: "@actions/http-client@npm:2.0.1"
dependencies:
tunnel: ^0.0.6
checksum: b58987ba2f53d7988f612ede7ff834573a3360c21f8fdea9fea92f26ada0fd0efafb22aa7d83f49c18965a5b765775d5253e2edb8d9476d924c4b304ef726b67
tunnel: "npm:^0.0.6"
checksum: 8c0/b58987ba2f53d7988f612ede7ff834573a3360c21f8fdea9fea92f26ada0fd0efafb22aa7d83f49c18965a5b765775d5253e2edb8d9476d924c4b304ef726b67
languageName: node
linkType: hard

"@actions/io@npm:^1.0.1":
version: 1.1.2
resolution: "@actions/io@npm:1.1.2"
checksum: 61c871bbee1cf58f57917d9bb2cf6bb7ea4dc40de3f65c7fb4ec619ceff57fc98f56be9cca2d476b09e7a96e1cba0d88cd125c4f690d384b9483935186f256c1
checksum: 8c0/61c871bbee1cf58f57917d9bb2cf6bb7ea4dc40de3f65c7fb4ec619ceff57fc98f56be9cca2d476b09e7a96e1cba0d88cd125c4f690d384b9483935186f256c1
languageName: node
linkType: hard

"check_test_project_fixture@workspace:.":
version: 0.0.0-use.local
resolution: "check_test_project_fixture@workspace:."
dependencies:
"@actions/core": 1.10.1
"@actions/exec": 1.1.1
"@actions/core": "npm:1.10.1"
"@actions/exec": "npm:1.1.1"
languageName: unknown
linkType: soft

"tunnel@npm:^0.0.6":
version: 0.0.6
resolution: "tunnel@npm:0.0.6"
checksum: e27e7e896f2426c1c747325b5f54efebc1a004647d853fad892b46d64e37591ccd0b97439470795e5262b5c0748d22beb4489a04a0a448029636670bfd801b75
checksum: 8c0/e27e7e896f2426c1c747325b5f54efebc1a004647d853fad892b46d64e37591ccd0b97439470795e5262b5c0748d22beb4489a04a0a448029636670bfd801b75
languageName: node
linkType: hard

Expand All @@ -61,6 +61,6 @@ __metadata:
resolution: "uuid@npm:8.3.2"
bin:
uuid: dist/bin/uuid
checksum: bcbb807a917d374a49f475fae2e87fdca7da5e5530820ef53f65ba1d12131bd81a92ecf259cc7ce317cbe0f289e7d79fdfebcef9bfa3087c8c8a2fa304c9be54
checksum: 8c0/bcbb807a917d374a49f475fae2e87fdca7da5e5530820ef53f65ba1d12131bd81a92ecf259cc7ce317cbe0f289e7d79fdfebcef9bfa3087c8c8a2fa304c9be54
languageName: node
linkType: hard
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.1",
"@actions/exec": "1.1.1"
},
"packageManager": "yarn@3.7.0"
"packageManager": "yarn@4.0.2"
}
28 changes: 14 additions & 14 deletions .github/actions/check_test_project_fixture/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,57 @@
# Manual changes might be lost - proceed with caution!

__metadata:
version: 6
cacheKey: 8c0
version: 8
cacheKey: 10c0

"@actions/core@npm:1.10.1":
version: 1.10.1
resolution: "@actions/core@npm:1.10.1"
dependencies:
"@actions/http-client": ^2.0.1
uuid: ^8.3.2
checksum: 7a61446697a23dcad3545cf0634dedbdedf20ae9a0ee6ee977554589a15deb4a93593ee48a41258933d58ce0778f446b0d2c162b60750956fb75e0b9560fb832
"@actions/http-client": "npm:^2.0.1"
uuid: "npm:^8.3.2"
checksum: 8c0/7a61446697a23dcad3545cf0634dedbdedf20ae9a0ee6ee977554589a15deb4a93593ee48a41258933d58ce0778f446b0d2c162b60750956fb75e0b9560fb832
languageName: node
linkType: hard

"@actions/exec@npm:1.1.1":
version: 1.1.1
resolution: "@actions/exec@npm:1.1.1"
dependencies:
"@actions/io": ^1.0.1
checksum: 4a09f6bdbe50ce68b5cf8a7254d176230d6a74bccf6ecc3857feee209a8c950ba9adec87cc5ecceb04110182d1c17117234e45557d72fde6229b7fd3a395322a
"@actions/io": "npm:^1.0.1"
checksum: 8c0/4a09f6bdbe50ce68b5cf8a7254d176230d6a74bccf6ecc3857feee209a8c950ba9adec87cc5ecceb04110182d1c17117234e45557d72fde6229b7fd3a395322a
languageName: node
linkType: hard

"@actions/http-client@npm:^2.0.1":
version: 2.0.1
resolution: "@actions/http-client@npm:2.0.1"
dependencies:
tunnel: ^0.0.6
checksum: b58987ba2f53d7988f612ede7ff834573a3360c21f8fdea9fea92f26ada0fd0efafb22aa7d83f49c18965a5b765775d5253e2edb8d9476d924c4b304ef726b67
tunnel: "npm:^0.0.6"
checksum: 8c0/b58987ba2f53d7988f612ede7ff834573a3360c21f8fdea9fea92f26ada0fd0efafb22aa7d83f49c18965a5b765775d5253e2edb8d9476d924c4b304ef726b67
languageName: node
linkType: hard

"@actions/io@npm:^1.0.1":
version: 1.1.2
resolution: "@actions/io@npm:1.1.2"
checksum: 61c871bbee1cf58f57917d9bb2cf6bb7ea4dc40de3f65c7fb4ec619ceff57fc98f56be9cca2d476b09e7a96e1cba0d88cd125c4f690d384b9483935186f256c1
checksum: 8c0/61c871bbee1cf58f57917d9bb2cf6bb7ea4dc40de3f65c7fb4ec619ceff57fc98f56be9cca2d476b09e7a96e1cba0d88cd125c4f690d384b9483935186f256c1
languageName: node
linkType: hard

"check_test_project_fixture@workspace:.":
version: 0.0.0-use.local
resolution: "check_test_project_fixture@workspace:."
dependencies:
"@actions/core": 1.10.1
"@actions/exec": 1.1.1
"@actions/core": "npm:1.10.1"
"@actions/exec": "npm:1.1.1"
languageName: unknown
linkType: soft

"tunnel@npm:^0.0.6":
version: 0.0.6
resolution: "tunnel@npm:0.0.6"
checksum: e27e7e896f2426c1c747325b5f54efebc1a004647d853fad892b46d64e37591ccd0b97439470795e5262b5c0748d22beb4489a04a0a448029636670bfd801b75
checksum: 8c0/e27e7e896f2426c1c747325b5f54efebc1a004647d853fad892b46d64e37591ccd0b97439470795e5262b5c0748d22beb4489a04a0a448029636670bfd801b75
languageName: node
linkType: hard

Expand All @@ -61,6 +61,6 @@ __metadata:
resolution: "uuid@npm:8.3.2"
bin:
uuid: dist/bin/uuid
checksum: bcbb807a917d374a49f475fae2e87fdca7da5e5530820ef53f65ba1d12131bd81a92ecf259cc7ce317cbe0f289e7d79fdfebcef9bfa3087c8c8a2fa304c9be54
checksum: 8c0/bcbb807a917d374a49f475fae2e87fdca7da5e5530820ef53f65ba1d12131bd81a92ecf259cc7ce317cbe0f289e7d79fdfebcef9bfa3087c8c8a2fa304c9be54
languageName: node
linkType: hard
40 changes: 40 additions & 0 deletions .github/actions/detect-changes/cases/code_changes.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Detects if the given file path points to a code file (as apposed to a docs
* file)
*/
function isCodeFile(filePath) {
if (filePath.startsWith('docs')) {
return false
}

if (
[
'CHANGELOG.md',
'CODE_OF_CONDUCT.md',
'CONTRIBUTING.md',
'CONTRIBUTORS.md',
'LICENSE',
'README.md',
'SECURITY.md',
].includes(filePath)
) {
return false
}

return true
}

/**
* Checks if the given array of file paths contains any files with potential
* code changes
*/
export function hasCodeChanges(changedFiles) {
return changedFiles.some((file) => {
if (isCodeFile(file)) {
console.log(`Found code file: ${file}`)
return true
}

return false
})
}
33 changes: 0 additions & 33 deletions .github/actions/detect-changes/cases/onlydocs.mjs

This file was deleted.

3 changes: 2 additions & 1 deletion .github/actions/detect-changes/cases/ssr.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export function ssrChanged(changedFiles){
for (const changedFile of changedFiles) {
if (
changedFile.startsWith('tasks/smoke-tests/streaming-ssr') ||
changedFile.startsWith('tasks/smoke-tests/basePlaywright.config.ts') ||
changedFile === 'tasks/smoke-tests/basePlaywright.config.ts' ||
changedFile === 'tasks/test-project/codemods/delayedPage.js' ||
changedFile.startsWith('packages/internal/') ||
changedFile.startsWith('packages/project-config/') ||
changedFile.startsWith('packages/web/') ||
Expand Down
113 changes: 105 additions & 8 deletions .github/actions/detect-changes/detectChanges.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,98 @@
import fs from 'node:fs'

import core from '@actions/core'
import { exec, getExecOutput } from '@actions/exec'
import { onlyDocsChanged } from './cases/onlydocs.mjs'
import { hasCodeChanges } from './cases/code_changes.mjs'
import { rscChanged } from './cases/rsc.mjs'
import { ssrChanged } from './cases/ssr.mjs'

const getPrNumber = () => {
// Example GITHUB_REF refs/pull/9544/merge
const result = /refs\/pull\/(\d+)\/merge/g.exec(process.env.GITHUB_REF)

let prNumber = result?.[1]

if (!prNumber) {
try {
// Example GITHUB_EVENT_PATH
// /home/runner/work/_temp/_github_workflow/event.json
const ev = JSON.parse(
fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8')
)
prNumber = ev.pull_request?.number
} catch {
// fall through
}
}

if (!prNumber) {
throw new Error('Could not find the PR number')
}

return prNumber
}

async function getChangedFiles(page = 1, retries = 0) {
const prNumber = getPrNumber()

if (retries) {
console.log(
`Retry ${retries}: Getting changed files for PR ${prNumber} (page ${page})`
)
} else {
console.log(`Getting changed files for PR ${prNumber} (page ${page})`)
}

let changedFiles = []

// Query the GitHub API to get the changed files in the PR
const githubToken = process.env.GITHUB_TOKEN
const url = `https://api.github.com/repos/redwoodjs/redwood/pulls/${prNumber}/files?per_page=100&page=${page}`
let resp
let files = []

try {
resp = await fetch(url, {
headers: {
Authorization: githubToken ? `Bearer ${githubToken}` : undefined,
['X-GitHub-Api-Version']: '2022-11-28',
Accept: 'application/vnd.github+json',
},
})

if (!resp.ok) {
console.log()
console.error('Response not ok')
console.log('resp', resp)
}

const json = await resp.json()
files = json.map((file) => file.filename) || []
} catch (e) {
if (retries >= 3) {
console.error(e)

console.log()
console.log('Too many retries, giving up.')

return []
} else {
await new Promise((resolve) => setTimeout(resolve, 3000 * retries))
files = await getChangedFiles(page, ++retries)
}
}

changedFiles = changedFiles.concat(files)

// Look at the headers to see if the result is paginated
const linkHeader = resp.headers.get('link')
if (linkHeader && linkHeader.includes('rel="next"')) {
const files = await getChangedFiles(page + 1)
changedFiles = changedFiles.concat(files)
}

return changedFiles
}

async function main() {
const branch = process.env.GITHUB_BASE_REF

Expand All @@ -15,14 +104,22 @@ async function main() {
return
}

await exec(`git fetch origin ${branch}`)

const { stdout } = await getExecOutput(`git diff origin/${branch} --name-only`)
const changedFiles = stdout.toString().trim().split('\n').filter(Boolean)
const changedFiles = await getChangedFiles()
console.log(`${changedFiles.length} changed files`)

const onlyDocs = onlyDocsChanged(changedFiles)
if(onlyDocs){
if (changedFiles.length === 0) {
console.log(
'No changed files found. Something must have gone wrong. Falling back ' +
'to running all tests.'
)
core.setOutput('onlydocs', false)
core.setOutput('rsc', true)
core.setOutput('ssr', true)
return
}

if (!hasCodeChanges(changedFiles)) {
console.log('No code changes detected, only docs')
core.setOutput('onlydocs', true)
core.setOutput('rsc', false)
core.setOutput('ssr', false)
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/detect-changes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"@actions/core": "1.10.1",
"@actions/exec": "1.1.1"
},
"packageManager": "yarn@3.7.0"
"packageManager": "yarn@4.0.2"
}
Loading

0 comments on commit 9eb1f19

Please sign in to comment.