Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Binary file modified scripts/android/screenshots/BrowserComponent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified scripts/android/screenshots/MainActivity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 22 additions & 5 deletions scripts/android/tests/PostPrComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private static int execute(String[] args) throws Exception {
Map<String, String> attachmentUrls = new HashMap<>();
if (body.contains("(attachment:")) {
try {
attachmentUrls = publishPreviewsToBranch(previewDir, repo, prNumber, token, !isForkPr);
attachmentUrls = publishPreviewsToBranch(previewDir, repo, prNumber, token, !isForkPr, arguments.previewSubdir);
for (Map.Entry<String, String> entry : attachmentUrls.entrySet()) {
log("Preview available for " + entry.getKey() + ": " + entry.getValue());
}
Expand Down Expand Up @@ -258,7 +258,7 @@ private static String nextLink(String header) {
return null;
}

private static Map<String, String> publishPreviewsToBranch(Path previewDir, String repo, int prNumber, String token, boolean allowPush) throws IOException, InterruptedException {
private static Map<String, String> publishPreviewsToBranch(Path previewDir, String repo, int prNumber, String token, boolean allowPush, String previewSubdir) throws IOException, InterruptedException {
if (previewDir == null || !Files.isDirectory(previewDir)) {
return Map.of();
}
Expand Down Expand Up @@ -302,6 +302,9 @@ private static Map<String, String> publishPreviewsToBranch(Path previewDir, Stri
runGit(worktree, env, "checkout", "--orphan", "cn1ss-previews");
}
Path dest = worktree.resolve("pr-" + prNumber);
if (previewSubdir != null && !previewSubdir.isBlank()) {
dest = dest.resolve(previewSubdir);
}
deleteRecursively(dest);
Files.createDirectories(dest);
for (Path source : imageFiles) {
Expand All @@ -320,11 +323,15 @@ private static Map<String, String> publishPreviewsToBranch(Path previewDir, Stri
log("Preview branch already up-to-date for PR #" + prNumber);
}
String rawBase = "https://raw.githubusercontent.com/" + repo + "/cn1ss-previews/pr-" + prNumber;
if (previewSubdir != null && !previewSubdir.isBlank()) {
rawBase += "/" + previewSubdir;
}
final String rawBaseUrl = rawBase;
Map<String, String> urls = new LinkedHashMap<>();
try (var stream = Files.list(dest)) {
stream.filter(Files::isRegularFile)
.sorted()
.forEach(path -> urls.put(path.getFileName().toString(), rawBase + "/" + path.getFileName()));
.forEach(path -> urls.put(path.getFileName().toString(), rawBaseUrl + "/" + path.getFileName()));
}
deleteRecursively(worktree);
return urls;
Expand Down Expand Up @@ -444,19 +451,22 @@ private static class Arguments {
final Path previewDir;
final String marker;
final String logPrefix;
final String previewSubdir;

private Arguments(Path body, Path previewDir, String marker, String logPrefix) {
private Arguments(Path body, Path previewDir, String marker, String logPrefix, String previewSubdir) {
this.body = body;
this.previewDir = previewDir;
this.marker = marker;
this.logPrefix = logPrefix;
this.previewSubdir = previewSubdir;
}

static Arguments parse(String[] args) {
Path body = null;
Path previewDir = null;
String marker = null;
String logPrefix = null;
String previewSubdir = null;
for (int i = 0; i < args.length; i++) {
String arg = args[i];
switch (arg) {
Expand Down Expand Up @@ -488,6 +498,13 @@ static Arguments parse(String[] args) {
}
logPrefix = args[i];
}
case "--preview-subdir" -> {
if (++i >= args.length) {
System.err.println("Missing value for --preview-subdir");
return null;
}
previewSubdir = args[i];
}
default -> {
System.err.println("Unknown argument: " + arg);
return null;
Expand All @@ -498,7 +515,7 @@ static Arguments parse(String[] args) {
System.err.println("--body is required");
return null;
}
return new Arguments(body, previewDir, marker, logPrefix);
return new Arguments(body, previewDir, marker, logPrefix, previewSubdir);
}
}

Expand Down
Binary file modified scripts/ios/screenshots/BrowserComponent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified scripts/ios/screenshots/MainActivity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions scripts/lib/cn1ss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ cn1ss_post_pr_comment() {
if [ -n "${CN1SS_COMMENT_LOG_PREFIX:-}" ]; then
extra_args+=(--log-prefix "${CN1SS_COMMENT_LOG_PREFIX}")
fi
if [ -n "${CN1SS_PREVIEW_SUBDIR:-}" ]; then
extra_args+=(--preview-subdir "${CN1SS_PREVIEW_SUBDIR}")
fi
GITHUB_TOKEN="$comment_token" cn1ss_java_run "$CN1SS_POST_COMMENT_CLASS" \
--body "$body_file" \
--preview-dir "$preview_dir" \
Expand Down
1 change: 1 addition & 0 deletions scripts/run-android-instrumentation-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ ra_log "STAGE:COMMENT_POST -> Submitting PR feedback"
comment_rc=0
export CN1SS_COMMENT_MARKER="<!-- CN1SS_ANDROID_COMMENT -->"
export CN1SS_COMMENT_LOG_PREFIX="[run-android-device-tests]"
export CN1SS_PREVIEW_SUBDIR="android"
if ! cn1ss_post_pr_comment "$COMMENT_FILE" "$SCREENSHOT_PREVIEW_DIR"; then
comment_rc=$?
fi
Expand Down
1 change: 1 addition & 0 deletions scripts/run-ios-ui-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ ri_log "STAGE:COMMENT_POST -> Submitting PR feedback"
comment_rc=0
export CN1SS_COMMENT_MARKER="<!-- CN1SS_IOS_COMMENT -->"
export CN1SS_COMMENT_LOG_PREFIX="[run-ios-device-tests]"
export CN1SS_PREVIEW_SUBDIR="ios"
if ! cn1ss_post_pr_comment "$COMMENT_FILE" "$SCREENSHOT_PREVIEW_DIR"; then
comment_rc=$?
fi
Expand Down
Loading