|
| 1 | +# Default image for linux builds |
| 2 | +image: objectboxio/buildenv:21.11.11-centos7 |
| 3 | + |
| 4 | +# Assumes these environment variables are configured in GitLab CI/CD Settings: |
| 5 | +# - SONATYPE_USER |
| 6 | +# - SONATYPE_PWD |
| 7 | +# - GOOGLE_CHAT_WEBHOOK_JAVA_CI |
| 8 | +# Additionally, Gradle scripts assume these Gradle project properties are set: |
| 9 | +# https://docs.gradle.org/current/userguide/build_environment.html#sec:project_properties |
| 10 | +# - ORG_GRADLE_PROJECT_signingKeyFile |
| 11 | +# - ORG_GRADLE_PROJECT_signingKeyId |
| 12 | +# - ORG_GRADLE_PROJECT_signingPassword |
| 13 | + |
| 14 | +variables: |
| 15 | + # Disable the Gradle daemon for Continuous Integration servers as correctness |
| 16 | + # is usually a priority over speed in CI environments. Using a fresh |
| 17 | + # runtime for each build is more reliable since the runtime is completely |
| 18 | + # isolated from any previous builds. |
| 19 | + GRADLE_OPTS: "-Dorg.gradle.daemon=false" |
| 20 | + GITLAB_REPO_ARGS: "-PgitlabUrl=$CI_SERVER_URL -PgitlabTokenName=Job-Token -PgitlabPrivateToken=$CI_JOB_TOKEN" |
| 21 | + CENTRAL_REPO_ARGS: "-PsonatypeUsername=$SONATYPE_USER -PsonatypePassword=$SONATYPE_PWD" |
| 22 | + # CI_COMMIT_REF_SLUG is the branch or tag name, but web-safe (only 0-9, a-z) |
| 23 | + VERSION_ARGS: "-PversionPostFix=$CI_COMMIT_REF_SLUG" |
| 24 | + |
| 25 | +# Using multiple test stages to avoid running some things in parallel (see job notes). |
| 26 | +stages: |
| 27 | + - test |
| 28 | + - test-2 |
| 29 | + - test-3 |
| 30 | + - upload-to-internal |
| 31 | + - upload-to-central |
| 32 | + - package-api-docs |
| 33 | + - integ-tests |
| 34 | + |
| 35 | +test: |
| 36 | + stage: test |
| 37 | + tags: [ docker, x64 ] |
| 38 | + before_script: |
| 39 | + # Print Gradle and JVM version info |
| 40 | + - ./gradlew -version |
| 41 | + # Remove any previous JVM (Hotspot) crash log. |
| 42 | + # "|| true" for an OK exit code if no file is found |
| 43 | + - rm **/hs_err_pid*.log || true |
| 44 | + script: |
| 45 | + - ./ci/test-with-asan.sh $GITLAB_REPO_ARGS $VERSION_ARGS clean build |
| 46 | + artifacts: |
| 47 | + when: always |
| 48 | + paths: |
| 49 | + - "**/hs_err_pid*.log" # Only on JVM (Hotspot) crash. |
| 50 | + - "**/build/reports/spotbugs/*.html" |
| 51 | + reports: |
| 52 | + junit: "**/build/test-results/**/TEST-*.xml" |
| 53 | + |
| 54 | +.test-template: |
| 55 | + before_script: |
| 56 | + # Remove any previous JVM (Hotspot) crash log. |
| 57 | + # "|| true" for an OK exit code if no file is found |
| 58 | + - rm **/hs_err_pid*.log || true |
| 59 | + artifacts: |
| 60 | + when: always |
| 61 | + paths: |
| 62 | + - "**/hs_err_pid*.log" # Only on JVM (Hotspot) crash. |
| 63 | + reports: |
| 64 | + junit: "**/build/test-results/**/TEST-*.xml" |
| 65 | + |
| 66 | +test-windows: |
| 67 | + extends: .test-template |
| 68 | + stage: test-2 |
| 69 | + tags: [ windows ] |
| 70 | + script: ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean build |
| 71 | + |
| 72 | +test-macos: |
| 73 | + extends: .test-template |
| 74 | + stage: test-2 |
| 75 | + tags: [mac11+, x64] |
| 76 | + script: ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean build |
| 77 | + |
| 78 | +# Address sanitizer is only available on Linux runners (see script). |
| 79 | +.test-asan-template: |
| 80 | + extends: .test-template |
| 81 | + tags: [ docker, x64 ] |
| 82 | + script: |
| 83 | + # Note: do not run check task as it includes SpotBugs. |
| 84 | + - ./ci/test-with-asan.sh $GITLAB_REPO_ARGS $VERSION_ARGS clean :tests:objectbox-java-test:test |
| 85 | + |
| 86 | +# Test oldest supported and a recent JDK. |
| 87 | +# Note: can not run these in parallel using a matrix configuration as Gradle would step over itself. |
| 88 | +test-jdk-8: |
| 89 | + extends: .test-asan-template |
| 90 | + stage: test-2 |
| 91 | + variables: |
| 92 | + TEST_JDK: 8 |
| 93 | + |
| 94 | +test-jdk-16: |
| 95 | + extends: .test-asan-template |
| 96 | + stage: test-3 |
| 97 | + variables: |
| 98 | + TEST_JDK: 16 |
| 99 | + |
| 100 | +test-jdk-x86: |
| 101 | + extends: .test-template |
| 102 | + stage: test-3 |
| 103 | + tags: [ windows ] |
| 104 | + variables: |
| 105 | + # TEST_WITH_JAVA_X86 makes objectbox-java-test use 32-bit java executable and therefore |
| 106 | + # 32-bit ObjectBox to run tests (see build.gradle file). |
| 107 | + # Note: assumes JAVA_HOME_X86 is set to 32-bit JDK path. |
| 108 | + TEST_WITH_JAVA_X86: "true" |
| 109 | + script: ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean build |
| 110 | + |
| 111 | +upload-to-internal: |
| 112 | + stage: upload-to-internal |
| 113 | + tags: [ docker, x64 ] |
| 114 | + script: |
| 115 | + - ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS publishMavenJavaPublicationToGitLabRepository |
| 116 | + |
| 117 | +upload-to-central: |
| 118 | + stage: upload-to-central |
| 119 | + tags: [ docker, x64 ] |
| 120 | + only: |
| 121 | + - publish |
| 122 | + before_script: |
| 123 | + - ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "*Releasing Java library:* job $CI_JOB_NAME from branch $CI_COMMIT_BRANCH ($CI_COMMIT_SHORT_SHA)..." |
| 124 | + script: |
| 125 | + # Note: supply internal repo as tests use native dependencies that might not be published, yet. |
| 126 | + - ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS $CENTRAL_REPO_ARGS publishMavenJavaPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository |
| 127 | + after_script: |
| 128 | + # Also runs on failure, so show CI_JOB_STATUS. |
| 129 | + - ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "*Releasing Java library:* *$CI_JOB_STATUS* for $CI_JOB_NAME" |
| 130 | + - ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "Check https://repo1.maven.org/maven2/io/objectbox/ in a few minutes." |
| 131 | + |
| 132 | +package-api-docs: |
| 133 | + stage: package-api-docs |
| 134 | + tags: [ docker, x64 ] |
| 135 | + only: |
| 136 | + - publish |
| 137 | + script: |
| 138 | + - ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS :objectbox-java:packageJavadocForWeb |
| 139 | + after_script: |
| 140 | + - ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "API docs for web available as job artifact $CI_JOB_URL" |
| 141 | + artifacts: |
| 142 | + paths: |
| 143 | + - "objectbox-java/build/dist/objectbox-java-web-api-docs.zip" |
| 144 | + |
| 145 | +trigger-integ-tests: |
| 146 | + stage: integ-tests |
| 147 | + except: |
| 148 | + - schedules # Do not trigger when run on schedule, integ tests have own schedule. |
| 149 | + inherit: |
| 150 | + variables: false |
| 151 | + allow_failure: true # Branch might not exist in integ test project. |
| 152 | + trigger: |
| 153 | + project: objectbox/objectbox-integration-test |
| 154 | + branch: $CI_COMMIT_BRANCH |
0 commit comments