-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Chore: Add a CI script to check if patches are valid and still applied #15086
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
Open
laurent22
wants to merge
5
commits into
dev
Choose a base branch
from
ci_validate_patches
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
.yarn/patches/react-native-camera-npm-4.2.1-24b2600a7e.patch
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.kt b/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.kt | ||
| index 3bc9143d7ed7923c11e5d73853a285f648e9745e..eb69fdc38be63bcf887cec5294e68b3128255083 100644 | ||
| --- a/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.kt | ||
| +++ b/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.kt | ||
| @@ -7,6 +7,7 @@ | ||
|
|
||
| package com.facebook.react.animated | ||
|
|
||
| +import android.os.Build | ||
| import androidx.annotation.AnyThread | ||
| import androidx.annotation.UiThread | ||
| import com.facebook.common.logging.FLog | ||
| @@ -34,6 +35,7 @@ import com.facebook.react.uimanager.common.ViewUtil | ||
| import java.util.ArrayList | ||
| import java.util.Queue | ||
| import java.util.concurrent.ConcurrentLinkedQueue | ||
| +import java.util.concurrent.LinkedBlockingQueue | ||
| import java.util.concurrent.atomic.AtomicReference | ||
| import kotlin.concurrent.Volatile | ||
|
|
||
| @@ -130,7 +132,12 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) : | ||
| } | ||
|
|
||
| private inner class ConcurrentOperationQueue { | ||
| - private val queue: Queue<UIThreadOperation> = ConcurrentLinkedQueue() | ||
| + // Patch: Use LinkedBlockingQueue instead of ConcurrentLinkedQueue on Android 12. | ||
| + // In some versions of Android, ConcurrentLinkedQueue is known to drop | ||
| + // items, causing crashes. See https://github.com/laurent22/joplin/issues/8425 | ||
| + private val queue: Queue<UIThreadOperation> = if ( | ||
| + Build.VERSION.SDK_INT == 31 || Build.VERSION.SDK_INT == 32 | ||
| + ) LinkedBlockingQueue() else ConcurrentLinkedQueue() | ||
| private var peekedOperation: UIThreadOperation? = null | ||
|
|
||
| @get:AnyThread |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { getRootDir } from '@joplin/utils'; | ||
| import { readFile } from 'fs-extra'; | ||
| import { join } from 'path'; | ||
|
|
||
| // Checks that all patch resolutions in package.json are actually applied in | ||
| // yarn.lock. Catches the case where a dependency version is upgraded but the | ||
| // resolution still targets the old version, causing the patch to silently not | ||
| // apply. | ||
|
|
||
| const main = async () => { | ||
| const rootDir = await getRootDir(); | ||
| const packageJson = JSON.parse(await readFile(join(rootDir, 'package.json'), 'utf8')); | ||
| const yarnLock = await readFile(join(rootDir, 'yarn.lock'), 'utf8'); | ||
|
|
||
| const resolutions: Record<string, string> = packageJson.resolutions ?? {}; | ||
| const errors: string[] = []; | ||
|
laurent22 marked this conversation as resolved.
|
||
|
|
||
| for (const [key, value] of Object.entries(resolutions)) { | ||
| if (!value.startsWith('patch:')) continue; | ||
|
|
||
| // Extract the patch target, e.g. "patch:nanoid@npm%3A3.3.11#..." -> "nanoid@npm:3.3.11" | ||
| const patchTarget = value | ||
| .replace(/^patch:/, '') | ||
| .replace(/#.*$/, '') | ||
| .replace(/%3A/g, ':'); | ||
|
|
||
| // Extract package name and version from the patch target. | ||
| // Supports both "pkg@npm:version" and "pkg@version" formats. | ||
| const match = patchTarget.match(/^(.+)@(?:npm:)?(.+)$/); | ||
| if (!match) { | ||
| errors.push( | ||
| `Invalid patch format for "${key}": "${patchTarget}" does not match ` + | ||
| 'expected pattern "packageName@npm:version" or "packageName@version".', | ||
| ); | ||
| continue; | ||
| } | ||
|
|
||
| const [, packageName, patchVersion] = match; | ||
| const hasNpmPrefix = patchTarget.includes('@npm:'); | ||
|
|
||
| // Check that yarn.lock contains a resolved entry for this exact | ||
| // patch. The lockfile entry looks like: | ||
| // "pkg@patch:pkg@npm%3Aversion#path::..." (with npm prefix) | ||
| // "pkg@patch:pkg@version#path::..." (without npm prefix) | ||
| const versionPart = hasNpmPrefix ? `@npm%3A${patchVersion}` : `@${patchVersion}`; | ||
| const patchPattern = `"${packageName}@patch:${packageName}${versionPart}#`; | ||
| if (!yarnLock.includes(patchPattern)) { | ||
| errors.push( | ||
| `Resolution "${key}" patches ${packageName}@${patchVersion}, ` + | ||
| 'but yarn.lock has no matching entry. The dependency was likely ' + | ||
| 'upgraded — update the patch to target the current version.', | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| if (errors.length > 0) { | ||
| throw new Error(`Yarn patch validation failed:\n\n${errors.join('\n\n')}`); | ||
| } | ||
|
|
||
| console.log(`All ${Object.values(resolutions).filter(v => v.startsWith('patch:')).length} patch resolutions are applied.`); | ||
| }; | ||
|
|
||
| main().catch((error) => { | ||
| console.error(error); | ||
| process.exit(1); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.