|
| 1 | +name: rcdb CLI smoke test |
| 2 | + |
| 3 | +# Installs the `rcdb` command from the Python package and exercises the common |
| 4 | +# CLI commands against a fresh SQLite database: create schema, add a condition |
| 5 | +# type and values, then query them back with info / ls / select / rp. |
| 6 | +# Mirrors python-examples.yml and cpp-examples.yml. |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: ["*"] |
| 11 | + pull_request: |
| 12 | + branches: [main] |
| 13 | + |
| 14 | +env: |
| 15 | + # The 4-slash form gives SQLAlchemy an absolute path. All steps read this env var, |
| 16 | + # so no -c/--connection flag is needed. |
| 17 | + RCDB_CONNECTION: "sqlite:////${{ github.workspace }}/cli_smoke.sqlite" |
| 18 | + |
| 19 | +jobs: |
| 20 | + cli-smoke: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v6 |
| 25 | + |
| 26 | + - name: Set up Python |
| 27 | + uses: actions/setup-python@v6 |
| 28 | + with: |
| 29 | + python-version: "3.12" |
| 30 | + |
| 31 | + - name: Install rcdb (provides the `rcdb` command) |
| 32 | + run: | |
| 33 | + python -m pip install --upgrade pip |
| 34 | + pip install --editable $GITHUB_WORKSPACE/python |
| 35 | +
|
| 36 | + # ── Each command gets its own step so a failure points at the culprit ── |
| 37 | + |
| 38 | + - name: "rcdb --version" |
| 39 | + run: rcdb --version |
| 40 | + |
| 41 | + - name: "Create schema (db init)" |
| 42 | + run: rcdb db init --confirm |
| 43 | + |
| 44 | + - name: "Add a condition type and values" |
| 45 | + run: | |
| 46 | + rcdb add type beam_current --type=float --description "Beam current in nA" |
| 47 | + rcdb add condition 100 beam_current 12.5 |
| 48 | + rcdb add condition 101 beam_current 0.0 |
| 49 | +
|
| 50 | + - name: "Summary (info)" |
| 51 | + run: | |
| 52 | + OUT=$(rcdb info) |
| 53 | + echo "$OUT" |
| 54 | + echo "$OUT" | grep -q "Number of runs: 2" |
| 55 | +
|
| 56 | + - name: "List condition types (ls)" |
| 57 | + run: | |
| 58 | + OUT=$(rcdb ls) |
| 59 | + echo "$OUT" |
| 60 | + echo "$OUT" | grep -q "beam_current" |
| 61 | +
|
| 62 | + - name: "Select with a query" |
| 63 | + run: | |
| 64 | + # beam_current > 5 must match run 100 (12.5) and exclude run 101 (0.0) |
| 65 | + OUT=$(rcdb select "beam_current > 5" 100-101) |
| 66 | + echo "$OUT" |
| 67 | + echo "$OUT" | grep -q "100" |
| 68 | + if echo "$OUT" | grep -qw "101"; then |
| 69 | + echo "ERROR: run 101 (beam_current=0.0) should not match 'beam_current > 5'" |
| 70 | + exit 1 |
| 71 | + fi |
| 72 | +
|
| 73 | + - name: "Select export view (--dump)" |
| 74 | + run: | |
| 75 | + OUT=$(rcdb select "beam_current > 5" 100-101 --dump) |
| 76 | + echo "$OUT" |
| 77 | + # dump view prepends a "#! " header line |
| 78 | + echo "$OUT" | grep -q "^#!" |
| 79 | +
|
| 80 | + - name: "List run periods (rp)" |
| 81 | + run: rcdb rp |
0 commit comments