add: ci for java #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Java CI | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| branches: | |
| - main | |
| - master | |
| push: | |
| branches: | |
| - main | |
| - master | |
| jobs: | |
| build: | |
| name: Build and Test | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| java: [25] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up JDK ${{ matrix.java }} | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: ${{ matrix.java }} | |
| distribution: 'temurin' | |
| cache: 'gradle' | |
| - name: Install Ubuntu dependencies | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake build-essential libboost-all-dev | |
| - name: Install macOS dependencies | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install cmake boost | |
| - name: Cache Bitcoin Kernel build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| bitcoinkernel/bitcoin/build | |
| /usr/local/lib/libbitcoinkernel.* | |
| key: ${{ runner.os }}-bitcoinkernel-${{ hashFiles('bitcoinkernel/bitcoin/**') }} | |
| restore-keys: | | |
| ${{ runner.os }}-bitcoinkernel- | |
| - name: Build bitcoinkernel | |
| run: | | |
| cd bitcoinkernel/bitcoin | |
| cmake -B build -DBUILD_KERNEL_LIB=ON -DCMAKE_BUILD_TYPE=Release | |
| cmake --build build -j$(nproc 2>/dev/null || sysctl -n hw.ncpu) | |
| sudo cmake --install build | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Build with Gradle | |
| run: ./gradlew build --no-daemon --stacktrace | |
| - name: Run tests | |
| run: ./gradlew test --no-daemon --stacktrace | |
| continue-on-error: false | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-${{ matrix.os }}-java${{ matrix.java }} | |
| path: | | |
| build/reports/tests/ | |
| build/test-results/ | |
| - name: Upload build artifacts | |
| if: success() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifacts-${{ matrix.os }}-java${{ matrix.java }} | |
| path: build/libs/ | |
| code-quality: | |
| name: Code Quality Checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 25 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 25 | |
| distribution: 'temurin' | |
| cache: 'gradle' | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Run checkstyle (if configured) | |
| run: ./gradlew checkstyleMain checkstyleTest --no-daemon | |
| continue-on-error: true | |
| - name: Run spotbugs (if configured) | |
| run: ./gradlew spotbugsMain --no-daemon | |
| continue-on-error: true |