|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 2 | +# contributor license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright ownership. |
| 4 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 5 | +# (the "License"); you may not use this file except in compliance with |
| 6 | +# the License. You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +version: v1.0 |
| 17 | +name: build-test-release |
| 18 | +agent: |
| 19 | + machine: |
| 20 | + type: s1-prod-ubuntu24-04-arm64-3 |
| 21 | +fail_fast: |
| 22 | + cancel: |
| 23 | + when: "true" |
| 24 | +execution_time_limit: |
| 25 | + hours: 4 |
| 26 | +queue: |
| 27 | + - when: "branch != 'master' and branch !~ '[0-9]+\\.[0-9]+\\.x'" |
| 28 | + processing: parallel |
| 29 | +global_job_config: |
| 30 | + env_vars: |
| 31 | + - name: NANO_VERSION |
| 32 | + value: "true" |
| 33 | + - name: PUBLISH |
| 34 | + value: "true" |
| 35 | + - name: ENABLE_PUBLISH_ARTIFACTS |
| 36 | + value: "true" |
| 37 | + - name: ENABLE_DOWNSTREAM_TRIGGER |
| 38 | + value: "true" |
| 39 | + - name: DOWNSTREAM_PROJECTS |
| 40 | + value: "common" |
| 41 | + prologue: |
| 42 | + commands: |
| 43 | + - echo $SEMAPHORE_WORKFLOW_ID |
| 44 | + - echo $SEMAPHORE_GIT_REPO_SLUG |
| 45 | + - checkout |
| 46 | + - sem-version java 21 |
| 47 | + - sem-version go 1.16.15 |
| 48 | + - sem-version python 3.11 |
| 49 | + - python --version |
| 50 | + - python -m venv junitparser |
| 51 | + - source junitparser/bin/activate |
| 52 | + - pip install junitparser |
| 53 | + - git config --global url."[email protected]:".insteadOf "https://github.com/" |
| 54 | + - export SEMAPHORE_CACHE_DIR=/home/semaphore |
| 55 | + - source scripts/set_env_vars.sh |
| 56 | + - source scripts/set_downstream_branch.sh |
| 57 | +blocks: |
| 58 | + - name: Gradle Build |
| 59 | + dependencies: [] |
| 60 | + task: |
| 61 | + jobs: |
| 62 | + - name: Build, Compile, Validations, Publish |
| 63 | + commands: |
| 64 | + - | |
| 65 | + if [[ "${SEMAPHORE_ORGANIZATION_URL}" != *".semaphoreci.com" ]]; then |
| 66 | + . vault-setup |
| 67 | + fi |
| 68 | + - >- |
| 69 | + if [[ "${SEMAPHORE_ORGANIZATION_URL}" != *".semaphoreci.com" ]] && [ "$NANO_VERSION" = "true" ] && [ "$RELEASE_JOB" = "false" ] && [ "$ENABLE_PUBLISH_ARTIFACTS" = "true" ]; then |
| 70 | + . ci-tools ci-update-version |
| 71 | + fi |
| 72 | + - | |
| 73 | + if [[ "${SEMAPHORE_ORGANIZATION_URL}" != *".semaphoreci.com" ]]; then |
| 74 | + make compile-validate |
| 75 | + fi |
| 76 | + - | |
| 77 | + if [[ "${SEMAPHORE_ORGANIZATION_URL}" != *".semaphoreci.com" ]] && [ "$PUBLISH" = "true" ] && [ "$SEMAPHORE_GIT_REF_TYPE" != "pull-request" ] && [ "$ENABLE_PUBLISH_ARTIFACTS" = "true" ]; then \ |
| 78 | + if [[ "$RELEASE_JOB" = "false" ]]; then \ |
| 79 | + . ci-tools ci-push-tag; \ |
| 80 | + mavenUrl=$(vault kv get v1/ci/kv/gradle/artifactory_snapshots_settings | grep mavenUrl | cut -d "," -f 2 | cut -d "'" -f 2); \ |
| 81 | + elif [[ "$SEMAPHORE_GIT_BRANCH" == *-alpha* ]]; then \ |
| 82 | + mavenUrl=$(vault kv get v1/ci/kv/gradle/artifactory_preview_release_settings | grep mavenUrl | cut -d "," -f 2 | cut -d "'" -f 2); \ |
| 83 | + fi; \ |
| 84 | + ./gradlewAll -PmavenUrl=$mavenUrl -PkeepAliveMode=session uploadArchives; \ |
| 85 | + fi |
| 86 | + - | |
| 87 | + echo "PUBLISH: $PUBLISH, RELEASE_JOB: $RELEASE_JOB, SEMAPHORE_GIT_REF_TYPE: $SEMAPHORE_GIT_REF_TYPE, ENABLE_DOWNSTREAM_TRIGGER: $ENABLE_DOWNSTREAM_TRIGGER" |
| 88 | + if [[ "${SEMAPHORE_ORGANIZATION_URL}" != *".semaphoreci.com" ]] && [ "$PUBLISH" = "true" ] && [ "$RELEASE_JOB" = "false" ] && [ "$SEMAPHORE_GIT_REF_TYPE" != "pull-request" ] && [ "$ENABLE_DOWNSTREAM_TRIGGER" = "true" ]; then |
| 89 | + for project in $DOWNSTREAM_PROJECTS; do |
| 90 | + sem-trigger -p $project -b $DOWNSTREAM_BRANCH_NAME -f .semaphore/semaphore.yml |
| 91 | + done |
| 92 | + fi |
| 93 | + - name: Tests |
| 94 | + dependencies: [] |
| 95 | + task: |
| 96 | + jobs: |
| 97 | + - name: Unit tests and Integration tests |
| 98 | + commands: |
| 99 | + - | |
| 100 | + ./gradlew \ |
| 101 | + unitTest integrationTest --no-daemon --stacktrace --continue \ |
| 102 | + -Dorg.gradle.jvmargs="-Xmx6g -Xss4m -XX:+UseParallelGC" \ |
| 103 | + -PtestLoggingEvents=started,passed,skipped,failed -PmaxParallelForks=2 \ |
| 104 | + -PignoreFailures=true -PmaxTestRetries=1 -PmaxTestRetryFailures=5 |
| 105 | + gradle_exit=$? |
| 106 | + |
| 107 | + # Check Gradle exit code and fail the job if non-zero |
| 108 | + if [ "$gradle_exit" -ne 0 ]; then |
| 109 | + echo "❌ Gradle exited with code $gradle_exit — failing the job." |
| 110 | + exit "$gradle_exit" |
| 111 | + else |
| 112 | + echo "✅ Gradle completed successfully (exit code 0)." |
| 113 | + fi |
| 114 | + |
| 115 | + shopt -s globstar |
| 116 | + python scripts/check_test_failures.py **/build/test-results/**/TEST-*.xml |
| 117 | + check_exit=$? |
| 118 | +
|
| 119 | + test-results publish --name Test-Suite --trim-output-to 1024 --omit-output-for-passed **/build/test-results/**/TEST-*.xml || true |
| 120 | +
|
| 121 | + # Check if check_test_failures.py returned non-zero exit code |
| 122 | + if [ "$check_exit" -ne 0 ]; then |
| 123 | + echo "❌ check_test_failures.py returned $check_exit" |
| 124 | + exit "$check_exit" |
| 125 | + fi |
| 126 | + execution_time_limit: |
| 127 | + minutes: 120 |
| 128 | + epilogue: |
| 129 | + always: |
| 130 | + commands: |
| 131 | + - | |
| 132 | + echo "Job creation time: $((SEMAPHORE_JOB_CREATION_TIME * 1000))" |
| 133 | + echo "Current time: $(date +%s%3N)" |
| 134 | + echo $(( ($(date +%s%3N) - $SEMAPHORE_JOB_CREATION_TIME * 1000) )) > duration.txt |
| 135 | + artifact push workflow duration.txt --destination $SEMAPHORE_JOB_INDEX-test-duration-$SEMAPHORE_WORKFLOW_ID || true |
| 136 | +after_pipeline: |
| 137 | + task: |
| 138 | + agent: |
| 139 | + machine: |
| 140 | + type: s1-prod-ubuntu24-04-arm64-0 |
| 141 | + jobs: |
| 142 | + - name: Metrics |
| 143 | + commands: |
| 144 | + - emit-ci-metrics -p -a test-results |
| 145 | + - name: Publish Test Results |
| 146 | + commands: |
| 147 | + - test-results gen-pipeline-report || true |
| 148 | + - name: SonarQube |
| 149 | + commands: |
| 150 | + - checkout |
| 151 | + - sem-version java 11 |
| 152 | + - emit-sonarqube-data -a test-results |
| 153 | + - name: Trigger cp-jar-build to verify CP packaging |
| 154 | + commands: |
| 155 | + - | |
| 156 | + if [[ -z "$SEMAPHORE_GIT_PR_BRANCH" ]] && [[ "$SEMAPHORE_GIT_BRANCH" == "master" ]]; then \ |
| 157 | + echo "Commit to master (not a PR), triggering cp-jar-build task to verify CP packaging"; \ |
| 158 | + sem-trigger -p packaging \ |
| 159 | + -t cp-jar-build-on-commit \ |
| 160 | + -d "|" -i "UPSTREAM_COMPONENT|$SEMAPHORE_PROJECT_NAME" \ |
| 161 | + -i "UPSTREAM_GIT_SHA|$SEMAPHORE_GIT_SHA" \ |
| 162 | + -i "UPSTREAM_WORKFLOW_LINK|https://semaphore.ci.confluent.io/workflows/${SEMAPHORE_WORKFLOW_ID}" \ |
| 163 | + -b $SEMAPHORE_GIT_BRANCH; \ |
| 164 | + else \ |
| 165 | + echo "Skipping: either it's a PR or not a commit to master branch"; \ |
| 166 | + fi; |
0 commit comments