MapWithAI/.gitlab-ci.yml

305 wiersze
8.5 KiB
YAML
Czysty Zwykły widok Historia

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: Code-Quality.gitlab-ci.yml
- template: SAST.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: {}
variables:
GRADLE_PATH: "./gradlew"
FAIL_NEVER: 1
# CI_DEBUG_TRACE: "true"
###############
# Build stage #
###############
assemble:
stage: build
script:
- ./gradlew assemble
artifacts:
paths:
- build/
assemble with java 11:
stage: build
image: registry.gitlab.com/josm/docker-library/openjdk-11-josmplugin:latest
script:
- ./gradlew assemble
artifacts:
paths:
- build/
assemble with java 12:
stage: build
image: registry.gitlab.com/josm/docker-library/openjdk-12-josmplugin:latest
script:
- ./gradlew assemble
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
artifacts:
paths:
- build/
allow_failure: true
assemble with java 14:
stage: build
image: registry.gitlab.com/josm/docker-library/openjdk-14-josmplugin:latest
script:
- ./gradlew assemble
artifacts:
paths:
- build/
allow_failure: true
assemble with java 15:
stage: build
image: registry.gitlab.com/josm/docker-library/openjdk-15-josmplugin:latest
script:
- ./gradlew assemble
artifacts:
paths:
- build/
allow_failure: true
code_navigation:
stage: build
image: maven:3-openjdk-8
script:
- cat /etc/os-release
- apt update && apt install -y git
- git clone https://github.com/sourcegraph/lsif-java
- cd lsif-java
- ./gradlew installDist
- cd ..
- ./gradlew generatePomFileForJosmPluginPublication
- cp ./build/publications/josmPlugin/pom-default.xml ./pom.xml
- $(pwd)/lsif-java/build/install/lsifjava/bin/lsifjava -projectRoot . -out dump.lsif -debug
artifacts:
reports:
lsif: dump.lsif
rules:
- if: '$CI_PIPELINE_SOURCE != "schedule" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: always
allow_failure: true
##############
# Test stage #
##############
build:
stage: test
script:
- ./gradlew build generatePot generateSnapshotUpdateSite #--info
artifacts:
paths:
- build
needs: ["assemble"]
sonarcloud.io:
image: registry.gitlab.com/josm/docker-library/openjdk-11-josmplugin:latest
stage: test
environment:
name: sonarcloud.io
url: https://sonarcloud.io/dashboard?id=mapwithai
script:
- git fetch --unshallow
- ./gradlew -Dsonar.login=$SONAR_TOKEN sonarqube
rules:
- if: '$CI_COMMIT_TAG && $SONAR_TOKEN =~ /[0-9a-z]+/'
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $SONAR_TOKEN =~ /[0-9a-z]+/'
- if: '$CI_MERGE_REQUEST_IID && $SONAR_TOKEN =~ /[0-9a-z]+/'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $SONAR_TOKEN =~ /[0-9a-z]+/'
test:
stage: test
script:
- ./gradlew check --stacktrace --continue #--info
- ./gradlew jacocoTestReport
- ./gradlew jacocoTestCoverageVerification
artifacts:
paths:
- build
reports:
junit: build/test-results/**/TEST-*.xml
needs: ["assemble"]
compile against min JOSM:
stage: test
script:
- ./gradlew compileJava_minJosm
needs: ["assemble"]
compile against latest JOSM:
stage: test
script:
- ./gradlew compileJava_latestJosm
needs: ["assemble"]
build with java 11:
stage: test
image: registry.gitlab.com/josm/docker-library/openjdk-11-josmplugin:latest
script:
- ./gradlew build
allow_failure: true # due to copy-paste-detection
needs: ["assemble with java 11"]
build with java 12:
stage: test
image: registry.gitlab.com/josm/docker-library/openjdk-12-josmplugin:latest
script:
- ./gradlew build
allow_failure: true
needs: ["assemble with java 12"]
build with java 13:
stage: test
image: registry.gitlab.com/josm/docker-library/openjdk-13-josmplugin:latest
script:
- ./gradlew build
allow_failure: true
needs: ["assemble with java 13"]
build with java 14:
stage: test
image: registry.gitlab.com/josm/docker-library/openjdk-14-josmplugin:latest
script:
- ./gradlew build
allow_failure: true
needs: ["assemble with java 14"]
build with java 15:
stage: test
image: registry.gitlab.com/josm/docker-library/openjdk-15-josmplugin:latest
script:
- ./gradlew build
allow_failure: true
needs: ["assemble with java 15"]
################
# Deploy stage #
################
#upload to transifex:
# image: python:3.6-stretch
# stage: deploy
# environment:
# name: transifex
# url: https://www.transifex.com/josm/josm/josm-plugin_mapwithai/
# 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
# needs: ["assemble"]
# 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
- &current_version |
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
needs: ["compile against min JOSM", "compile against latest JOSM", "build"]
rules:
- if: '$SSH_PRIVATE_DEPLOY_KEY != null && $CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG != null && $CI_PIPELINE_SOURCE != "schedule"'
when: manual
release hotfix:
stage: deploy
environment:
name: pages branch / dist directory
url: ${CI_PAGES_URL}/${CI_PROJECT_NAME}
script:
- *clone_pages_branch
- *current_version
- |
mkdir -pv "pages/public/dist/$version"
cp -v "build/dist/"* "build/tmp/jar/MANIFEST.MF" "pages/public/dist/$version"
- *push_pages_branch
needs: ["compile against min JOSM", "compile against latest JOSM", "build"]
rules:
- if: '$SSH_PRIVATE_DEPLOY_KEY != null && $CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG != null && $CI_PIPELINE_SOURCE != "schedule" && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
when: always
publish update site:
stage: deploy
environment:
name: pages branch / snapshot update site
url: ${CI_PAGES_URL}/${CI_PROJECT_NAME}/snapshot/${CI_COMMIT_REF_NAME}/update-site
script:
- *clone_pages_branch
- |
commitHash=`git rev-parse HEAD`
commitMessage="Make latest commit from ${CI_COMMIT_REF_NAME} available via JOSM update site ($commitHash)"
- |
rm -vrf "pages/public/snapshot/${CI_COMMIT_REF_NAME}"
mkdir -pv "pages/public/snapshot/${CI_COMMIT_REF_NAME}"
cp -v "build/snapshot-update-site" "pages/public/snapshot/${CI_COMMIT_REF_NAME}/update-site"
cp -v "build/dist/"* "pages/public/snapshot/${CI_COMMIT_REF_NAME}"
cp -v "build/dist/mapwithai.jar" "pages/public/snapshot/${CI_COMMIT_REF_NAME}/mapwithai-dev.jar"
- *push_pages_branch
needs: ["compile against min JOSM", "compile against latest JOSM", "build"]
rules:
- if: '$SSH_PRIVATE_DEPLOY_KEY != null && $CI_PIPELINE_SOURCE != "schedule" && $CI_COMMIT_REF_NAME != null'
when: always
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
needs: ["compile against min JOSM", "compile against latest JOSM", "build"]
rules:
- if: '$SSH_PRIVATE_DEPLOY_KEY != null && $CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG != null && $CI_PIPELINE_SOURCE != "schedule"'
when: always