File tree Expand file tree Collapse file tree 9 files changed +123
-27
lines changed
integration-tests/js-compute Expand file tree Collapse file tree 9 files changed +123
-27
lines changed Original file line number Diff line number Diff line change 8
8
fastly-api-token :
9
9
description : ' The Fastly API token to use for interacting with Fastly API'
10
10
required : true
11
+ fastly-cli-version :
12
+ description : ' The version of the Fastli CLI app to use during testing'
13
+ required : true
11
14
github-token :
12
15
description : ' The GitHub token to use for downloading the Fastly CLI'
13
16
required : true
22
25
uses : fastly/compute-actions/setup@v4
23
26
with :
24
27
token : ${{ inputs.github-token }}
25
- cli_version : ' 7.0.1 '
28
+ cli_version : ${{ inputs.fastly-cli-version }}
26
29
- name : Download Engine
27
30
uses : actions/download-artifact@v3
28
31
with :
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ defaults:
12
12
env :
13
13
viceroy_version : 0.5.1
14
14
wasm-tools_version : 1.0.28
15
+ fastly-cli_version : 10.3.0
15
16
16
17
jobs :
17
18
@@ -269,7 +270,7 @@ jobs:
269
270
uses : fastly/compute-actions/setup@v4
270
271
with :
271
272
token : ${{ secrets.GITHUB_TOKEN }}
272
- cli_version : ' 7.0.1 '
273
+ cli_version : ${{ env.fastly-cli_version }}
273
274
274
275
- name : Restore Viceroy from cache
275
276
uses : actions/cache@v3
@@ -413,5 +414,6 @@ jobs:
413
414
- uses : ./.github/actions/e2e
414
415
with :
415
416
fastly-api-token : ${{ secrets.FASTLY_API_TOKEN }}
417
+ fastly-cli-version : ${{ env.fastly-cli_version }}
416
418
github-token : ${{ secrets.GITHUB_TOKEN }}
417
419
fixture : ${{ matrix.fixture }}
Original file line number Diff line number Diff line change @@ -12,15 +12,15 @@ service_id = ""
12
12
build = "node ../../../../js-compute-runtime-cli.js"
13
13
14
14
[local_server]
15
- [local_server.dictionaries ]
16
- [local_server.dictionaries .testconfig]
15
+ [local_server.config_stores ]
16
+ [local_server.config_stores .testconfig]
17
17
format = "inline-toml"
18
- [local_server.dictionaries .testconfig.contents]
18
+ [local_server.config_stores .testconfig.contents]
19
19
"twitter" = "https://twitter.com/fastly"
20
20
21
21
[setup]
22
- [setup.dictionaries ]
23
- [setup.dictionaries .testconfig]
24
- [setup.dictionaries .testconfig.items]
25
- [setup.dictionaries .testconfig.items.twitter]
26
- value = "https://twitter.com/fastly"
22
+ [setup.config_stores ]
23
+ [setup.config_stores .testconfig]
24
+ [setup.config_stores .testconfig.items]
25
+ [setup.config_stores .testconfig.items.twitter]
26
+ value = "https://twitter.com/fastly"
Original file line number Diff line number Diff line change 4
4
5
5
description = ""
6
6
language = "other"
7
- manifest_version = 2
7
+ manifest_version = 3
8
8
name = "edge-dictionary"
9
9
service_id = ""
10
10
11
11
[scripts]
12
12
build = "node ../../../../js-compute-runtime-cli.js"
13
13
14
14
[local_server]
15
- [local_server.dictionaries ]
16
- [local_server.dictionaries ."aZ1 __ 2"]
15
+ [local_server.config_stores ]
16
+ [local_server.config_stores ."aZ1 __ 2"]
17
17
format = "inline-toml"
18
- [local_server.dictionaries ."aZ1 __ 2".contents]
18
+ [local_server.config_stores ."aZ1 __ 2".contents]
19
19
"twitter" = "https://twitter.com/fastly"
20
-
21
- [setup]
22
- [setup.dictionaries]
23
- [setup.dictionaries."aZ1 __ 2"]
24
- [setup.dictionaries."aZ1 __ 2".items]
25
- [setup.dictionaries."aZ1 __ 2".items.twitter]
26
- value = "https://twitter.com/fastly"
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env node
2
+
3
+ import { $ as zx } from 'zx'
4
+
5
+ const startTime = Date . now ( ) ;
6
+
7
+ zx . verbose = false ;
8
+ if ( process . env . FASTLY_API_TOKEN === undefined ) {
9
+ try {
10
+ process . env . FASTLY_API_TOKEN = String ( await zx `fastly profile token --quiet` ) . trim ( )
11
+ } catch {
12
+ console . error ( 'No environment variable named FASTLY_API_TOKEN has been set and no default fastly profile exists.' ) ;
13
+ console . error ( 'In order to run the tests, either create a fastly profile using `fastly profile create` or export a fastly token under the name FASTLY_API_TOKEN' ) ;
14
+ process . exit ( 1 )
15
+ }
16
+ }
17
+
18
+ zx . verbose = true ;
19
+
20
+ let stores = await ( async function ( ) {
21
+ try {
22
+ return JSON . parse ( await zx `fastly config-store list --quiet --json --token $FASTLY_API_TOKEN` )
23
+ } catch {
24
+ return [ ]
25
+ }
26
+ } ( ) )
27
+
28
+ const STORE_ID = stores . find ( ( { name } ) => name === 'aZ1 __ 2' ) ?. id
29
+ if ( ! STORE_ID ) {
30
+ process . env . STORE_ID = JSON . parse ( await zx `fastly config-store create --quiet --name='aZ1 __ 2' --json --token $FASTLY_API_TOKEN` ) . id
31
+ } else {
32
+ process . env . STORE_ID = STORE_ID ;
33
+ }
34
+
35
+ try {
36
+ await zx `echo -n 'https://twitter.com/fastly' | fastly config-store-entry create --key twitter --store-id=$STORE_ID --stdin --token $FASTLY_API_TOKEN`
37
+ } catch { }
38
+
39
+ await zx `fastly resource-link create --version latest --resource-id $STORE_ID --token $FASTLY_API_TOKEN --autoclone`
40
+ await zx `fastly service-version activate --version latest --token $FASTLY_API_TOKEN`
41
+
42
+ console . log ( `Set up has finished! Took ${ ( Date . now ( ) - startTime ) / 1000 } seconds to complete` ) ;
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env node
2
+
3
+ import { $ as zx } from 'zx'
4
+
5
+ const startTime = Date . now ( ) ;
6
+
7
+
8
+ zx . verbose = false ;
9
+ if ( process . env . FASTLY_API_TOKEN === undefined ) {
10
+ try {
11
+ process . env . FASTLY_API_TOKEN = String ( await zx `fastly profile token --quiet` ) . trim ( )
12
+ } catch {
13
+ console . error ( 'No environment variable named FASTLY_API_TOKEN has been set and no default fastly profile exists.' ) ;
14
+ console . error ( 'In order to run the tests, either create a fastly profile using `fastly profile create` or export a fastly token under the name FASTLY_API_TOKEN' ) ;
15
+ process . exit ( 1 )
16
+ }
17
+ }
18
+ zx . verbose = true ;
19
+ let stores = await ( async function ( ) {
20
+ try {
21
+ return JSON . parse ( await zx `fastly config-store list --quiet --json --token $FASTLY_API_TOKEN` )
22
+ } catch {
23
+ return [ ]
24
+ }
25
+ } ( ) )
26
+ let links = await ( async function ( ) {
27
+ try {
28
+ return JSON . parse ( await zx `fastly resource-link list --quiet --json --version latest --token $FASTLY_API_TOKEN` )
29
+ } catch {
30
+ return [ ]
31
+ }
32
+ } ( ) )
33
+
34
+ const STORE_ID = stores . find ( ( { name } ) => name === 'aZ1 __ 2' ) ?. id
35
+ if ( STORE_ID ) {
36
+ process . env . STORE_ID = STORE_ID ;
37
+ let LINK_ID = links . find ( ( { resource_id} ) => resource_id == STORE_ID ) ?. id ;
38
+ if ( LINK_ID ) {
39
+ process . env . LINK_ID = LINK_ID ;
40
+ try {
41
+ await zx `fastly resource-link delete --version latest --autoclone --id=$LINK_ID --token $FASTLY_API_TOKEN`
42
+ await zx `fastly service-version activate --version latest --token $FASTLY_API_TOKEN`
43
+ } catch { }
44
+ }
45
+ try {
46
+ await zx `fastly config-store delete --store-id=$STORE_ID --token $FASTLY_API_TOKEN`
47
+ } catch { }
48
+ }
49
+
50
+ console . log ( `Tear down has finished! Took ${ ( Date . now ( ) - startTime ) / 1000 } seconds to complete` ) ;
Original file line number Diff line number Diff line change @@ -21,11 +21,10 @@ let stores = await (async function() {
21
21
try {
22
22
return JSON . parse ( await zx `fastly secret-store list --quiet --json --token $FASTLY_API_TOKEN` )
23
23
} catch {
24
- return { data : [ ] }
24
+ return [ ]
25
25
}
26
26
} ( ) )
27
-
28
- const STORE_ID = stores . data . find ( ( { name } ) => name === 'example-test-secret-store' ) ?. id
27
+ const STORE_ID = stores . find ( ( { name } ) => name === 'example-test-secret-store' ) ?. id
29
28
if ( ! STORE_ID ) {
30
29
process . env . STORE_ID = JSON . parse ( await zx `fastly secret-store create --quiet --name=example-test-secret-store --json --token $FASTLY_API_TOKEN` ) . id
31
30
} else {
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ let stores = await (async function() {
20
20
try {
21
21
return JSON . parse ( await zx `fastly secret-store list --quiet --json --token $FASTLY_API_TOKEN` )
22
22
} catch {
23
- return { data : [ ] }
23
+ return [ ]
24
24
}
25
25
} ( ) )
26
26
let links = await ( async function ( ) {
@@ -31,7 +31,7 @@ let links = await (async function() {
31
31
}
32
32
} ( ) )
33
33
34
- const STORE_ID = stores . data . find ( ( { name } ) => name === 'example-test-secret-store' ) ?. id
34
+ const STORE_ID = stores . find ( ( { name } ) => name === 'example-test-secret-store' ) ?. id
35
35
if ( STORE_ID ) {
36
36
process . env . STORE_ID = STORE_ID ;
37
37
let LINK_ID = links . find ( ( { resource_id} ) => resource_id == STORE_ID ) ?. id ;
Original file line number Diff line number Diff line change @@ -15,6 +15,12 @@ import TOML from '@iarna/toml'
15
15
const startTime = Date . now ( ) ;
16
16
const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
17
17
18
+ async function sleep ( seconds ) {
19
+ return new Promise ( resolve => {
20
+ setTimeout ( resolve , 1_000 * seconds )
21
+ } )
22
+ }
23
+
18
24
let testFixtures = argv . slice ( 2 ) ;
19
25
const existingFixtures = await fixturesWithComputeTests ( ) ;
20
26
if ( testFixtures . length === 0 ) {
@@ -96,7 +102,7 @@ for (const fixture of testFixtures) {
96
102
core . endGroup ( )
97
103
core . startGroup ( 'Build and deploy service' )
98
104
await zx `npm i`
99
- await $ `fastly compute publish -i --quiet --token $FASTLY_API_TOKEN`
105
+ await $ `fastly compute publish -i --quiet --token $FASTLY_API_TOKEN --status-check-off `
100
106
core . endGroup ( )
101
107
102
108
// get the public domain of the deployed application
@@ -107,6 +113,7 @@ for (const fixture of testFixtures) {
107
113
if ( existsSync ( setupPath ) ) {
108
114
core . startGroup ( 'Extra set-up steps for the service' )
109
115
await $ `${ setupPath } `
116
+ await sleep ( 60 )
110
117
core . endGroup ( )
111
118
}
112
119
You can’t perform that action at this time.
0 commit comments