Skip to content
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

Update GitHub workflows #10

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
120 changes: 85 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@
name: Build

on:
workflow_dispatch:
workflow_call:
inputs:
os:
required: true
type: string
jdk:
required: true
type: string
openjfx:
required: true
type: string
push:
branches: [ main ]
pull_request:
branches: [ main ]

permissions:
actions: read
Expand All @@ -25,53 +17,111 @@ permissions:
statuses: read
security-events: write

env:
DISPLAY: ":99"
XVFB_PARMS: "-screen 0 1920x1080x24 -nolisten unix"
OPENJFX_VERSION: "${{ inputs.openjfx }}"

jobs:
build:
name: Build TestFX on ${{ inputs.os }} JDK ${{ inputs.jdk }} OpenJFX ${{ inputs.openjfx }}
runs-on: ${{ inputs.os }}
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
include:
- os: macos-latest
FILE: openjfx-24+874_headless_mac-aarch64_bin-sdk
- os: ubuntu-latest
FILE: openjfx-24+871_headless_linux-x86_64_bin-sdk
- os: windows-latest
FILE: openjfx-24+875_headless_windows-x86_64_bin-sdk

runs-on: ${{ matrix.os }}
timeout-minutes: 20

steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup JDK
uses: actions/setup-java@v3
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-package: jdk+fx
java-version: ${{ inputs.jdk }}
java-version: 22
distribution: 'temurin'

- name: Download SDK (Linux/macOS)
if: runner.os != 'Windows'
run: |
wget -nv https://download2.gluonhq.com/openjfx/forks/johan/headless/${{ matrix.FILE }}.zip -O ${{ matrix.FILE }}.zip
unzip -q ${{ matrix.FILE }}.zip
echo "JAVAFX_HOME=${{ github.workspace }}/javafx-sdk-24" >> ${GITHUB_ENV}

- name: Download SDK (Windows)
if: runner.os == 'Windows'
run: |
Invoke-WebRequest https://download2.gluonhq.com/openjfx/forks/johan/headless/${{ matrix.FILE }}.zip -OutFile ${{ matrix.FILE }}.zip
Expand-Archive .\${{ matrix.FILE }}.zip -Force
Move-Item -Path .\${{ matrix.FILE }}\javafx-sdk-24 -Destination .\
echo "JAVAFX_HOME=${{ github.workspace }}\javafx-sdk-24" >> $env:GITHUB_ENV

- name: Cache Gradle Resources
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

- name: Set up Virtual Display (for Linux)
if: runner.os == 'Linux'
- name: Build (Linux/macOS)
if: runner.os != 'Windows'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Xvfb ${{env.DISPLAY}} ${{env.XVFB_PARMS}} &
./gradlew -Dtestfx.headless=true versions check

- name: Build
- name: Build (Windows)
if: runner.os == 'Windows'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew versions check
.\gradlew -Dtestfx.headless=true versions check
shell: cmd

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: always()
- name: Publish Test Results (Linux)
uses: EnricoMi/publish-unit-test-result-action/linux@v2
if: runner.os == 'Linux'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
check_name: Unit Test Results (${{ inputs.os }}-java-${{ inputs.jvm }})
check_name: Unit Test Results (${{ runner.os }})
report_individual_runs: true
check_run_annotations_branch: master
check_run_annotations: all tests, skipped tests
files: subprojects/**/build/test-results/**/*.xml

- name: Publish Test Results (macOS)
uses: EnricoMi/publish-unit-test-result-action/macos@v2
if: runner.os == 'macOS'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
check_name: Unit Test Results (${{ runner.os }})
report_individual_runs: true
check_run_annotations_branch: master
check_run_annotations: all tests, skipped tests
files: subprojects/**/build/test-results/**/*.xml

- name: Publish Test Results (Windows)
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: runner.os == 'Windows'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
check_name: Unit Test Results (${{ runner.os }})
report_individual_runs: true
check_run_annotations_branch: master
check_run_annotations: all tests, skipped tests
files: subprojects/**/build/test-results/**/*.xml

- name: Publish Snapshots
if: github.ref == 'refs/heads/master' && runner.os == 'Linux'
run: |
ver=$(./gradlew properties -q | grep "version:" | awk '{print $2}')
if [[ $ver == *"SNAPSHOT"* ]]
then
./gradlew publish -PgluonNexusDeployUsername=NEXUS_USERNAME -PgluonNexusDeployPassword=NEXUS_PASSWORD
fi
shell: bash
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
39 changes: 0 additions & 39 deletions .github/workflows/entry.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: Release

on:
push:
tags: [ '*' ]

permissions:
actions: read
checks: write
contents: read
issues: read
packages: read
pull-requests: write
statuses: read
security-events: write

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: 22
distribution: 'temurin'

- name: Publish Release
run: |
ver=$(./gradlew properties -q | grep "version:" | awk '{print $2}')
if [[ $ver != *"SNAPSHOT"* ]]
then
./gradlew publish -PgluonNexusDeployUsername=NEXUS_USERNAME -PgluonNexusDeployPassword=NEXUS_PASSWORD
fi
shell: bash
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ Finally, you must add a dependency corresponding to the matcher/assertions libra

Download the latest JavaFX SDK that includes the experimental headless platform from here:

- Linux AArch64 [SDK](https://download2.gluonhq.com/openjfx/forks/johan/headless/openjfx-24+77_headless_linux-aarch64_bin-sdk.zip)
- Linux x86_64 [SDK](https://download2.gluonhq.com/openjfx/forks/johan/headless/openjfx-24+77_headless_linux-x86_64_bin-sdk.zip)
- macOS AArch64 [SDK](https://download2.gluonhq.com/openjfx/forks/johan/headless/openjfx-24+77_headless_mac-aarch64_bin-sdk.zip)
- macOS x86_64 [SDK](https://download2.gluonhq.com/openjfx/forks/johan/headless/openjfx-24+77_headless_mac-x86_64_bin-sdk.zip)
- Windows x86_64 [SDK](https://download2.gluonhq.com/openjfx/forks/johan/headless/openjfx-24+77_headless_windows-x86_64_bin-sdk.zip)
- Linux AArch64 [SDK](https://download2.gluonhq.com/openjfx/forks/johan/headless/openjfx-24+872_headless_linux-aarch64_bin-sdk.zip)
- Linux x86_64 [SDK](https://download2.gluonhq.com/openjfx/forks/johan/headless/openjfx-24+871_headless_linux-x86_64_bin-sdk.zip)
- macOS AArch64 [SDK](https://download2.gluonhq.com/openjfx/forks/johan/headless/openjfx-24+874_headless_mac-aarch64_bin-sdk.zip)
- macOS x86_64 [SDK](https://download2.gluonhq.com/openjfx/forks/johan/headless/openjfx-24+873_headless_mac-x86_64_bin-sdk.zip)
- Windows x86_64 [SDK](https://download2.gluonhq.com/openjfx/forks/johan/headless/openjfx-24+875_headless_windows-x86_64_bin-sdk.zip)

Then extract the zip file to a path of your convenience, and set the following environmental variable:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ private static <T> String getErrorMessage(Matcher<? extends T> matcher, T actual
matcher.describeTo(reasonDescription);
errorMessageBuilder.append(reasonDescription.toString())
.append(invert ? " to be false" : "")
.append("\n but: ")
.append(System.lineSeparator())
.append(" but: ")
.append(getActual(matcher, actual));
return errorMessageBuilder.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public static Matcher<Color> isColor(Color color, ColorMatcher colorMatcher) {
*/
public static Matcher<Color> isColor(String namedColor) {
if (!ColorUtils.getNamedColor(namedColor).isPresent()) {
throw new AssertionError("given color name: \"" + namedColor + "\" is not a named color\n" +
throw new AssertionError("given color name: \"" + namedColor + "\" is not a named color" +
System.lineSeparator() +
"See: https://docs.oracle.com/javase/9/docs/api/javafx/scene/doc-files/cssref.html#typecolor");
}
String descriptionText = "is \"" + namedColor + "\"";
Expand All @@ -82,7 +83,7 @@ public static Matcher<Color> hasClosestNamedColor(Color namedColor) {
namedColor.toString().substring(2, 8), 16));
if (!namedColorOptional.isPresent()) {
throw new AssertionError("given color: \"#" + namedColor.toString().substring(2, 8) +
"\" is not a named color\n" +
"\" is not a named color" + System.lineSeparator() +
"See: https://docs.oracle.com/javase/9/docs/api/javafx/scene/doc-files/cssref.html#typecolor");
}
String descriptionText = "has closest named color " + getColorText(namedColor);
Expand All @@ -102,7 +103,8 @@ public static Matcher<Color> hasClosestNamedColor(Color namedColor) {
public static Matcher<Color> hasClosestNamedColor(String namedColor) {
Optional<Color> namedColorOptional = ColorUtils.getNamedColor(namedColor);
if (!namedColorOptional.isPresent()) {
throw new AssertionError("given color name: \"" + namedColor + "\" is not a named color\n" +
throw new AssertionError("given color name: \"" + namedColor + "\" is not a named color" +
System.lineSeparator() +
"See: https://docs.oracle.com/javase/9/docs/api/javafx/scene/doc-files/cssref.html#typecolor");
}
String descriptionText = "has closest named color " + getColorText(namedColorOptional.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ public static Matcher<TextFlow> hasExactlyColoredText(String coloredTextMarkup)
String textColor = fill.toString().substring(2, 8);
if (!ColorUtils.getNamedColor((Color) fill).isPresent()) {
return "impossible to exactly match TextFlow containing colored text: \"" +
((Text) child).getText() + "\" which has color: \"#" + textColor + "\".\n" +
((Text) child).getText() + "\" which has color: \"#" + textColor + "\"." +
System.lineSeparator() +
"This is not a named color. The closest named color is: \"" +
ColorUtils.getClosestNamedColor(Integer.parseInt(textColor, 16)) + "\".\nSee: " +
ColorUtils.getClosestNamedColor(Integer.parseInt(textColor, 16)) + "\"." +
System.lineSeparator() + "See: " +
"https://docs.oracle.com/javase/9/docs/api/javafx/scene/doc-files" +
"/cssref.html#typecolor";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public class WriteRobotImpl implements WriteRobot {
}
catch (NumberFormatException e) {
System.err.println("\"testfx.robot.write_sleep\" property must be a number but was: \"" +
System.getProperty("testfx.robot.write_sleep") + "\".\nUsing default of \"25\" milliseconds.");
System.getProperty("testfx.robot.write_sleep") + "\"." +
System.lineSeparator() + "Using default of \"25\" milliseconds.");
e.printStackTrace();
writeSleep = 25;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,13 @@ private static void blockFxThreadWithSemaphore() {

private static void printException(Throwable e, StackTraceElement[] trace) {
StringBuilder out = new StringBuilder("--- Exception in Async Thread ---\n");
out.append(e.getClass().getName()).append(": ").append(e.getMessage()).append('\n');
out.append(e.getClass().getName()).append(": ").append(e.getMessage()).append(System.lineSeparator());
StackTraceElement[] st = e.getStackTrace();
out.append(printTrace(st));
Throwable cause = e.getCause();
while (cause != null) {
out.append(cause.getClass().getName()).append(": ").append(cause.getMessage()).append('\n');
out.append(cause.getClass().getName()).append(": ").append(cause.getMessage())
.append(System.lineSeparator());
st = cause.getStackTrace();
out.append(printTrace(st));
cause = cause.getCause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void isDefaultButton() {
public void isDefaultButton_fails() {
assertThatThrownBy(() -> assertThat(button).isDefaultButton())
.isExactlyInstanceOf(AssertionError.class)
.hasMessageStartingWith("Expected: Button is default button\n");
.hasMessageStartingWith("Expected: Button is default button" + System.lineSeparator());
}

@Test
Expand All @@ -109,6 +109,6 @@ public void isNotDefaultButton_fails() {
// then:
assertThatThrownBy(() -> assertThat(button).isNotDefaultButton())
.isExactlyInstanceOf(AssertionError.class)
.hasMessageStartingWith("Expected: Button is default button to be false\n");
.hasMessageStartingWith("Expected: Button is default button to be false" + System.lineSeparator());
}
}
Loading