Add ancillary files (license, readme, contributing, YAML.

This commit is contained in:
James Peachey
2024-05-31 10:07:09 -04:00
parent 7d9a054bfe
commit 2c9a70c11e
4 changed files with 169 additions and 0 deletions

116
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,116 @@
stages:
- update
- build
- verify
- deploy
variables:
JAVA_HOME: "/opt/openjdk17" # Sets Java version to run (see /opt for details)
VERSION_COMMIT: "GitLab CI Versioning Commit" # Commit text for version update
VERSION_BRANCH: "update_version" # Branch used to merge version update commit
# Sets the artifact cache to a local directory within build area
MAVEN_CLI_OPTS: "-Dmaven.repo.local=../.m2/repository --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN"
#Workflow rules that filters across the entire pipeline. Cleaner than -o ci.skip since there won't be a "skipped" pipeline.
workflow:
rules:
# If user is not the runner, branch is the default branch, and the pipeline source is a push
- if: '$GITLAB_USER_LOGIN != $RUNNER_USER_LOGIN && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
when: always
- if: '$GITLAB_USER_LOGIN != $RUNNER_USER_LOGIN && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
when: always
# if the first statement fails, never succeed
- when: never
pom to next version:
stage: update
script:
- export
# --- Get old version
- OLD_VERSION=$(mvn $MAVEN_CLI_OPTS -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
# --- Update the version
# ABC-bR-oldhash to ABC-b(R+1)-newhash
- UPDATED_VERSION=`echo $OLD_VERSION | awk -F '[-b]+' '{printf "%s-b%s\n",$1,(++$2)}'`
- echo $OLD_VERSION " updated to "$UPDATED_VERSION
# --- Create temporary branch for merge
# This helps "get around" the push restriction, if enforced
# Check if the branch exists, if it does then forceably delete it.
- if git show-ref --verify --quiet refs/heads/$VERSION_BRANCH; then git branch -D $VERSION_BRANCH; fi
- git branch $VERSION_BRANCH
- git checkout $VERSION_BRANCH
# --- Set the update version in the pom file(s)
- mvn $MAVEN_CLI_OPTS versions:set -q -DnewVersion=${UPDATED_VERSION}
# --- Merge new version to default branch
- git add -u # Only adds updated files, no new files (pom version backup skipped)
- git commit -q -m "${VERSION_COMMIT}"
- git checkout -q $CI_COMMIT_BRANCH
- git pull -q origin $CI_COMMIT_BRANCH
- git merge -q $VERSION_BRANCH
# Use the runner authentication token to push up the merge commit
- URL_TO_PUSH="http://${RUNNER_USER_LOGIN}:${RUNNER_USER_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
# Capture the merge request ID from the stderr output
- git push $URL_TO_PUSH HEAD:$VERSION_BRANCH -o merge_request.create -o merge_request.target=$CI_COMMIT_BRANCH -o merge_request.title=auto-merge-request-update-version-to-$UPDATED_VERSION -o merge_request.remove_source_branch 2> merge_request_created
- MR_ID=`grep "remote:" merge_request_created | grep http | sed 's:.*/::'`
# Accept the merge request with the GITLAB API
- URL_TO_MRACCEPT="${CI_SERVER_URL}/api/v4/projects/${CI_PROJECT_ID}/merge_requests/${MR_ID}/merge"
# sleep of 1 second seems to resolve the issue of the accept MR failure
- sleep 1
- 'curl --header "PRIVATE-TOKEN: ${RUNNER_USER_TOKEN}" --request PUT "${URL_TO_MRACCEPT}" > /dev/null 2>&1'
- rm merge_request_created # remove the file used to capture stderr from git push
rules:
- if: '$GITLAB_USER_LOGIN != $RUNNER_USER_LOGIN && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
when: never
- if: '$GITLAB_USER_LOGIN != $RUNNER_USER_LOGIN && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
when: never
maven build:
stage: build
script:
# --- Checks if code compiles
- mvn $MAVEN_CLI_OPTS clean compile
rules:
- if: '$GITLAB_USER_LOGIN != $RUNNER_USER_LOGIN && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
when: always
- if: '$GITLAB_USER_LOGIN != $RUNNER_USER_LOGIN && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
when: always
maven verify:
stage: verify
script:
# -fn indicates that it should never fail, this allows artifacts to be built even when unit tests fail to execute successfully
- mvn $MAVEN_CLI_OPTS clean verify
rules:
- if: '$GITLAB_USER_LOGIN != $RUNNER_USER_LOGIN && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
when: always
- if: '$GITLAB_USER_LOGIN != $RUNNER_USER_LOGIN && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
when: always
# instruct gitlab to capture the test reports
# test reporting to be handled in gitlab requires:
# sudo gitlab-rails console
# irb(main):001:0> Feature.enable(:junit_pipeline_view,Project.find(84))
artifacts:
reports:
junit:
- target/surefire-reports/TEST-*.xml
- target/failsafe-reports/TEST-*.xml
# Allows a this job to fail, and the pipeline will continue
allow_failure: true
maven deploy:
stage: deploy
script:
# --- Deploy to artifactory
# Again, -fn might be necessary here if artifacts are to be deployed even when unit tests fail
# -DskipTests will not execute unit tests, this should allow the artifact to be deployed if unit tests fail in the previous stage
# -Dmaven.test.skip=true will also stop the unit tests from being compiled--which potentially would speed this up
- mvn $MAVEN_CLI_OPTS -DskipTests clean deploy
rules:
- if: '$GITLAB_USER_LOGIN != $RUNNER_USER_LOGIN && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
when: manual
- if: '$GITLAB_USER_LOGIN != $RUNNER_USER_LOGIN && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
when: manual

16
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,16 @@
# Contributing
We welcome pull requests on this project. However, due to funding constraints, there is no guarantee that pull requests will be merged with the main line code or even reviewed. We will do the best we can.
To contribute: fork, then clone the repo:
```
git clone git@github.com:your-username/jsqrl.git
```
Make your changes, and push them to your fork. Then submit a pull request.
Things that will help increase that your pull request is reviewed and accepted:
- Write tests (and make sure they pass!)
- Write a [good commit message](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)

9
LICENSE.md Normal file
View File

@@ -0,0 +1,9 @@
# License
Copyright 2024 Johns Hopkins University Applied Physics Laboratory, LLC
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.

28
README.md Normal file
View File

@@ -0,0 +1,28 @@
# Jsqrl
Jsqrl (pronounced "Jay Squirrel") is a general use, low level Java library for saving/restoring the state of Java objects to/from JSON format files.
## Usage
Jsqrl directly supports saving and restoring Java primitive types, arrays, containers, and maps. There is a registry system to enable saving and restoring objects of arbitrary type. It can also save and restore the state of stateful (mutable) objects.
Jsqrl is available as a jar at [Maven Central](https://central.sonatype.com/artifact/edu.jhuapl.ses/jsqrl). The dependency listing is:
```
<dependency>
<groupId>edu.jhuapl.ses.jsqrl>/groupId>
<artifactId>jsqrl</artifactId>
<version>0.0.1</version>
</dependency>
```
## Contributing
Please see the [Contributing](Contributing.md) file for information. Pull requests will be reviewed and merged on a best-effort basis; there are no guarantees, due to funding restrictions.
## Code of Conduct
The Jsqrl package ascribes to the [Github Code of Conduct](https://docs.github.com/en/site-policy/github-terms/github-community-code-of-conduct).