|
| 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 | +# This workflow can be called by other workflows to build Ratis. |
| 17 | +# |
| 18 | +# Inputs: |
| 19 | +# - Ratis repo |
| 20 | +# - the commit to build |
| 21 | +# Outputs: |
| 22 | +# - various version numbers that need to be provided to the Ozone build process. |
| 23 | +# - Ratis repository is uploaded as an artifact named `ratis-jars` |
| 24 | +# |
| 25 | +# See `intermittent-test-check.yml` as an example use of this workflow. |
| 26 | + |
| 27 | +name: build-ratis |
| 28 | +on: |
| 29 | + workflow_call: |
| 30 | + inputs: |
| 31 | + repo: |
| 32 | + description: Ratis repository |
| 33 | + default: apache/ratis |
| 34 | + required: false |
| 35 | + type: string |
| 36 | + ref: |
| 37 | + description: Ratis ref (branch, tag or commit SHA) |
| 38 | + default: master |
| 39 | + required: false |
| 40 | + type: string |
| 41 | + outputs: |
| 42 | + ratis-version: |
| 43 | + description: "Ratis Version" |
| 44 | + value: ${{ jobs.ratis.outputs.ratis-version }} |
| 45 | + thirdparty-version: |
| 46 | + description: "Ratis Third-Party Version" |
| 47 | + value: ${{ jobs.ratis.outputs.thirdparty-version }} |
| 48 | + grpc-version: |
| 49 | + description: "gRPC Version" |
| 50 | + value: ${{ jobs.ratis-thirdparty.outputs.grpc-version }} |
| 51 | + netty-version: |
| 52 | + description: "Netty Version" |
| 53 | + value: ${{ jobs.ratis-thirdparty.outputs.netty-version }} |
| 54 | + protobuf-version: |
| 55 | + description: "Protobuf Version" |
| 56 | + value: ${{ jobs.ratis-thirdparty.outputs.protobuf-version }} |
| 57 | +env: |
| 58 | + MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 |
| 59 | +jobs: |
| 60 | + ratis: |
| 61 | + runs-on: ubuntu-24.04 |
| 62 | + timeout-minutes: 60 |
| 63 | + outputs: |
| 64 | + ratis-version: ${{ steps.versions.outputs.ratis }} |
| 65 | + thirdparty-version: ${{ steps.versions.outputs.thirdparty }} |
| 66 | + steps: |
| 67 | + - name: Checkout project |
| 68 | + uses: actions/checkout@v4 |
| 69 | + with: |
| 70 | + repository: ${{ inputs.repo }} |
| 71 | + ref: ${{ inputs.ref }} |
| 72 | + - name: Cache for maven dependencies |
| 73 | + uses: actions/cache@v4 |
| 74 | + with: |
| 75 | + path: | |
| 76 | + ~/.m2/repository |
| 77 | + !~/.m2/repository/org/apache/ratis |
| 78 | + key: ratis-dependencies-${{ hashFiles('**/pom.xml') }} |
| 79 | + - name: Setup java |
| 80 | + uses: actions/setup-java@v4 |
| 81 | + with: |
| 82 | + distribution: 'temurin' |
| 83 | + java-version: 8 |
| 84 | + - name: Get component versions |
| 85 | + id: versions |
| 86 | + run: | |
| 87 | + thirdparty_version="$(mvn help:evaluate -N -q -DforceStdout -Dscan=false -Dexpression=ratis.thirdparty.version)" |
| 88 | + echo "thirdparty=${thirdparty_version}" >> $GITHUB_OUTPUT |
| 89 | +
|
| 90 | + ratis_sha=$(git rev-parse --short HEAD) |
| 91 | + ratis_version="$(mvn help:evaluate -N -q -DforceStdout -Dscan=false -Dexpression=project.version | sed -e "s/-SNAPSHOT/-${ratis_sha}-SNAPSHOT/")" |
| 92 | + echo "ratis=${ratis_version}" >> $GITHUB_OUTPUT |
| 93 | + - name: Run a full build |
| 94 | + run: | |
| 95 | + mvn -B --no-transfer-progress -Dscan=false versions:set -DnewVersion=${{ steps.versions.outputs.ratis }} |
| 96 | + dev-support/checks/build.sh |
| 97 | + - name: Store Maven repo for tests |
| 98 | + uses: actions/upload-artifact@v4 |
| 99 | + with: |
| 100 | + name: ratis-jars |
| 101 | + path: | |
| 102 | + ~/.m2/repository/org/apache/ratis |
| 103 | + retention-days: 1 |
| 104 | + ratis-thirdparty: |
| 105 | + runs-on: ubuntu-24.04 |
| 106 | + needs: |
| 107 | + - ratis |
| 108 | + timeout-minutes: 30 |
| 109 | + outputs: |
| 110 | + grpc-version: ${{ steps.versions.outputs.grpc }} |
| 111 | + netty-version: ${{ steps.versions.outputs.netty }} |
| 112 | + protobuf-version: ${{ steps.versions.outputs.protobuf }} |
| 113 | + steps: |
| 114 | + - name: Checkout project |
| 115 | + uses: actions/checkout@v4 |
| 116 | + with: |
| 117 | + repository: apache/ratis-thirdparty |
| 118 | + ref: ${{ needs.ratis.outputs.thirdparty-version }} |
| 119 | + - name: Get component versions |
| 120 | + id: versions |
| 121 | + run: | |
| 122 | + echo "grpc=$(mvn help:evaluate -N -q -DforceStdout -Dscan=false -Dexpression=shaded.grpc.version)" >> $GITHUB_OUTPUT |
| 123 | + echo "netty=$(mvn help:evaluate -N -q -DforceStdout -Dscan=false -Dexpression=shaded.netty.version)" >> $GITHUB_OUTPUT |
| 124 | + echo "protobuf=$(mvn help:evaluate -N -q -DforceStdout -Dscan=false -Dexpression=shaded.protobuf.version)" >> $GITHUB_OUTPUT |
| 125 | + debug: |
| 126 | + runs-on: ubuntu-24.04 |
| 127 | + needs: |
| 128 | + - ratis |
| 129 | + - ratis-thirdparty |
| 130 | + steps: |
| 131 | + - name: Print versions |
| 132 | + run: | |
| 133 | + echo ${{ needs.ratis.outputs.ratis-version }} |
| 134 | + echo ${{ needs.ratis.outputs.thirdparty-version }} |
| 135 | + echo ${{ needs.ratis-thirdparty.outputs.grpc-version }} |
| 136 | + echo ${{ needs.ratis-thirdparty.outputs.netty-version }} |
| 137 | + echo ${{ needs.ratis-thirdparty.outputs.protobuf-version }} |
0 commit comments