Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Upgrade renovate
  • Loading branch information
Obi-Dann committed May 2, 2023
commit 97b9aa7bdb859964cbddb9cc65aa2a66726c2810
32,447 changes: 10,778 additions & 21,669 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
"renovate": "24.110.0"
"@ungap/structured-clone": "^1.1.0",
"renovate": "35.66.3"
},
"devDependencies": {
"@types/bunyan": "^1.8.8",
Expand Down
8 changes: 5 additions & 3 deletions src/fetchChangelogs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {getManagerConfig, RenovateConfig} from 'renovate/dist/config'
import {getChangeLogJSON} from 'renovate/dist/workers/pr/changelog'
import {getManagerConfig} from 'renovate/dist/config'
import {RenovateConfig} from 'renovate/dist/config/types'
import {getChangeLogJSON} from 'renovate/dist/workers/repository/update/pr/changelog'
import type {UpdatedDependency} from './types'
import type {BranchUpgradeConfig} from 'renovate/dist/workers/types'

export async function fetchChangelogs(
config: RenovateConfig,
Expand All @@ -14,7 +16,7 @@ export async function fetchChangelogs(
...getManagerConfig(config, manager),
...dependency,
...update
})
} as BranchUpgradeConfig)

result.push({...updatedDependency, changelog: logJSON ?? undefined})
}
Expand Down
8 changes: 4 additions & 4 deletions src/getPrCommentBody.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {PackageDependency} from 'renovate/dist/manager/types'
import {ChangeLogResult} from 'renovate/dist/workers/pr/changelog'
import {PackageDependency} from 'renovate/dist/modules/manager/types'
import {ChangeLogResult} from 'renovate/dist/workers/repository/update/pr/changelog'
import {sanitizeMarkdown} from 'renovate/dist/util/markdown'
import type {UpdatedDependency} from './types'

Expand Down Expand Up @@ -40,8 +40,8 @@ function getDependencyChangeContent({
}: UpdatedDependency): {tableRow: string; changelog: string} {
const dependencyLink = getDependencyNameLinked(dependency)
const type = dependency.prettyDepType ?? dependency.depType
const from = update.displayFrom ?? update.currentVersion
const to = update.displayTo ?? update.newVersion
const from = dependency.currentVersion
const to = update.newVersion

const change = `<code>${from}</code> → <code>${to}</code>`

Expand Down
34 changes: 15 additions & 19 deletions src/getRenovateConfig.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {parseConfigs, RenovateConfig} from 'renovate/dist/config'
import {parseConfigs} from 'renovate/dist/workers/global/config/parse'
import {RenovateConfig} from 'renovate/dist/config/types'
import * as core from '@actions/core'
import {setUtilConfig} from 'renovate/dist/util'
import {GlobalConfig} from 'renovate/dist/config/global'
import {getRepositoryConfig} from 'renovate/dist/workers/global'
import {globalInitialize} from 'renovate/dist/workers/global/initialize'
import path from 'path'
import {initRepo} from 'renovate/dist/workers/repository/init'
import simpleGit from 'simple-git'
import simpleGitLib from 'simple-git'

export async function getRenovateConfig({
token,
Expand All @@ -15,25 +16,20 @@ export async function getRenovateConfig({
token: string
owner: string
repo: string
}): Promise<{config: RenovateConfig; git: ReturnType<typeof simpleGit>}> {
}): Promise<{config: RenovateConfig; git: ReturnType<typeof simpleGitLib>}> {
const globalConfig = await parseConfigs(
{
...process.env,
GITHUB_COM_TOKEN: token
},
[
GITHUB_COM_TOKEN: token,
// this might prevent renovate from making changes to the repository
'--dry-run',
'true',
// this prevents renovate from creating the onboarding branch
'--onboarding',
'false',
RENOVATE_DRY_RUN: 'true',
// this prevents renovate from complaining that the onboarding branch does not exist
'--require-config',
'false',
'--token',
token
]
RENOVATE_REQUIRE_CONFIG: 'ignored',
// this prevents renovate from creating the onboarding branch
RENOVATE_ONBOARDING: 'false',
RENOVATE_TOKEN: token
},
[]
)

// not sure if it's necessary, but it probably is, renovate uses this setting to use the locked version as the current version
Expand Down Expand Up @@ -64,9 +60,9 @@ export async function getRenovateConfig({
config.localDir = repositoryPath
}

const git = simpleGit(config.localDir)
const git = simpleGitLib(config.localDir)

await setUtilConfig(config)
GlobalConfig.set(config)

// otherwise initRepo fails
if (githubWorkspacePath) {
Expand Down
12 changes: 6 additions & 6 deletions src/getUpdatedDependencies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import {PackageDependency, PackageFile} from 'renovate/dist/manager/types'
import {
PackageDependency,
PackageFile
} from 'renovate/dist/modules/manager/types'
import type {UpdatedDependency} from './types'

export function* getUpdatedDependencies(
Expand Down Expand Up @@ -57,15 +60,12 @@ export function* getUpdatedDependencies(
manager: managerName,
packageFile: basePackage,
update: {
currentVersion:
baseDependency.lockedVersion ||
baseDependency.currentVersion ||
baseDependency.currentValue,
newValue: headDependency.currentValue || '',
newVersion:
headDependency.lockedVersion ||
headDependency.currentVersion ||
headDependency.currentValue
headDependency.currentValue ||
undefined
},
dependency: baseDependency
}
Expand Down
2 changes: 1 addition & 1 deletion src/githubActionsBunyanStream.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ERROR, INFO, Stream, WARN} from 'bunyan'
import {BunyanRecord} from 'renovate/dist/logger/utils'
import {BunyanRecord} from 'renovate/dist/logger/types'
import * as core from '@actions/core'
import {Writable} from 'stream'

Expand Down
18 changes: 16 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ import {getUpdatedDependencies} from './getUpdatedDependencies'
import {ensurePrCommentRemoved, upsertPrComment} from './updatePrComment'
import {getRunContext} from './getRunContext'

// Github actions can only run on Node 16
// but renovate requires Node 18
// adding a polyfill for onle of the functions that is missing
import structuredClone from '@ungap/structured-clone'
// eslint-disable-next-line no-undef
if (!('structuredClone' in globalThis)) {
// @ts-expect-error -- polyfilling :(
// eslint-disable-next-line no-undef
globalThis.structuredClone = structuredClone
}

async function run(): Promise<void> {
try {
const {baseRef, headRef, pullRequestNumber, repo} = getRunContext()
Expand Down Expand Up @@ -40,7 +51,7 @@ async function run(): Promise<void> {
const baseDependencies = await extractAllDependencies(config)

core.info(`Fetching possible updates for all base ref dependencies`)
await fetchUpdates(config, baseDependencies)
await fetchUpdates(config, baseDependencies.packageFiles)

core.info(`Checking out PR head sha ${headRef}`)
await git.checkout(headRef)
Expand All @@ -49,7 +60,10 @@ async function run(): Promise<void> {
const headDependencies = await extractAllDependencies(config)

let updatedDependencies = [
...getUpdatedDependencies(baseDependencies, headDependencies)
...getUpdatedDependencies(
baseDependencies.packageFiles,
headDependencies.packageFiles
)
]

const github = getOctokit(token)
Expand Down
4 changes: 2 additions & 2 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
LookupUpdate,
PackageDependency,
PackageFile
} from 'renovate/dist/manager/types'
import {ChangeLogResult} from 'renovate/dist/workers/pr/changelog'
} from 'renovate/dist/modules/manager/types'
import {ChangeLogResult} from 'renovate/dist/workers/repository/update/pr/changelog'

export interface UpdatedDependency {
manager: string
Expand Down