Skip to content

Commit

Permalink
Some cleanup and more CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
eriq-augustine committed Feb 1, 2025
1 parent fc00cb6 commit 785b408
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Main
name: Deploy

on:
push:
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Test

on:
push:
branch:
- '*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
deploy:

runs-on: ubuntu-22.04

permissions:
contents: read
packages: write
attestations: write
id-token: write

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

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
platforms: linux/amd64,linux/arm64
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ bin/
dist/
test/

/out/
/out.zip
/src/

*.gz
test.json
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ ENV JPLAG_VERSION=5.1.0
RUN apk update
RUN apk add --no-cache bash openjdk21

RUN mkdir /jplag /jplag-bin
RUN chmod 777 /jplag /jplag-bin

WORKDIR /jplag-bin

COPY scripts/entrypoint.sh .
COPY scripts/entrypoint.sh /jplag-bin/entrypoint.sh

RUN wget https://github.com/jplag/JPlag/releases/download/v$JPLAG_VERSION/jplag-$JPLAG_VERSION-jar-with-dependencies.jar
RUN mv jplag-$JPLAG_VERSION-jar-with-dependencies.jar jplag-jar-with-dependencies.jar

RUN chmod 777 /jplag-bin/entrypoint.sh /jplag-bin/jplag-jar-with-dependencies.jar

WORKDIR /jplag

ENTRYPOINT ["/bin/bash", "/jplag-bin/entrypoint.sh"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JPlag Docker

A simple Docker container to run [JPlag code similarity tool](https://github.com/jplag/JPlag).
A simple Docker container to run the [JPlag code similarity tool](https://github.com/jplag/JPlag).

## Running

Expand Down
7 changes: 4 additions & 3 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
#!/bin/bash

readonly WORK_DIR=/jplag
readonly OUT_DIR="${WORK_DIR}/out"

function main() {
trap exit SIGINT

cd "${WORK_DIR}"

# Run the main command.
/usr/bin/java -jar /jplag-bin/jplag-jar-with-dependencies.jar --result-file out $@
/usr/bin/java -jar /jplag-bin/jplag-jar-with-dependencies.jar --result-file "${OUT_DIR}" $@
local exit_status=$?

# Cleanup regardless of the status of the command.
if [[ -d out ]] ; then
chmod -f 777 out
chmod -f 666 out/* out.zip
chmod -f 777 "${OUT_DIR}"
chmod -f 666 "${OUT_DIR}"/* *.zip
fi

return ${exist_status}
Expand Down

0 comments on commit 785b408

Please sign in to comment.