Skip to content

Commit 9969207

Browse files
elliotttJakeChampionJake Champion
authored
chore: Update the fastly cli used in ci to 10.3.0 (#631)
Co-authored-by: Jake Champion <[email protected]> Co-authored-by: Jake Champion <[email protected]>
1 parent b5ade75 commit 9969207

File tree

9 files changed

+123
-27
lines changed

9 files changed

+123
-27
lines changed

.github/actions/e2e/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ inputs:
88
fastly-api-token:
99
description: 'The Fastly API token to use for interacting with Fastly API'
1010
required: true
11+
fastly-cli-version:
12+
description: 'The version of the Fastli CLI app to use during testing'
13+
required: true
1114
github-token:
1215
description: 'The GitHub token to use for downloading the Fastly CLI'
1316
required: true
@@ -22,7 +25,7 @@ runs:
2225
uses: fastly/compute-actions/setup@v4
2326
with:
2427
token: ${{ inputs.github-token }}
25-
cli_version: '7.0.1'
28+
cli_version: ${{ inputs.fastly-cli-version }}
2629
- name: Download Engine
2730
uses: actions/download-artifact@v3
2831
with:

.github/workflows/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ defaults:
1212
env:
1313
viceroy_version: 0.5.1
1414
wasm-tools_version: 1.0.28
15+
fastly-cli_version: 10.3.0
1516

1617
jobs:
1718

@@ -269,7 +270,7 @@ jobs:
269270
uses: fastly/compute-actions/setup@v4
270271
with:
271272
token: ${{ secrets.GITHUB_TOKEN }}
272-
cli_version: '7.0.1'
273+
cli_version: ${{ env.fastly-cli_version }}
273274

274275
- name: Restore Viceroy from cache
275276
uses: actions/cache@v3
@@ -413,5 +414,6 @@ jobs:
413414
- uses: ./.github/actions/e2e
414415
with:
415416
fastly-api-token: ${{ secrets.FASTLY_API_TOKEN }}
417+
fastly-cli-version: ${{ env.fastly-cli_version }}
416418
github-token: ${{ secrets.GITHUB_TOKEN }}
417419
fixture: ${{ matrix.fixture }}

integration-tests/js-compute/fixtures/config-store/fastly.toml.in

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ service_id = ""
1212
build = "node ../../../../js-compute-runtime-cli.js"
1313

1414
[local_server]
15-
[local_server.dictionaries]
16-
[local_server.dictionaries.testconfig]
15+
[local_server.config_stores]
16+
[local_server.config_stores.testconfig]
1717
format = "inline-toml"
18-
[local_server.dictionaries.testconfig.contents]
18+
[local_server.config_stores.testconfig.contents]
1919
"twitter" = "https://twitter.com/fastly"
2020

2121
[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"

integration-tests/js-compute/fixtures/edge-dictionary/fastly.toml.in

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,16 @@
44
authors = ["[email protected]"]
55
description = ""
66
language = "other"
7-
manifest_version = 2
7+
manifest_version = 3
88
name = "edge-dictionary"
99
service_id = ""
1010

1111
[scripts]
1212
build = "node ../../../../js-compute-runtime-cli.js"
1313

1414
[local_server]
15-
[local_server.dictionaries]
16-
[local_server.dictionaries."aZ1 __ 2"]
15+
[local_server.config_stores]
16+
[local_server.config_stores."aZ1 __ 2"]
1717
format = "inline-toml"
18-
[local_server.dictionaries."aZ1 __ 2".contents]
18+
[local_server.config_stores."aZ1 __ 2".contents]
1919
"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"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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`);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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`);

integration-tests/js-compute/fixtures/secret-store/setup.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ let stores = await (async function() {
2121
try {
2222
return JSON.parse(await zx`fastly secret-store list --quiet --json --token $FASTLY_API_TOKEN`)
2323
} catch {
24-
return {data:[]}
24+
return []
2525
}
2626
}())
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
2928
if (!STORE_ID) {
3029
process.env.STORE_ID = JSON.parse(await zx`fastly secret-store create --quiet --name=example-test-secret-store --json --token $FASTLY_API_TOKEN`).id
3130
} else {

integration-tests/js-compute/fixtures/secret-store/teardown.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let stores = await (async function() {
2020
try {
2121
return JSON.parse(await zx`fastly secret-store list --quiet --json --token $FASTLY_API_TOKEN`)
2222
} catch {
23-
return {data:[]}
23+
return []
2424
}
2525
}())
2626
let links = await (async function() {
@@ -31,7 +31,7 @@ let links = await (async function() {
3131
}
3232
}())
3333

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
3535
if (STORE_ID) {
3636
process.env.STORE_ID = STORE_ID;
3737
let LINK_ID = links.find(({resource_id}) => resource_id == STORE_ID)?.id;

integration-tests/js-compute/test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ import TOML from '@iarna/toml'
1515
const startTime = Date.now();
1616
const __dirname = dirname(fileURLToPath(import.meta.url));
1717

18+
async function sleep(seconds) {
19+
return new Promise(resolve => {
20+
setTimeout(resolve, 1_000 * seconds)
21+
})
22+
}
23+
1824
let testFixtures = argv.slice(2);
1925
const existingFixtures = await fixturesWithComputeTests();
2026
if (testFixtures.length === 0) {
@@ -96,7 +102,7 @@ for (const fixture of testFixtures) {
96102
core.endGroup()
97103
core.startGroup('Build and deploy service')
98104
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`
100106
core.endGroup()
101107

102108
// get the public domain of the deployed application
@@ -107,6 +113,7 @@ for (const fixture of testFixtures) {
107113
if (existsSync(setupPath)) {
108114
core.startGroup('Extra set-up steps for the service')
109115
await $`${setupPath}`
116+
await sleep(60)
110117
core.endGroup()
111118
}
112119

0 commit comments

Comments
 (0)