Repository navigation
170 lines (167 loc) · 7.58 KB
/
Copy pathcode-runner.yaml
File metadata and controls
170 lines (167 loc) · 7.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Code runner
on:
pull_request:
paths:
- "agents/code-runner/**"
- "server/internal/codemode/**"
- "server/internal/sandbox/**"
- "server/cmd/gram/code_runtime*.go"
- "server/internal/mcp/serve_meta*.go"
- "server/internal/mcp/toolselection.go"
- "server/internal/mcp/metamcp/**"
- "server/internal/metamcp/**"
- "server/internal/testenv/code_runner.go"
- ".mise-tasks/test/code-mode.sh"
- ".mise-tasks/**/code-runner*.sh"
- ".mise-tasks/build/monty.sh"
- ".github/workflows/code-runner.yaml"
- "mise.toml"
- "go.mod"
- "go.sum"
- ".dockerignore"
push:
branches: [main]
paths:
- "agents/code-runner/**"
- "server/internal/codemode/**"
- "server/internal/sandbox/**"
- "server/cmd/gram/code_runtime*.go"
- "server/internal/mcp/serve_meta*.go"
- "server/internal/mcp/toolselection.go"
- "server/internal/mcp/metamcp/**"
- "server/internal/metamcp/**"
- "server/internal/testenv/code_runner.go"
- ".mise-tasks/test/code-mode.sh"
- ".mise-tasks/**/code-runner*.sh"
- ".mise-tasks/build/monty.sh"
- ".github/workflows/code-runner.yaml"
- "mise.toml"
- "go.mod"
- "go.sum"
- ".dockerignore"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
validate:
name: validate
runs-on: ubuntu-24.04
timeout-minutes: 45
permissions:
contents: read
pull-requests: read # paths-filter lists the pull request files
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Go integration changes still need the runtime binaries, but do not
# require rerunning Rust checks or rebuilding the restricted Linux image.
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: changes
with:
filters: |
runner:
- 'agents/code-runner/Cargo.toml'
- 'agents/code-runner/Cargo.lock'
- 'agents/code-runner/rust-toolchain.toml'
- 'agents/code-runner/src/**'
- 'agents/code-runner/tests/**'
- '.mise-tasks/build/code-runner.sh'
- '.mise-tasks/build/monty.sh'
- '.mise-tasks/test/code-runner.sh'
- '.mise-tasks/lint/code-runner.sh'
- 'mise.toml'
- '.github/workflows/code-runner.yaml'
image:
- 'agents/code-runner/Cargo.toml'
- 'agents/code-runner/Cargo.lock'
- 'agents/code-runner/Dockerfile'
- 'agents/code-runner/src/**'
- '.mise-tasks/build/code-runner-image.sh'
- '.mise-tasks/test/code-runner-image.sh'
- '.dockerignore'
- 'mise.toml'
- '.github/workflows/code-runner.yaml'
# Caches are ref-scoped; this workflow only tests, never publishes artifacts.
- uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0 # zizmor: ignore[cache-poisoning]
with:
minimum_release_age: 1d
install: true
cache: true
env: false
- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 # zizmor: ignore[cache-poisoning]
with:
rust-src-dir: agents/code-runner
rustflags: ""
# cargo install's executable is not retained by the Rust dependency cache.
# Keep this after Rust setup: its post-action must save Monty before the
# Rust cache post-action cleans target/monty.
# Use an exact key: a different pinned revision must never reuse this binary.
- name: Cache pinned Monty installation
id: monty-cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 # zizmor: ignore[cache-poisoning]
with:
path: agents/code-runner/target/monty
key: monty-github-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.mise-tasks/build/monty.sh', 'agents/code-runner/rust-toolchain.toml') }}
- if: steps.monty-cache.outputs.cache-hit != 'true'
run: mise run build:monty
- run: mise run build:code-runner
- if: github.event_name == 'workflow_dispatch' || steps.changes.outputs.runner == 'true'
run: mise run test:code-runner
- if: github.event_name == 'workflow_dispatch' || steps.changes.outputs.runner == 'true'
run: mise run lint:code-runner
# The local docker build task has no cross-run cache. Build/load the same
# Dockerfile here, retaining intermediate stages (including pinned Monty).
- name: Setup Docker Buildx
if: github.event_name == 'workflow_dispatch' || steps.changes.outputs.image == 'true'
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
- name: Build smoke-test image
if: github.event_name == 'workflow_dispatch' || steps.changes.outputs.image == 'true'
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: .
file: agents/code-runner/Dockerfile
load: true
push: false
tags: gram-code-runner:test
cache-from: type=gha,scope=code-runner-validation
cache-to: type=gha,scope=code-runner-validation,mode=max
- name: Smoke-test cached image
if: github.event_name == 'workflow_dispatch' || steps.changes.outputs.image == 'true'
# The preceding step already built and loaded the image.
run: mise run --skip-deps test:code-runner-image
- name: Locate Go caches
id: go-cache
run: |
echo "GO_BUILD_CACHE=$(go env GOCACHE)" >> "$GITHUB_ENV"
echo "GO_MOD_CACHE=$(go env GOMODCACHE)" >> "$GITHUB_ENV"
echo "week=$(date -u +%G-%V)" >> "$GITHUB_OUTPUT"
# The Go cache is ~2.3 GB, and the repository's Actions cache is capped
# at 10 GB. Saving it per commit evicted the BuildKit layers above, so
# image builds recompiled the pinned Monty stage from source. Only main
# saves, at most once a week per dependency set; pull requests restore.
- name: Restore Go integration build
id: go-restore
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 # zizmor: ignore[cache-poisoning]
with:
path: |
${{ env.GO_BUILD_CACHE }}
${{ env.GO_MOD_CACHE }}
key: code-mode-go-github-v2-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('mise.toml', 'go.mod', 'go.sum') }}-${{ steps.go-cache.outputs.week }}
restore-keys: |
code-mode-go-github-v2-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('mise.toml', 'go.mod', 'go.sum') }}-
code-mode-go-github-v2-${{ runner.os }}-${{ runner.arch }}-
# Go cannot track changes to the external Rust/Monty executables. Reuse
# compiled packages, but always execute the integration tests.
- run: mise run test:code-mode -count=1
- name: Save Go integration build
if: github.event_name == 'push' && steps.go-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
${{ env.GO_BUILD_CACHE }}
${{ env.GO_MOD_CACHE }}
key: ${{ steps.go-restore.outputs.cache-primary-key }}