-
Notifications
You must be signed in to change notification settings - Fork 248
169 lines (145 loc) · 5.35 KB
/
fork-external-live-manual.yml
File metadata and controls
169 lines (145 loc) · 5.35 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
name: Fork External Live Tests (manual)
on:
workflow_dispatch:
inputs:
pr_number:
description: "Fork PR number to validate with external live tests"
required: true
type: string
permissions:
actions: write
contents: read
issues: write
pull-requests: write
jobs:
external-live:
name: Run Fork External Live Tests
runs-on: ubuntu-latest
timeout-minutes: 45
environment: external-live-tests
steps:
- name: Resolve PR context
id: pr
uses: actions/github-script@v7
with:
script: |
const prNumber = Number("${{ inputs.pr_number }}");
if (!Number.isInteger(prNumber) || prNumber <= 0) {
core.setFailed("pr_number must be a positive integer.");
return;
}
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
if (!pr.head.repo) {
core.setFailed(`PR #${prNumber} fork repository no longer exists.`);
return;
}
core.setOutput("pr_number", String(pr.number));
core.setOutput("head_sha", pr.head.sha);
core.setOutput("is_fork", String(pr.head.repo.fork));
core.setOutput("merge_ref", `refs/pull/${pr.number}/merge`);
- name: Ensure PR is from fork
if: steps.pr.outputs.is_fork != 'true'
run: |
echo "PR #${{ steps.pr.outputs.pr_number }} is not a fork PR."
echo "Use the normal CI workflows for internal branches."
exit 1
- name: Checkout PR merge ref
uses: actions/checkout@v4
with:
ref: ${{ steps.pr.outputs.merge_ref }}
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: "rust-integration-fork-live-manual"
- name: Install just
uses: extractions/setup-just@v3
- name: Build workspace
run: just build
- name: Setup Solana CLI
uses: ./.github/actions/setup-solana
- name: Ensure Jupiter API key is configured
env:
JUPITER_API_KEY: ${{ secrets.JUPITER_API_KEY }}
run: |
if [ -z "${JUPITER_API_KEY}" ]; then
echo "JUPITER_API_KEY is required for fork external live tests." >&2
exit 1
fi
- name: Run external live tests
uses: ./.github/actions/run-test-runner
with:
filters: "--filter external_live"
env:
JUPITER_API_KEY: ${{ secrets.JUPITER_API_KEY }}
- name: Cleanup test environment
if: always()
uses: ./.github/actions/cleanup-test-env
- name: Show failure logs
if: failure()
uses: ./.github/actions/show-failure-logs
with:
test-type: "Rust integration (fork external live)"
- name: Verify PR head is unchanged
if: success()
uses: actions/github-script@v7
with:
script: |
const prNumber = Number("${{ steps.pr.outputs.pr_number }}");
const testedSha = "${{ steps.pr.outputs.head_sha }}";
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
if (pr.head.sha !== testedSha) {
core.setFailed(
`PR head changed during manual validation. tested=${testedSha}, current=${pr.head.sha}.`
);
return;
}
- name: Record fork live approval marker
if: success()
uses: actions/github-script@v7
with:
script: |
const prNumber = Number("${{ steps.pr.outputs.pr_number }}");
const headSha = "${{ steps.pr.outputs.head_sha }}";
const marker = `fork-external-live-pass:${headSha}`;
const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `✅ Fork external live tests passed.\n\n${marker}\nrun: ${runUrl}`,
});
- name: Rerun fork live gate
if: success()
uses: actions/github-script@v7
with:
script: |
const headSha = "${{ steps.pr.outputs.head_sha }}";
const runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "fork-live-gate.yml",
event: "pull_request",
head_sha: headSha,
per_page: 20,
});
const gateRun = runs.data.workflow_runs.find((run) => run.status === "completed");
if (!gateRun) {
core.warning(
`No completed fork-live-gate workflow run found for ${headSha}. ` +
"Re-run the gate workflow manually if required."
);
return;
}
await github.rest.actions.reRunWorkflow({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: gateRun.id,
});