diff --git a/.actrc b/.actrc new file mode 100644 index 000000000..ea9138c04 --- /dev/null +++ b/.actrc @@ -0,0 +1,3 @@ +# config file for https://github.com/nektos/act +--matrix os:ubuntu-latest +-W .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..a4b0de717 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,235 @@ +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions +name: Build + +on: + push: + branches-ignore: # build all branches except: + - 'dependabot/**' # prevent GHA triggered twice (once for commit to the branch and once for opening/syncing the PR) + tags-ignore: # don't build tags + - '**' + paths-ignore: + - '**/*.md' + - '.github/*.yml' + - '.github/workflows/licensecheck.yml' + - '**/.project' + - '**/.settings/*.prefs' + - '.gitignore' + - '.actrc' + - 'Jenkinsfile' + pull_request: + paths-ignore: + - '**/*.md' + - '.github/*.yml' + - '.github/workflows/licensecheck.yml' + - '**/.project' + - '**/.settings/*.prefs' + - '.gitignore' + - '.actrc' + - 'Jenkinsfile' + workflow_dispatch: + # https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/ + inputs: + additional_maven_args: + description: 'Additional Maven Args' + required: false + default: '' + debug-with-ssh: + description: "Start an SSH session for debugging purposes at the end of the build:" + default: never + type: choice + options: [ always, on_failure, on_failure_or_cancelled, never ] + debug-with-ssh-only-for-actor: + description: "Limit access to the SSH session to the GitHub user that triggered the job." + default: true + type: boolean + + +defaults: + run: + shell: bash + + +env: + JAVA_VERSION: 17 + + +jobs: + + ########################################################### + build: + ########################################################### + + strategy: + fail-fast: false + matrix: + os: + # https://github.com/actions/runner-images#available-images + - ubuntu-latest + - macos-12 # Intel + - macos-14 # ARM + - windows-latest + runs-on: ${{ matrix.os }} + timeout-minutes: 15 + + steps: + - name: "Show: GitHub context" + run: echo '${{ toJSON(github) }}' + + + - name: "Show: environment variables" + run: env | sort + + + - name: Git Checkout + uses: actions/checkout@v4 # https://github.com/actions/checkout + with: + fetch-depth: 0 # required to prevent tycho-p2-extras-plugin:compare-version-with-baseline potentially failing the build + + + - name: Configure fast APT repository mirror + if: runner.os == 'Linux' + uses: vegardit/fast-apt-mirror.sh@v1 + + + - name: "Install: Linux packages 📦" + if: runner.os == 'Linux' + run: | + set -eux + sudo apt-get install --no-install-recommends -y xvfb + + # prevents: "Failed to execute child process “dbus-launch” (No such file or directory)" + sudo apt-get install --no-install-recommends -y dbus-x11 + + # 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" + # see https://gist.github.com/jeffcogswell/62395900725acef1c0a5a608f7eb7a05 + sudo apt-get install --no-install-recommends -y at-spi2-core + + # prevents: + # java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: + # no swt-pi4-gtk-4956r13 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib + # no swt-pi4-gtk in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib + # no swt-pi4 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib + sudo apt-get install --no-install-recommends -y libswt-gtk-*-java + + # prevents: + # java.io.IOException: Cannot run program "xdg-mime": error=2, No such file or directory + # at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143) + # at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073) + # at org.eclipse.urischeme.internal.registration.ProcessExecutor.execute(ProcessExecutor.java:36) + # at org.eclipse.urischeme.internal.registration.RegistrationLinux.getRegisteredDesktopFileForScheme(RegistrationLinux.java:144) + # at org.eclipse.urischeme.internal.registration.RegistrationLinux.determineHandlerLocation(RegistrationLinux.java:86) + # at org.eclipse.urischeme.internal.registration.RegistrationLinux.getSchemesInformation(RegistrationLinux.java:75) + # at org.eclipse.urischeme.AutoRegisterSchemeHandlersJob.run(AutoRegisterSchemeHandlersJob.java:85) + sudo apt-get install --no-install-recommends -y xdg-utils + + # required by org.eclipse.lsp4e.test.hover.HoverTest#testIntroUrlLink + # see https://www.eclipse.org/swt/faq.php#browserwebkitgtk + sudo apt-get install -y libwebkit2gtk-4.1-0 + + + - name: "Install: JDK ${{ env.JAVA_VERSION }} ☕" + uses: actions/setup-java@v4 # https://github.com/actions/setup-java + with: + distribution: temurin + java-version: ${{ env.JAVA_VERSION }} + + + - name: "Cache: Local Maven Repository" + uses: actions/cache@v4 + with: + # Excluded sub directory not working https://github.com/actions/toolkit/issues/713 + path: | + ~/.m2/repository/* + !~/.m2/repository/.cache/tycho + !~/.m2/repository/.meta/p2-artifacts.properties + !~/.m2/repository/p2 + !~/.m2/repository/*SNAPSHOT* + key: ${{ matrix.os }}-${{ runner.arch }}-repo-mvn-${{ hashFiles('**/pom.xml') }} + + + - name: "Cache: Local Tycho Repository" + uses: actions/cache@v4 + with: + path: | + ~/.m2/repository/.cache/tycho + ~/.m2/repository/.meta/p2-artifacts.properties + ~/.m2/repository/p2 + key: ${{ matrix.os }}-${{ runner.arch }}-repo-tycho-${{ hashFiles('target-platforms/target-platform-latest/target-platform-latest.target') }} + + + - name: "Install: Maven" + uses: stCarolas/setup-maven@v5 # https://github.com/stCarolas/setup-maven + with: + maven-version: 3.9.6 + + + - name: "Build with Maven 🔨" + run: | + set -eu + + MAVEN_OPTS="${MAVEN_OPTS:-}" + if [[ "${{ runner.os }}" == "Windows" ]]; then + MAVEN_OPTS+=" -Djava.security.egd=file:/dev/urandom" # https://www.baeldung.com/java-security-egd#bd-testing-the-effect-of-javasecurityegd + else + MAVEN_OPTS+=" -Djava.security.egd=file:/dev/./urandom" # https://stackoverflow.com/questions/58991966/what-java-security-egd-option-is-for/59097932#59097932 + fi + 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 + MAVEN_OPTS+=" -Xmx1024m -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dhttps.protocols=TLSv1.3,TLSv1.2" + export MAVEN_OPTS + echo "MAVEN_OPTS: $MAVEN_OPTS" + + if [[ ${ACT:-} == "true" ]]; then # when running locally using nektos/act + maven_args="-Djgit.dirtyWorkingTree=warning" + else + maven_args="--no-transfer-progress" + fi + + # prevent "org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]" on Linux + ${{ runner.os == 'Linux' && 'xvfb-run --auto-servernum --server-args="-screen 0 1600x900x24" \' || '' }} + mvn \ + --errors \ + --update-snapshots \ + --batch-mode \ + --show-version \ + -Dtycho.disableP2Mirrors=true \ + -Dsurefire.rerunFailingTestsCount=3 \ + $maven_args \ + ${{ github.event.inputs.additional_maven_args }} \ + clean verify || ( + rc=$? + if [[ ${ACT:-} != "true" ]]; then + find . -path "*/target/work/data/.metadata/.log" | while IFS= read -r file; do + echo "::group::$file" + cat "$file" + echo "::endgroup::" + done + fi + exit $rc + ) + + + ################################################## + # Setup SSH debug session + ################################################## + - name: "SSH session for debugging: check" + id: DEBUG_SSH_SESSSION_CHECK + if: always() + run: | + set -eu + + when="${{ inputs.debug-with-ssh }}" + + if [[ $when == "always" ]] || case "${{ job.status }}" in + success) [[ $when == "always" ]] ;; + cancelled) [[ $when == "on_failure_or_cancelled" ]] ;; + failure) [[ $when == "on_failure"* ]] ;; + esac; then + echo "start_ssh_session=true" | tee -a "$GITHUB_OUTPUT" + fi + + + - name: "SSH session for debugging: start" + uses: mxschmitt/action-tmate@v3 # https://github.com/mxschmitt/action-tmate + if: always() && steps.DEBUG_SSH_SESSSION_CHECK.outputs.start_ssh_session + with: + limit-access-to-actor: ${{ inputs.debug-with-ssh-only-for-actor }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c59345713..7be9cd2ac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -80,6 +80,22 @@ mvn -Dtest=# -DfailIfNoTests=false -Dtycho.testArgLin Once Maven is about to execute the test it will wait for you to attach to the test JVM using a remote debugger, e.g. using Eclipse's `Remote Java Application` debug configuration. +#### Running the CI job locally: + +The GitHub actions wokflow is compatible with [nektos/act](https://github.com/nektos/act) a command-line tool that allows you to run GitHub action workflows locally. + +1. Install the [docker engine](https://docs.docker.com/engine/install/) +1. Install [nektos/act](https://github.com/nektos/act) +1. From the command line navigate into the LSP4E project root +1. Run the command `act` +1. On subsequent re-runs you can use `act -r` to reuse previous container which avoids reinstallation system packages and reduces build time. + +In case of build failures the docker container will still be running and you can ssh into it for analysis using `docker exec -u root -it /bin/bash`, e.g.: +```bash +container_id=$(docker container ps --filter status=running --filter name=act-Build-build --format {{.ID}}) +docker exec -u root -it $container_id /bin/bash +``` + ### ⬆️ Version bump LSP4E tries to use OSGi Semantic Version (to properly expose its API contracts and breakage) and Reproducible Version Qualifiers (to minimize the avoid producing multiple equivalent artifacts for identical source). diff --git a/README.md b/README.md index e4dd6473e..22e3f8013 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Eclipse LSP4E - Language Server Protocol client for Eclipse IDE [![Jenkins Tests](https://img.shields.io/jenkins/tests?jobUrl=https%3A%2F%2Fci.eclipse.org%2Flsp4e%2Fjob%2Flsp4e-github%2Fjob%2Fmaster%2F&logo=jenkins&logoColor=white&label=Jenkins%20Tests)](https://ci.eclipse.org/lsp4e/job/lsp4e-github/job/master/) +[![GitHub Actions](https://github.com/eclipse/lsp4e/actions/workflows/build.yml/badge.svg)](https://github.com/eclipse/lsp4e/actions/workflows/build.yml) [![License](https://img.shields.io/github/license/eclipse/lsp4e.svg?color=blue)](LICENSE) [![Clone to Eclipse IDE](https://mickaelistria.github.io/redirctToEclipseIDECloneCommand/cloneToEclipseBadge.png)](https://mickaelistria.github.io/redirctToEclipseIDECloneCommand/redirect.html) diff --git a/org.eclipse.lsp4e.test/pom.xml b/org.eclipse.lsp4e.test/pom.xml index 12c8d1330..eba1b961c 100644 --- a/org.eclipse.lsp4e.test/pom.xml +++ b/org.eclipse.lsp4e.test/pom.xml @@ -51,14 +51,14 @@ macosx-jvm-flags - - - mac - - - - -XstartOnFirstThread - + + + mac + + + + -XstartOnFirstThread + diff --git a/pom.xml b/pom.xml index 9269082bc..42295cd0d 100644 --- a/pom.xml +++ b/pom.xml @@ -93,6 +93,11 @@ cocoa x86_64 + + macosx + cocoa + aarch64 +