Skip to content

Commit dffed4a

Browse files
CI Check
1 parent e74e877 commit dffed4a

3 files changed

Lines changed: 76 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Check Replay Stubs
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'packages/core/android/libs/replay-stubs.jar'
7+
8+
jobs:
9+
danger:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: '20'
22+
23+
- name: Install Danger
24+
run: |
25+
yarn install
26+
yarn add --save-dev danger
27+
28+
- name: Check Replay Stubs
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
run: npx danger ci --dangerfile scripts/check-replay-stubs.js
0 Bytes
Binary file not shown.

scripts/check-replay-stubs.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { danger, warn } from "danger";
2+
import { execSync } from "child_process";
3+
import fs from "fs";
4+
import path from "path";
5+
6+
const replayJarChanged = danger.git.modified_files.includes(
7+
"packages/core/android/libs/replay-stubs.jar"
8+
);
9+
10+
if (!replayJarChanged) {
11+
console.log("replay-stubs.jar not changed, skipping check.");
12+
return;
13+
}
14+
15+
16+
const jsDist = path.join(process.cwd(), "js-dist");
17+
const newSrc = path.join(process.cwd(), "replay-stubs-src");
18+
const oldSrc = path.join(process.cwd(), "replay-stubs-old-src");
19+
20+
[jsDist, newSrc, oldSrc].forEach(dir => {
21+
if (!fs.existsSync(dir)) fs.mkdirSync(dir);
22+
});
23+
24+
// Tool for decompiling JARs.
25+
execSync(`curl -L -o ${jsDist}/jd-cli.zip https://github.com/intoolswetrust/jd-cli/releases/download/jd-cli-1.2.0/jd-cli-1.2.0-dist.zip`);
26+
execSync(`unzip -o ${jsDist}/jd-cli.zip -d ${jsDist}`);
27+
28+
const newJarPath = path.join(jsDist, "replay-stubs.jar");
29+
fs.copyFileSync("packages/core/android/libs/replay-stubs.jar", newJarPath);
30+
31+
const baseJarPath = path.join(jsDist, "replay-stubs-old.jar");
32+
const baseJarContent = execSync(`git show ${danger.github.pr.base.ref}:packages/core/android/libs/replay-stubs.jar`);
33+
fs.writeFileSync(baseJarPath, baseJarContent);
34+
35+
// Decompile both JARs
36+
execSync(`java -jar ${jsDist}/jd-cli.jar -od ${newSrc} ${newJarPath}`);
37+
execSync(`java -jar ${jsDist}/jd-cli.jar -od ${oldSrc} ${baseJarPath}`);
38+
39+
// Compare directory listings
40+
const newListing = execSync(`ls -lR ${newSrc}`).toString();
41+
const oldListing = execSync(`ls -lR ${oldSrc}`).toString();
42+
43+
if (newListing !== oldListing) {
44+
warn(`⚠️ replay-stubs.jar changes detected. Directory listing diff:\n\`\`\`\n${oldListing}\n---\n${newListing}\n\`\`\``);
45+
}

0 commit comments

Comments
 (0)