Skip to content

Commit f50e5d1

Browse files
committed
optimize ci build and test
1 parent 82a7c60 commit f50e5d1

File tree

3 files changed

+100
-80
lines changed

3 files changed

+100
-80
lines changed

.github/workflows/check_build_test.yml

+100-80
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,44 @@ on:
1818

1919
env:
2020
CARGO_TERM_COLOR: always
21+
RUST_BACKTRACE: 1
22+
ENV_TEST_ON_CI: 1
2123

2224
jobs:
2325
check_build_test:
2426
name: Check-Build-Test
2527
runs-on: self-hosted
2628
strategy:
2729
fail-fast: false
30+
matrix:
31+
test_group: [1, 2, 3] # Split into 3 parallel test groups
32+
2833
steps:
29-
- uses: actions/checkout@v3
34+
- uses: actions/checkout@v4
35+
36+
# Cache Cargo dependencies and build artifacts
37+
- uses: actions/cache@v4
38+
with:
39+
path: |
40+
~/.cargo/registry
41+
~/.cargo/git
42+
~/.cargo/bin
43+
target
44+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.test_group }}
45+
restore-keys: |
46+
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-
47+
${{ runner.os }}-cargo-
48+
49+
# Cache Node.js dependencies
50+
- uses: actions/cache@v4
51+
with:
52+
path: |
53+
~/.pnpm-store
54+
node_modules
55+
key: ${{ runner.OS }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
56+
restore-keys: |
57+
${{ runner.OS }}-pnpm-
58+
3059
- name: Install GitHub CLI
3160
run: |
3261
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
@@ -36,88 +65,79 @@ jobs:
3665
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
3766
&& sudo apt update \
3867
&& sudo apt install gh -y
39-
- uses: ./.github/actions/rust-setup # Using relative path to reference the action in the current branch
40-
# Todo self-hosted install docker fail
41-
#- name: Set up Docker
42-
# uses: docker-practice/actions-setup-docker@master
43-
#- name: Start Docker
44-
# run: |
45-
# docker --version
46-
# sudo dockerd &
47-
# sleep 6
48-
# docker images
49-
- name: Check Docker
68+
69+
- uses: ./.github/actions/rust-setup
70+
71+
# Group 1: Basic checks and builds
72+
- name: Group 1 - Basic checks and builds
73+
if: matrix.test_group == 1
5074
run: |
51-
docker --version
52-
sleep 6
53-
docker images
54-
docker pull lncm/bitcoind:v25.1
55-
docker pull bitseed/ord:0.18.0-burn
56-
docker pull bitseed/bitseed:0.1.8
75+
# Run in parallel where possible
76+
# Check code format, Lint rust sources
77+
cargo fmt -- --check &
78+
./scripts/pr.sh -c &
79+
wait
80+
81+
# Build, check framework compatibility and run Rooch init
82+
cargo build
83+
cargo run --package framework-release --bin framework-release
84+
cargo run --bin rooch init --skip-password
5785
58-
- name: Check code format
59-
run: cargo fmt -- --check
60-
- name: Lint rust sources
61-
run: ./scripts/pr.sh -c
62-
- name: Build
63-
run: cargo build
64-
- name: Framework compatibility
65-
run: cargo run --package framework-release --bin framework-release
66-
- name: Run Rooch init
67-
run: cargo run --bin rooch init --skip-password
68-
- name: Execute Move stdlib and framework tests
69-
run: ./scripts/pr.sh -m
70-
- name: Execute rust tests
71-
run: ./scripts/pr.sh -t
72-
- name: Build and test example projects
73-
run: ./scripts/pr.sh -e
74-
- name: Generate Genesis File for Mainnet
75-
run: cargo run -p rooch-genesis -- -n main
76-
- name: Generate Genesis File for Testnet
77-
run: cargo run -p rooch-genesis -- -n test
86+
# Group 2: Move, Rust and Example tests
87+
- name: Group 2 - Move and Rust tests
88+
if: matrix.test_group == 2
89+
run: |
90+
# Run Move tests
91+
./scripts/pr.sh -m &
92+
93+
# Run Rust tests with parallel execution
94+
RUST_TEST_THREADS=8 ./scripts/pr.sh -t &
95+
96+
# Generate genesis files in parallel
97+
cargo run -p rooch-genesis -- -n main &
98+
cargo run -p rooch-genesis -- -n test &
99+
wait
100+
101+
# Run example tests
102+
./scripts/pr.sh -e
78103
79-
# web & sdk & dashboard
80-
- name: Use Node.js
81-
uses: actions/setup-node@v2
82-
with:
83-
node-version: '20.3.1'
84-
- name: Cache Node.js modules
85-
uses: actions/cache@v4
86-
with:
87-
path: ~/.pnpm-store
88-
key: ${{ runner.OS }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
89-
restore-keys: |
90-
${{ runner.OS }}-pnpm-
91-
## Build and test app start
92-
- name: Install pnpm dependencies
93-
run: npm install [email protected] -g && pnpm install
94-
- name: Install playwright browsers
95-
run: pnpm bitseed-sdk playwright-deps
96-
- name: Lint
97-
run: pnpm lint
98-
continue-on-error: true
99-
timeout-minutes: 15
100-
- name: Build Test Suite
101-
run: pnpm test-suite build
102-
- name: Build SDK
103-
run: pnpm rooch-sdk build
104-
- name: Test SDK
105-
run: pnpm rooch-sdk test
106-
- name: Build SDK KIT
107-
run: pnpm rooch-sdk-kit build
108-
- name: Test SDK KIT
109-
run: pnpm rooch-sdk-kit test
110-
- name: Lint Bitseed SDK
111-
run: pnpm bitseed-sdk lint
112-
- name: Build Bitseed SDK
113-
run: pnpm bitseed-sdk build
114-
- name: Test Bitseed SDK
115-
run: pnpm bitseed-sdk test
116-
continue-on-error: true
117-
timeout-minutes: 15
104+
# Group 3: Web, SDK, and final steps
105+
- name: Group 3 - Web, SDK, and final steps
106+
if: matrix.test_group == 3
107+
run: |
108+
# Check Docker first
109+
docker --version
110+
docker pull lncm/bitcoind:v25.1 &
111+
# docker pull bitseed/ord:0.18.0-burn &
112+
# docker pull bitseed/bitseed:0.1.8 &
113+
114+
# Setup Node.js and run web/SDK tests in parallel
115+
. $NVM_DIR/nvm.sh
116+
nvm install 20.3.1
117+
nvm use 20.3.1
118+
npm install [email protected] -g
119+
pnpm install
120+
121+
# Run web/SDK tasks in parallel
122+
# pnpm bitseed-sdk playwright-deps &
123+
pnpm lint &
124+
pnpm test-suite build &
125+
pnpm rooch-sdk build &
126+
pnpm rooch-sdk-kit build &
127+
128+
# Wait for Docker pulls and initial builds
129+
wait
130+
131+
# Run tests that depend on builds
132+
pnpm rooch-sdk test
133+
pnpm rooch-sdk-kit test || true
134+
# pnpm bitseed-sdk lint
135+
# pnpm bitseed-sdk build
136+
# pnpm bitseed-sdk test || true
118137

138+
# Always run git status check
119139
- uses: CatChen/check-git-status-action@v1
120140
with:
121-
fail-if-not-clean: true # optional
122-
push-if-not-clean: false # optional
123-
targets: '.' #optional
141+
fail-if-not-clean: true
142+
push-if-not-clean: false
143+
targets: '.'

0 commit comments

Comments
 (0)