blob: 2d3258ccc5a56e1e0c8d07e648aa961157c2a984 [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: build-branch
on:
- push
- pull_request
env:
WITH_COVERAGE: true
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Cache for maven dependencies
uses: actions/cache@v4
with:
path: |
~/.m2/repository
!~/.m2/repository/org/apache/ratis
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-repo-
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 8
- name: Run a full build
run: ./dev-support/checks/build.sh -Prelease assembly:single
- name: Store binaries for tests
uses: actions/upload-artifact@v4
with:
name: ratis-bin
path: |
ratis-assembly/target/apache-ratis-*.tar.gz
!ratis-assembly/target/apache-ratis-*-src.tar.gz
retention-days: 1
- name: Store source tarball for compilation
uses: actions/upload-artifact@v4
with:
name: ratis-src
path: ratis-assembly/target/apache-ratis-*-src.tar.gz
retention-days: 1
compile:
needs:
- build
runs-on: ubuntu-20.04
strategy:
matrix:
java: [ 11 ]
fail-fast: false
steps:
- name: Download source tarball
uses: actions/download-artifact@v4
with:
name: ratis-src
- name: Untar sources
run: |
tar --strip-components 1 -xzvf apache-ratis-*-src.tar.gz
- name: Cache for maven dependencies
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
!~/.m2/repository/org/apache/ratis
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-repo-
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Run a full build
run: ./dev-support/checks/build.sh
rat:
name: rat
runs-on: ubuntu-20.04
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Cache for maven dependencies
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
!~/.m2/repository/org/apache/ratis
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-repo-
- name: Run tests
run: ./dev-support/checks/rat.sh
- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: rat
path: target/rat
author:
name: author
runs-on: ubuntu-20.04
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Run tests
run: ./dev-support/checks/author.sh
- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: author
path: target/author
unit:
name: unit
runs-on: ubuntu-20.04
strategy:
matrix:
profile:
- grpc
- server
- misc
fail-fast: false
steps:
# TEMPORARY WHILE GITHUB FIXES https://github.com/actions/virtual-environments/issues/3185
- name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
run: |
echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
# REMOVE CODE ABOVE WHEN ISSUE IS ADDRESSED!
- name: Checkout project
uses: actions/checkout@v4
- name: Cache for maven dependencies
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
!~/.m2/repository/org/apache/ratis
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-repo-
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 8
- name: Run tests
run: ./dev-support/checks/unit.sh -P${{ matrix.profile }}-tests
- name: Summary of failures
run: cat target/${{ github.job }}/summary.txt
if: ${{ !cancelled() }}
- name: Upload results
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: unit-${{ matrix.profile }}
path: target/unit
checkstyle:
name: checkstyle
runs-on: ubuntu-20.04
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Cache for maven dependencies
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
!~/.m2/repository/org/apache/ratis
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-repo-
- name: Run tests
run: ./dev-support/checks/checkstyle.sh
- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: checkstyle
path: target/checkstyle
findbugs:
name: findbugs
runs-on: ubuntu-20.04
steps:
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 8
- name: Checkout project
uses: actions/checkout@v4
- name: Cache for maven dependencies
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
!~/.m2/repository/org/apache/ratis
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-repo-
- name: Run tests
run: ./dev-support/checks/findbugs.sh
- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: findbugs
path: target/findbugs
coverage:
needs:
- build
- unit
runs-on: ubuntu-20.04
if: (github.repository == 'apache/ratis' || github.repository == 'apache/incubator-ratis') && github.event_name != 'pull_request'
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache for maven dependencies
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
!~/.m2/repository/org/apache/ratis
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-repo-
- name: Setup java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: target/artifacts
- name: Untar binaries
run: |
mkdir -p ratis-assembly/target
tar xzvf target/artifacts/ratis-bin/apache-ratis*.tar.gz -C ratis-assembly/target
- name: Calculate combined coverage
run: ./dev-support/checks/coverage.sh
- name: Upload coverage to Sonar
run: ./dev-support/checks/sonar.sh
env:
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Archive build results
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ github.job }}
path: target/${{ github.job }}