Skip to content

Commit 61855b1

Browse files
authored
Merge of #2331
2 parents bf902e2 + 12634b8 commit 61855b1

13 files changed

Lines changed: 973 additions & 20 deletions

File tree

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: test-suite-compatibility-matrix
2+
3+
on:
4+
pull_request:
5+
# Include label events so applying or removing `rollout` reevaluates the
6+
# job-level gate below without requiring a new commit.
7+
types:
8+
- opened
9+
- synchronize
10+
- reopened
11+
- labeled
12+
- unlabeled
13+
workflow_dispatch:
14+
inputs:
15+
compat-test:
16+
description: "Compat-test JSON path or stem from test-suite/fhevm/compat-tests"
17+
default: "v0.12-to-main"
18+
type: string
19+
20+
permissions: {}
21+
22+
concurrency:
23+
group: test-suite-compatibility-matrix-${{ github.ref }}-${{ inputs.compat-test || 'v0.12-to-main' }}-${{ github.run_id }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
prepare_rollout:
28+
name: prepare-rollout
29+
# On PRs, only same-repo heads with the `rollout` label may enter this
30+
# secreted compat path. Manual dispatch remains always available.
31+
if: ${{ github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && contains(github.event.pull_request.labels.*.name, 'rollout')) }}
32+
permissions:
33+
contents: 'read' # Required to checkout repository code
34+
packages: 'read' # Required to resolve published GitHub Container Registry package tags
35+
runs-on: ubuntu-latest
36+
env:
37+
GH_TOKEN: ${{ secrets.GHCR_READ_TOKEN || github.token }}
38+
outputs:
39+
compat_test: ${{ steps.prepare.outputs.compat_test }}
40+
matrix: ${{ steps.prepare.outputs.matrix }}
41+
scenario: ${{ steps.prepare.outputs.scenario }}
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
45+
with:
46+
persist-credentials: 'false'
47+
fetch-depth: 0
48+
49+
- name: Setup Bun
50+
uses: oven-sh/setup-bun@ecf28ddc73e819eb6fa29df6b34ef8921c743461 # v2.1.3
51+
52+
- name: Install GitHub CLI
53+
run: |
54+
sudo apt-get update
55+
sudo apt-get install -y gh
56+
57+
- name: Install CLI deps
58+
working-directory: test-suite/fhevm
59+
run: bun install --frozen-lockfile
60+
61+
- id: prepare
62+
name: Resolve compat-test and generate rollout matrix
63+
working-directory: test-suite/fhevm
64+
env:
65+
COMPAT_TEST_INPUT: ${{ github.event.inputs.compat-test || 'v0.12-to-main' }}
66+
run: |
67+
set -euo pipefail
68+
resolve_test() {
69+
local value="$1"
70+
local workspace_value="${GITHUB_WORKSPACE}/${value}"
71+
local compat_dir="${GITHUB_WORKSPACE}/test-suite/fhevm/compat-tests"
72+
if [ -f "$value" ]; then
73+
realpath "$value"
74+
return
75+
fi
76+
if [ -f "$workspace_value" ]; then
77+
realpath "$workspace_value"
78+
return
79+
fi
80+
if [ -f "${compat_dir}/${value}.json" ]; then
81+
realpath "${compat_dir}/${value}.json"
82+
return
83+
fi
84+
if [ -f "${compat_dir}/${value}" ]; then
85+
realpath "${compat_dir}/${value}"
86+
return
87+
fi
88+
echo "Could not resolve compat-test: $value" >&2
89+
exit 1
90+
}
91+
compat_test="$(resolve_test "$COMPAT_TEST_INPUT")"
92+
compat_test_rel="${compat_test#"$GITHUB_WORKSPACE"/}"
93+
scenario="$(jq -r '.execution.scenario // "two-of-two"' "$compat_test")"
94+
matrix="$(./fhevm-cli rollout --compat-test "$compat_test" --matrix)"
95+
{
96+
echo "compat_test=$compat_test_rel"
97+
echo "scenario=$scenario"
98+
echo "matrix<<EOF"
99+
echo "$matrix"
100+
echo "EOF"
101+
} >> "$GITHUB_OUTPUT"
102+
103+
compatibility-e2e:
104+
name: compatibility-${{ matrix.name }}
105+
needs: [prepare_rollout]
106+
strategy:
107+
fail-fast: false
108+
matrix: ${{ fromJSON(needs.prepare_rollout.outputs.matrix) }}
109+
uses: ./.github/workflows/test-suite-e2e-tests.yml
110+
permissions:
111+
contents: 'read' # Required by the called workflow to checkout repository code
112+
id-token: 'write' # Required by the called workflow for OIDC-authenticated actions
113+
packages: 'read' # Required by the called workflow to pull GitHub Container Registry images
114+
secrets:
115+
GHCR_READ_TOKEN: ${{ secrets.GHCR_READ_TOKEN }}
116+
CGR_USERNAME: ${{ secrets.CGR_USERNAME }}
117+
CGR_PASSWORD: ${{ secrets.CGR_PASSWORD }}
118+
with:
119+
build: false
120+
compat-test: ${{ needs.prepare_rollout.outputs.compat_test }}
121+
rollout-step: ${{ matrix.stepIndex }}
122+
scenario: ${{ needs.prepare_rollout.outputs.scenario }}
123+
test-profile: standard

.github/workflows/test-suite-e2e-tests.yml

Lines changed: 83 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- labeled
1010
- unlabeled
1111
workflow_dispatch:
12-
inputs: &workflow_inputs
12+
inputs: &shared_inputs
1313
orchestrated:
1414
description: "Run from the orchestrated image-validation path."
1515
default: false
@@ -82,8 +82,16 @@ on:
8282
description: "Relayer version"
8383
default: ""
8484
type: string
85+
compat-test:
86+
description: "Compat-test JSON path or stem under test-suite/fhevm/compat-tests"
87+
default: ""
88+
type: string
89+
rollout-step:
90+
description: "Compat rollout step index to render locally before boot"
91+
default: ""
92+
type: string
8593
lock-artifact-name:
86-
description: "Uploaded lock artifact name used to freeze the baseline bundle"
94+
description: "Uploaded lock artifact name used to freeze the resolved bundle"
8795
default: ""
8896
type: string
8997
kms-core-version:
@@ -94,6 +102,10 @@ on:
94102
description: "Deployment scenario (e.g. two-of-two, two-of-two-multi-chain)"
95103
default: "two-of-two"
96104
type: string
105+
test-profile:
106+
description: "Named test profile to run instead of the default standard suite"
107+
default: "standard"
108+
type: string
97109
workflow_call:
98110
secrets:
99111
GHCR_READ_TOKEN:
@@ -102,26 +114,26 @@ on:
102114
required: true
103115
CGR_PASSWORD:
104116
required: true
105-
inputs: *workflow_inputs
117+
inputs: *shared_inputs
106118

107119
permissions: {}
108120

109121
# Cancel stale PR runs on new pushes while keeping manual dispatches independent.
110122
concurrency:
111-
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.ref }}-${{ github.event_name == 'workflow_dispatch' && github.run_id || 'auto' }}
123+
group: ${{ github.workflow }}-${{ inputs.rollout-step != '' && format('compat-{0}-{1}-{2}', github.event_name == 'pull_request' && github.event.pull_request.number || github.ref, inputs.compat-test || 'default', inputs.rollout-step) || github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.ref }}-${{ github.event_name == 'workflow_dispatch' && github.run_id || 'auto' }}
112124
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.ref != 'refs/heads/main' }}
113125

114126
jobs:
115127
fhevm-e2e-test:
116128
# Run on manual/reusable invocations. For direct PRs, require the `e2e` label.
117-
if: ${{ github.event_name != 'pull_request' || inputs.orchestrated || (github.event.pull_request.head.repo.full_name == github.repository && !startsWith(github.head_ref, 'mergify/merge-queue/') && contains(github.event.pull_request.labels.*.name, 'e2e')) }}
129+
if: ${{ github.event_name != 'pull_request' || inputs.orchestrated || inputs.compat-test != '' || (github.event.pull_request.head.repo.full_name == github.repository && !startsWith(github.head_ref, 'mergify/merge-queue/') && contains(github.event.pull_request.labels.*.name, 'e2e')) }}
118130
permissions:
119131
contents: 'read' # Required to checkout repository code
120132
id-token: 'write' # Required for OIDC authentication
121133
packages: 'read' # Required to read GitHub packages/container registry
122134
env:
123135
GH_TOKEN: ${{ github.token }}
124-
BUILD: ${{ inputs.orchestrated && 'false' || github.event_name == 'pull_request' && 'true' || inputs.build && 'true' || 'false' }}
136+
BUILD: ${{ inputs.compat-test != '' && 'false' || inputs.orchestrated && 'false' || github.event_name == 'pull_request' && 'true' || inputs.build && 'true' || 'false' }}
125137
COPROCESSOR_DB_MIGRATION_VERSION: ${{ inputs.coprocessor-db-migration-version }}
126138
COPROCESSOR_HOST_LISTENER_VERSION: ${{ inputs.coprocessor-host-listener-version }}
127139
COPROCESSOR_GW_LISTENER_VERSION: ${{ inputs.coprocessor-gw-listener-version }}
@@ -140,6 +152,7 @@ jobs:
140152
RELAYER_VERSION: ${{ inputs.relayer-version }}
141153
CORE_VERSION: ${{ inputs.kms-core-version }}
142154
SCENARIO: ${{ inputs.scenario || 'two-of-two' }}
155+
TEST_PROFILE: ${{ inputs.test-profile || 'standard' }}
143156
runs-on: large_ubuntu_32
144157
steps:
145158
- name: Checkout code
@@ -181,26 +194,29 @@ jobs:
181194
sudo apt-get install -y gh
182195
183196
- name: Typecheck CLI
197+
if: ${{ inputs.compat-test == '' }}
184198
working-directory: test-suite/fhevm
185199
run: bun run check
186200

187201
- name: Unit test CLI
202+
if: ${{ inputs.compat-test == '' }}
188203
working-directory: test-suite/fhevm
189204
run: bun test src
190205

191206
- name: Compat smoke
207+
if: ${{ inputs.compat-test == '' }}
192208
working-directory: test-suite/fhevm
193209
run: bun run compat-smoke
194210

195211
- name: Download frozen baseline lock
196-
if: ${{ inputs.lock-artifact-name != '' }}
212+
if: ${{ inputs.compat-test == '' && inputs.lock-artifact-name != '' }}
197213
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
198214
with:
199215
name: ${{ inputs.lock-artifact-name }}
200216
path: ${{ runner.temp }}/baseline-lock
201217

202218
- name: Resolve frozen lock path
203-
if: ${{ inputs.lock-artifact-name != '' }}
219+
if: ${{ inputs.compat-test == '' && inputs.lock-artifact-name != '' }}
204220
run: |
205221
set -euo pipefail
206222
lock_file="$(find "${RUNNER_TEMP}/baseline-lock" -maxdepth 1 -name '*.json' -print -quit)"
@@ -210,8 +226,49 @@ jobs:
210226
fi
211227
echo "LOCK_FILE=$lock_file" >> "$GITHUB_ENV"
212228
229+
- name: Render compat rollout step
230+
if: ${{ inputs.compat-test != '' }}
231+
working-directory: test-suite/fhevm
232+
env:
233+
COMPAT_TEST_INPUT: ${{ inputs.compat-test }}
234+
ROLLOUT_STEP_INPUT: ${{ inputs.rollout-step }}
235+
run: |
236+
set -euo pipefail
237+
resolve_test() {
238+
local value="$1"
239+
local workspace_value="${GITHUB_WORKSPACE}/${value}"
240+
local compat_dir="${GITHUB_WORKSPACE}/test-suite/fhevm/compat-tests"
241+
if [ -f "$value" ]; then
242+
realpath "$value"
243+
return
244+
fi
245+
if [ -f "$workspace_value" ]; then
246+
realpath "$workspace_value"
247+
return
248+
fi
249+
if [ -f "${compat_dir}/${value}.json" ]; then
250+
realpath "${compat_dir}/${value}.json"
251+
return
252+
fi
253+
if [ -f "${compat_dir}/${value}" ]; then
254+
realpath "${compat_dir}/${value}"
255+
return
256+
fi
257+
echo "Could not resolve compat-test: $value" >&2
258+
exit 1
259+
}
260+
compat_test="$(resolve_test "$COMPAT_TEST_INPUT")"
261+
lock_file="${RUNNER_TEMP}/compat-step.lock.json"
262+
./fhevm-cli rollout --compat-test "$compat_test" --step "${ROLLOUT_STEP_INPUT:-0}" --out "$lock_file"
263+
echo "LOCK_FILE=$lock_file" >> "$GITHUB_ENV"
264+
265+
- name: Resolve compat local overrides
266+
if: ${{ inputs.compat-test != '' }}
267+
run: |
268+
echo "COMPAT_OVERRIDES=test-suite" >> "$GITHUB_ENV"
269+
213270
- name: Resolve latest-main lock once
214-
if: ${{ inputs.lock-artifact-name == '' && !inputs.orchestrated }}
271+
if: ${{ inputs.compat-test == '' && inputs.lock-artifact-name == '' && !inputs.orchestrated }}
215272
working-directory: test-suite/fhevm
216273
run: |
217274
lock_file="$(./fhevm-cli resolve --target latest-main | tail -n1)"
@@ -233,6 +290,12 @@ jobs:
233290
if [ "$BUILD" = "true" ]; then
234291
args+=(--build)
235292
fi
293+
if [ -n "${COMPAT_OVERRIDES:-}" ]; then
294+
IFS=',' read -r -a override_groups <<< "$COMPAT_OVERRIDES"
295+
for group in "${override_groups[@]}"; do
296+
[ -n "$group" ] && args+=(--override "$group")
297+
done
298+
fi
236299
./fhevm-cli up "${args[@]}" --dry-run
237300
238301
- name: Boot fhevm Stack
@@ -247,19 +310,28 @@ jobs:
247310
if [ "$BUILD" = "true" ]; then
248311
args+=(--build)
249312
fi
313+
if [ -n "${COMPAT_OVERRIDES:-}" ]; then
314+
IFS=',' read -r -a override_groups <<< "$COMPAT_OVERRIDES"
315+
for group in "${override_groups[@]}"; do
316+
[ -n "$group" ] && args+=(--override "$group")
317+
done
318+
fi
250319
./fhevm-cli up "${args[@]}"
251320
252-
- name: Standard e2e suite
321+
- name: Selected e2e suite
253322
working-directory: test-suite/fhevm
254323
run: |
255-
./fhevm-cli test standard
324+
./fhevm-cli test "$TEST_PROFILE"
256325
257326
- name: Host listener poller test
327+
if: ${{ inputs.test-profile == '' || inputs.test-profile == 'standard' }}
258328
working-directory: test-suite/fhevm
259329
run: |
330+
trap 'docker start coprocessor-host-listener >/dev/null 2>&1 || true' EXIT
260331
docker stop coprocessor-host-listener
261332
./fhevm-cli test erc20
262333
docker start coprocessor-host-listener
334+
trap - EXIT
263335
264336
- name: Show logs
265337
working-directory: test-suite/fhevm

coprocessor/fhevm-engine/Dockerfile.workspace

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,15 @@ COPY --from=sqlx_builder /usr/local/cargo/bin/sqlx /usr/local/bin/sqlx
201201
COPY coprocessor/fhevm-engine/db-migration/initialize_db.sh /initialize_db.sh
202202
COPY coprocessor/fhevm-engine/db-migration/insert_test_host_chain.sh /insert_test_host_chain.sh
203203
COPY coprocessor/fhevm-engine/db-migration/migrations /migrations
204+
COPY coprocessor/fhevm-engine/db-migration/db-scripts /db-scripts
205+
COPY coprocessor/fhevm-engine/db-migration/revert_coprocessor_db_state.sh /revert_coprocessor_db_state.sh
204206

205207
# Copy user/group from builder for consistency
206208
COPY --from=builder /etc/group /etc/group
207209
COPY --from=builder /etc/passwd /etc/passwd
208210

209211
# Set ownership
210-
RUN chown -R fhevm:fhevm /initialize_db.sh /insert_test_host_chain.sh /migrations
212+
RUN chown -R fhevm:fhevm /initialize_db.sh /insert_test_host_chain.sh /migrations /db-scripts /revert_coprocessor_db_state.sh
211213

212214
USER fhevm:fhevm
213215

test-suite/e2e/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
ARG NODE_VERSION=20.19.1-alpine3.21
2+
ARG RELAYER_SDK_VERSION=""
23

34
# --- Builder Stage ---
45
FROM node:${NODE_VERSION} AS builder
6+
ARG RELAYER_SDK_VERSION=""
57

68
WORKDIR /app
79

@@ -26,7 +28,10 @@ COPY test-suite/e2e/package.json ./test-suite/e2e/
2628

2729
# Install dependencies
2830
RUN npm ci && \
29-
npm prune
31+
npm prune && \
32+
if [ -n "$RELAYER_SDK_VERSION" ]; then \
33+
npm install --prefix test-suite/e2e --no-save "@zama-fhe/relayer-sdk@${RELAYER_SDK_VERSION}"; \
34+
fi
3035

3136
# Copy sources after deps are cached
3237
COPY library-solidity ./library-solidity

0 commit comments

Comments
 (0)