Skip to content

Commit 58898e1

Browse files
committed
add: ci for java
1 parent 63dfb5c commit 58898e1

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

.github/workflows/ci.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Java CI
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
branches:
7+
- main
8+
- master
9+
push:
10+
branches:
11+
- main
12+
- master
13+
14+
jobs:
15+
build:
16+
name: Build and Test
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
matrix:
20+
os: [ubuntu-latest, macos-latest]
21+
java: [25]
22+
fail-fast: false
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
with:
28+
submodules: recursive
29+
30+
- name: Set up JDK ${{ matrix.java }}
31+
uses: actions/setup-java@v4
32+
with:
33+
java-version: ${{ matrix.java }}
34+
distribution: 'temurin'
35+
cache: 'gradle'
36+
37+
- name: Install Ubuntu dependencies
38+
if: runner.os == 'Linux'
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get install -y cmake build-essential libboost-all-dev
42+
43+
- name: Install macOS dependencies
44+
if: runner.os == 'macOS'
45+
run: |
46+
brew install cmake boost
47+
48+
- name: Cache Bitcoin Kernel build
49+
uses: actions/cache@v4
50+
with:
51+
path: |
52+
bitcoinkernel/bitcoin/build
53+
/usr/local/lib/libbitcoinkernel.*
54+
key: ${{ runner.os }}-bitcoinkernel-${{ hashFiles('bitcoinkernel/bitcoin/**') }}
55+
restore-keys: |
56+
${{ runner.os }}-bitcoinkernel-
57+
58+
- name: Build bitcoinkernel
59+
run: |
60+
cd bitcoinkernel/bitcoin
61+
cmake -B build -DBUILD_KERNEL_LIB=ON -DCMAKE_BUILD_TYPE=Release
62+
cmake --build build -j$(nproc 2>/dev/null || sysctl -n hw.ncpu)
63+
sudo cmake --install build
64+
65+
- name: Grant execute permission for gradlew
66+
run: chmod +x gradlew
67+
68+
- name: Build with Gradle
69+
run: ./gradlew build --no-daemon --stacktrace
70+
71+
- name: Run tests
72+
run: ./gradlew test --no-daemon --stacktrace
73+
continue-on-error: false
74+
75+
- name: Upload test results
76+
if: always()
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: test-results-${{ matrix.os }}-java${{ matrix.java }}
80+
path: |
81+
build/reports/tests/
82+
build/test-results/
83+
84+
- name: Upload build artifacts
85+
if: success()
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: build-artifacts-${{ matrix.os }}-java${{ matrix.java }}
89+
path: build/libs/
90+
91+
code-quality:
92+
name: Code Quality Checks
93+
runs-on: ubuntu-latest
94+
95+
steps:
96+
- name: Checkout code
97+
uses: actions/checkout@v4
98+
with:
99+
fetch-depth: 0
100+
101+
- name: Set up JDK 25
102+
uses: actions/setup-java@v4
103+
with:
104+
java-version: 25
105+
distribution: 'temurin'
106+
cache: 'gradle'
107+
108+
- name: Grant execute permission for gradlew
109+
run: chmod +x gradlew
110+
111+
- name: Run checkstyle (if configured)
112+
run: ./gradlew checkstyleMain checkstyleTest --no-daemon
113+
continue-on-error: true
114+
115+
- name: Run spotbugs (if configured)
116+
run: ./gradlew spotbugsMain --no-daemon

0 commit comments

Comments
 (0)