@oxy-hq/cli 0.12.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1031 -71
- package/dist/main.mjs +21844 -4166
- package/dist/main.mjs.map +1 -1
- package/dist/{mcp-CJWQm-yd.mjs → mcp-bxf7JBJu.mjs} +2 -2
- package/dist/mcp-bxf7JBJu.mjs.map +1 -0
- package/json-schemas/agent-test.json +116 -3
- package/json-schemas/agentic.json +81 -1
- package/json-schemas/config.json +2 -1
- package/json-schemas/flow-test.json +11 -2
- package/json-schemas/topic.json +252 -0
- package/json-schemas/view.json +473 -0
- package/package.json +9 -5
- package/skills/oxy-agents/SKILL.md +98 -54
- package/skills/oxy-agents/references/quick-reference.md +22 -20
- package/skills/oxy-agents/templates/agentic-template.yml +34 -90
- package/skills/oxy-airway-pipelines/SKILL.md +35 -2
- package/skills/oxy-automations/SKILL.md +42 -28
- package/skills/oxy-cli/SKILL.md +15 -7
- package/skills/oxy-custom-apps/SKILL.md +413 -7
- package/skills/oxy-custom-apps/references/app-calls.md +98 -0
- package/skills/oxy-custom-apps/references/phone-layout.md +16 -2
- package/skills/oxy-custom-apps/references/sandbox-agent-loop.md +8 -8
- package/skills/oxy-evals/SKILL.md +112 -46
- package/skills/oxy-evals/references/diagnosis.md +18 -21
- package/skills/oxy-evals/references/results-json.md +30 -18
- package/skills/oxy-evals/references/writing-expected.md +5 -4
- package/skills/oxy-experiments/SKILL.md +4 -3
- package/skills/oxy-semantic-modeling/SKILL.md +14 -12
- package/template/.claude/hooks/oxyc-cloud-session.sh +40 -8
- package/template/.github/workflows/publish.yaml +5 -5
- package/template/.github/workflows/validate.yaml +125 -199
- package/template/README.md +50 -21
- package/template/_gitignore +4 -4
- package/template/config.yml +2 -2
- package/dist/mcp-CJWQm-yd.mjs.map +0 -1
|
@@ -95,8 +95,8 @@ resolves relative dates against today in its `timezone:` (UTC when unset).
|
|
|
95
95
|
missing, so you can't tell which half broke.
|
|
96
96
|
- **Propose a rewrite** when the runs answer different, reasonable readings of the prompt
|
|
97
97
|
(net or gross, calendar or fiscal year), or when the agent stops to ask a clarifying
|
|
98
|
-
question. That ends the run as an error
|
|
99
|
-
choose.
|
|
98
|
+
question. That ends the run as an error (unless the case sets `expect: {asks_user: true}`,
|
|
99
|
+
to test that the agent asks). Show the user the readings you saw, and let them choose.
|
|
100
100
|
- **Flag, don't draft,** when no view or table holds the data. That's a gap in the agent, not
|
|
101
101
|
something a test can fix.
|
|
102
102
|
|
|
@@ -108,5 +108,6 @@ resolves relative dates against today in its `timezone:` (UTC when unset).
|
|
|
108
108
|
- [ ] No schema, view or column names the user wouldn't say.
|
|
109
109
|
- [ ] No `expected` was copied from a single run without agreement or verification.
|
|
110
110
|
- [ ] Uncertain cases carry a narrowed `DRAFT:` note, not an invented value.
|
|
111
|
-
- [ ] The file parses:
|
|
112
|
-
|
|
111
|
+
- [ ] The file parses: once it is pushed, run it by path
|
|
112
|
+
(`oxyc evals run <file> --workspace <id> --case 0`). A run with no file skips a broken
|
|
113
|
+
file silently.
|
|
@@ -232,9 +232,10 @@ before passing `--yes` — say which design (`design <name>` prints its hash).
|
|
|
232
232
|
- A report: state its `verdict` (not a bare "significant"), and repeat every
|
|
233
233
|
line under `assumptions` — a switchback's carryover and pull-forward
|
|
234
234
|
assumptions are part of the result.
|
|
235
|
-
-
|
|
236
|
-
|
|
237
|
-
|
|
235
|
+
- A report may propose a measured coefficient for a World Model edge
|
|
236
|
+
(`write_back` in the result: the file, edge and value). Oxygen does not write
|
|
237
|
+
the repository: make that edit in the workspace's repository (`oxyc workspace
|
|
238
|
+
clone`) and push it like any other change.
|
|
238
239
|
|
|
239
240
|
## Branch on exit codes
|
|
240
241
|
|
|
@@ -311,22 +311,24 @@ pre_aggregations:
|
|
|
311
311
|
|
|
312
312
|
## Validating a change
|
|
313
313
|
|
|
314
|
-
- **`
|
|
315
|
-
topic file and reports where it fails — a bare boolean in `samples`,
|
|
316
|
-
missing `entities:` or `dimensions:` list, a removed feature
|
|
317
|
-
|
|
314
|
+
- **`oxyc validate --file semantics/views/orders.view.yml`** checks one view or
|
|
315
|
+
topic file offline and reports where it fails — a bare boolean in `samples`,
|
|
316
|
+
a missing `entities:` or `dimensions:` list, a removed feature
|
|
317
|
+
(`inherits_from:`, `{{ globals.* }}`), a malformed `{{variables.x}}`. Run it
|
|
318
|
+
on every file you touch. It does **not** look inside `pre_aggregations:` or
|
|
318
319
|
`refresh_key:`; mistakes there surface only when the model is loaded for a
|
|
319
|
-
query.
|
|
320
|
-
- Bare **`
|
|
321
|
-
|
|
322
|
-
|
|
320
|
+
query. (The Rust `oxy validate` is gone; use this command.)
|
|
321
|
+
- Bare **`oxyc validate`** (every file) checks views and topics wherever they
|
|
322
|
+
are, as the compiler finds them — not only under `semantics/`. It exits `9`
|
|
323
|
+
when anything fails.
|
|
323
324
|
- Neither checks **cross-file** wiring — an entity join that matches nothing,
|
|
324
325
|
a topic naming a view that does not exist, a measure that a twin lacks. Run
|
|
325
326
|
a real query through the topic before calling it done.
|
|
326
|
-
- **`
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
327
|
+
- **`oxyc sync <database> --workspace <id>`** writes table and column metadata
|
|
328
|
+
to `.databases/`, which is the place to read real column names from. The
|
|
329
|
+
server introspects the warehouse from the DEPLOYED `config.yml` and `oxyc`
|
|
330
|
+
writes the files into the checkout (`-o` to replace existing ones). The old
|
|
331
|
+
`oxy sync` is gone; use this command.
|
|
330
332
|
- `inherits_from:` and `{{ globals.* }}` were removed from views; a file using
|
|
331
333
|
either is refused at load. Inline the values.
|
|
332
334
|
|
|
@@ -27,9 +27,24 @@ case "$ENV" in
|
|
|
27
27
|
*) HOST="" ;;
|
|
28
28
|
esac
|
|
29
29
|
|
|
30
|
+
# Installed, and current. A cloud image can ship an oxyc older than the
|
|
31
|
+
# commands the docs and skills name (one shipped 0.11 when they named 0.12's
|
|
32
|
+
# `oxyc login --no-wait`), so an older one is upgraded, not only a missing one.
|
|
33
|
+
# A version this cannot read is left alone rather than replaced.
|
|
34
|
+
have=$(oxyc --version 2>/dev/null | tail -n 1)
|
|
30
35
|
if ! command -v oxyc >/dev/null 2>&1; then
|
|
31
36
|
npm install -g @oxy-hq/cli >/dev/null 2>&1 \
|
|
32
37
|
|| echo "oxyc: 'npm install -g @oxy-hq/cli' failed — run it before any oxyc command."
|
|
38
|
+
elif [[ $have =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
39
|
+
# A registry that does not answer costs 20 s at most, not the hook's budget.
|
|
40
|
+
limit=()
|
|
41
|
+
command -v timeout >/dev/null 2>&1 && limit=(timeout 20)
|
|
42
|
+
want=$("${limit[@]}" npm view @oxy-hq/cli version 2>/dev/null | tail -n 1)
|
|
43
|
+
if [[ $want =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && [ "$want" != "$have" ] &&
|
|
44
|
+
[ "$(printf '%s\n%s\n' "$have" "$want" | sort -V | tail -n 1)" = "$want" ]; then
|
|
45
|
+
npm install -g "@oxy-hq/cli@$want" >/dev/null 2>&1 \
|
|
46
|
+
|| echo "oxyc: $have is installed and 'npm install -g @oxy-hq/cli@$want' failed — commands newer than $have will not exist."
|
|
47
|
+
fi
|
|
33
48
|
fi
|
|
34
49
|
|
|
35
50
|
if [ -n "${CLAUDE_ENV_FILE:-}" ]; then
|
|
@@ -48,19 +63,36 @@ if [ -n "$HOST" ] && ! curl -fsS --max-time 10 -o /dev/null "https://$HOST/api/h
|
|
|
48
63
|
echo " access must allow it (Custom: app.oxygen-hq.com, *.oxy.tech) — ask the user to add it."
|
|
49
64
|
fi
|
|
50
65
|
|
|
51
|
-
if [
|
|
66
|
+
if [ "${OXY_TOKEN:-}" = "from-proxy" ]; then
|
|
67
|
+
# The environment's network secret: its proxy adds Authorization on the way
|
|
68
|
+
# out, so no token is in this VM. A minted token file, sourced before every
|
|
69
|
+
# command, replaces the sentinel.
|
|
70
|
+
if [ -s "$TOKEN_FILE" ]; then
|
|
71
|
+
echo "oxyc: OXY_TOKEN=from-proxy, but the agent token in $TOKEN_FILE replaces it in every command."
|
|
72
|
+
elif command -v oxyc >/dev/null 2>&1 && ! oxyc whoami --env "$ENV" >/dev/null 2>&1; then
|
|
73
|
+
echo "oxyc: OXY_TOKEN=from-proxy (a network secret), but 'oxyc whoami --env $ENV' fails. Run it to"
|
|
74
|
+
echo " see why, and tell the user: the secret's Allowed websites must cover ${HOST:-the Oxy host}, with"
|
|
75
|
+
echo " header Authorization and prefix Bearer. Do not mint a token in its place without asking."
|
|
76
|
+
else
|
|
77
|
+
echo "oxyc: credential is the environment's network secret (OXY_TOKEN=from-proxy); no token is in this VM."
|
|
78
|
+
fi
|
|
79
|
+
elif [ -n "${OXY_TOKEN:-}" ]; then
|
|
52
80
|
echo "oxyc: credential is OXY_TOKEN from the environment."
|
|
53
81
|
elif [ -s "$TOKEN_FILE" ]; then
|
|
54
|
-
echo "oxyc: credential is the agent token in $TOKEN_FILE
|
|
82
|
+
echo "oxyc: credential is the agent token in $TOKEN_FILE, good on the one deployment that minted it"
|
|
83
|
+
echo " (it expires: on exit 4, mint again)."
|
|
55
84
|
else
|
|
56
85
|
cat <<EOF
|
|
57
|
-
oxyc: no Oxy credential yet.
|
|
58
|
-
|
|
86
|
+
oxyc: no Oxy credential yet. A token is good on one deployment (production, staging or dev), so
|
|
87
|
+
mint an agent token for the one the task uses. Start it with the Bash tool's run_in_background:
|
|
59
88
|
mkdir -p ~/.config/oxy && (umask 077; oxyc tokens create --agent --no-browser --env $ENV >$TOKEN_FILE)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
89
|
+
It ends only once a person approves, so do not wait for it: a few seconds in, Read the task's
|
|
90
|
+
output file for the approval URL and code (the token goes to the file, never to you) and give
|
|
91
|
+
both to the user. --approver <their email> (or OXY_APPROVER) also pushes the request to them.
|
|
92
|
+
Once approved, every later command has OXY_TOKEN. It reaches what the approver's org
|
|
93
|
+
memberships do, never staff access: no device-code approval grants that. To sign a browser in,
|
|
94
|
+
navigate to the one-time URL 'oxyc login-link --env $ENV --next <path>' prints, never to the
|
|
95
|
+
Google, GitHub or email sign-in. See the oxy-custom-apps skill, "Headless and cloud sessions".
|
|
64
96
|
EOF
|
|
65
97
|
fi
|
|
66
98
|
exit 0
|
|
@@ -149,10 +149,10 @@ permissions:
|
|
|
149
149
|
contents: read
|
|
150
150
|
|
|
151
151
|
env:
|
|
152
|
-
# The `@oxy-hq/cli` (`oxyc`) both jobs install, exactly
|
|
153
|
-
# validate.yaml's `
|
|
154
|
-
#
|
|
155
|
-
#
|
|
152
|
+
# The `@oxy-hq/cli` (`oxyc`) both jobs install, exactly — the same pin as
|
|
153
|
+
# validate.yaml's `OXYC_VERSION`, raised together on every release.
|
|
154
|
+
# `--build-only` and `--prebuilt`, which the two jobs below depend on,
|
|
155
|
+
# arrived in 0.4.0.
|
|
156
156
|
#
|
|
157
157
|
# THE PIN DECIDES WHICH OIDC REGISTRATION THE PUBLISH JOB CAN USE. Through
|
|
158
158
|
# 0.6.0, `oxyc publish` knows one exchange: the app's own registered
|
|
@@ -160,7 +160,7 @@ env:
|
|
|
160
160
|
# service account are honoured from 0.7.0, which tries them first and falls
|
|
161
161
|
# back to the publisher. A pin older than that still publishes, through the
|
|
162
162
|
# publisher alone.
|
|
163
|
-
OXYC_VERSION: "0.
|
|
163
|
+
OXYC_VERSION: "0.13.0"
|
|
164
164
|
|
|
165
165
|
jobs:
|
|
166
166
|
build:
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# Validate __NAME__'s semantic model on every pull request.
|
|
2
2
|
#
|
|
3
|
-
# `
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
3
|
+
# `oxyc compile` is the gate. It asks the oxy deployment that serves this
|
|
4
|
+
# workspace to compile the branch — the commit GitHub has for it, as the
|
|
5
|
+
# workspace's registered subdirectory — into a STAGING revision, waits for the
|
|
6
|
+
# answer, and fails the job when any file recorded a failure. A staging
|
|
7
|
+
# revision is never promoted and nothing a customer sees reads it, so this
|
|
8
|
+
# changes nothing anyone is served.
|
|
9
9
|
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
10
|
+
# It replaced a job that installed the Rust `oxy`, booted a throwaway Postgres,
|
|
11
|
+
# ran `oxy migrate`, INSERTed a `workspaces` row with psql and ran
|
|
12
|
+
# `oxy compile --json` over the checkout. That compiled what was on the runner,
|
|
13
|
+
# with whatever compiler the pin named; this compiles what the deployment will
|
|
14
|
+
# compile, with its compiler, and needs no database, no checkout and no
|
|
15
|
+
# installer script.
|
|
14
16
|
#
|
|
15
17
|
# What this gate catches and what it does not: see "What CI checks" in README.md.
|
|
16
18
|
|
|
@@ -25,240 +27,164 @@ on:
|
|
|
25
27
|
# nothing. It stays useful once PRs are required too — a merge is a push, and
|
|
26
28
|
# a branch protected today can be unprotected tomorrow.
|
|
27
29
|
#
|
|
28
|
-
# Deliberately no `paths:` filter.
|
|
29
|
-
#
|
|
30
|
-
#
|
|
30
|
+
# Deliberately no `paths:` filter. A compile reads the whole workspace, and a
|
|
31
|
+
# filter that missed a path would skip validation silently, which is worse
|
|
32
|
+
# than compiling on a README change.
|
|
31
33
|
push:
|
|
32
34
|
branches: [main]
|
|
33
35
|
|
|
34
|
-
# This gate
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
# for many repos is read/write on every scope.
|
|
36
|
+
# This gate never writes to the repository, so it does not need a token that
|
|
37
|
+
# can. Stated explicitly because the DEFAULT is whatever the repo or org is set
|
|
38
|
+
# to, which for many repos is read/write on every scope.
|
|
38
39
|
permissions:
|
|
39
40
|
contents: read
|
|
40
41
|
|
|
41
42
|
env:
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
|
|
45
|
-
OXY_VERSION: "0.5.126"
|
|
43
|
+
# The `@oxy-hq/cli` (`oxyc`) this job installs, exactly. `oxyc compile`
|
|
44
|
+
# exists from 0.13.0; an older pin has no such command.
|
|
45
|
+
OXYC_VERSION: "0.13.0"
|
|
46
46
|
|
|
47
47
|
# WHERE THE OXY WORKSPACE IS, relative to the repo root.
|
|
48
48
|
#
|
|
49
49
|
# . the repo IS the workspace — every repo `oxyc new` scaffolds
|
|
50
50
|
# oxy the repo CONTAINS one — the shape of every repo that was imported
|
|
51
51
|
#
|
|
52
|
-
# Substituted at render time from `__WORKSPACE__
|
|
53
|
-
#
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
# It exists because this gate cannot be layout-agnostic and must not be
|
|
57
|
-
# layout-wrong: `oxy compile` at the repo root of a repo whose workspace is
|
|
58
|
-
# `oxy/` reads no config.yml, compiles nothing, and fails. A CI file that
|
|
59
|
-
# installs cleanly and then fails on every run is worse than one that was
|
|
60
|
-
# never installed.
|
|
61
|
-
#
|
|
62
|
-
# The TOOLING adapts to the repo, never the other way round. The platform
|
|
63
|
-
# registered this subdirectory when the workspace was onboarded and there is
|
|
64
|
-
# no UI or CLI to change it, so flattening a repo to match this template
|
|
65
|
-
# would silently break its registration with no repair short of re-onboarding.
|
|
52
|
+
# Substituted at render time from `__WORKSPACE__`. The deployment already
|
|
53
|
+
# knows the subdirectory it registered and compiles that; this is only used
|
|
54
|
+
# to anchor a failure annotation (a workspace-relative path) on the right
|
|
55
|
+
# file of the repo.
|
|
66
56
|
OXY_WORKSPACE: "__WORKSPACE__"
|
|
67
57
|
|
|
68
58
|
jobs:
|
|
69
59
|
compile:
|
|
70
|
-
name:
|
|
60
|
+
name: oxyc compile
|
|
71
61
|
runs-on: ubuntu-latest
|
|
72
62
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
63
|
+
# `id-token: write` lets this job ask GitHub for a signed statement of what
|
|
64
|
+
# it is — this repository, this workflow file, this environment — which
|
|
65
|
+
# oxyc trades for a fifteen-minute token acting as the org's service
|
|
66
|
+
# account. No secret is stored anywhere.
|
|
67
|
+
permissions:
|
|
68
|
+
contents: read
|
|
69
|
+
id-token: write
|
|
70
|
+
|
|
71
|
+
# The environment the trust policy names. Trust policies must name one
|
|
72
|
+
# unless the org's token policy says otherwise, because without it anyone
|
|
73
|
+
# who can push a branch can mint. Create the trust policy for
|
|
74
|
+
# `.github/workflows/validate.yaml` with environment `validate` (see
|
|
75
|
+
# "What CI checks" in README.md).
|
|
76
|
+
environment: validate
|
|
85
77
|
|
|
86
78
|
env:
|
|
87
|
-
|
|
88
|
-
#
|
|
89
|
-
#
|
|
90
|
-
#
|
|
91
|
-
|
|
79
|
+
# The ID of the oxy workspace this repo is registered as — the one a
|
|
80
|
+
# branch is compiled for. Repository variable; from the workspace's
|
|
81
|
+
# settings page in Oxygen. Unset: the job says so and passes (the day-one
|
|
82
|
+
# state of a scaffold, before the repo is registered).
|
|
83
|
+
OXY_WORKSPACE_ID: ${{ vars.OXY_WORKSPACE_ID }}
|
|
84
|
+
# The ID of the org service account the OIDC exchange acts as, from
|
|
85
|
+
# Organization settings -> API access. Its trust policy needs a workspace
|
|
86
|
+
# grant on OXY_WORKSPACE_ID; `viewer` is enough — a compile check needs
|
|
87
|
+
# no editor standing, and the account gains nothing else from it.
|
|
88
|
+
OXY_SERVICE_ACCOUNT: ${{ vars.OXY_SERVICE_ACCOUNT }}
|
|
89
|
+
# The fallback, as in publish.yaml: a stored token wins when it is set,
|
|
90
|
+
# and no OIDC token is requested. Leave it unset to use trusted access.
|
|
91
|
+
OXY_TOKEN: ${{ secrets.OXY_TOKEN }}
|
|
92
|
+
# Which deployment: `production` unless the repository variable says
|
|
93
|
+
# otherwise. OXY_TARGET, when set, is an explicit base URL and overrides it.
|
|
94
|
+
OXY_ENV: ${{ vars.OXY_ENV }}
|
|
95
|
+
OXY_TARGET: ${{ vars.OXY_TARGET }}
|
|
96
|
+
# The branch the deployment compiles. On a pull request that is the head
|
|
97
|
+
# branch (`github.ref_name` would be `<n>/merge`, which GitHub's API does
|
|
98
|
+
# not serve as a branch); on a push, the pushed branch.
|
|
99
|
+
BRANCH: ${{ github.head_ref || github.ref_name }}
|
|
100
|
+
# The commit this run is about, to say so when the branch has moved on.
|
|
101
|
+
EXPECTED_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
|
|
92
102
|
|
|
93
103
|
steps:
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
# This job runs a downloaded installer script. Without this, checkout
|
|
97
|
-
# leaves a GITHUB_TOKEN in .git/config for that script to find. The
|
|
98
|
-
# job-level `permissions: contents: read` already narrows what such a
|
|
99
|
-
# token could do; not persisting it at all is the cheaper half of the
|
|
100
|
-
# same argument, and it costs nothing here — nothing in this job
|
|
101
|
-
# pushes.
|
|
102
|
-
persist-credentials: false
|
|
103
|
-
|
|
104
|
-
- name: Install the pinned oxy CLI
|
|
104
|
+
- name: Check this repo is set up for the gate
|
|
105
|
+
id: setup
|
|
105
106
|
run: |
|
|
106
107
|
set -euo pipefail
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
curl -sSfL https://get.oxy.tech -o "$RUNNER_TEMP/get-oxy.sh"
|
|
112
|
-
OXY_VERSION="$OXY_VERSION" bash "$RUNNER_TEMP/get-oxy.sh"
|
|
113
|
-
|
|
114
|
-
# And check the installer left something behind: it downloads the
|
|
115
|
-
# binary with `curl -L` (no -f) and exits 0 regardless.
|
|
116
|
-
if [ ! -x "$HOME/.local/bin/oxy" ]; then
|
|
117
|
-
echo "::error::the installer exited 0 but left no executable at $HOME/.local/bin/oxy." >&2
|
|
118
|
-
exit 1
|
|
108
|
+
if [ -z "${OXY_WORKSPACE_ID:-}" ]; then
|
|
109
|
+
echo "::notice::not checked: no OXY_WORKSPACE_ID repository variable, so there is no oxy workspace to compile this branch for. Set it (and OXY_SERVICE_ACCOUNT, with a trust policy) once the repo is registered — see 'What CI checks' in README.md."
|
|
110
|
+
echo "ready=false" >> "$GITHUB_OUTPUT"
|
|
111
|
+
exit 0
|
|
119
112
|
fi
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
- name: Verify the oxy CLI
|
|
127
|
-
run: |
|
|
128
|
-
set -euo pipefail
|
|
129
|
-
# Not ceremony. Two silent failures make this load-bearing:
|
|
130
|
-
# 1. the installer runs `curl -L` WITHOUT -f, so a tag that does
|
|
131
|
-
# not exist writes GitHub's 404 HTML page to the binary path,
|
|
132
|
-
# chmod +x's it, and still exits 0;
|
|
133
|
-
# 2. this CLI falls through to `--help` with exit 0 on a subcommand
|
|
134
|
-
# it does not have, so an old binary "succeeds" at doing nothing.
|
|
135
|
-
if ! raw="$(oxy --version 2>&1)"; then
|
|
136
|
-
echo "::error::'oxy --version' failed — the installed binary is not runnable." >&2
|
|
137
|
-
printf '%s\n' "$raw" >&2
|
|
138
|
-
exit 1
|
|
113
|
+
if [ -z "${OXY_TOKEN:-}" ] && [ -z "${ACTIONS_ID_TOKEN_REQUEST_URL:-}" ]; then
|
|
114
|
+
# A pull request from a fork gets no OIDC token, by GitHub's design:
|
|
115
|
+
# a fork's code must not be able to act as this repo.
|
|
116
|
+
echo "::notice::not checked: GitHub issued this run no OIDC token (a pull request from a fork gets none) and no OXY_TOKEN secret is set. The branch is checked when it reaches this repository."
|
|
117
|
+
echo "ready=false" >> "$GITHUB_OUTPUT"
|
|
118
|
+
exit 0
|
|
139
119
|
fi
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if [ -z "$have" ]; then
|
|
143
|
-
echo "::error::could not read a version out of 'oxy --version' — the install probably wrote a 404 page." >&2
|
|
144
|
-
printf '%s\n' "$raw" >&2
|
|
120
|
+
if [ -z "${OXY_TOKEN:-}" ] && [ -z "${OXY_SERVICE_ACCOUNT:-}" ]; then
|
|
121
|
+
echo "::error::OXY_WORKSPACE_ID is set but OXY_SERVICE_ACCOUNT is not: trusted access needs the ID of the service account to act as. Set the repository variable, or an OXY_TOKEN secret as the fallback." >&2
|
|
145
122
|
exit 1
|
|
146
123
|
fi
|
|
124
|
+
echo "ready=true" >> "$GITHUB_OUTPUT"
|
|
147
125
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
echo "oxy $have (pin $OXY_VERSION)"
|
|
155
|
-
|
|
156
|
-
- name: Migrate the throwaway database
|
|
157
|
-
env:
|
|
158
|
-
OXY_STATE_DIR: ${{ runner.temp }}/oxy-state
|
|
159
|
-
run: oxy migrate
|
|
126
|
+
- name: Install the pinned oxyc CLI
|
|
127
|
+
if: steps.setup.outputs.ready == 'true'
|
|
128
|
+
run: |
|
|
129
|
+
set -euo pipefail
|
|
130
|
+
npm install --prefix "$RUNNER_TEMP/oxyc" --no-audit --no-fund "@oxy-hq/cli@$OXYC_VERSION"
|
|
131
|
+
echo "$RUNNER_TEMP/oxyc/node_modules/.bin" >> "$GITHUB_PATH"
|
|
160
132
|
|
|
161
|
-
- name:
|
|
133
|
+
- name: Verify the oxyc CLI
|
|
134
|
+
if: steps.setup.outputs.ready == 'true'
|
|
162
135
|
run: |
|
|
163
136
|
set -euo pipefail
|
|
164
|
-
#
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
# `oxy serve --local` just to trigger its boot-time seed — costs ~25s,
|
|
169
|
-
# binds two ports, and has no "seed and exit" mode.
|
|
170
|
-
if ! command -v psql >/dev/null 2>&1; then
|
|
171
|
-
echo "::error::psql is not on this runner. GitHub's ubuntu-latest image ships it; a self-hosted runner may not. Install postgresql-client, or run this INSERT with: docker exec ${{ job.services.postgres.id }} psql -U postgres" >&2
|
|
137
|
+
# A version other than the pin means PATH found a different oxyc first.
|
|
138
|
+
have="$(oxyc --version)"
|
|
139
|
+
if [ "$have" != "$OXYC_VERSION" ]; then
|
|
140
|
+
echo "::error::oxyc $have is on PATH, not the pinned $OXYC_VERSION." >&2
|
|
172
141
|
exit 1
|
|
173
142
|
fi
|
|
174
|
-
|
|
175
|
-
"INSERT INTO workspaces (id, name) VALUES ('00000000-0000-0000-0000-000000000000', 'ci-validate') ON CONFLICT (id) DO NOTHING;"
|
|
143
|
+
echo "oxyc $have (pin $OXYC_VERSION)"
|
|
176
144
|
|
|
177
|
-
- name: Compile the
|
|
178
|
-
|
|
179
|
-
OXY_STATE_DIR: ${{ runner.temp }}/oxy-state
|
|
145
|
+
- name: Compile the branch
|
|
146
|
+
if: steps.setup.outputs.ready == 'true'
|
|
180
147
|
run: |
|
|
181
148
|
set -euo pipefail
|
|
182
|
-
|
|
183
|
-
#
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
# a repo that is the workspace and for one that contains it.
|
|
191
|
-
ws=""
|
|
192
|
-
if ! ws="$(cd "$GITHUB_WORKSPACE/$OXY_WORKSPACE" 2>/dev/null && pwd -P)"; then
|
|
193
|
-
echo "::error::no directory at \$GITHUB_WORKSPACE/$OXY_WORKSPACE. OXY_WORKSPACE says where this repo's Oxy workspace is, relative to the repo root: '.' when the repo IS the workspace, a subdirectory name when it contains one." >&2
|
|
194
|
-
exit 1
|
|
149
|
+
# An unset secret arrives as an EMPTY variable; oxyc treats the two
|
|
150
|
+
# alike, and unsetting it says which path this run takes.
|
|
151
|
+
if [ -z "${OXY_TOKEN:-}" ]; then
|
|
152
|
+
unset OXY_TOKEN
|
|
153
|
+
echo "authenticating with this job's GitHub OIDC token as service account $OXY_SERVICE_ACCOUNT"
|
|
154
|
+
else
|
|
155
|
+
unset OXY_SERVICE_ACCOUNT
|
|
156
|
+
echo "authenticating with the OXY_TOKEN secret (the fallback path)"
|
|
195
157
|
fi
|
|
196
|
-
|
|
158
|
+
where=(--env "${OXY_ENV:-production}")
|
|
159
|
+
if [ -n "${OXY_TARGET:-}" ]; then where=(--target "$OXY_TARGET"); fi
|
|
197
160
|
|
|
198
161
|
status=0
|
|
199
|
-
|
|
200
|
-
>"$RUNNER_TEMP/compile.
|
|
201
|
-
|
|
202
|
-
cat "$RUNNER_TEMP/compile.stderr" >&2
|
|
203
|
-
|
|
204
|
-
# `--json` does NOT put only JSON on stdout: a human-readable
|
|
205
|
-
# "Compiling workspace id=... path=..." line comes first, so piping
|
|
206
|
-
# stdout straight into jq fails ("Invalid numeric literal", exit 4).
|
|
207
|
-
# Extract from the line that opens the JSON object instead.
|
|
208
|
-
sed -n '/^{/,$p' "$RUNNER_TEMP/compile.stdout" > "$RUNNER_TEMP/compile.json"
|
|
162
|
+
oxyc compile "$BRANCH" --workspace "$OXY_WORKSPACE_ID" "${where[@]}" --wait --json \
|
|
163
|
+
>"$RUNNER_TEMP/compile.json" || status=$?
|
|
209
164
|
|
|
165
|
+
# `--json` prints the report whenever the compile ran to an answer,
|
|
166
|
+
# failed or not. Empty means oxyc stopped before that — not signed
|
|
167
|
+
# in, not allowed, no such branch — and said why on stderr above.
|
|
210
168
|
if [ ! -s "$RUNNER_TEMP/compile.json" ]; then
|
|
211
|
-
echo "::error::
|
|
212
|
-
exit
|
|
169
|
+
echo "::error::oxyc compile stopped before the compile answered (exit $status) — the lines above say why." >&2
|
|
170
|
+
exit "$status"
|
|
213
171
|
fi
|
|
214
172
|
|
|
215
|
-
#
|
|
216
|
-
#
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
jq -r
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
#
|
|
226
|
-
#
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
# `oxy/` the root has no config.yml, so a root-relative floor would
|
|
231
|
-
# sit one lower than the truth — quietly agreeing with a walk that saw
|
|
232
|
-
# nothing, which is the exact silence this check exists to break.
|
|
233
|
-
if [ -f "$ws/config.yml" ]; then
|
|
234
|
-
floor=$((floor + 1))
|
|
235
|
-
fi
|
|
236
|
-
# Count the WHOLE workspace tree, not just semantics/: the walker
|
|
237
|
-
# globs `**/*.view.yml` from the workspace root, so a view under
|
|
238
|
-
# models/ counts too, and a floor that only looked at semantics/ would
|
|
239
|
-
# sit at 1 and agree with a walk that saw nothing — the same silent
|
|
240
|
-
# agreement it exists to catch. Rooted at $ws for the same reason the
|
|
241
|
-
# config.yml check is: what the walker will descend into is the
|
|
242
|
-
# workspace, and a repo that contains one may hold .view.yml files
|
|
243
|
-
# outside it (a vendored fixture, an example) that the walker will
|
|
244
|
-
# never see and that would make this floor unreachably high.
|
|
245
|
-
# The prunes mirror the walker's own skip list; pruning a directory
|
|
246
|
-
# the walker would have descended can only UNDER-count, and a floor
|
|
247
|
-
# that is too low never fails a healthy repo.
|
|
248
|
-
# find prints nothing and exits 0 when there is no match, which is
|
|
249
|
-
# this repo's day-one state — a legitimate result, not an error to
|
|
250
|
-
# swallow. (On that empty tree floor=1=seen, so the check has nothing
|
|
251
|
-
# to detect and correctly says nothing.)
|
|
252
|
-
n="$(find "$ws" \( -name .git -o -name node_modules -o -name target \
|
|
253
|
-
-o -name dist -o -name build -o -name .oxy_state \
|
|
254
|
-
-o -name .semantics -o -name .preagg -o -name .worktrees \
|
|
255
|
-
-o -name .cubestore -o -name .airlayer_cache \) -prune \
|
|
256
|
-
-o -type f \( -name '*.view.yml' -o -name '*.topic.yml' \) \
|
|
257
|
-
! -name '*.test.*' -print | wc -l | tr -d ' ')"
|
|
258
|
-
floor=$((floor + n))
|
|
259
|
-
if [ "$seen" -lt "$floor" ]; then
|
|
260
|
-
echo "::error::oxy compile saw $seen file(s) but at least $floor are on disk under $ws — the walker did not descend into the workspace. Check that --workspace-path is absolute, and that OXY_WORKSPACE ('$OXY_WORKSPACE') names the directory holding config.yml." >&2
|
|
261
|
-
exit 1
|
|
173
|
+
# The paths are workspace-relative; anchor each on the repo's file.
|
|
174
|
+
# An empty `failures` array is the green case and jq exits 0 for it.
|
|
175
|
+
prefix=""
|
|
176
|
+
if [ "$OXY_WORKSPACE" != "." ]; then prefix="$OXY_WORKSPACE/"; fi
|
|
177
|
+
jq -r --arg prefix "$prefix" \
|
|
178
|
+
'.failures[] | "::error file=\($prefix)\(.path)::[\(.kind)] \(.message)"' \
|
|
179
|
+
"$RUNNER_TEMP/compile.json"
|
|
180
|
+
jq -r '"compile: status=\(.status) sha=\(.git_sha) seen=\(.file_count_seen // "?") compiled=\(.file_count_compiled // "?") failed=\(.file_count_failed // "?")"' \
|
|
181
|
+
"$RUNNER_TEMP/compile.json"
|
|
182
|
+
|
|
183
|
+
# The deployment compiles the branch as GitHub has it NOW, which can
|
|
184
|
+
# be a later commit than the one this run was started for.
|
|
185
|
+
sha="$(jq -r '.git_sha' "$RUNNER_TEMP/compile.json")"
|
|
186
|
+
if [ "$sha" != "$EXPECTED_SHA" ]; then
|
|
187
|
+
echo "::warning::compiled $BRANCH at $sha, not $EXPECTED_SHA: the branch moved on after this run started. The newer run checks the newer commit."
|
|
262
188
|
fi
|
|
263
189
|
|
|
264
190
|
exit "$status"
|