Skip to content

Commit beecc07

Browse files
authored
Merge pull request #732 from gre/ci-rn-compat
ci: weekly React Native compatibility watch
2 parents e070ae4 + 27350e1 commit beecc07

2 files changed

Lines changed: 530 additions & 0 deletions

File tree

‎.github/scripts/rn-compat-app.sh‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
# Creates a fresh React Native app at a given version, installs the packed
3+
# library into it and wires a capture into App.tsx. The JS checks and native
4+
# builds are run by the caller (.github/workflows/rn-compat.yml).
5+
#
6+
# Usage: rn-compat-app.sh <react-native version> <library .tgz> <app dir>
7+
set -euo pipefail
8+
9+
RN_VERSION="$1"
10+
TARBALL="$(cd "$(dirname "$2")" && pwd)/$(basename "$2")"
11+
APP_DIR="$3"
12+
13+
npx --yes @react-native-community/cli@latest init RNCompat \
14+
--version "$RN_VERSION" \
15+
--directory "$APP_DIR" \
16+
--skip-git-init \
17+
--install-pods false \
18+
--pm npm
19+
20+
cd "$APP_DIR"
21+
# Prereleases (RCs, nightlies) never satisfy the `>=0.80.0` peer range; for a
22+
# stable release a peer conflict is a real finding, so keep npm strict.
23+
peer_flags=()
24+
if [[ "$RN_VERSION" == *-* ]]; then
25+
peer_flags=(--legacy-peer-deps)
26+
fi
27+
npm install --no-audit --no-fund ${peer_flags[@]+"${peer_flags[@]}"} "$TARBALL"
28+
29+
# Use the public API so the bundle and type-check exercise it.
30+
cat > App.tsx <<'EOF'
31+
import React, { useRef } from 'react';
32+
import { Button, Text, View } from 'react-native';
33+
import ViewShot, { captureRef, captureScreen } from 'react-native-view-shot';
34+
35+
export default function App(): React.JSX.Element {
36+
const ref = useRef<React.ComponentRef<typeof View>>(null);
37+
return (
38+
<ViewShot style={{ flex: 1 }} options={{ format: 'png' }}>
39+
<View ref={ref} collapsable={false}>
40+
<Text>react-native-view-shot compat</Text>
41+
</View>
42+
<Button
43+
title="capture"
44+
onPress={async () => {
45+
console.log(await captureRef(ref, { format: 'png', width: 100 }));
46+
console.log(await captureScreen({ format: 'jpg' }));
47+
}}
48+
/>
49+
</ViewShot>
50+
);
51+
}
52+
EOF
53+
54+
# Surface javac deprecation details (by default it only prints a one-line
55+
# "Note: Some input files use or override a deprecated API.").
56+
if [ -f android/build.gradle ]; then
57+
cat >> android/build.gradle <<'EOF'
58+
59+
allprojects {
60+
tasks.withType(JavaCompile).configureEach {
61+
options.compilerArgs += ["-Xlint:deprecation", "-Xlint:unchecked"]
62+
}
63+
}
64+
EOF
65+
else
66+
echo "android/build.gradle not found (Kotlin DSL template?): javac deprecation details won't be listed" >&2
67+
fi

0 commit comments

Comments
 (0)