Skip to content

Commit

Permalink
Merge pull request #22 from chrisgleissner/feature/github-action-build
Browse files Browse the repository at this point in the history
Build with GitHub actions. Updated docs.
  • Loading branch information
chrisgleissner committed Sep 1, 2023
2 parents 28d6a37 + a9ea26f commit 996b713
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 56 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: build

on: [push]

jobs:
build:
strategy:
matrix:
jdk-version: [8, 11]

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: JDK Setup
uses: actions/setup-java@v3
with:
java-version: '${{ matrix.jdk-version }}'
distribution: 'adopt'
cache: 'maven'

- name: Build
run: mvn --batch-mode --update-snapshots package -Pjacoco

- name: Coveralls Report
run: mvn coveralls:report --define repoToken=${{ secrets.COVERALLS_REPO_TOKEN }}
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

107 changes: 63 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,19 @@

[![Maven Central](https://img.shields.io/maven-central/v/com.github.chrisgleissner/spring-batch-rest-api)](https://search.maven.org/artifact/com.github.chrisgleissner/spring-batch-rest-api/)
[![Javadocs](https://www.javadoc.io/badge/com.github.chrisgleissner/spring-batch-rest-api.svg)](https://www.javadoc.io/doc/com.github.chrisgleissner/spring-batch-rest-api)
[![Build Status](https://travis-ci.org/chrisgleissner/spring-batch-rest.svg?branch=master)](https://travis-ci.org/chrisgleissner/spring-batch-rest)
![Build Status](https://github.com/chrisgleissner/spring-batch-rest/actions/workflows/build.yml/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/chrisgleissner/spring-batch-rest/badge.svg?branch=master)](https://coveralls.io/github/chrisgleissner/spring-batch-rest?branch=master)
[![Maintainability](https://api.codeclimate.com/v1/badges/2267ddd7cbbfc5e22b86/maintainability)](https://codeclimate.com/github/chrisgleissner/spring-batch-rest/maintainability)

REST API for <a href="https://spring.io/projects/spring-batch">Spring Batch</a> based on <a href="https://github.com/spring-projects/spring-boot">Spring Boot 2.2</a> and <a href="https://github.com/spring-projects/spring-hateoas">Spring HATOEAS</a>. It comes with an OpenAPI 3 documentation provided by <a href="https://github.com/springdoc/springdoc-openapi">Springdoc</a>.

Supports Java 8 and above. Tested on OpenJDK 8, 11, and 14.
Supports Java 8 and above. Tested on OpenJDK 8 and 11.

## Features
- Get information on jobs, job executions, and Quartz schedules
- Start job execution (synchronous or asynchronous) with optional job property overrides. The job properties can
either be obtained via a custom API or via standard Spring Batch job parameters, accessible from <a href="https://docs.spring.io/spring-batch/trunk/apidocs/org/springframework/batch/core/scope/StepScope.html">step-scoped beans</a>.

## Live Demo

Check out the <a href="https://spring-batch-rest.herokuapp.com/swagger-ui.html">live demo</a> of this project's Swagger UI. This demo is automatically updated whenever the repo's master branch changes. Please note that it may take up to 30s for this Heroku app to perform a cold start after it has not been used for a while.

Here's how to run a <a href="https://github.com/chrisgleissner/spring-batch-rest/tree/master/example/api/src/main/java/com/github/chrisgleissner/springbatchrest/example/core/PersonJobConfig.java">sample job<a>:
* Click on `Spring Batch Job Executions`, then on `POST`. Now click on `Try it Out` on the right-hand side. Replace the contents of the `Example Value` input field with `{"name": "personJob"}` and press `Execute`.
* The job has now been triggered. When it completes, you'll get a response body similar to:
```
{
"jobExecution": {
"id": 1,
"jobId": 1,
"jobName": "personJob",
"startTime": "2018-12-23T18:19:13.185",
"endTime": "2018-12-23T18:19:13.223",
"exitCode": "COMPLETED",
"exitDescription": "",
"status": "COMPLETED",
"exceptions": []
},
"_links": {
"self": {
"href": "https://spring-batch-rest.herokuapp.com/jobExecutions/1"
}
}
}
```
* You can now view this and other recently completed jobs via the <a href="https://spring-batch-rest.herokuapp.com/jobExecutions?jobName=personJob&limitPerJob=3">job execution overview<a>:
```
{
"_embedded": {
"jobExecutionResourceList": [
{
"jobExecution": {
"id": 1,
"jobId": 1,
"jobName": "personJob",
...
```

## Getting Started

To integrate the REST API in your Spring Boot project, first ensure you have an entry point to your application such as
Expand Down Expand Up @@ -110,7 +70,7 @@ implementation 'com.github.chrisgleissner:spring-batch-rest-quartz-api:1.5.1'

### See it in Action

To see `spring-batch-rest-api` in action, run
To see `spring-batch-rest-api` in action, first install Java 8 or 11 as well as Maven, then run
```text
mvn install -Dmaven.test.skip; java -jar example/api/target/*.jar
```
Expand All @@ -121,8 +81,67 @@ mvn install -Dmaven.test.skip; java -jar example/quartz-api/target/*.jar
```

Once it's up, check the Swagger REST API docs at
<a href="http://localhost:8080/swagger-ui.html">http://localhost:8080/swagger-ui.html</a>.
[http://localhost:8080/swagger-ui.html](http://localhost:8080/swagger-ui.html).

### Sample Walkthrough

Here's how to run a [sample job](https://github.com/chrisgleissner/spring-batch-rest/tree/master/example/api/src/main/java/com/github/chrisgleissner/springbatchrest/example/core/PersonJobConfig.java), assuming
you've started the API as described above:

* Click on `POST` to the left of `/jobExecutions`, then on `Try it Out` on the right-hand side. Replace the contents of the `Request body` with `{"name": "personJob"}`, then click `Execute`.
* The job has now been triggered. When it completes, you'll get a response body similar to:
```
{
"jobExecution": {
"id": 0,
"jobId": 0,
"jobName": "personJob",
"startTime": "2023-09-01T19:01:55.264",
"endTime": "2023-09-01T19:01:55.317",
"exitCode": "COMPLETED",
"exitDescription": "",
"status": "COMPLETED",
"exceptions": []
},
"_links": {
"self": {
"href": "http://localhost:8080/jobExecutions/0"
}
}
}
```
* You can now view this and other recently completed jobs by clicking on `GET` to the left of `/jobExecutions`, then on `Try it Out` followed by `Execute`. You should see something like:
```
{
"_embedded": {
"jobExecutionResourceList": [
{
"jobExecution": {
"id": 0,
"jobId": 0,
"jobName": "personJob",
"startTime": "2023-09-01T19:01:55.264",
"endTime": "2023-09-01T19:01:55.317",
"exitCode": "COMPLETED",
"exitDescription": "",
"status": "COMPLETED",
"exceptions": []
},
"_links": {
"self": {
"href": "http://localhost:8080/jobExecutions/0"
}
}
}
]
},
"_links": {
"self": {
"href": "http://localhost:8080/jobExecutions?limitPerJob=3"
}
}
}
```

## REST Endpoints

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<version>0.8.10</version>
<executions>
<execution>
<goals>
Expand Down

0 comments on commit 996b713

Please sign in to comment.