Skip to content

Commit 94ea4e3

Browse files
committed
add --quiet flag; github ci workflow for PRs
1 parent 0dbef66 commit 94ea4e3

File tree

4 files changed

+240
-60
lines changed

4 files changed

+240
-60
lines changed

.github/workflows/ci.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
7+
concurrency:
8+
group: ci-${{ github.event.pull_request.number }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
ci:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 120
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0 # full history for change detection
21+
22+
- name: Initialize submodules
23+
run: git submodule update --init --depth 1 --jobs 4
24+
25+
- name: Check for docs-only changes
26+
id: filter
27+
run: |
28+
base="${{ github.event.pull_request.base.sha }}"
29+
head="${{ github.sha }}"
30+
non_docs=$(git diff --name-only "$base" "$head" | grep -cvE '\.(md|txt)$' || true)
31+
echo "skip_build=$( [[ "$non_docs" -eq 0 ]] && echo true || echo false )" >> "$GITHUB_OUTPUT"
32+
33+
- name: Install Nix
34+
if: steps.filter.outputs.skip_build != 'true'
35+
uses: DeterminateSystems/nix-installer-action@main
36+
37+
- name: Setup Nix cache
38+
if: steps.filter.outputs.skip_build != 'true'
39+
uses: DeterminateSystems/magic-nix-cache-action@main
40+
# For faster CI, consider adding a dedicated binary cache:
41+
# cachix-name: logos-workspace
42+
# cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
43+
44+
- name: Add workspace tools to PATH
45+
if: steps.filter.outputs.skip_build != 'true'
46+
run: echo "${{ github.workspace }}/scripts" >> "$GITHUB_PATH"
47+
48+
- name: Detect changes
49+
if: steps.filter.outputs.skip_build != 'true'
50+
id: changes
51+
run: |
52+
base="${{ github.event.pull_request.base.sha }}"
53+
head="${{ github.sha }}"
54+
55+
# Infrastructure = flake config, nix support files, workspace scripts
56+
infra=false
57+
if git diff --name-only "$base" "$head" | grep -qE '^(flake\.(nix|lock)|nix/|scripts/)'; then
58+
infra=true
59+
fi
60+
echo "infra=$infra" >> "$GITHUB_OUTPUT"
61+
62+
# Repos with changed submodule pointers
63+
changed=""
64+
while IFS= read -r line; do
65+
[[ -z "$line" ]] && continue
66+
repo=$(echo "$line" | cut -d/ -f2)
67+
[[ -n "$repo" ]] && changed="$changed $repo"
68+
done < <(git diff --name-only "$base" "$head" -- repos/)
69+
changed=$(echo "$changed" | xargs -n1 2>/dev/null | sort -u | xargs 2>/dev/null || true)
70+
echo "changed=$changed" >> "$GITHUB_OUTPUT"
71+
72+
# Expand to include downstream dependents (parsed from dep-graph.nix).
73+
# Each line in dep-graph.nix looks like:
74+
# repo-name = { deps = [ "dep1" "dep2" ]; hasTests = ...; };
75+
# Grep for "repo" (quoted) matches lines where repo appears in a deps array.
76+
affected="$changed"
77+
for repo in $changed; do
78+
dependents=$(grep "\"$repo\"" nix/dep-graph.nix 2>/dev/null | \
79+
sed 's/^[[:space:]]*\([^[:space:]]*\).*/\1/' || true)
80+
affected="$affected $dependents"
81+
done
82+
affected=$(echo "$affected" | xargs -n1 2>/dev/null | sort -u | xargs 2>/dev/null || true)
83+
echo "affected=$affected" >> "$GITHUB_OUTPUT"
84+
85+
echo "## Change Detection" >> "$GITHUB_STEP_SUMMARY"
86+
echo "- Infrastructure changed: \`$infra\`" >> "$GITHUB_STEP_SUMMARY"
87+
echo "- Changed repos: \`${changed:-none}\`" >> "$GITHUB_STEP_SUMMARY"
88+
echo "- Affected repos (+ dependents): \`${affected:-none}\`" >> "$GITHUB_STEP_SUMMARY"
89+
90+
- name: Validate dep-graph.nix is up to date
91+
if: steps.filter.outputs.skip_build != 'true'
92+
run: |
93+
cp nix/dep-graph.nix /tmp/dep-graph-before.nix
94+
ws sync-graph --quiet
95+
if ! diff -q nix/dep-graph.nix /tmp/dep-graph-before.nix >/dev/null 2>&1; then
96+
echo "::error::nix/dep-graph.nix is stale — run 'ws sync-graph' and commit the result"
97+
diff --color=never -u /tmp/dep-graph-before.nix nix/dep-graph.nix || true
98+
exit 1
99+
fi
100+
101+
- name: Build changed repos and dependents
102+
if: steps.filter.outputs.skip_build != 'true' && steps.changes.outputs.infra != 'true' && steps.changes.outputs.affected != ''
103+
run: |
104+
failed=0
105+
for repo in ${{ steps.changes.outputs.affected }}; do
106+
[[ ! -f "repos/$repo/flake.nix" ]] && continue
107+
echo "::group::Build $repo"
108+
if ! ws build "$repo" --quiet; then
109+
echo "::error::Build failed: $repo"
110+
failed=1
111+
fi
112+
echo "::endgroup::"
113+
done
114+
exit $failed
115+
116+
- name: Build core chain (infrastructure changed)
117+
if: steps.filter.outputs.skip_build != 'true' && steps.changes.outputs.infra == 'true'
118+
run: |
119+
failed=0
120+
for repo in logos-cpp-sdk logos-module logos-liblogos logos-package logos-app-poc; do
121+
echo "::group::Build $repo"
122+
if ! ws build "$repo" --quiet; then
123+
echo "::error::Build failed: $repo"
124+
failed=1
125+
fi
126+
echo "::endgroup::"
127+
done
128+
exit $failed
129+
130+
- name: Run tests
131+
if: steps.filter.outputs.skip_build != 'true'
132+
run: ws test --all --quiet

CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ ws list # Show all repos
4141
ws sync-graph # Regenerate dep-graph.nix
4242
```
4343

44+
All commands accept `--quiet` / `-q` to suppress informational output and colors (useful for CI/scripting).
45+
4446
Use `ws <command> --help` for detailed usage.
4547

4648
## Searching code

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ Because the workspace flake declares `logos-liblogos.inputs.logos-cpp-sdk.follow
9090
| `ws worktree remove <name>` | Remove a worktree |
9191
| `ws sync-graph` | Regenerate `nix/dep-graph.nix` from repo flake.nix files |
9292

93+
### Global Options
94+
95+
- `--quiet`, `-q` — Suppress informational output (headers, progress, hints) and strip colors. Useful for CI pipelines and scripting. Primary output (test results, status lines, data) is still shown.
96+
97+
```bash
98+
# Machine-friendly status output (no colors, no header)
99+
ws --quiet status
100+
101+
# Quiet test run — only PASS/FAIL lines and summary
102+
ws test --all --quiet
103+
```
104+
93105
### CLI Tools
94106

95107
These are also in `scripts/` and auto-build from the local repo on first use. They rebuild automatically when source files change.
@@ -490,6 +502,17 @@ ws build logos-app-poc --local logos-cpp-sdk
490502

491503
If a build fails unexpectedly with overrides, check that the dirty repo is in a buildable state — `--auto-local` uses whatever is on disk, including broken or half-finished work.
492504

505+
## CI
506+
507+
The workspace has GitHub Actions CI (`.github/workflows/ci.yml`) that runs on pull requests to `master`:
508+
509+
- **Change detection** — identifies which repos changed (submodule pointer diffs) and expands to include downstream dependents via `dep-graph.nix`
510+
- **Infrastructure changes** (flake.nix, nix/, scripts/) trigger a build of the core chain: logos-cpp-sdk, logos-module, logos-liblogos, logos-package, logos-app-poc
511+
- **Repo changes** trigger builds of only the affected repos and their dependents
512+
- **Docs-only PRs** (.md/.txt) skip builds entirely
513+
- **Validates** that `dep-graph.nix` is up to date (`ws sync-graph` produces no diff)
514+
- **Runs all tests** via `ws test --all`
515+
493516
## Dev Shell Quick Reference
494517

495518
`ws develop` drops you into a modern shell environment with zsh, tmux, and a curated set of tools. For the best experience, install a [Nerd Font](https://www.nerdfonts.com/font-downloads) (e.g. Monaco Nerd Font or FiraCode Nerd Font).

0 commit comments

Comments
 (0)