|
| 1 | +# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax |
| 2 | +name: Build |
| 3 | + |
| 4 | +on: # https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows |
| 5 | + push: |
| 6 | + branches-ignore: # build all branches except: |
| 7 | + - 'dependabot/**' # prevent GHA triggered twice (once for commit to the branch and once for opening/syncing the PR) |
| 8 | + tags-ignore: # don't build tags |
| 9 | + - '**' |
| 10 | + paths-ignore: |
| 11 | + - '**/*.md' |
| 12 | + - '.github/*.yml' |
| 13 | + - '.github/workflows/codeql.yml' |
| 14 | + - '.github/workflows/licensecheck.yml' |
| 15 | + - '.github/workflows/updateTarget.yml' |
| 16 | + - '**/.project' |
| 17 | + - '**/.settings/*.prefs' |
| 18 | + - '.gitignore' |
| 19 | + - '.actrc' |
| 20 | + - 'Jenkinsfile' |
| 21 | + pull_request: |
| 22 | + paths-ignore: |
| 23 | + - '**/*.md' |
| 24 | + - '.github/*.yml' |
| 25 | + - '.github/workflows/codeql.yml' |
| 26 | + - '.github/workflows/licensecheck.yml' |
| 27 | + - '.github/workflows/updateTarget.yml' |
| 28 | + - '**/.project' |
| 29 | + - '**/.settings/*.prefs' |
| 30 | + - '.gitignore' |
| 31 | + - '.actrc' |
| 32 | + - 'Jenkinsfile' |
| 33 | + workflow_dispatch: |
| 34 | + # https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#workflow_dispatch |
| 35 | + inputs: |
| 36 | + additional_maven_args: |
| 37 | + description: 'Additional Maven Args' |
| 38 | + required: false |
| 39 | + default: '' |
| 40 | + debug-with-ssh: |
| 41 | + description: "When to open an SSH session for post-build debugging:" |
| 42 | + default: never |
| 43 | + type: choice |
| 44 | + options: [ always, on_failure, on_failure_or_cancelled, never ] |
| 45 | + debug-with-ssh-only-for-actor: |
| 46 | + description: "Restrict SSH debug session access to the GitHub user who triggered the workflow" |
| 47 | + default: true |
| 48 | + type: boolean |
| 49 | + |
| 50 | + |
| 51 | +defaults: |
| 52 | + run: |
| 53 | + shell: bash |
| 54 | + |
| 55 | + |
| 56 | +env: |
| 57 | + JAVA_VERSION: 21 |
| 58 | + |
| 59 | + |
| 60 | +jobs: |
| 61 | + |
| 62 | + ########################################################### |
| 63 | + build: |
| 64 | + ########################################################### |
| 65 | + |
| 66 | + strategy: |
| 67 | + fail-fast: false |
| 68 | + matrix: |
| 69 | + os: # https://github.com/actions/runner-images#available-images |
| 70 | + - ubuntu-latest |
| 71 | + - macos-15-intel # Intel |
| 72 | + - macos-latest # ARM |
| 73 | + - windows-latest |
| 74 | + runs-on: ${{ matrix.os }} |
| 75 | + timeout-minutes: 20 |
| 76 | + |
| 77 | + |
| 78 | + steps: |
| 79 | + - name: "Show: GitHub context" |
| 80 | + env: |
| 81 | + GITHUB_CONTEXT: ${{ toJSON(github) }} |
| 82 | + run: printf '%s' "$GITHUB_CONTEXT" | python -m json.tool |
| 83 | + |
| 84 | + |
| 85 | + - name: "Show: environment variables" |
| 86 | + run: env | sort |
| 87 | + |
| 88 | + |
| 89 | + - name: Git Checkout |
| 90 | + uses: actions/checkout@v5 # https://github.com/actions/checkout |
| 91 | + with: |
| 92 | + fetch-depth: 0 # required to prevent tycho-p2-extras-plugin:compare-version-with-baseline potentially failing the build |
| 93 | + |
| 94 | + |
| 95 | + - name: Configure fast APT repository mirror |
| 96 | + if: runner.os == 'Linux' |
| 97 | + uses: vegardit/fast-apt-mirror.sh@v1 |
| 98 | + |
| 99 | + |
| 100 | + - name: "Install: Linux packages 📦" |
| 101 | + if: runner.os == 'Linux' |
| 102 | + run: | |
| 103 | + set -eux |
| 104 | + sudo apt-get install --no-install-recommends -y xvfb |
| 105 | +
|
| 106 | + # prevents: "Failed to execute child process “dbus-launch” (No such file or directory)" |
| 107 | + sudo apt-get install --no-install-recommends -y dbus-x11 |
| 108 | +
|
| 109 | + # prevents: "dbind-WARNING **: 20:17:55.046: AT-SPI: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files" |
| 110 | + # see https://gist.github.com/jeffcogswell/62395900725acef1c0a5a608f7eb7a05 |
| 111 | + sudo apt-get install --no-install-recommends -y at-spi2-core |
| 112 | +
|
| 113 | + # prevents: |
| 114 | + # java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: |
| 115 | + # no swt-pi4-gtk-4956r13 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib |
| 116 | + # no swt-pi4-gtk in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib |
| 117 | + # no swt-pi4 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib |
| 118 | + sudo apt-get install --no-install-recommends -y libswt-gtk-*-java |
| 119 | +
|
| 120 | + # prevents: |
| 121 | + # java.io.IOException: Cannot run program "xdg-mime": error=2, No such file or directory |
| 122 | + # at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143) |
| 123 | + # at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073) |
| 124 | + # at org.eclipse.urischeme.internal.registration.ProcessExecutor.execute(ProcessExecutor.java:36) |
| 125 | + # at org.eclipse.urischeme.internal.registration.RegistrationLinux.getRegisteredDesktopFileForScheme(RegistrationLinux.java:144) |
| 126 | + # at org.eclipse.urischeme.internal.registration.RegistrationLinux.determineHandlerLocation(RegistrationLinux.java:86) |
| 127 | + # at org.eclipse.urischeme.internal.registration.RegistrationLinux.getSchemesInformation(RegistrationLinux.java:75) |
| 128 | + # at org.eclipse.urischeme.AutoRegisterSchemeHandlersJob.run(AutoRegisterSchemeHandlersJob.java:85) |
| 129 | + sudo apt-get install --no-install-recommends -y xdg-utils |
| 130 | +
|
| 131 | +
|
| 132 | + - name: "Install: JDK ${{ env.JAVA_VERSION }} ☕" |
| 133 | + uses: actions/setup-java@v5 # https://github.com/actions/setup-java |
| 134 | + with: |
| 135 | + distribution: temurin |
| 136 | + java-version: ${{ env.JAVA_VERSION }} |
| 137 | + |
| 138 | + |
| 139 | + - name: "Install: Node 22 🍵" |
| 140 | + uses: actions/setup-node@v6 |
| 141 | + with: |
| 142 | + node-version: 22 |
| 143 | + |
| 144 | + |
| 145 | + - name: "Cache: Local Maven Repository" |
| 146 | + uses: actions/cache@v4 |
| 147 | + with: |
| 148 | + # Excluded sub directory not working https://github.com/actions/toolkit/issues/713 |
| 149 | + path: | |
| 150 | + ~/.m2/repository/* |
| 151 | + !~/.m2/repository/.cache/tycho |
| 152 | + !~/.m2/repository/.meta/p2-artifacts.properties |
| 153 | + !~/.m2/repository/p2 |
| 154 | + !~/.m2/repository/*SNAPSHOT* |
| 155 | + key: ${{ runner.os }}-${{ runner.arch }}-repo-mvn-${{ hashFiles('**/pom.xml') }} |
| 156 | + |
| 157 | + |
| 158 | + - name: "Cache: Local Tycho Repository" |
| 159 | + uses: actions/cache@v4 |
| 160 | + with: |
| 161 | + path: | |
| 162 | + ~/.m2/repository/.cache/tycho |
| 163 | + ~/.m2/repository/.meta/p2-artifacts.properties |
| 164 | + ~/.m2/repository/p2 |
| 165 | + key: ${{ runner.os }}-${{ runner.arch }}-repo-tycho-${{ hashFiles('target-platform/target-platform.target') }} |
| 166 | + |
| 167 | + |
| 168 | + - name: "Build with Maven 🔨" |
| 169 | + run: | |
| 170 | + set -euo pipefail |
| 171 | +
|
| 172 | + MAVEN_OPTS="${MAVEN_OPTS:-}" |
| 173 | + if [[ "${{ runner.os }}" == "Windows" ]]; then |
| 174 | + MAVEN_OPTS+=" -Djava.security.egd=file:/dev/urandom" # https://www.baeldung.com/java-security-egd#bd-testing-the-effect-of-javasecurityegd |
| 175 | + else |
| 176 | + MAVEN_OPTS+=" -Djava.security.egd=file:/dev/./urandom" # https://stackoverflow.com/questions/58991966/what-java-security-egd-option-is-for/59097932#59097932 |
| 177 | + fi |
| 178 | + MAVEN_OPTS+=" -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS" # https://stackoverflow.com/questions/5120470/how-to-time-the-different-stages-of-maven-execution/49494561#49494561 |
| 179 | + MAVEN_OPTS+=" -Xmx1024m -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dhttps.protocols=TLSv1.3,TLSv1.2" |
| 180 | + export MAVEN_OPTS |
| 181 | + echo "MAVEN_OPTS: $MAVEN_OPTS" |
| 182 | +
|
| 183 | + if [[ ${ACT:-} == "true" ]]; then # when running locally using nektos/act |
| 184 | + maven_args="-Djgit.dirtyWorkingTree=warning" |
| 185 | + else |
| 186 | + maven_args="--no-transfer-progress" |
| 187 | + fi |
| 188 | +
|
| 189 | + # prevent "org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]" on Linux |
| 190 | + ${{ runner.os == 'Linux' && 'xvfb-run --auto-servernum --server-args="-screen 0 1600x900x24" \' || '' }} |
| 191 | + ./mvnw \ |
| 192 | + --errors \ |
| 193 | + --update-snapshots \ |
| 194 | + --batch-mode \ |
| 195 | + --show-version \ |
| 196 | + -Declipse.p2.mirrors=false \ |
| 197 | + -Dsurefire.rerunFailingTestsCount=3 \ |
| 198 | + $maven_args \ |
| 199 | + ${{ github.event.inputs.additional_maven_args }} \ |
| 200 | + clean verify || ( |
| 201 | + rc=$? |
| 202 | + if [[ ${ACT:-} != "true" ]]; then |
| 203 | + find . -path "*/target/work/data/.metadata/.log" | while IFS= read -r file; do |
| 204 | + echo "::group::$file" |
| 205 | + cat "$file" |
| 206 | + echo "::endgroup::" |
| 207 | + done |
| 208 | + fi |
| 209 | + exit $rc |
| 210 | + ) |
| 211 | +
|
| 212 | +
|
| 213 | + - name: "Upload: Repository Zip" |
| 214 | + uses: actions/upload-artifact@v5 |
| 215 | + if: runner.os == 'Linux' |
| 216 | + with: |
| 217 | + name: org.eclipse.wildwebdeveloper.repository-${{ github.sha }} |
| 218 | + path: repository/target/repository-*.zip |
| 219 | + retention-days: 14 |
| 220 | + |
| 221 | + |
| 222 | + ################################################## |
| 223 | + # Setup SSH debug session |
| 224 | + ################################################## |
| 225 | + - name: "SSH session for debugging: check" |
| 226 | + id: DEBUG_SSH_SESSSION_CHECK |
| 227 | + if: always() |
| 228 | + run: | |
| 229 | + set -eu |
| 230 | +
|
| 231 | + when="${{ inputs.debug-with-ssh }}" |
| 232 | +
|
| 233 | + if [[ $when == "always" ]] || case "${{ job.status }}" in |
| 234 | + success) [[ $when == "always" ]] ;; |
| 235 | + cancelled) [[ $when == "on_failure_or_cancelled" ]] ;; |
| 236 | + failure) [[ $when == "on_failure"* ]] ;; |
| 237 | + esac; then |
| 238 | + echo "start_ssh_session=true" | tee -a "$GITHUB_OUTPUT" |
| 239 | + fi |
| 240 | +
|
| 241 | +
|
| 242 | + - name: "SSH session for debugging: start" |
| 243 | + uses: mxschmitt/action-tmate@v3 # https://github.com/mxschmitt/action-tmate |
| 244 | + if: always() && steps.DEBUG_SSH_SESSSION_CHECK.outputs.start_ssh_session |
| 245 | + with: |
| 246 | + limit-access-to-actor: ${{ inputs.debug-with-ssh-only-for-actor }} |
0 commit comments