Skip to content

Commit 8a396a4

Browse files
ci: wire compat-test bundle from quantcli/common against crono-export (#31)
First consumer of the quantcli/common compat framework (QUA-8). - Adds build-tag-gated compat_contract_test.go that runs compat/dates.RunContract against the built crono-export binary. - New CI job builds the binary, resolves github.com/quantcli/common/compat via go mod tidy, and runs `go test -tags=compat -run TestContractDates ./...` with CRONO_EXPORT_BIN pointed at the built binary. - compat.Runner uses the Subcommands affordance to dispatch per-data-producing subcommand (biometrics/exercises/nutrition/servings/notes) since crono's --since/--until live on subcommands, not the root binary. - require pinned to the post-merge main-rooted pseudo-version of quantcli/common/compat (v0.0.0-20260510225630-4c588c19cd1b, = merge commit 4c588c1). Refs QUA-8. Co-Authored-By: Paperclip <noreply@paperclip.ing>
1 parent fea5daa commit 8a396a4

4 files changed

Lines changed: 91 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
go:
14+
name: go vet + test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-go@v5
19+
with:
20+
go-version-file: go.mod
21+
cache: true
22+
- name: go vet
23+
run: go vet ./...
24+
- name: go test
25+
run: go test ./...
26+
27+
compat:
28+
name: compat (CONTRACT machine-attestation)
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: actions/setup-go@v5
33+
with:
34+
go-version-file: go.mod
35+
cache: true
36+
- name: resolve compat dependency
37+
# The compat module lives at github.com/quantcli/common/compat
38+
# under a subpath. `go mod tidy` materializes go.sum for it on
39+
# first run; subsequent runs are cache-served.
40+
run: go mod tidy
41+
- name: build crono-export
42+
run: go build -o /tmp/crono-export .
43+
- name: run compat suite
44+
env:
45+
# Path the compat-tagged test reads from os.Getenv.
46+
CRONO_EXPORT_BIN: /tmp/crono-export
47+
run: go test -tags=compat -run TestContractDates ./...

compat_contract_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//go:build compat
2+
3+
// Compat-test entry point for crono-export-cli.
4+
//
5+
// This file is only compiled under the `compat` build tag, so it does
6+
// not affect the default `go test ./...` run. CI invokes it as
7+
// `go test -tags=compat ./...` after building the export binary and
8+
// exposing its path through CRONO_EXPORT_BIN.
9+
//
10+
// The actual assertions live in github.com/quantcli/common/compat.
11+
// Drift between this CLI and CONTRACT.md surfaces as a failure here.
12+
package main_test
13+
14+
import (
15+
"os"
16+
"testing"
17+
18+
"github.com/quantcli/common/compat"
19+
"github.com/quantcli/common/compat/dates"
20+
)
21+
22+
func TestContractDates(t *testing.T) {
23+
bin := os.Getenv("CRONO_EXPORT_BIN")
24+
if bin == "" {
25+
t.Skip("CRONO_EXPORT_BIN not set; skipping compat suite")
26+
}
27+
// crono is cobra-based: --since/--until live on each data-producing
28+
// subcommand, not the root binary. The compat suite dispatches per
29+
// subcommand under a `subcommand=NAME/...` subtree so any single
30+
// regression surfaces as a named subtest failure.
31+
dates.RunContract(t, compat.Runner{
32+
Binary: bin,
33+
Subcommands: []string{
34+
"biometrics",
35+
"exercises",
36+
"nutrition",
37+
"servings",
38+
"notes",
39+
},
40+
})
41+
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.25.5
44

55
require (
66
github.com/jrmycanady/gocronometer v1.5.1
7+
github.com/quantcli/common/compat v0.0.0-20260510225630-4c588c19cd1b
78
github.com/spf13/cobra v1.10.2
89
)
910

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
33
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
44
github.com/jrmycanady/gocronometer v1.5.1 h1:m2J31jEuLlL4RRdQLY33IFs4TAwmfevvJYl2SZxBSQ0=
55
github.com/jrmycanady/gocronometer v1.5.1/go.mod h1:swnvYB6twU20LDzNpAz8JOX5mCHktTW06zlSXmmyZWc=
6+
github.com/quantcli/common/compat v0.0.0-20260510225630-4c588c19cd1b h1:fO7EfkEqzLRC8Ev22jIq05fPs+JwAB7bCDy6FA+GA5k=
7+
github.com/quantcli/common/compat v0.0.0-20260510225630-4c588c19cd1b/go.mod h1:VBC/zEphSZgCZS1rhWsR3A8EWYSbTkP/MwqWHL7266s=
68
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
79
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
810
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=

0 commit comments

Comments
 (0)