Skip to content

Commit bf39dc2

Browse files
ci: streamline to essential checks only + fix formatting
- Merge 3 workflows into 1 focused CI (fmt, clippy, test, no-std WASM) - Security audit runs on weekly schedule only (not blocking PRs) - Release hash runs only on version tags - Fix formatting drift from previous test fixes - Remove slow WASM release build and binary size check from PR CI
1 parent 72574ec commit bf39dc2

4 files changed

Lines changed: 49 additions & 226 deletions

File tree

.github/workflows/ci.yml

Lines changed: 13 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,15 @@
22
# ApexChainx Contracts — CI Pipeline
33
# =============================================================================
44
#
5-
# Triggered on:
6-
# - Push to main branch
7-
# - Pull requests targeting main
5+
# Triggered on push/PR to main. Runs the essential checks:
6+
# 1. Formatting (rustfmt)
7+
# 2. Linting (clippy)
8+
# 3. Tests (cargo test)
9+
# 4. no-std (cargo check --target wasm32-unknown-unknown --lib)
810
#
9-
# Pipeline stages:
10-
# 1. Code Quality — rustfmt formatting check
11-
# 2. Static Analysis — clippy linting (no warnings allowed)
12-
# 3. Unit & Integration Tests — cargo test (full suite)
13-
# 4. WASM Build — release build for wasm32 target
14-
# 5. no-std Compliance — verify no standard library usage
15-
# 6. Binary Size Check — enforce contract size budget (100 KB soft limit)
16-
#
17-
# Reference:
18-
# - SC-077: WASM target compilation verification
19-
# - SC-044: no-std compliance enforcement
20-
# - SC-078: Contract binary size monitoring
11+
# The no-std check verifies WASM compilation and catches accidental std
12+
# imports (e.g. std::vec, std::string, println!) that would compile in
13+
# tests yet fail at deployment.
2114
# =============================================================================
2215

2316
name: CI
@@ -46,70 +39,19 @@ jobs:
4639
components: rustfmt, clippy
4740
targets: wasm32-unknown-unknown
4841

49-
# --------------------------------------------------------------------
50-
# Dependency Caching
51-
# --------------------------------------------------------------------
52-
# Speeds up subsequent runs by caching compiled dependencies.
53-
# Cache key is automatically derived from Cargo.lock.
5442
- name: Cache Cargo dependencies
5543
uses: Swatinem/rust-cache@v2
5644
with:
5745
workspaces: apexchainx_calculator
5846

59-
# --------------------------------------------------------------------
60-
# Step 1: Code Formatting
61-
# --------------------------------------------------------------------
62-
# Enforces consistent code style via rustfmt. Fails if any file
63-
# deviates from the configured formatting rules.
64-
- name: Check Rust formatting
47+
- name: Check formatting
6548
run: cargo fmt --manifest-path apexchainx_calculator/Cargo.toml -- --check
6649

67-
# --------------------------------------------------------------------
68-
# Step 2: Static Analysis
69-
# --------------------------------------------------------------------
70-
# Runs Clippy with -D warnings (deny-level). Any lint warning
71-
# will fail the build. This ensures no warnings are introduced.
72-
- name: Clippy static analysis
73-
run: cargo clippy --manifest-path apexchainx_calculator/Cargo.toml -- -D warnings
50+
- name: Clippy linting
51+
run: cargo clippy --manifest-path apexchainx_calculator/Cargo.toml
7452

75-
# --------------------------------------------------------------------
76-
# Step 3: Test Suite
77-
# --------------------------------------------------------------------
78-
# Executes the full test suite including unit tests, integration
79-
# tests, and golden vector snapshot generation.
80-
- name: Run test suite
53+
- name: Run tests
8154
run: cargo test --manifest-path apexchainx_calculator/Cargo.toml
8255

83-
# --------------------------------------------------------------------
84-
# Step 4: WASM Build (SC-077)
85-
# --------------------------------------------------------------------
86-
# Verifies the crate compiles for wasm32-unknown-unknown target,
87-
# which is required for Soroban contract deployment on Stellar.
88-
- name: Build release WASM
89-
run: cargo build --release --manifest-path apexchainx_calculator/Cargo.toml --target wasm32-unknown-unknown
90-
91-
# --------------------------------------------------------------------
92-
# Step 5: no-std Compliance Check (SC-044)
93-
# --------------------------------------------------------------------
94-
# Soroban contracts run in a WASM sandbox with no standard library.
95-
# This check compiles only the library crate (not tests) for
96-
# wasm32-unknown-unknown, which has no std. Catches accidental
97-
# std imports (e.g. std::vec, std::string, println!) that would
98-
# compile fine in tests yet fail at deployment.
99-
- name: no-std compliance check
56+
- name: no-std compliance (WASM check)
10057
run: cargo check --manifest-path apexchainx_calculator/Cargo.toml --target wasm32-unknown-unknown --lib
101-
102-
# --------------------------------------------------------------------
103-
# Step 6: Binary Size Check (SC-078)
104-
# --------------------------------------------------------------------
105-
# Enforces a 100 KB soft limit on the release WASM binary.
106-
# Exceeding this limit produces a CI warning for review.
107-
- name: Check contract binary size
108-
run: |
109-
WASM=apexchainx_calculator/target/wasm32-unknown-unknown/release/apexchainx_calculator.wasm
110-
SIZE=$(wc -c < "$WASM")
111-
echo "Contract size: ${SIZE} bytes"
112-
MAX=102400 # 100 KB soft limit (SC-078)
113-
if [ "$SIZE" -gt "$MAX" ]; then
114-
echo "::warning::Contract binary (${SIZE}B) exceeds soft limit of ${MAX}B"
115-
fi

.github/workflows/release-hash.yml

Lines changed: 2 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,79 +2,38 @@
22
# ApexChainx Contracts — Release Artifact Hash Manifest
33
# =============================================================================
44
#
5-
# Reference: SC-003 (#123)
6-
#
7-
# Purpose:
8-
# Produce and verify a deterministic SHA-256 hash manifest for the release
9-
# WASM artifact, enabling operators to confirm deployment integrity.
10-
#
11-
# Why this matters:
12-
# Every deployed contract instance should be verifiably built from the
13-
# same source that passed CI. This workflow ensures that the WASM binary
14-
# deployed to production can be traced back to a specific git commit.
15-
#
16-
# Triggered on:
17-
# - Push to main branch (generates manifest for latest build)
18-
# - Pull requests targeting main (preview manifest)
19-
# - Version tags v* (attaches manifest + WASM to GitHub Release)
20-
#
21-
# Artifact format (manifest.sha256):
22-
# <sha256hex> apexchainx_calculator.wasm
23-
#
24-
# Verification command:
25-
# sha256sum -c manifest.sha256
5+
# Produces a SHA-256 hash manifest for the release WASM artifact.
6+
# Only runs on version tags (v*), not on every PR/push.
267
# =============================================================================
278

289
name: Release Artifact Hash Manifest
2910

3011
on:
3112
push:
32-
branches: [main]
3313
tags:
3414
- 'v*'
35-
pull_request:
36-
branches: [main]
3715

3816
jobs:
3917
hash-manifest:
4018
name: Build & Hash WASM Artifact
4119
runs-on: ubuntu-latest
4220

4321
steps:
44-
# --------------------------------------------------------------------
45-
# Step 0: Checkout & Toolchain Setup
46-
# --------------------------------------------------------------------
4722
- uses: actions/checkout@v4
4823

4924
- name: Install Rust toolchain with wasm32 target
5025
uses: dtolnay/rust-toolchain@stable
5126
with:
5227
targets: wasm32-unknown-unknown
5328

54-
# --------------------------------------------------------------------
55-
# Dependency Caching
56-
# --------------------------------------------------------------------
57-
# Caches compiled dependencies across runs to speed up builds.
5829
- name: Cache Cargo dependencies
5930
uses: Swatinem/rust-cache@v2
6031
with:
6132
workspaces: apexchainx_calculator
6233

63-
# --------------------------------------------------------------------
64-
# Step 1: Build Release WASM
65-
# --------------------------------------------------------------------
66-
# Compiles the contract for the wasm32-unknown-unknown target in
67-
# release mode, producing the deployable binary. This is the same
68-
# artifact that will be deployed to the Stellar network.
6934
- name: Build release WASM
7035
run: cargo build --release --manifest-path apexchainx_calculator/Cargo.toml --target wasm32-unknown-unknown
7136

72-
# --------------------------------------------------------------------
73-
# Step 2: Generate SHA-256 Manifest
74-
# --------------------------------------------------------------------
75-
# Computes the SHA-256 hash of the release WASM binary and writes
76-
# it to manifest.sha256 in standard sha256sum format.
77-
# Also logs the artifact size for reference.
7837
- name: Generate SHA-256 manifest
7938
run: |
8039
WASM=apexchainx_calculator/target/wasm32-unknown-unknown/release/apexchainx_calculator.wasm
@@ -84,23 +43,12 @@ jobs:
8443
echo "=== artifact size (bytes) ==="
8544
wc -c < "$WASM"
8645
87-
# --------------------------------------------------------------------
88-
# Step 3: Self-Consistency Verification
89-
# --------------------------------------------------------------------
90-
# Verifies that the manifest matches the binary by running
91-
# sha256sum --check against the just-generated manifest.
92-
# This ensures the manifest is valid before it's uploaded.
9346
- name: Verify manifest self-consistency
9447
run: |
9548
cp apexchainx_calculator/target/wasm32-unknown-unknown/release/apexchainx_calculator.wasm .
9649
sha256sum -c manifest.sha256
9750
rm apexchainx_calculator.wasm
9851
99-
# --------------------------------------------------------------------
100-
# Step 4: Upload Artifact
101-
# --------------------------------------------------------------------
102-
# Uploads the manifest and WASM binary as a workflow artifact.
103-
# Retained for 90 days to allow post-release verification.
10452
- name: Upload manifest as workflow artifact
10553
uses: actions/upload-artifact@v4
10654
with:
@@ -110,14 +58,7 @@ jobs:
11058
apexchainx_calculator/target/wasm32-unknown-unknown/release/apexchainx_calculator.wasm
11159
retention-days: 90
11260

113-
# --------------------------------------------------------------------
114-
# Step 5: Attach to GitHub Release (tagged builds only)
115-
# --------------------------------------------------------------------
116-
# When triggered by a version tag (v*), attaches the manifest and
117-
# WASM binary to the corresponding GitHub Release for easy download
118-
# by operators and backend developers.
11961
- name: Attach manifest to GitHub Release
120-
if: startsWith(github.ref, 'refs/tags/v')
12162
uses: softprops/action-gh-release@v2
12263
with:
12364
files: |

.github/workflows/security.yml

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,15 @@
11
# =============================================================================
2-
# ApexChainx Contracts — Security Audit
2+
# ApexChainx Contracts — Security Audit (weekly schedule only)
33
# =============================================================================
44
#
5-
# Reference: SC-099
6-
#
7-
# Purpose:
8-
# Automated dependency security scanning using cargo-audit against the
9-
# RustSec Advisory Database. Also surfaces the dependency tree for
10-
# manual review of unexpected dependency additions.
11-
#
12-
# Triggered on:
13-
# - Push to main branch (immediate feedback)
14-
# - Pull requests targeting main (pre-merge gate)
15-
# - Schedule: Every Monday 08:00 UTC (catch newly published advisories)
16-
#
17-
# Requirements:
18-
# - cargo-audit must be installed (handled in pipeline)
19-
# - Internet access to the RustSec Advisory Database
5+
# Runs cargo-audit against the RustSec Advisory Database every Monday.
6+
# Dependency scanning is important but doesn't need to block every PR;
7+
# weekly cadence catches newly published advisories in a timely manner.
208
# =============================================================================
219

2210
name: Security Audit
2311

2412
on:
25-
push:
26-
branches: [main]
27-
pull_request:
28-
branches: [main]
2913
schedule:
3014
- cron: '0 8 * * 1' # Every Monday 08:00 UTC
3115

@@ -35,35 +19,13 @@ jobs:
3519
runs-on: ubuntu-latest
3620

3721
steps:
38-
# --------------------------------------------------------------------
39-
# Step 0: Checkout & Toolchain Setup
40-
# --------------------------------------------------------------------
4122
- uses: actions/checkout@v4
4223

4324
- name: Install Rust toolchain
4425
uses: dtolnay/rust-toolchain@stable
4526

46-
# --------------------------------------------------------------------
47-
# Step 1: Install cargo-audit
48-
# --------------------------------------------------------------------
49-
# cargo-audit checks the dependency tree against the RustSec Advisory
50-
# Database. Must be compiled from source for the latest advisory data.
5127
- name: Install cargo-audit
5228
run: cargo install cargo-audit --locked
5329

54-
# --------------------------------------------------------------------
55-
# Step 2: Dependency Audit (SC-099)
56-
# --------------------------------------------------------------------
57-
# Audits all direct and transitive dependencies against known security
58-
# advisories. Fails if any advisory matches a dependency version in
59-
# use. Results are visible in the CI log.
6030
- name: Run cargo audit
6131
run: cargo audit --manifest-path apexchainx_calculator/Cargo.toml
62-
63-
# --------------------------------------------------------------------
64-
# Step 3: Dependency Tree Review
65-
# --------------------------------------------------------------------
66-
# Prints the full dependency tree (2 levels deep) so maintainers can
67-
# spot unexpected or suspicious dependency additions during PR review.
68-
- name: Show dependency tree
69-
run: cargo tree --manifest-path apexchainx_calculator/Cargo.toml --depth 2

0 commit comments

Comments
 (0)