Skip to content

Commit

Permalink
Add gitlab ci and gradle build scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed Oct 18, 2019
1 parent faec1ae commit f728aa5
Show file tree
Hide file tree
Showing 9 changed files with 738 additions and 33 deletions.
217 changes: 217 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
image: registry.gitlab.com/josm/docker-library/openjdk-8-josmplugin:latest

before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle

cache:
paths:
- .gradle/wrapper
- .gradle/caches

#############################
# Various additional Checks #
#############################
#include:
# - template: SAST.gitlab-ci.yml
# - template: Code-Quality.gitlab-ci.yml
# - template: Dependency-Scanning.gitlab-ci.yml
# - template: Container-Scanning.gitlab-ci.yml
# - template: DAST.gitlab-ci.yml
# - template: License-Management.gitlab-ci.yml

#sast:
# variables:
# GRADLE_PATH: "./gradlew"
# CI_DEBUG_TRACE: "true"

###############
# Build stage #
###############

assemble:
stage: build
script:
- ./gradlew assemble --stacktrace
artifacts:
paths:
- build/

assemble with java 11:
stage: build
image: registry.gitlab.com/josm/docker-library/openjdk-11-josmplugin:latest
script:
- ./gradlew assemble --stacktrace
artifacts:
paths:
- build/

assemble with java 12:
stage: build
image: registry.gitlab.com/josm/docker-library/openjdk-12-josmplugin:latest
script:
- ./gradlew assemble --stacktrace
artifacts:
paths:
- build/
allow_failure: true

assemble with java 13:
stage: build
image: registry.gitlab.com/josm/docker-library/openjdk-13-josmplugin:latest
script:
- ./gradlew assemble --stacktrace
artifacts:
paths:
- build/
allow_failure: true

##############
# Test stage #
##############

build:
stage: test
script:
- ./gradlew build generateSnapshotUpdateSite --stacktrace
artifacts:
paths:
- build
reports:
codequality: build/reports/pmd/main.xml
sast: build/reports/spotbugs/main.html
#junit: build/test-results/test/TEST-*.xml
dependencies:
- assemble

compile against min JOSM:
stage: test
script:
- ./gradlew compileJava_minJosm
dependencies:
- assemble

compile against latest JOSM:
stage: test
script:
- ./gradlew compileJava_latestJosm
dependencies:
- assemble

build with java 11:
stage: test
image: registry.gitlab.com/josm/docker-library/openjdk-11-josmplugin:latest
script:
- ./gradlew build --stacktrace
dependencies:
- assemble with java 11
allow_failure: true # due to copy-paste-detection

build with java 12:
stage: test
image: registry.gitlab.com/josm/docker-library/openjdk-12-josmplugin:latest
script:
- ./gradlew build --stacktrace
dependencies:
- assemble with java 12
allow_failure: true

build with java 13:
stage: test
image: registry.gitlab.com/josm/docker-library/openjdk-13-josmplugin:latest
script:
- ./gradlew build --stacktrace
dependencies:
- assemble with java 13
allow_failure: true

################
# Deploy stage #
################

#upload to transifex:
# image: python:3.6-stretch
# stage: deploy
# environment:
# name: transifex
# url: https://www.transifex.com/josm/josm/josm-plugin_highwaynamemodification/
# before_script:
# - apt-get update && apt-get install -yq gettext git
# - pip install git+https://github.com/transifex/transifex-client.git
# script:
# - TX_TOKEN="$TRANSIFEX_TOKEN" tx push -s --no-interactive
# dependencies:
# - build
# only:
# - master

release:
stage: deploy
environment:
name: pages branch / dist directory
url: ${CI_PAGES_URL}/${CI_PROJECT_NAME}
script:
- &clone_pages_branch |
echo "$SSH_PRIVATE_DEPLOY_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
git clone --depth 1 --branch pages git@${CI_SERVER_HOST}:${CI_PROJECT_PATH} pages
- |
version=`git describe --always --dirty`
longVersion=`git describe --always --long --dirty`
commitMessage="Release version $longVersion"
- |
mkdir -pv "pages/public/dist/$version"
cp -v "build/dist/"* "build/tmp/jar/MANIFEST.MF" "pages/public/dist/$version"
rm -fv "pages/public/dist/latest"
ln -s "./$version" "pages/public/dist/latest"
- &push_pages_branch |
cd pages/
git config user.name "Deploy with GitLab CI"
git config user.email "${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}@${CI_SERVER_HOST}"
git stage .
git commit -a -m "$commitMessage"
git push origin pages
dependencies:
- build
only:
refs:
- tags
variables:
- $SSH_PRIVATE_DEPLOY_KEY

publish master update site:
stage: deploy
environment:
name: pages branch / snapshot update site
url: ${CI_PAGES_URL}/${CI_PROJECT_NAME}/snapshot/master/update-site
script:
- *clone_pages_branch
- |
commitHash=`git rev-parse HEAD`
commitMessage="Make latest commit from master available via JOSM update site ($commitHash)"
- |
rm -vrf "pages/public/snapshot/master"
mkdir -pv "pages/public/snapshot/master"
cp -v "build/snapshot-update-site" "pages/public/snapshot/master/update-site"
cp -v "build/dist/"* "pages/public/snapshot/master"
- *push_pages_branch
dependencies:
- build
only:
refs:
- master
variables:
- $SSH_PRIVATE_DEPLOY_KEY

publish to / GitLab.com packages:
stage: deploy
environment:
name: GitLab.com / ${CI_PROJECT_NAME} packages
url: ${CI_PROJECT_URL}/-/packages
script:
- ./gradlew publishAllPublicationsToGitlabRepository
- ./gradlew releaseToGitlab
dependencies:
- build
only:
refs:
- tags
Loading

0 comments on commit f728aa5

Please sign in to comment.