@@ -16,7 +16,7 @@ import assert from 'assert';
1616import { config } from 'dotenv' ;
1717import { CLI } from '@adobe/helix-deploy' ;
1818import fse from 'fs-extra' ;
19- import path , { resolve } from 'path' ;
19+ import path from 'path' ;
2020import { createTestRoot , TestLogger } from './utils.js' ;
2121
2222// Only load .env if environment variables aren't already set (e.g., in CI)
@@ -29,21 +29,52 @@ describe('Edge Integration Test', () => {
2929 let origPwd ;
3030 const deployments = { } ;
3131
32- async function deployToCloudflare ( ) {
33- // Use static names to update existing worker instead of creating new ones
32+ before ( async function deployToBothPlatforms ( ) {
33+ this . timeout ( 600000 ) ; // 10 minutes for deployment
34+
35+ // Fail explicitly if required credentials are missing
36+ if ( ! process . env . HLX_FASTLY_AUTH ) {
37+ throw new Error ( 'HLX_FASTLY_AUTH environment variable is required for Fastly integration tests. Please set it in GitHub repository secrets.' ) ;
38+ }
39+ if ( ! process . env . CLOUDFLARE_AUTH ) {
40+ throw new Error ( 'CLOUDFLARE_AUTH environment variable is required for Cloudflare integration tests. Please set it in GitHub repository secrets.' ) ;
41+ }
42+
43+ testRoot = await createTestRoot ( ) ;
44+ origPwd = process . cwd ( ) ;
45+
46+ // Copy the edge-action fixture
47+ await fse . copy ( path . resolve ( __rootdir , 'test' , 'fixtures' , 'edge-action' ) , testRoot ) ;
48+ process . chdir ( testRoot ) ;
49+
50+ const fastlyServiceID = '1yv1Wl7NQCFmNBkW4L8htc' ;
51+ const fastlyTestDomain = 'possibly-working-sawfish' ;
3452
53+ // eslint-disable-next-line no-console
54+ console . log ( '--: Starting deployment to Cloudflare and Fastly...' ) ;
55+
56+ // Deploy to both platforms with a single CLI call using multiple --target arguments
3557 const builder = await new CLI ( )
3658 . prepare ( [
3759 '--build' ,
3860 '--verbose' ,
3961 '--deploy' ,
4062 '--target' , 'cloudflare' ,
63+ '--target' , 'c@e' ,
4164 '--plugin' , path . resolve ( __rootdir , 'src' , 'index.js' ) ,
4265 '--arch' , 'edge' ,
66+ // Cloudflare config
4367 '--cloudflare-email' , '[email protected] ' , 4468 '--cloudflare-account-id' , '155ec15a52a18a14801e04b019da5e5a' ,
4569 '--cloudflare-test-domain' , 'minivelos' ,
4670 '--cloudflare-auth' , process . env . CLOUDFLARE_AUTH ,
71+ // Fastly config
72+ '--compute-service-id' , fastlyServiceID ,
73+ '--compute-test-domain' , fastlyTestDomain ,
74+ '--package.name' , 'Test' ,
75+ '--fastly-gateway' , 'deploy-test.anywhere.run' ,
76+ '--fastly-service-id' , '4u8SAdblhzzbXntBYCjhcK' ,
77+ // Shared config
4778 '--package.params' , 'HEY=ho' ,
4879 '--package.params' , 'ZIP=zap' ,
4980 '--update-package' , 'true' ,
@@ -56,85 +87,19 @@ describe('Edge Integration Test', () => {
5687 builder . cfg . _logger = new TestLogger ( ) ;
5788
5889 const res = await builder . run ( ) ;
59- assert . ok ( res , 'Cloudflare deployment should succeed' ) ;
90+ assert . ok ( res , 'Deployment should succeed' ) ;
6091
61- return {
92+ deployments . cloudflare = {
6293 url : 'https://simple-package--simple-project.minivelos.workers.dev' ,
6394 logger : builder . cfg . _logger ,
6495 } ;
65- }
66-
67- async function deployToFastly ( ) {
68- const serviceID = '1yv1Wl7NQCFmNBkW4L8htc' ;
69- const testDomain = 'possibly-working-sawfish' ;
70- // Use the same package name as the existing working test
71- const packageName = 'Test' ;
72-
73- const builder = await new CLI ( )
74- . prepare ( [
75- '--build' ,
76- '--plugin' , resolve ( __rootdir , 'src' , 'index.js' ) ,
77- '--verbose' ,
78- '--deploy' ,
79- '--target' , 'c@e' ,
80- '--arch' , 'edge' ,
81- '--compute-service-id' , serviceID ,
82- '--compute-test-domain' , testDomain ,
83- '--package.name' , packageName ,
84- '--package.params' , 'HEY=ho' ,
85- '--package.params' , 'ZIP=zap' ,
86- '--update-package' , 'true' ,
87- '--fastly-gateway' , 'deploy-test.anywhere.run' ,
88- '-p' , 'FOO=bar' ,
89- '--fastly-service-id' , '4u8SAdblhzzbXntBYCjhcK' ,
90- '--directory' , testRoot ,
91- '--entryFile' , 'src/index.js' ,
92- '--bundler' , 'webpack' ,
93- '--esm' , 'false' ,
94- ] ) ;
95- builder . cfg . _logger = new TestLogger ( ) ;
96-
97- const res = await builder . run ( ) ;
98- assert . ok ( res , 'Fastly deployment should succeed' ) ;
99-
100- return {
101- url : `https://${ testDomain } .edgecompute.app` ,
96+ deployments . fastly = {
97+ url : `https://${ fastlyTestDomain } .edgecompute.app` ,
10298 logger : builder . cfg . _logger ,
10399 } ;
104- }
105-
106- before ( async function deployToBothPlatforms ( ) {
107- this . timeout ( 600000 ) ; // 10 minutes for parallel deployment
108-
109- // Fail explicitly if required credentials are missing
110- if ( ! process . env . HLX_FASTLY_AUTH ) {
111- throw new Error ( 'HLX_FASTLY_AUTH environment variable is required for Fastly integration tests. Please set it in GitHub repository secrets.' ) ;
112- }
113- if ( ! process . env . CLOUDFLARE_AUTH ) {
114- throw new Error ( 'CLOUDFLARE_AUTH environment variable is required for Cloudflare integration tests. Please set it in GitHub repository secrets.' ) ;
115- }
116-
117- testRoot = await createTestRoot ( ) ;
118- origPwd = process . cwd ( ) ;
119-
120- // Copy the edge-action fixture
121- await fse . copy ( path . resolve ( __rootdir , 'test' , 'fixtures' , 'edge-action' ) , testRoot ) ;
122- process . chdir ( testRoot ) ;
123-
124- // eslint-disable-next-line no-console
125- console . log ( '--: Starting parallel deployment to Cloudflare and Fastly...' ) ;
126-
127- // Deploy to both platforms in parallel
128- const [ cloudflareResult , fastlyResult ] = await Promise . all ( [
129- deployToCloudflare ( ) ,
130- deployToFastly ( ) ,
131- ] ) ;
132-
133- deployments . cloudflare = cloudflareResult ;
134- deployments . fastly = fastlyResult ;
135100
136101 // eslint-disable-next-line no-console
137- console . log ( '--: Parallel deployment completed' ) ;
102+ console . log ( '--: Deployment completed' ) ;
138103 // eslint-disable-next-line no-console
139104 console . log ( `--: Cloudflare URL: ${ deployments . cloudflare . url } ` ) ;
140105 // eslint-disable-next-line no-console
0 commit comments