Skip to content

Commit

Permalink
Upgrade renovate
Browse files Browse the repository at this point in the history
  • Loading branch information
Obi-Dann committed May 2, 2023
1 parent 61ee29f commit 8fe0009
Show file tree
Hide file tree
Showing 9 changed files with 10,823 additions and 21,699 deletions.
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
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
5 changes: 3 additions & 2 deletions src/fetchChangelogs.ts
@@ -1,5 +1,6 @@
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'

export async function fetchChangelogs(
Expand Down
4 changes: 2 additions & 2 deletions src/getPrCommentBody.ts
@@ -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
34 changes: 15 additions & 19 deletions src/getRenovateConfig.ts
@@ -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
5 changes: 4 additions & 1 deletion src/getUpdatedDependencies.ts
@@ -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
2 changes: 1 addition & 1 deletion src/githubActionsBunyanStream.ts
@@ -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
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
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

0 comments on commit 8fe0009

Please sign in to comment.