Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): retry detectChanges on error, and await result #9772

Merged
merged 3 commits into from
Dec 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions .github/actions/detect-changes/detectChanges.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { hasCodeChanges } from './cases/code_changes.mjs'
import { rscChanged } from './cases/rsc.mjs'
import { ssrChanged } from './cases/ssr.mjs'

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

Expand Down Expand Up @@ -48,7 +48,7 @@ async function getChangedFiles(page = 1, retries = 0) {
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
let files = []

try {
resp = await fetch(url, {
Expand All @@ -59,6 +59,12 @@ async function getChangedFiles(page = 1, retries = 0) {
},
})

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) {
Expand All @@ -70,8 +76,8 @@ async function getChangedFiles(page = 1, retries = 0) {

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

Expand Down Expand Up @@ -103,8 +109,8 @@ async function main() {

if (changedFiles.length === 0) {
console.log(
'No changed files found. Something must have gone wrong. Fall back to ' +
'running all tests.'
'No changed files found. Something must have gone wrong. Falling back ' +
'to running all tests.'
)
core.setOutput('onlydocs', false)
core.setOutput('rsc', true)
Expand Down
Loading