44 * SPDX-License-Identifier: Apache-2.0
55 */
66
7- import { execFileSync } from 'node:child_process' ;
8- import {
9- existsSync ,
10- mkdirSync ,
11- mkdtempSync ,
12- readFileSync ,
13- rmSync ,
14- } from 'node:fs' ;
15- import { tmpdir } from 'node:os' ;
7+ import { readFileSync } from 'node:fs' ;
168import path from 'node:path' ;
179import { describe , expect , it } from 'vitest' ;
1810
@@ -27,104 +19,6 @@ const NODE_ACTION_PATH = '.github/actions/self-hosted-node/action.yml';
2719const GUARD_STEP = 'Verify checkout includes expected head commit' ;
2820
2921describe ( 'no-AK integration CI wiring' , ( ) => {
30- it . runIf ( process . platform === 'linux' ) (
31- 'keeps Linux Unix socket paths short and identity-stable' ,
32- ( ) => {
33- const workflow = readFileSync (
34- path . join ( ROOT , '.github/workflows/ci.yml' ) ,
35- 'utf8' ,
36- ) ;
37- const routingBlocks = [ 'test' , 'test_macos' , 'test_windows' ] . map (
38- ( jobName ) => {
39- const testStep = getWorkflowStep (
40- getWorkflowJob ( workflow , jobName ) ,
41- 'Run tests and generate reports' ,
42- ) ;
43- const start = testStep . indexOf ( 'export TMPDIR=' ) ;
44- expect (
45- start ,
46- `${ jobName } : TMPDIR routing block` ,
47- ) . toBeGreaterThanOrEqual ( 0 ) ;
48- const end = testStep . indexOf ( '\n ( while true' , start ) ;
49- expect ( end , `${ jobName } : sampler sentinel` ) . toBeGreaterThan ( start ) ;
50- return testStep . slice ( start , end ) ;
51- } ,
52- ) ;
53- expect ( new Set ( routingBlocks ) ) . toHaveLength ( 1 ) ;
54- const [ routeTemp ] = routingBlocks ;
55- const root = mkdtempSync ( path . join ( tmpdir ( ) , 'ci-temp-routing-' ) ) ;
56- const longRunnerTemp = path . join ( root , 'x' . repeat ( 180 ) ) ;
57-
58- try {
59- mkdirSync ( longRunnerTemp ) ;
60- const [ routedTemp , resolvedTemp ] = execFileSync (
61- 'bash' ,
62- [
63- '-c' ,
64- `${ routeTemp } \nprintf '%s\\n%s\\n' "$TMPDIR" "$(cd "$TMPDIR" && pwd -P)"` ,
65- ] ,
66- {
67- encoding : 'utf8' ,
68- env : {
69- ...process . env ,
70- RUNNER_OS : 'Linux' ,
71- RUNNER_TEMP : longRunnerTemp ,
72- } ,
73- } ,
74- )
75- . trim ( )
76- . split ( '\n' ) ;
77-
78- expect ( resolvedTemp ) . toBe ( routedTemp ) ;
79- expect ( routedTemp ) . toMatch ( / ^ \/ v a r \/ t m p \/ q w e n - c i - / ) ;
80- expect ( existsSync ( routedTemp ) ) . toBe ( false ) ;
81- expect (
82- Buffer . byteLength (
83- path . join ( routedTemp , 'qwen-agent-view-XXXXXX' , 'supervisor.sock' ) ,
84- ) ,
85- ) . toBeLessThan ( 108 ) ;
86- expect (
87- workflow . match ( / m k t e m p - d \/ v a r \/ t m p \/ q w e n - c i - X X X X X X / g) ,
88- ) . toHaveLength ( 3 ) ;
89- expect ( workflow ) . toContain ( 'QWEN_CI_TMPDIR="$(mktemp -d' ) ;
90- expect ( workflow ) . toContain ( 'if [ -n "$QWEN_CI_TMPDIR" ]; then' ) ;
91- } finally {
92- rmSync ( root , { recursive : true , force : true } ) ;
93- }
94- } ,
95- ) ;
96-
97- it ( 'preserves test failures in every wrapped OS job' , ( ) => {
98- const workflow = readFileSync (
99- path . join ( ROOT , '.github/workflows/ci.yml' ) ,
100- 'utf8' ,
101- ) ;
102-
103- for ( const jobName of [ 'test' , 'test_macos' , 'test_windows' ] ) {
104- const testStep = getWorkflowStep (
105- getWorkflowJob ( workflow , jobName ) ,
106- 'Run tests and generate reports' ,
107- ) ;
108- expect ( testStep ) . toContain (
109- 'trap \'rm -rf "$TMPDIR" 2>/dev/null || true\' EXIT' ,
110- ) ;
111- let previous = - 1 ;
112- for ( const command of [
113- 'set +e' ,
114- 'npm run test:ci' ,
115- 'RC=$?' ,
116- 'set -e' ,
117- 'pkill -TERM -P "$SAMPLER_PID" 2>/dev/null || true' ,
118- 'kill "$SAMPLER_PID" 2>/dev/null || true' ,
119- 'exit "$RC"' ,
120- ] ) {
121- const index = testStep . indexOf ( command ) ;
122- expect ( index , `${ jobName } : ${ command } ` ) . toBeGreaterThan ( previous ) ;
123- previous = index ;
124- }
125- }
126- } ) ;
127-
12822 it ( 'defines a focused no-AK integration script' , ( ) => {
12923 const packageJson = JSON . parse (
13024 readFileSync ( path . join ( ROOT , 'package.json' ) , 'utf8' ) ,
0 commit comments