Skip to content

Commit

Permalink
Merge pull request #1 from m-dzianishchyts/workflows
Browse files Browse the repository at this point in the history
Workflows
  • Loading branch information
m-dzianishchyts authored May 18, 2024
2 parents af9e632 + f04549a commit 5a0e125
Show file tree
Hide file tree
Showing 48 changed files with 412 additions and 1,213 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'build test'

on:
push:
branches: [ main ]
pull_request:
branches: [ '*' ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
java: [ 11, 17, 21 ]

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

- name: Set up JDK...
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'maven'

- name: Build and test...
run: mvn clean verify -U
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: 'create release'

on:
push:
tags:
- '[0-9]+.[0-9]+*'

jobs:
prepare-release:
runs-on: ubuntu-latest

outputs:
tag: ${{ steps.vars.outputs.tag }}
version: ${{ steps.vars.outputs.version }}
upload_url: ${{ steps.create_release.outputs.upload_url }}

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

- name: Set version...
id: vars
run: |
RELEASE_TAG=${GITHUB_REF#refs/*/}
echo ::set-output name=tag::${RELEASE_TAG}
echo ::set-output name=version::${RELEASE_TAG:1}
- name: Create release...
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.vars.outputs.tag }}
release_name: ${{ steps.vars.outputs.tag }}
body: JJava ${{ steps.vars.outputs.tag }} release
draft: true
prerelease: false

build-and-upload:
needs: prepare-release
runs-on: ubuntu-latest

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

- name: Set up JDK...
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'maven'

- name: Build and test...
run: mvn clean verify -U

- name: Upload Archive...
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.prepare-release.outputs.upload_url }}
asset_path: ./target/jjava-${{ needs.prepare-release.outputs.version }}.zip
asset_name: jjava-${{ needs.prepare-release.outputs.version }}.zip
asset_content_type: application/zip
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.gradle/
.idea/
build/
out/
target/
.classpath
.project
.settings
*.iml
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,27 +123,26 @@ Get the latest version of the kernel but possibly run into some issues with inst
```

2. Build the kernel.

On *nix `./gradlew zipKernel`

On windows `gradlew zipKernel`
```bash
mvn package
```

3. Install `build/distributions/jjava-$version.zip` custom build as a pre-built binary
3. Install `target/jjava-$version.zip` custom build as a pre-built binary


### Configuring

Configuring the kernel can be done via environment variables. These can be set on the system or inside the `kernel.json`. The configuration can be done at install time, which may be repeated as often as desired. The parameters are listed with `python3 install.py -h` as well as below in the list of options. Configuration done via the installer (or `gradlew installKernel --param ...:...`) should use the names in the _Parameter name_ column.
Configuring the kernel can be done via environment variables. These can be set on the system or inside the `kernel.json`. The configuration can be done at install time, which may be repeated as often as desired. The parameters are listed with `python3 install.py -h` as well as below in the list of options.

#### List of options

| Environment variable | Parameter name | Default | Description |
|----------------------|----------------|---------|-------------|
| `IJAVA_COMPILER_OPTS` | `comp-opts` | `""` | A space delimited list of command line options that would be passed to the `javac` command when compiling a project. For example `-parameters` to enable retaining parameter names for reflection. |
| `IJAVA_TIMEOUT` | `timeout` | `"-1"` | A duration specifying a timeout (in milliseconds by default) for a _single top level statement_. If less than `1` then there is no timeout. If desired a time may be specified with a [`TimeUnit`](https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/TimeUnit.html) may be given following the duration number (ex `"30 SECONDS"`). |
| `IJAVA_CLASSPATH` | `classpath` | `""` | A file path separator delimited list of classpath entries that should be available to the user code. **Important:** no matter what OS, this should use forward slash "/" as the file separator. Also each path may actually be a [simple glob](#simple-glob-syntax). |
| `IJAVA_STARTUP_SCRIPTS_PATH` | `startup-scripts-path` | `""` | A file path seperator delimited list of `.jshell` scripts to run on startup. This includes [ijava-jshell-init.jshell](src/main/resources/ijava-jshell-init.jshell) and [ijava-display-init.jshell](src/main/resources/ijava-display-init.jshell). **Important:** no matter what OS, this should use forward slash "/" as the file separator. Also each path may actually be a [simple glob](#simple-glob-syntax). |
| `IJAVA_STARTUP_SCRIPT` | `startup-script` | `""` | A block of java code to run when the kernel starts up. This may be something like `import my.utils;` to setup some default imports or even `void sleep(long time) { try {Thread.sleep(time); } catch (InterruptedException e) { throw new RuntimeException(e); }}` to declare a default utility method to use in the notebook. |
| `JJAVA_COMPILER_OPTS` | `comp-opts` | `""` | A space delimited list of command line options that would be passed to the `javac` command when compiling a project. For example `-parameters` to enable retaining parameter names for reflection. |
| `JJAVA_TIMEOUT` | `timeout` | `"-1"` | A duration specifying a timeout (in milliseconds by default) for a _single top level statement_. If less than `1` then there is no timeout. If desired a time may be specified with a [`TimeUnit`](https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/TimeUnit.html) may be given following the duration number (ex `"30 SECONDS"`). |
| `JJAVA_CLASSPATH` | `classpath` | `""` | A file path separator delimited list of classpath entries that should be available to the user code. **Important:** no matter what OS, this should use forward slash "/" as the file separator. Also each path may actually be a [simple glob](#simple-glob-syntax). |
| `JJAVA_STARTUP_SCRIPTS_PATH` | `startup-scripts-path` | `""` | A file path seperator delimited list of `.jshell` scripts to run on startup. This includes [jjava-jshell-init.jshell](src/main/resources/jjava-jshell-init.jshell) and [jjava-display-init.jshell](src/main/resources/jjava-display-init.jshell). **Important:** no matter what OS, this should use forward slash "/" as the file separator. Also each path may actually be a [simple glob](#simple-glob-syntax). |
| `JJAVA_STARTUP_SCRIPT` | `startup-script` | `""` | A block of java code to run when the kernel starts up. This may be something like `import my.utils;` to setup some default imports or even `void sleep(long time) { try {Thread.sleep(time); } catch (InterruptedException e) { throw new RuntimeException(e); }}` to declare a default utility method to use in the notebook. |

##### Simple glob syntax

Expand All @@ -161,7 +160,7 @@ Any relative paths are resolved from the notebook server's working directory. Fo
See the [List of options](#list-of-options) section for all of the configuration options.
To change compiler options use the `IJAVA_COMPILER_OPTS` environment variable (or `--comp-opts` parameter during installation) with a string of flags as if running the `javac` command.
To change compiler options use the `JJAVA_COMPILER_OPTS` environment variable (or `--comp-opts` parameter during installation) with a string of flags as if running the `javac` command.
The kernel VM parameters must currently be assigned in the `kernel.json` by adding/editing a JSON dictionary at the `env` key and changing the `argv` list. To find where the kernel is installed run
Expand Down
6 changes: 6 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.0-M2

- #5 Switch project to Maven
- #7 Project renaming
- #8 Java package change

# 1.0-M1

- #1 Upgrade to Gradle 8.5
Expand Down
22 changes: 11 additions & 11 deletions buildSrc/src/main/resources/install.py → assembly/zip/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
from jupyter_client.kernelspec import KernelSpecManager

ALIASES = {
"IJAVA_CLASSPATH": {
"JJAVA_CLASSPATH": {
},
"IJAVA_COMPILER_OPTS": {
"JJAVA_COMPILER_OPTS": {
},
"IJAVA_STARTUP_SCRIPTS_PATH": {
"JJAVA_STARTUP_SCRIPTS_PATH": {
},
"IJAVA_STARTUP_SCRIPT": {
"JJAVA_STARTUP_SCRIPT": {
},
"IJAVA_TIMEOUT": {
"JJAVA_TIMEOUT": {
"NO_TIMEOUT": "-1",
},

}

NAME_MAP = {
"classpath": "IJAVA_CLASSPATH",
"comp-opts": "IJAVA_COMPILER_OPTS",
"startup-scripts-path": "IJAVA_STARTUP_SCRIPTS_PATH",
"startup-script": "IJAVA_STARTUP_SCRIPT",
"timeout": "IJAVA_TIMEOUT",
"classpath": "JJAVA_CLASSPATH",
"comp-opts": "JJAVA_COMPILER_OPTS",
"startup-scripts-path": "JJAVA_STARTUP_SCRIPTS_PATH",
"startup-script": "JJAVA_STARTUP_SCRIPT",
"timeout": "JJAVA_TIMEOUT",

}

Expand Down Expand Up @@ -130,7 +130,7 @@ def __call__(self, parser, namespace, value, option_string=None):
action=EnvVar,
aliases=ALIASES,
name_map=NAME_MAP,
help="A file path seperator delimited list of `.jshell` scripts to run on startup. This includes ijava-jshell-init.jshell and ijava-display-init.jshell. **Important:** no matter what OS, this should use forward slash \"/\" as the file separator. Also each path may actually be a simple glob.",
help="A file path separator delimited list of `.jshell` scripts to run on startup. This includes jjava-jshell-init.jshell and jjava-display-init.jshell. **Important:** no matter what OS, this should use forward slash \"/\" as the file separator. Also each path may actually be a simple glob.",
type=type_assertion("startup-scripts-path", str),
list_sep=os.pathsep,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"--add-opens",
"jdk.jshell/jdk.jshell=ALL-UNNAMED",
"-jar",
"@KERNEL_INSTALL_DIRECTORY@/@JAR_FILE@",
"@KERNEL_INSTALL_DIRECTORY@/${project.build.finalName}.jar",
"{connection_file}"
],
"display_name": "Java",
Expand Down
24 changes: 24 additions & 0 deletions assembly/zip/zip.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>zip</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<files>
<file>
<source>${project.build.directory}/${project.build.finalName}.jar</source>
<outputDirectory>java</outputDirectory>
</file>
<file>
<source>assembly/zip/kernel.json</source>
<outputDirectory>java</outputDirectory>
<filtered>true</filtered>
</file>
<file>
<source>assembly/zip/install.py</source>
<outputDirectory>/</outputDirectory>
</file>
</files>
</assembly>
129 changes: 0 additions & 129 deletions build.gradle

This file was deleted.

13 changes: 0 additions & 13 deletions buildSrc/build.gradle

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5a0e125

Please sign in to comment.