Skip to content

Commit

Permalink
chore: v0.0.2 (#9)
Browse files Browse the repository at this point in the history
* feat: Initial project structure (#2)

* feat: Base gradle project

* feat: clang-format

* feat: nix-shell development shell

* feat: Dockerfile

* docs: Update README

* feat: RMI server with interfaces as git module (#3)

* chore: Add RMI submodule as library

* style: Specify column limit

* feat: RMI service sample implementation

* fix: Update submodule

* docs: Simplify README

* feat: Add formatting commands to README

* chore: Bump rmi-java

* chore: Add clang-format to nix-shell

* ci: release workflow (#8)

* ci: formatter pipeline (#4)

* ci: Add format workflow

* fix: format pipeline run step with privileges

* ci: testing pipeline (#5)

* ci: Add testing workflow

* fix: Remove docker-compose steps

* ci: Add coverage workflow (#7)

* ci: tagging pipeline (#6)

* chore(release): 0.0.1

* ci: Tagging workflow

* chore: tagging dependencies

---------

Co-authored-by: Antonio Donis <antoniojosedonishung@gmail.com>
  • Loading branch information
Woynert and shoriwe authored Aug 30, 2023
1 parent a676657 commit 87e0759
Show file tree
Hide file tree
Showing 26 changed files with 2,834 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
BasedOnStyle: LLVM
AlignAfterOpenBracket: AlwaysBreak
BreakBeforeBraces: Mozilla
ColumnLimit: '100'
Cpp11BracedListStyle: 'false'
IndentWidth: '4'
PointerAlignment: Left
SpaceBeforeParens: Always
TabWidth: '4'
UseTab: Always

...
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

24 changes: 24 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Coverage

on:
push:
branches: ["main"]

jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'
- name: Test
run: chmod +x ./gradlew && ./gradlew testCodeCoverageReport
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./app/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml
fail_ci_if_error: true
17 changes: 17 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Format

on:
pull_request:
branches: ["dev"]

jobs:
formatter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install clang-format
run: sudo apt update && sudo apt --assume-yes install clang-format

- name: Clang check
run: chmod +x ./format.sh && ./format.sh clang-check

74 changes: 74 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Release

on:
push:
branches: ["main"]

jobs:
versioning:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.latest_version.outputs.version }}
steps:
- uses: actions/checkout@v3
- id: latest_version
name: Latest version
run: python version.py >> $GITHUB_OUTPUT

create-release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
needs:
- versioning
outputs:
upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.versioning.outputs.version }}
release_name: Release ${{ needs.versioning.outputs.version }}
draft: false
prerelease: false

build-docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs:
- versioning
- create-release
steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Docker image
run: echo "v${{ needs.versioning.outputs.version }}"

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ needs.versioning.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}
28 changes: 28 additions & 0 deletions .github/workflows/tagging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Tagging

on:
push:
branches: ["dev"]

jobs:
tagging:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup node 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "npm"
- name: Git Identity
run: |
git checkout dev
git fetch --all --tags
git config --global user.email "antoniojosedonishung@gmail.com"
git config --global user.name "Antonio Donis"
- name: Changelog
run: 'npx standard-version --message "[ci skip] chore(release): %s"'
- name: Push changes
run: git push --follow-tags --force origin dev
32 changes: 32 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Test

on:
pull_request:
branches: ["dev"]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'
- name: Build
run: chmod +x ./gradlew && ./gradlew build

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'
- name: Test
run: chmod +x ./gradlew && ./gradlew test
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build

node_modules
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "rmi"]
path = rmi
url = https://github.com/hawks-atlanta/rmi-java
branch = dev
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### 0.0.2 (2023-08-29)

### 0.0.1 (2023-08-29)


### Features

* Initial project structure ([#2](https://github.com/hawks-atlanta/worker-java/issues/2)) ([a4984d0](https://github.com/hawks-atlanta/worker-java/commit/a4984d0bf48c462123784eca850ce14507d0b48b))
* RMI server with interfaces as git module ([#3](https://github.com/hawks-atlanta/worker-java/issues/3)) ([1860daf](https://github.com/hawks-atlanta/worker-java/commit/1860dafcc0c8110e8d930e280183b9b9f3d22208))
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# build

FROM adoptopenjdk/openjdk11:x86_64-alpine-jdk-11.0.20_8-slim as builder

COPY . /src
WORKDIR /src

RUN ./gradlew build

# runner

FROM adoptopenjdk/openjdk11:x86_64-alpine-jre-11.0.20_8

COPY --from=builder /src/app/build/libs/app-all.jar /opt/app.jar
EXPOSE 8080/tcp

CMD ["java", "-jar", "/opt/app.jar"]
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,48 @@
# worker-java
# Worker

## Development

### Submodules

Fetch submodules after cloning:

```sh
git clone https://github.com/hawks-atlanta/worker-java
git submodule update --init
```

### Tools

- Have `jdk11` or newer installed.
- (Optional) Use the **gradle wrapper script** (`./gradlew`) for all `gradle` commands. For example:

```sh
./gradlew build
```

- (Optional) Use the provided `nix-shell` to get into a shell with all required dependecies [[install Nix](https://nixos.org/download)].

```sh
nix-shell
```

### Run

```sh
gradle run
```

### Run tests

```sh
gradle test
```

### Format

You need to have `clang-format` installed.

```sh
./format.sh clang-check # check (doesn't write)
./format.sh clang-format # apply (writes)
```
46 changes: 46 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'

// Coverage report
id 'jacoco-report-aggregation'

// Single JAR artifact bundle
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'java'
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

dependencies {
// Use JUnit Jupiter for testing.
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2'

testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

// This dependency is used by the application.
implementation 'com.google.guava:guava:31.1-jre'

// Use subproject
implementation project(':capyfile.rmi.interfaces')
}

// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}

application {
// Define the main class for the application.
mainClass = 'worker.App'
}

tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
25 changes: 25 additions & 0 deletions app/src/main/java/worker/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package worker;

import capyfile.rmi.*;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

public class App
{
public static void main (String[] args)
{
System.out.println ("Worker: Serving RMI");

try {
// serve RMI
MessengerServiceImpl server = new MessengerServiceImpl ();
server.createStubAndBind ();

} catch (Exception e) {
System.out.println (e);
}
}
}
Loading

0 comments on commit 87e0759

Please sign in to comment.