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
55 changes: 53 additions & 2 deletions .github/workflows/tests-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,8 @@ jobs:
DBMS: "postgresql"

jbang:
name: JBang
name: JBang (main)
runs-on: ubuntu-latest
# JBang scripts depend on main-SNAPSHOT; thus, we can only test fully when main is updated
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout source
Expand Down Expand Up @@ -426,8 +425,60 @@ jobs:
- run: jbang build .jbang/CheckoutPR.java
- run: jbang build .jbang/CloneJabRef.java
- run: jbang build --fresh .jbang/JabKitLauncher.java
- run: jbang build --fresh .jbang/JabLsLauncher.java
- run: jbang build --fresh .jbang/JabSrvLauncher.java

jbang-pr:
name: JBang (PR)
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main'
strategy:
fail-fast: false
matrix:
launcher: [JabKitLauncher, JabLsLauncher, JabSrvLauncher]
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
submodules: 'false'
show-progress: 'false'
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: 24
distribution: 'corretto'
- name: Generate JBang cache key
id: cache-key
shell: bash
run: |
echo "cache_key=jbang-$(date +%F)" >> $GITHUB_OUTPUT
- name: Use cache
uses: actions/cache@v4
with:
path: ~/.jbang
key: ${{ steps.cache-key.outputs.cache_key }}
restore-keys:
jbang-
- name: Setup JBang
uses: jbangdev/setup-jbang@main

- name: Detect changed jablib classes
id: changed-jablib-files
uses: tj-actions/changed-files@v45
with:
files: |
jablib/src/main/java/**/*.java

- name: Build ${{ matrix.launcher }} launcher including changed classes
shell: bash
# We always run, because changes in jabls, jabsrv also could cause JBang to fail
run: |
# We modify the JBang scripts directly to avoid issues with relative paths
for f in ${{ steps.changed-jablib-files.outputs.all_changed_files }}; do
echo "//SOURCES $f" >> ".jbang/${{ matrix.launcher }}.java"
done
jbang build --fresh ".jbang/${{ matrix.launcher }}.java"

codecoverage:
if: false
name: Code coverage
Expand Down
10 changes: 8 additions & 2 deletions .jbang/JabLsLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@

//SOURCES ../jabls/src/main/java/org/jabref/languageserver/BibtexTextDocumentService.java
//SOURCES ../jabls/src/main/java/org/jabref/languageserver/BibtexWorkspaceService.java
//SOURCES ../jabls/src/main/java/org/jabref/languageserver/LSPLauncher.java
//SOURCES ../jabls/src/main/java/org/jabref/languageserver/LSPServer.java
//SOURCES ../jabls/src/main/java/org/jabref/languageserver/controller/LanguageServerController.java
//SOURCES ../jabls/src/main/java/org/jabref/languageserver/ExtensionSettings.java
//SOURCES ../jabls/src/main/java/org/jabref/languageserver/LspClientHandler.java
//SOURCES ../jabls/src/main/java/org/jabref/languageserver/LspLauncher.java
//SOURCES ../jabls/src/main/java/org/jabref/languageserver/util/LspConsistencyCheck.java
//SOURCES ../jabls/src/main/java/org/jabref/languageserver/util/LspDiagnosticBuilder.java
//SOURCES ../jabls/src/main/java/org/jabref/languageserver/util/LspDiagnosticHandler.java
//SOURCES ../jabls/src/main/java/org/jabref/languageserver/util/LspIntegrityCheck.java

// REPOS mavencentral,snapshots=https://central.sonatype.com/repository/maven-snapshots/
// REPOS mavencentral,mavencentralsnapshots=https://central.sonatype.com/repository/maven-snapshots/,s01oss=https://s01.oss.sonatype.org/content/repositories/snapshots/,oss=https://oss.sonatype.org/content/repositories,jitpack=https://jitpack.io,oss2=https://oss.sonatype.org/content/groups/public,ossrh=https://oss.sonatype.org/content/repositories/snapshots
Expand Down
61 changes: 61 additions & 0 deletions docs/decisions/0048-jbang-script-modification-for-testing-in-ci.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
nav_order: 48
parent: Decision Records
---

# JBang script modification for testing in CI

## Context and Problem Statement

All JBang scripts on `main` should always compile.

Example:

```terminal
gg.cmd https://github.com/JabRef/jabref/blob/main/.jbang/JabLsLauncher.java
```

- JBang scripts link to `org.jabref:jablib:6.0-SNAPSHOT`.
- JBang scripts include java files from the respective `-cli` repository and the sources of the respective server project. E.g., `JabLsLauncher.java` includes `ServerCli.java` from `jabls-cli` and all sources from `jabls`.
- Code changes might change a) things inside the server project and b) things in JabRef's logic.

As a consequence, the JBang script might break.

Case a) can be detected when running the JBang check in the respective PR.
Case b) can be detected when running the JBang check in the main branch, because `org.jabref:jablib:6.0-SNAPSHOT` is updated there.

We aim for checking JBang scripts in PRs and on `main`.

## Decision Drivers

- Fast detection of issues at all JBang files
- Easy CI pipeline

## Considered Options

- Have JBang script have all changed classes of `jablib` included directly
- Use jitpack
-Temporary `-SNAPSHOT.jar`

## Decision Outcome

Chosen option: "Have JBang script have all changed classes of `jablib` included directly.", because comes out best (see below).

## Pros and Cons of the Options

### Have JBang script have all changed classes of `jablib` included directly

- `org.jabref:jablib:6.0-SNAPSHOT` provides non-modified classes
- modified classes are included using JBang's `//SOURCES` directive.

[tj-actions/changed-files](https://github.com/marketplace/actions/changed-files) can be used.

- Good, because least effort

### Use jitpack

- Bad, because jitpack is unreliable

### Temporary `-SNAPSHOT.jar`

- Bad, because setting up a temporary maven repository is effort.