Skip to content

Commit

Permalink
Implement GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mikir committed Oct 25, 2023
1 parent ea26246 commit b33af51
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Linux

on:
push:
branches: [ master, '*-ci' ]
pull_request:
branches: [ master ]
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'

jobs:
build_linux:
runs-on: ${{matrix.os}}
strategy:
matrix:
os: ["ubuntu-20.04", "ubuntu-22.04"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Set up JDK 1.8
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8

- name: Build Zserio Java Service Rmi
run: |
# download the latest zserio version
mvn dependency:copy -Dmaven.repo.local="build/download" \
-Dartifact=io.github.ndsev:zserio:LATEST \
-DoutputDirectory="build" -Dmdep.stripVersion=true
# download the latest zserio runtime version
mvn dependency:copy -Dmaven.repo.local="build/download" \
-Dartifact=io.github.ndsev:zserio-runtime:LATEST \
-DoutputDirectory="build" -Dmdep.stripVersion=true
# generate example using Zserio
java -jar build/zserio.jar \
-src examples/zserio/service/rmi/examples/calculator calculator.zs -java build \
-setTopLevelPackage rmi.examples.calculator.gen
# compile example
javac -d build -cp build/zserio-runtime.jar \
src/zserio/service/rmi/*.java \
examples/zserio/service/rmi/examples/calculator/*.java \
build/rmi/examples/calculator/gen/calculator/*.java
- name: Test Zserio Java Service Rmi
run: |
SERVICE_CLASSPATH="build/zserio-runtime.jar:build"
java -cp "${SERVICE_CLASSPATH}" zserio.service.rmi.examples.calculator.CalculatorServer &
sleep 10
{ echo "p"; sleep 1; echo "100"; sleep 1; echo "q"; } | java -cp "${SERVICE_CLASSPATH}" \
zserio.service.rmi.examples.calculator.CalculatorClient | grep "10000"
{ echo "s"; sleep 1; echo "100"; sleep 1; echo "q"; } | java -cp "${SERVICE_CLASSPATH}" \
zserio.service.rmi.examples.calculator.CalculatorClient | grep "10.0"
kill $(jobs -p)
- name: Archive Zserio Java Service Rmi classes
uses: actions/upload-artifact@v3
with:
name: zserio-service-rest-java-${{matrix.os}}
path: |
build/rmi/**/*.class
build/zserio/**/*.class
build/*.jar
73 changes: 73 additions & 0 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Windows

on:
push:
branches: [ master, '*-ci' ]
pull_request:
branches: [ master ]
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'

jobs:
build_windows:
runs-on: ${{matrix.os}}
strategy:
matrix:
os: ["windows-latest"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Set up JDK 1.8
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8

- name: Build Zserio Java Service Rmi
run: |
# download the latest zserio version
mvn dependency:copy -Dmaven.repo.local="build/download" \
-Dartifact=io.github.ndsev:zserio:LATEST \
-DoutputDirectory="build" -Dmdep.stripVersion=true
# download the latest zserio runtime version
mvn dependency:copy -Dmaven.repo.local="build/download" \
-Dartifact=io.github.ndsev:zserio-runtime:LATEST \
-DoutputDirectory="build" -Dmdep.stripVersion=true
# generate example using Zserio
java -jar build/zserio.jar \
-src examples/zserio/service/rmi/examples/calculator calculator.zs -java build \
-setTopLevelPackage rmi.examples.calculator.gen
# compile example
javac -d build -cp build/zserio-runtime.jar \
src/zserio/service/rmi/*.java \
examples/zserio/service/rmi/examples/calculator/*.java \
build/rmi/examples/calculator/gen/calculator/*.java
shell: bash

- name: Test Zserio Java Service Rmi
run: |
SERVICE_CLASSPATH="build/zserio-runtime.jar;build"
java -cp "${SERVICE_CLASSPATH}" zserio.service.rmi.examples.calculator.CalculatorServer &
sleep 10
{ echo "p"; sleep 1; echo "100"; sleep 1; echo "q"; } | java -cp "${SERVICE_CLASSPATH}" \
zserio.service.rmi.examples.calculator.CalculatorClient | grep "10000"
{ echo "s"; sleep 1; echo "100"; sleep 1; echo "q"; } | java -cp "${SERVICE_CLASSPATH}" \
zserio.service.rmi.examples.calculator.CalculatorClient | grep "10.0"
kill $(jobs -p)
shell: bash

- name: Archive Zserio Java Service Rmi classes
uses: actions/upload-artifact@v3
with:
name: zserio-service-rest-java-${{matrix.os}}
path: |
build/rmi/**/*.class
build/zserio/**/*.class
build/*.jar
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Zserio Service RMI backend

[![](https://github.com/ndsev/zserio-service-rmi-java/actions/workflows/build_linux.yml/badge.svg)](https://github.com/ndsev/zserio-service-rmi-java/actions/workflows/build_linux.yml)
[![](https://github.com/ndsev/zserio-service-rmi-java/actions/workflows/build_windows.yml/badge.svg)](https://github.com/ndsev/zserio-service-rmi-java/actions/workflows/build_windows.yml)
[![](https://img.shields.io/github/watchers/ndsev/zserio-service-rmi-java.svg)](https://GitHub.com/ndsev/zserio-service-rmi-java/watchers)
[![](https://img.shields.io/github/forks/ndsev/zserio-service-rmi-java.svg)](https://GitHub.com/ndsev/zserio-service-rmi-java/network/members)
[![](https://img.shields.io/github/stars/ndsev/zserio-service-rmi-java.svg?color=yellow)](https://GitHub.com/ndsev/zserio-service-rmi-java/stargazers)

--------

Sample implementation of Zserio Service RMI backend in **Java**.

# Prerequisites
Expand Down

0 comments on commit b33af51

Please sign in to comment.