Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ jobs:
with:
path: "/home/runner/.cargo/bin/viceroy"
key: crate-cache-viceroy-${{ env.viceroy_version }}

- name: Restore wasm-tools from cache
uses: actions/cache@v3
id: wasm-tools
Expand Down Expand Up @@ -403,18 +403,18 @@ jobs:
run: npm run build:cli

- name: Run Tests
run: SUFFIX_STRING=${{matrix.profile}} node integration-tests/js-compute/test.js --ci --skip-teardown${{ matrix.platform == 'viceroy' && ' --local' || '' }}${{ matrix.profile == 'weval' && ' --aot' || '' }}${{ matrix.features == 'http-cache' && ' --http-cache' || '' }}
run: SUFFIX_STRING=${{matrix.profile}}-${{ github.run_id }}-${{ github.run_attempt }} node integration-tests/js-compute/test.js --ci --skip-teardown${{ matrix.platform == 'viceroy' && ' --local' || '' }}${{ matrix.profile == 'weval' && ' --aot' || '' }}${{ matrix.features == 'http-cache' && ' --http-cache' || '' }}
env:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}

- name: Run Module Mode Tests
run: SUFFIX_STRING=${{matrix.profile}} node integration-tests/js-compute/test.js --ci --fixture=module-mode${{ matrix.platform == 'viceroy' && ' --local' || '' }}${{ matrix.profile == 'weval' && ' --aot' || '' }}${{ matrix.features == 'http-cache' && ' --http-cache' || '' }}
run: SUFFIX_STRING=${{matrix.profile}}-${{ github.run_id }}-${{ github.run_attempt }} node integration-tests/js-compute/test.js --ci --fixture=module-mode${{ matrix.platform == 'viceroy' && ' --local' || '' }}${{ matrix.profile == 'weval' && ' --aot' || '' }}${{ matrix.features == 'http-cache' && ' --http-cache' || '' }}
env:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}

- name: Run Reusable Sandbox Tests
if: matrix.platform == 'viceroy'
run: SUFFIX_STRING=${{matrix.profile}} node integration-tests/js-compute/test.js --ci --serial --fixture=reusable-sandboxes --local${{ matrix.profile == 'weval' && ' --aot' || '' }}${{ matrix.features == 'http-cache' && ' --http-cache' || '' }}
run: SUFFIX_STRING=${{matrix.profile}}-${{ github.run_id }}-${{ github.run_attempt }} node integration-tests/js-compute/test.js --ci --serial --fixture=reusable-sandboxes --local${{ matrix.profile == 'weval' && ' --aot' || '' }}${{ matrix.features == 'http-cache' && ' --http-cache' || '' }}
env:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}

Expand Down Expand Up @@ -478,17 +478,17 @@ jobs:
run: npm run build:cli

- name: Run Tests
run: SUFFIX_STRING=debug node integration-tests/js-compute/test.js --ci --skip-teardown --debug-build${{ matrix.platform == 'viceroy' && ' --local' || '' }}${{ matrix.features == 'http-cache' && ' --http-cache' || '' }}
run: SUFFIX_STRING=debug-${{ github.run_id }}-${{ github.run_attempt }} node integration-tests/js-compute/test.js --ci --skip-teardown --debug-build${{ matrix.platform == 'viceroy' && ' --local' || '' }}${{ matrix.features == 'http-cache' && ' --http-cache' || '' }}
env:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}

- name: Run Module Mode Tests
run: SUFFIX_STRING=debug node integration-tests/js-compute/test.js --ci --fixture=module-mode --debug-build${{ matrix.platform == 'viceroy' && ' --local' || '' }}${{ matrix.features == 'http-cache' && ' --http-cache' || '' }}
run: SUFFIX_STRING=debug-${{ github.run_id }}-${{ github.run_attempt }} node integration-tests/js-compute/test.js --ci --fixture=module-mode --debug-build${{ matrix.platform == 'viceroy' && ' --local' || '' }}${{ matrix.features == 'http-cache' && ' --http-cache' || '' }}
env:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}

- name: Run Reusable Sandbox Tests
if: matrix.platform == 'viceroy'
run: SUFFIX_STRING=debug node integration-tests/js-compute/test.js --ci --serial --fixture=reusable-sandboxes --debug-build${{ matrix.platform == 'viceroy' && ' --local' || '' }}${{ matrix.features == 'http-cache' && ' --http-cache' || '' }}
run: SUFFIX_STRING=debug-${{ github.run_id }}-${{ github.run_attempt }} node integration-tests/js-compute/test.js --ci --serial --fixture=reusable-sandboxes --debug-build${{ matrix.platform == 'viceroy' && ' --local' || '' }}${{ matrix.features == 'http-cache' && ' --http-cache' || '' }}
env:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}
46 changes: 24 additions & 22 deletions integration-tests/js-compute/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { $ as zx } from 'zx';
import { argv } from 'node:process';
import { getEnv } from './env.js';

import { $ } from './util.js';

const serviceId = argv[2];
const serviceName = argv[3];

Expand All @@ -29,7 +31,7 @@ if (process.env.FASTLY_API_TOKEN === undefined) {
zx.verbose = false;
try {
process.env.FASTLY_API_TOKEN = String(
await zx`fastly profile token --quiet`,
await $`fastly profile token --quiet`,
).trim();
} catch {
console.error(
Expand All @@ -45,21 +47,21 @@ if (process.env.FASTLY_API_TOKEN === undefined) {

async function setupConfigStores() {
const stores = JSON.parse(
await zx`fastly config-store list --quiet --json --token $FASTLY_API_TOKEN`,
await $`fastly config-store list --quiet --json --token $FASTLY_API_TOKEN`,
);

let STORE_ID = existingListId(stores, DICTIONARY_NAME);
if (!STORE_ID) {
console.log(`Creating new config store ${DICTIONARY_NAME}`);
STORE_ID = JSON.parse(
await zx`fastly config-store create --quiet --name="$DICTIONARY_NAME" --json --token $FASTLY_API_TOKEN`,
await $`fastly config-store create --quiet --name="$DICTIONARY_NAME" --json --token $FASTLY_API_TOKEN`,
).id;
} else {
console.log(`Using existing config store ${DICTIONARY_NAME}`);
}
await zx`echo -n 'https://twitter.com/fastly' | fastly config-store-entry update --upsert --key twitter --store-id=${STORE_ID} --stdin --token $FASTLY_API_TOKEN`;
await $`echo -n 'https://twitter.com/fastly' | fastly config-store-entry update --upsert --key twitter --store-id=${STORE_ID} --stdin --token $FASTLY_API_TOKEN`;
try {
await zx`fastly resource-link create --service-id ${serviceId} --version latest --resource-id ${STORE_ID} --token $FASTLY_API_TOKEN --autoclone`;
await $`fastly service resource-link create --service-id ${serviceId} --version latest --resource-id ${STORE_ID} --token $FASTLY_API_TOKEN --autoclone`;
} catch (e) {
if (!e.message.includes('Duplicate record')) throw e;
}
Expand All @@ -68,59 +70,59 @@ async function setupConfigStores() {
if (!STORE_ID) {
console.log(`Creating new config store ${CONFIG_STORE_NAME}`);
STORE_ID = JSON.parse(
await zx`fastly config-store create --quiet --name="$CONFIG_STORE_NAME" --json --token $FASTLY_API_TOKEN`,
await $`fastly config-store create --quiet --name="$CONFIG_STORE_NAME" --json --token $FASTLY_API_TOKEN`,
).id;
} else {
console.log(`Using existing config store ${CONFIG_STORE_NAME}`);
}
await zx`echo -n 'https://twitter.com/fastly' | fastly config-store-entry update --upsert --key twitter --store-id=${STORE_ID} --stdin --token $FASTLY_API_TOKEN`;
await $`echo -n 'https://twitter.com/fastly' | fastly config-store-entry update --upsert --key twitter --store-id=${STORE_ID} --stdin --token $FASTLY_API_TOKEN`;
try {
await zx`fastly resource-link create --service-id ${serviceId} --version latest --resource-id ${STORE_ID} --token $FASTLY_API_TOKEN --autoclone`;
await $`fastly service resource-link create --service-id ${serviceId} --version latest --resource-id ${STORE_ID} --token $FASTLY_API_TOKEN --autoclone`;
} catch (e) {
if (!e.message.includes('Duplicate record')) throw e;
}
}

async function setupKVStore() {
let stores = JSON.parse(
await zx`fastly kv-store list --quiet --json --token $FASTLY_API_TOKEN`,
await $`fastly kv-store list --quiet --json --token $FASTLY_API_TOKEN`,
).Data;

let STORE_ID = existingListId(stores, KV_STORE_NAME);
if (!STORE_ID) {
console.log(`Creating new KV store ${KV_STORE_NAME}`);
STORE_ID = JSON.parse(
await zx`fastly kv-store create --quiet --name="$KV_STORE_NAME" --json --token $FASTLY_API_TOKEN`,
await $`fastly kv-store create --quiet --name="$KV_STORE_NAME" --json --token $FASTLY_API_TOKEN`,
).StoreID;
} else {
console.log(`Using existing KV store ${KV_STORE_NAME}`);
}
try {
await zx`fastly resource-link create --service-id ${serviceId} --version latest --resource-id ${STORE_ID} --token $FASTLY_API_TOKEN --autoclone`;
await $`fastly service resource-link create --service-id ${serviceId} --version latest --resource-id ${STORE_ID} --token $FASTLY_API_TOKEN --autoclone`;
} catch (e) {
if (!e.message.includes('Duplicate record')) throw e;
}
}

async function setupSecretStore() {
const stores = JSON.parse(
await zx`fastly secret-store list --quiet --json --token $FASTLY_API_TOKEN`,
await $`fastly secret-store list --quiet --json --token $FASTLY_API_TOKEN`,
);
let STORE_ID = stores && existingListId(stores, SECRET_STORE_NAME);
if (!STORE_ID) {
console.log(`Creating new secret store ${SECRET_STORE_NAME}`);
STORE_ID = JSON.parse(
await zx`fastly secret-store create --quiet --name="$SECRET_STORE_NAME" --json --token $FASTLY_API_TOKEN`,
await $`fastly secret-store create --quiet --name="$SECRET_STORE_NAME" --json --token $FASTLY_API_TOKEN`,
).id;
} else {
console.log(`Using existing secret store ${SECRET_STORE_NAME}`);
}
await zx`echo -n 'This is also some secret data' | fastly secret-store-entry create --recreate-allow --name first --store-id=${STORE_ID} --stdin --token $FASTLY_API_TOKEN`;
await $`echo -n 'This is also some secret data' | fastly secret-store-entry create --recreate-allow --name first --store-id=${STORE_ID} --stdin --token $FASTLY_API_TOKEN`;
let key =
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
await zx`echo -n 'This is some secret data' | fastly secret-store-entry create --recreate-allow --name ${key} --store-id=${STORE_ID} --stdin --token $FASTLY_API_TOKEN`;
await $`echo -n 'This is some secret data' | fastly secret-store-entry create --recreate-allow --name ${key} --store-id=${STORE_ID} --stdin --token $FASTLY_API_TOKEN`;
try {
await zx`fastly resource-link create --service-id ${serviceId} --version latest --resource-id ${STORE_ID} --token $FASTLY_API_TOKEN --autoclone`;
await $`fastly service resource-link create --service-id ${serviceId} --version latest --resource-id ${STORE_ID} --token $FASTLY_API_TOKEN --autoclone`;
} catch (e) {
if (!e.message.includes('Duplicate record')) throw e;
}
Expand All @@ -129,22 +131,22 @@ async function setupSecretStore() {
async function setupAcl() {
let ACL_ID = existingListId(
JSON.parse(
await zx`fastly compute acl list-acls --quiet --json --token $FASTLY_API_TOKEN`,
await $`fastly compute acl list-acls --quiet --json --token $FASTLY_API_TOKEN`,
).data,
ACL_NAME,
);
if (!ACL_ID) {
console.log(`Creating ACL ${ACL_NAME}`);
ACL_ID = JSON.parse(
await zx`fastly compute acl create --name="$ACL_NAME" --token $FASTLY_API_TOKEN --json`,
await $`fastly compute acl create --name="$ACL_NAME" --token $FASTLY_API_TOKEN --json`,
).id;
await zx`fastly compute acl update --acl-id=${ACL_ID} --operation=create --prefix=100.100.0.0/16 --action=BLOCK --token $FASTLY_API_TOKEN`;
await zx`fastly compute acl update --acl-id=${ACL_ID} --operation=create --prefix=2a03:4b80::/32 --action=ALLOW --token $FASTLY_API_TOKEN`;
await $`fastly compute acl update --acl-id=${ACL_ID} --operation=create --prefix=100.100.0.0/16 --action=BLOCK --token $FASTLY_API_TOKEN`;
await $`fastly compute acl update --acl-id=${ACL_ID} --operation=create --prefix=2a03:4b80::/32 --action=ALLOW --token $FASTLY_API_TOKEN`;
} else {
console.log(`Using existing ACL ${ACL_NAME}`);
}
try {
await zx`fastly resource-link create --service-id ${serviceId} --version latest --resource-id ${ACL_ID} --token $FASTLY_API_TOKEN --autoclone`;
await $`fastly service resource-link create --service-id ${serviceId} --version latest --resource-id ${ACL_ID} --token $FASTLY_API_TOKEN --autoclone`;
} catch (e) {
if (!e.message.includes('Duplicate record')) throw e;
}
Expand All @@ -157,4 +159,4 @@ await setupSecretStore();
await setupAcl();
zx.verbose = false;

await zx`fastly service-version activate --service-id ${serviceId} --version latest --token $FASTLY_API_TOKEN`;
await $`fastly service-version activate --service-id ${serviceId} --version latest --token $FASTLY_API_TOKEN`;
45 changes: 23 additions & 22 deletions integration-tests/js-compute/teardown.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env node

import { $ as zx } from 'zx';
import { argv } from 'node:process';
import { getEnv } from './env.js';

import { $ } from './util.js';

const serviceId = argv[2];
const serviceName = argv[3];

Expand All @@ -25,7 +26,7 @@ const startTime = Date.now();
if (process.env.FASTLY_API_TOKEN === undefined) {
try {
process.env.FASTLY_API_TOKEN = String(
await zx`fastly profile token --quiet`,
await $`fastly profile token --quiet`,
).trim();
} catch {
console.error(
Expand All @@ -41,10 +42,10 @@ const FASTLY_API_TOKEN = process.env.FASTLY_API_TOKEN;

async function removeConfigStores() {
const stores = JSON.parse(
await zx`fastly config-store list --quiet --json --token $FASTLY_API_TOKEN`,
await $`fastly config-store list --quiet --json --token $FASTLY_API_TOKEN`,
);
const links = JSON.parse(
await zx`fastly resource-link list --service-id=${serviceId} --quiet --json --version latest --token $FASTLY_API_TOKEN`,
await $`fastly service resource-link list --service-id=${serviceId} --quiet --json --version latest --token $FASTLY_API_TOKEN`,
);

let STORE_ID = existingListId(stores, DICTIONARY_NAME);
Expand All @@ -53,10 +54,10 @@ async function removeConfigStores() {
({ resource_id }) => resource_id == STORE_ID,
)?.id;
if (LINK_ID) {
await zx`fastly resource-link delete --version latest --autoclone --id=${LINK_ID} --token $FASTLY_API_TOKEN`;
await zx`fastly service-version activate --version latest --token $FASTLY_API_TOKEN`;
await $`fastly service resource-link delete --version latest --autoclone --id=${LINK_ID} --token $FASTLY_API_TOKEN`;
await $`fastly service-version activate --version latest --token $FASTLY_API_TOKEN`;
}
await zx`fastly config-store delete --store-id=${STORE_ID} --token $FASTLY_API_TOKEN`;
await $`fastly config-store delete --store-id=${STORE_ID} --token $FASTLY_API_TOKEN`;
}

STORE_ID = existingListId(stores, CONFIG_STORE_NAME);
Expand All @@ -65,34 +66,34 @@ async function removeConfigStores() {
({ resource_id }) => resource_id == STORE_ID,
)?.id;
if (LINK_ID) {
await zx`fastly resource-link delete --version latest --autoclone --id=${LINK_ID} --token $FASTLY_API_TOKEN`;
await zx`fastly service-version activate --version latest --token $FASTLY_API_TOKEN`;
await $`fastly service resource-link delete --version latest --autoclone --id=${LINK_ID} --token $FASTLY_API_TOKEN`;
await $`fastly service-version activate --version latest --token $FASTLY_API_TOKEN`;
}
try {
await zx`fastly config-store delete --store-id=${STORE_ID} --token $FASTLY_API_TOKEN`;
await $`fastly config-store delete --store-id=${STORE_ID} --token $FASTLY_API_TOKEN`;
} catch {}
}
}

async function removeKVStore() {
const stores = JSON.parse(
await zx`fastly kv-store list --quiet --json --token $FASTLY_API_TOKEN`,
await $`fastly kv-store list --quiet --json --token $FASTLY_API_TOKEN`,
).Data;

let STORE_ID = existingListId(stores, KV_STORE_NAME);
if (STORE_ID) {
await zx`fastly kv-store delete --store-id=${STORE_ID} --quiet --all -y --token $FASTLY_API_TOKEN`;
await $`fastly kv-store delete --store-id=${STORE_ID} --quiet --all -y --token $FASTLY_API_TOKEN`;
} else {
console.error(`Unable to find KV Store ${KV_STORE_NAME} to delete`);
}
}

async function removeSecretStore() {
const stores = JSON.parse(
await zx`fastly secret-store list --quiet --json --token $FASTLY_API_TOKEN`,
await $`fastly secret-store list --quiet --json --token $FASTLY_API_TOKEN`,
);
const links = JSON.parse(
await zx`fastly resource-link list --service-id=${serviceId} --quiet --json --version latest --token $FASTLY_API_TOKEN`,
await $`fastly service resource-link list --service-id=${serviceId} --quiet --json --version latest --token $FASTLY_API_TOKEN`,
);

const STORE_ID = existingListId(stores, SECRET_STORE_NAME);
Expand All @@ -101,34 +102,34 @@ async function removeSecretStore() {
({ resource_id }) => resource_id == STORE_ID,
)?.id;
if (LINK_ID) {
await zx`fastly resource-link delete --version latest --autoclone --id=${LINK_ID} --token $FASTLY_API_TOKEN`;
await zx`fastly service-version activate --version latest --token $FASTLY_API_TOKEN`;
await $`fastly service resource-link delete --version latest --autoclone --id=${LINK_ID} --token $FASTLY_API_TOKEN`;
await $`fastly service-version activate --version latest --token $FASTLY_API_TOKEN`;
}
try {
await zx`fastly secret-store delete --store-id=${STORE_ID} --token $FASTLY_API_TOKEN`;
await $`fastly secret-store delete --store-id=${STORE_ID} --token $FASTLY_API_TOKEN`;
} catch {}
}
}

async function removeAcl() {
const ACL_ID = existingListId(
JSON.parse(
await zx`fastly compute acl list-acls --quiet --json --token $FASTLY_API_TOKEN`,
await $`fastly compute acl list-acls --quiet --json --token $FASTLY_API_TOKEN`,
).data,
ACL_NAME,
);

const links = JSON.parse(
await zx`fastly resource-link list --service-id=${serviceId} --quiet --json --version latest --token $FASTLY_API_TOKEN`,
await $`fastly service resource-link list --service-id=${serviceId} --quiet --json --version latest --token $FASTLY_API_TOKEN`,
);
const LINK_ID = links.find(({ resource_id }) => resource_id == ACL_ID)?.id;
if (LINK_ID) {
await zx`fastly resource-link delete --version latest --autoclone --id=${LINK_ID} --token $FASTLY_API_TOKEN`;
await zx`fastly service-version activate --version latest --token $FASTLY_API_TOKEN`;
await $`fastly service resource-link delete --version latest --autoclone --id=${LINK_ID} --token $FASTLY_API_TOKEN`;
await $`fastly service-version activate --version latest --token $FASTLY_API_TOKEN`;
}

if (ACL_ID) {
await zx`fastly compute acl delete --acl-id=${ACL_ID} --token $FASTLY_API_TOKEN`;
await $`fastly compute acl delete --acl-id=${ACL_ID} --token $FASTLY_API_TOKEN`;
}
}

Expand Down
Loading
Loading