@@ -14,11 +14,20 @@ const E2E_TEMP_DIR_PREFIX = "pkg-pr-new-e2e-";
1414
1515let server : Awaited < ReturnType < ReturnType < typeof simulation > [ "listen" ] > > ;
1616let workerUrl : string ;
17- let githubOutputDir : string ;
17+ let tempDir : string ;
1818let githubOutputPath : string ;
1919
2020let worker : UnstableDevWorker ;
21+
22+ const { stdout : gitRevParseOutput } = await ezSpawn . async (
23+ "git rev-parse HEAD" ,
24+ { stdio : "overlapped" } ,
25+ ) ;
26+ const gitRevParse = gitRevParseOutput . trim ( ) ;
27+
2128beforeAll ( async ( ) => {
29+ tempDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , E2E_TEMP_DIR_PREFIX ) ) ;
30+
2231 const app = simulation ( {
2332 initialState : {
2433 users : [ ] ,
@@ -51,15 +60,12 @@ beforeAll(async () => {
5160 `${ import . meta. dirname } /dist/_worker.js/index.js` ,
5261 {
5362 config : `${ import . meta. dirname } /wrangler.toml` ,
63+ persistTo : path . join ( tempDir , "worker" ) ,
5464 } ,
5565 ) ;
5666 const url = `${ worker . proxyData . userWorkerUrl . protocol } //${ worker . proxyData . userWorkerUrl . hostname } :${ worker . proxyData . userWorkerUrl . port } ` ;
5767 workerUrl = url ;
58-
59- githubOutputDir = await fs . mkdtemp (
60- path . join ( os . tmpdir ( ) , E2E_TEMP_DIR_PREFIX ) ,
61- ) ;
62- githubOutputPath = path . join ( githubOutputDir , "output" ) ;
68+ githubOutputPath = path . join ( tempDir , "output" ) ;
6369 await fs . writeFile ( githubOutputPath , "" ) ;
6470
6571 await ezSpawn . async (
@@ -74,8 +80,8 @@ beforeAll(async () => {
7480
7581afterAll ( async ( ) => {
7682 await server . ensureClose ( ) ;
77- if ( githubOutputDir ?. includes ( E2E_TEMP_DIR_PREFIX ) ) {
78- await fs . rm ( githubOutputDir , { recursive : true , force : true } ) ;
83+ if ( tempDir ?. includes ( E2E_TEMP_DIR_PREFIX ) ) {
84+ await fs . rm ( tempDir , { recursive : true , force : true } ) ;
7985 }
8086} ) ;
8187
@@ -123,6 +129,7 @@ describe.sequential.each([
123129 GITHUB_SHA : payload . workflow_run . head_sha ,
124130 GITHUB_ACTION : payload . workflow_run . id ,
125131 GITHUB_JOB : payload . workflow_run . name ,
132+ GITHUB_EVENT_NAME : payload . workflow_run . event ,
126133 GITHUB_REF_NAME : pr
127134 ? `${ pr . payload . number } /merge`
128135 : payload . workflow_run . head_branch ,
@@ -147,14 +154,12 @@ describe.sequential.each([
147154 expect ( process . stderr ) . toContain ( "pkg-pr-new:" ) ;
148155 expect ( process . stderr ) . toContain ( "playground-a:" ) ;
149156 expect ( process . stderr ) . toContain ( "playground-b:" ) ;
150- } , 10_000 ) ;
157+ } , 20_000 ) ;
151158
152159 it ( `serves and installs playground-a for ${ mode } ` , async ( ) => {
153160 const [ owner , repo ] = payload . repository . full_name . split ( "/" ) ;
154- const { stdout : gitHeadSha } = await ezSpawn . async ( "git rev-parse HEAD" , {
155- stdio : "overlapped" ,
156- } ) ;
157- const sha = gitHeadSha . trim ( ) . substring ( 0 , 7 ) ;
161+ const fullSha = pr ? payload . workflow_run . head_sha : gitRevParse ;
162+ const sha = fullSha . substring ( 0 , 7 ) ;
158163 const ref = pr ?. payload . number ?? payload . workflow_run . head_branch ;
159164
160165 // Test download with SHA
@@ -190,14 +195,12 @@ describe.sequential.each([
190195 expect ( installProcess . stdout ) . toContain (
191196 "playground-a installed successfully!" ,
192197 ) ;
193- } , 10_000 ) ;
198+ } , 20_000 ) ;
194199
195200 it ( `serves and installs playground-b for ${ mode } ` , async ( ) => {
196201 const [ owner , repo ] = payload . repository . full_name . split ( "/" ) ;
197- const { stdout : gitHeadSha } = await ezSpawn . async ( "git rev-parse HEAD" , {
198- stdio : "overlapped" ,
199- } ) ;
200- const sha = gitHeadSha . trim ( ) . substring ( 0 , 7 ) ;
202+ const fullSha = pr ? payload . workflow_run . head_sha : gitRevParse ;
203+ const sha = fullSha . substring ( 0 , 7 ) ;
201204
202205 // Test download
203206 const response = await worker . fetch (
@@ -225,7 +228,7 @@ describe.sequential.each([
225228 expect ( installProcess . stdout ) . toContain (
226229 "playground-b installed successfully!" ,
227230 ) ;
228- } , 10_000 ) ;
231+ } , 20_000 ) ;
229232} ) ;
230233
231234describe ( "URL redirects" , ( ) => {
0 commit comments