Skip to content

ci: add minimal GitHub Actions workflow (fmt, clippy, test, wasm-check)#60

Merged
Alqku merged 7 commits into
mainfrom
ci/github-actions-setup
Jun 21, 2026
Merged

ci: add minimal GitHub Actions workflow (fmt, clippy, test, wasm-check)#60
Alqku merged 7 commits into
mainfrom
ci/github-actions-setup

Conversation

@Alqku

@Alqku Alqku commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary\n\nAdds `.github/workflows/ci.yml` — a minimal GitHub Actions CI pipeline for the Rust workspace. Four parallel jobs cover the same quality gates the Makefile exposes, plus a wasm-target compile check that catches Soroban-contract errors not visible on the host target.\n\n## Jobs\n\n- fmtcargo fmt --all -- --check (mirrors make fmt, with --check so it fails in CI without touching the working tree)\n- clippycargo clippy --workspace --all-targets -- -D warnings (mirrors make lint, plus --all-targets to lint test code too)\n- testcargo test --workspace (mirrors make test; runs the Soroban test snapshot suites on the host target)\n- wasm-checkcargo check --workspace --target wasm32-unknown-unknown (catches `#[contracttype]`-style compile errors that only fire under the wasm target)\n\n## Design notes\n\n- Toolchain + components live in `rust-toolchain.toml`; the workflow does not override them, so `rust-toolchain.toml` stays the single source of truth.\n- Cargo registry/target caching via `Swatinem/rust-cache@v2`. `dtolnay/rust-toolchain@stable` is invoked with `cache: false` to avoid the known double-cache conflict.\n- Triggers: push to `main`, PR to `main`, and manual `workflow_dispatch`. Concurrency cancels superseded PR runs but not the push-to-main run.\n- Token locked down to `contents: read` via top-level `permissions`.\n\n## Follow-ups (out of scope here)\n\n- Add a `deny.toml` and wire up `cargo deny check` / `cargo audit` as a fifth job.\n- Once CI is green on this PR, re-evaluate the in-flight PRs (#52, #55, #59) against the new gates.\n\n## Test plan\n\n- Watch the first run of this workflow on this PR — fmt/clippy/test/wasm-check should all go green (no code changes besides the new workflow file).\n- On the very first run the cache will be cold; subsequent runs should be ~10x faster.

Alqku added 7 commits June 21, 2026 00:53
Adds .github/workflows/ci.yml with four parallel jobs:

* fmt: cargo fmt --all -- --check

* clippy: cargo clippy --workspace --all-targets -- -D warnings

* test: cargo test --workspace (host target, mirrors make test)

* wasm-check: cargo check --workspace --target wasm32-unknown-unknown (catches Soroban contract compile errors not visible on host target)

Triggers on push to main, PR to main, and manual dispatch. Concurrency cancels superseded PR runs. Permissions locked to contents: read. Toolchain and components come from rust-toolchain.toml (single source of truth); Swatinem/rust-cache handles cargo registry/target caching.
PR #60 first CI run failed fmt/clippy/test/wasm-check across the workspace. This follow-up:

1. Scope the clippy/test/wasm-check jobs to the four Soroban contract crates

   (-p orbitchain-campaign -p orbitchain-common -p orbitchain-core

    -p orbitchain-token-bridge) using a single CONTRACTS env-var so the

    scope stays in sync across jobs. crates/tools is a native CLI binary,

    not a contract, and its dev-tooling lint/test drift is tracked separately.

2. Switch the wasm-check job to --target wasm32v1-none (the target

    rust-toolchain.toml pins, and the one soroban-sdk 26.x accepts on

    stable Rust >= 1.84; wasm32-unknown-unknown on Rust >= 1.82 enables

    reference-types/multi-value which the Soroban host cannot honour).

3. Drive fmt scoped to the same four packages via

    `cargo fmt ${{ env.CONTRACTS }} -- --check` so contracts stay clean

    without churning crates/tools/ formatting. (The workspace-wide check

    is kept as a guard so non-contract drift still surfaces.)

4. Fix the residual lib.rs clippy lints that broke the scoped clippy job:

   - drop redundant `as u32` cast on milestones.len() (redundant_cast)

   - drop redundant `&env` inside check_refund_eligibility where

     the parameter is already &Env (needless_borrow)

5. Apply the rustfmt-compliance fixes across campaign/src/, common/src/,

   and crates/contracts/core/src/ that the fmt job required for the

   scoped contract packages to pass.
GitHub Actions enforces a strict top-level schema and rejected the previous version because CONTRACTS was indented at column 0 instead of under env:. Symptom: workflow run reported "likely because of a workflow file issue" with an empty job list and no logs. Indenting it (and shifting the comment block + folded scalar body by 2 spaces) restores GitHub's schema validation while preserving the ${{ env.CONTRACTS }} interpolation pattern.
…ixes)

Three file-level conflicts surfaced when merging origin/main into ci/github-actions-setup (added MAX_DEADLINE_GAP_SECONDS to imports in campaign/src/contract.rs, expanded Error enum + storage bindings in campaign/src/types.rs, and grouped test imports in negative_path_tests.rs). Resolved by taking main's versions for the three files (--theirs), then re-applied strict clippy checks and landed two trivial cleanups:

1. Drop unused `Address` import in campaign/src/contract.rs (Address import was brought over from main's pre-resolve state but the symbol is not referenced in this module).

2. Replace `current_time.checked_add(MAX_DEADLINE_GAP_SECONDS).unwrap_or(u64::MAX)` with `current_time.saturating_add(MAX_DEADLINE_GAP_SECONDS)` per clippy ::manual_saturating_arithmetic.

Local validation (cargo fmt / cargo clippy --all-targets / cargo test / cargo check --target wasm32v1-none, all scoped to the four Soroban contract crates) is now green.
…/tools/ drift was blocking jobs)

The fmt job ran `cargo fmt --all -- --check && cargo fmt ${{ env.CONTRACTS }} -- --check`.

github Actions' default Rust install picked up the workspace-wide check and choked on 260 pre-existing rustfmt violations in crates/tools/src/**. All four Soroban contract packages are themselves rustfmt-clean (verified locally); but the workspace-wide pass cannot succeed in CI without committing 260 unrelated files to this PR.

Drop the workspace-wide check; keep only the per-package pass against the four contract packages. This brings the fmt job into alignment with the clippy/test/wasm-check jobs which already use ${{ env.CONTRACTS }}.

crates/tools/ rustfmt drift is tracked separately as a follow-up issue (not in scope for this CI-setup PR).
CI's fmt job fails on types.rs (can_transition_to + apply_donation) and clippy flags the manual saturating arithmetic in contract.rs. After the prior merge resolution + 9e85aff (drop workspace-wide fmt), the contracts still had whitespace drift that local `cargo fmt` would clean — this commit applies that clean.

rustfmt-version drift is suspected between the locally pinned rustfmt 1.9.0-stable (2026-05-25) and GitHub's `stable` channel at CI time. If this commit alone is insufficient, the next-step fix is to pin `<channel = "1.96.0">` (or similar) in rust-toolchain.toml so the runner installs a deterministic toolchain.
@Alqku Alqku merged commit f303383 into main Jun 21, 2026
4 checks passed
@Alqku Alqku deleted the ci/github-actions-setup branch June 21, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant