Skip to content

Commit c45c378

Browse files
authored
Allow the compute-sdk tests to run without building locally (#129)
* Allow main.js to run without building locally * Switch javascript actions to node16 * Port install-rust to a composite action * Revert package-lock.json changes
1 parent bd7451b commit c45c378

File tree

14 files changed

+395
-417
lines changed

14 files changed

+395
-417
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/*
2+
!dist/main.js

.github/actions/compute-sdk-test/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ inputs:
66
required: true
77

88
runs:
9-
using: "node12"
9+
using: "node16"
1010
main: dist/main.js

.github/actions/compute-sdk-test/dist/main.js

Lines changed: 344 additions & 362 deletions
Large diffs are not rendered by default.

.github/actions/compute-sdk-test/main.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// Node & 3P Modules
2-
const fs = require('fs');
3-
const path = require('path');
4-
const childProcess = require('child_process');
5-
const fetch = require('node-fetch');
6-
const chalk = require('chalk');
7-
require('better-logging')(console, {
2+
import fs from 'fs';
3+
import path from 'path';
4+
import childProcess from 'node:child_process';
5+
import fetch from 'node-fetch';
6+
import chalk from 'chalk';
7+
import betterLogging from 'better-logging';
8+
9+
betterLogging(console, {
810
format: ctx => {
911

1012
const tag = chalk.bold(`[compute-sdk-test]`);
@@ -24,10 +26,10 @@ require('better-logging')(console, {
2426
});
2527

2628
// Utility modules
27-
const Viceroy = require('./src/viceroy.js');
28-
const UpstreamServer = require('./src/upstream-server.js');
29-
const compareUpstreamRequest = require('./src/compare-upstream-request.js');
30-
const compareDownstreamResponse = require('./src/compare-downstream-response.js');
29+
import Viceroy from './src/viceroy.js';
30+
import UpstreamServer from './src/upstream-server.js';
31+
import compareUpstreamRequest from './src/compare-upstream-request.js';
32+
import compareDownstreamResponse from './src/compare-downstream-response.js';
3133

3234

3335
// Get our config from the Github Action

.github/actions/compute-sdk-test/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "compute-sdk-test",
33
"version": "1.0.0",
44
"main": "dist/main.js",
5+
"type": "module",
56
"scripts": {
67
"build": "npm run build:index",
78
"build:index": "ncc build main.js && mv dist/index.js dist/main.js"

.github/actions/compute-sdk-test/src/compare-downstream-response.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const compareHeaders = require('./compare-headers.js');
1+
import compareHeaders from './compare-headers.js';
22

33
// Function to compare a response from a server (Viceroy, C@E, etc...)
44
// With a JSON Response Object in our config
@@ -63,7 +63,6 @@ const compareDownstreamResponse = async (configResponse, actualResponse) => {
6363
}
6464
}
6565
}
66-
}
67-
68-
module.exports = compareDownstreamResponse;
66+
};
6967

68+
export default compareDownstreamResponse;

.github/actions/compute-sdk-test/src/compare-headers.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
const compareHeaders = (configHeaders, wasmModuleHeaders) => {
23

34
if (!configHeaders) {
@@ -20,6 +21,6 @@ const compareHeaders = (configHeaders, wasmModuleHeaders) => {
2021
throw new Error(`[Header Value mismatch] Expected: ${configHeaderValue} - Got: ${wasmModuleHeaderValue}`);
2122
}
2223
});
23-
}
24+
};
2425

25-
module.exports = compareHeaders;
26+
export default compareHeaders;

.github/actions/compute-sdk-test/src/compare-upstream-request.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const compareHeaders = require('./compare-headers.js');
1+
import compareHeaders from './compare-headers.js';
22

33
// Function to compare an upstream request from a wasm module running on aserver (Viceroy, C@E, etc...)
44
// With a JSON Request Object in our config. With additional parameters to help our index.js with logging.
@@ -25,6 +25,6 @@ const compareUpstreamRequest = async (configRequest, actualRequest, isDownstream
2525
} catch (err) {
2626
throw new Error(`[Header Error] ${err.message}`);
2727
}
28-
}
28+
};
2929

30-
module.exports = compareUpstreamRequest;
30+
export default compareUpstreamRequest;

.github/actions/compute-sdk-test/src/kill-process-and-wait.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ const killProcessAndWait = (childProcess) => {
99
});
1010
}
1111

12-
module.exports = killProcessAndWait;
12+
export default killProcessAndWait;

.github/actions/compute-sdk-test/src/upstream-server.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const http = require('http');
1+
import http from 'http';
22

33
// Upstream Server - A local node HTTP Server that was can assign as a backend
44
// To verify Upstream requests sent by a wasm module
@@ -93,6 +93,6 @@ class UpstreamServer {
9393
this.server.close();
9494
}
9595
}
96-
}
96+
};
9797

98-
module.exports = UpstreamServer;
98+
export default UpstreamServer;

0 commit comments

Comments
 (0)