Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hiwakaba committed Dec 24, 2020
0 parents commit 90bd9c6
Show file tree
Hide file tree
Showing 24 changed files with 6,671 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
6 changes: 6 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#### Relevant Issue (if applicable)
(If there are Issues related to this PullRequest, please list it.)

#### Details
(Please describe the details of PullRequest.)

42 changes: 42 additions & 0 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Periodic build for compatibility problems detection
on:
schedule:
- cron: '0 0 * * 1'

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Setup Java JDK
uses: actions/[email protected]
with:
java-version: 1.8
java-package: jdk
architecture: x64
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml

- name: Install dependent packages, build package and run tests
run: mvn -B clean exec:exec package --file pom.xml

- name: Deploy the package to github
# Run deploy action on release
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ github.token }}
if: github.event_name == 'release'
run: mvn -B deploy --file pom.xml

- name: Upload a jar file to asset
env:
GITHUB_TOKEN: ${{ github.token }}
if: github.event_name == 'release'
run: mvn -B exec:exec --file pom.xml -Pupload

- name: Deploy the docs to github
env:
GITPAGES_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKE_FOR_GITPAGES }}
if: github.event_name == 'release'
run: mvn -B site --file pom.xml -s settings.xml
55 changes: 55 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI

on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- master
pull_request:
branches:
- master
# Trigger the workflow on release,
# but only when published
release:
types:
- published

jobs:
build:

if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]') && ! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Setup Java JDK
uses: actions/[email protected]
with:
java-version: 1.8
java-package: jdk
architecture: x64
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml

- name: Install dependent packages, build package and run tests
run: mvn -B clean exec:exec package --file pom.xml

- name: Deploy the package to github
# Run deploy action on release
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ github.token }}
if: github.event_name == 'release'
run: mvn -B deploy --file pom.xml

- name: Upload a jar file to asset
env:
GITHUB_TOKEN: ${{ github.token }}
if: github.event_name == 'release'
run: mvn -B exec:exec --file pom.xml -Pupload

- name: Deploy the docs to github
env:
GITPAGES_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKE_FOR_GITPAGES }}
if: github.event_name == 'release'
run: mvn -B site --file pom.xml -s settings.xml
139 changes: 139 additions & 0 deletions .github/workflows/upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#!/bin/sh
#
# The MIT License
#
# Copyright 2018 Yahoo Japan Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# AUTHOR: Hirotaka Wakabayashi
# CREATE: Fri, 14 Sep 2018
# REVISION:
#

# Sets the default locale. LC_ALL has precedence over other LC* variables.
unset LANG
unset LANGUAGE
LC_ALL=en_US.utf8
export LC_ALL

# Sets PATH. setup_*.sh uses useradd command
PATH=${PATH}:/usr/sbin:/sbin

# an unset parameter expansion will fail
set -u

# umask 022 is enough
umask 022

# environments
REPOSITORY_PATH=${GITHUB_REPOSITORY}
SRCDIR=$(cd $(dirname "$0") && pwd)
DEBUG=1
if test "${DEBUG}" -eq 1; then
TAG="$(basename $0) -s"
else
TAG=$(basename $0)
fi

# GITHUB_TOKEN should be defined.
if test -z "${GITHUB_TOKEN}"; then
logger -t ${TAG} -p user.error "No GITHUB_TOKEN variable defined."
exit 1
fi
# GITHUB_REPOSITORY should be defined.
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables
if test -z "${GITHUB_REPOSITORY}"; then
logger -t ${TAG} -p user.error "No GITHUB_REPOSITORY variable defined."
exit 1
fi

# API SPEC
# https://developer.github.com/v3/repos/releases/#get-the-latest-release
TEMP_FILE=$(mktemp)
curl -sH "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${REPOSITORY_PATH}/releases/latest" -o ${TEMP_FILE}
if test "${?}" != "0"; then
logger -t ${TAG} -p user.error "GitHub API get-the-latest-release returned error."
rm -f ${TEMP_FILE}
exit 1
fi
UPLOAD_URL=$(cat ${TEMP_FILE} | python3 -c "import sys, json; print(json.load(sys.stdin)['upload_url'])")
if test -z "${UPLOAD_URL}"; then
logger -t ${TAG} -p user.error "UPLOAD_URL is empty(or undefined), which should be defined."
rm -f ${TEMP_FILE}
exit 1
fi
TAG_NAME=$(cat ${TEMP_FILE} | python3 -c "import sys, json; print(json.load(sys.stdin)['tag_name'])" | perl -ne '/v(.*)/; print $1;')
if test -z "${TAG_NAME}"; then
logger -t ${TAG} -p user.error "TAG_NAME is empty(or undefined), which should be defined."
rm -f ${TEMP_FILE}
exit 1
fi

# Get the jar file in local target directory.
TARGET_FILE="./target/k2hash-${TAG_NAME}.jar"
if ! test -f "${TARGET_FILE}"; then
logger -t ${TAG} -p user.error "${TARGET_FILE} doesn't exist, which should exist."
rm -f ${TEMP_FILE}
exit 1
fi
ASSET_FILE_NAME=$(basename ${TARGET_FILE})
if test -z "${ASSET_FILE_NAME}"; then
logger -t ${TAG} -p user.error "ASSET_FILE_NAME is empty(or undefined), which should be defined."
rm -f ${TEMP_FILE}
exit 1
fi
UPLOAD_URL_WITH_QUERY=$(echo ${UPLOAD_URL} | perl -pe "s|{\?name,label}|?name=${ASSET_FILE_NAME}|g")
if test -z "${UPLOAD_URL_WITH_QUERY}"; then
logger -t ${TAG} -p user.error "UPLOAD_URL_WITH_QUERY is empty(or undefined), which should be defined."
rm -f ${TEMP_FILE}
exit 1
fi
logger -t ${TAG} -p user.debug "TARGET_FILE:${TARGET_FILE} ASSET_FILE_NAME:${ASSET_FILE_NAME} UPLOAD_URL_WITH_QUERY:${UPLOAD_URL_WITH_QUERY}"

# API SPEC
# https://developer.github.com/v3/repos/releases/#upload-a-release-asset
# Note: curl exits with zero if the jar file already exists.
curl -s --request PATCH -L# --data-binary @"${TARGET_FILE}" -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application/octet-stream" ${UPLOAD_URL_WITH_QUERY}
RET=${?}
if test "${RET}" != "0"; then
logger -t ${TAG} -p user.error "GitHub API upload-a-release-asset returned error."
else
logger -t ${TAG} -p user.info "GitHub API upload-a-release-asset success"
fi

POM_FILE="./pom.xml"
if ! test -f "${POM_FILE}"; then
logger -t ${TAG} -p user.error "${POM_FILE} doesn't exist, which should exist."
rm -f ${TEMP_FILE}
exit 1
fi
POM_ASSET_FILE_NAME="k2hash-${TAG_NAME}.pom"
POM_UPLOAD_URL_WITH_QUERY=$(echo ${UPLOAD_URL} | perl -pe "s|{\?name,label}|?name=${POM_ASSET_FILE_NAME}|g")
curl -s --request PATCH -L# --data-binary @"${POM_FILE}" -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application/xml" ${POM_UPLOAD_URL_WITH_QUERY}
RET=${?}
if test "${RET}" != "0"; then
logger -t ${TAG} -p user.error "GitHub API upload-a-release-asset returned error."
else
logger -t ${TAG} -p user.info "GitHub API upload-a-release-asset success"
fi

rm -f ${TEMP_FILE}
exit ${RET}

23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/target/
7 changes: 7 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1. Takeshi Nakatani <[email protected]>

Wrote from scratch the initial version of k2hash.

2. Hirotaka Wakabayashi <[email protected]>

Wrote from scratch the initial version of k2hash-java.
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
k2hash-java (1.0.1) stable; urgency=low

* Updates control files.

-- Hirotaka Wakabayashi <[email protected]> Mon, 13 Apr 2020 06:18:39 +0000

k2hash-java (1.0.0) stable; urgency=low

* Initial Release

-- Hirotaka Wakabayashi <[email protected]> Fri, 14 Sep 2018 02:48:55 +0900
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Yahoo Japan Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 90bd9c6

Please sign in to comment.