Skip to content

Commit c1c4fde

Browse files
authored
Merge pull request #97 from karthik2804/ci/add_test_action
add test action
2 parents bc6184c + ef3ebca commit c1c4fde

File tree

14 files changed

+2992
-1
lines changed

14 files changed

+2992
-1
lines changed
File renamed without changes.

.github/workflows/test.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Test
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
paths-ignore:
8+
- "examples/**"
9+
- "README.md"
10+
- "release-process.md"
11+
- "templates/**"
12+
workflow_dispatch:
13+
14+
env:
15+
CARGO_TERM_COLOR: always
16+
17+
jobs:
18+
build:
19+
name: Build spinjs
20+
runs-on: "ubuntu-latest"
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: Install latest Rust stable toolchain
24+
uses: actions-rs/toolchain@v1
25+
with:
26+
toolchain: stable
27+
default: true
28+
components: clippy, rustfmt
29+
30+
- uses: Swatinem/rust-cache@v2
31+
with:
32+
shared-key: "${{ runner.os }}-lint-${{ hashFiles('./Cargo.lock') }}"
33+
cache-on-failure: "true"
34+
35+
- name: "Install Wasm Rust target"
36+
shell: bash
37+
run: rustup target add wasm32-wasi
38+
39+
- name: Install nodejs
40+
uses: actions/setup-node@v3
41+
with:
42+
node-version: 16
43+
44+
- name: Setup cmake
45+
uses: jwlawson/[email protected]
46+
with:
47+
cmake-version: '3.25.x'
48+
49+
- name: Setup WASI-SDK
50+
shell: bash
51+
run: |
52+
cd /tmp
53+
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-linux.tar.gz
54+
tar -xvf wasi-sdk-16.0-linux.tar.gz
55+
cp -v -r wasi-sdk-16.0 /opt/wasi-sdk
56+
57+
- name: Install NPM dependancies for SDK
58+
shell: bash
59+
run: |
60+
cd crates/spin-js-engine/src/js_sdk
61+
npm install -
62+
63+
- name: Build spinjs
64+
shell: bash
65+
run: make
66+
67+
- name: Install spin
68+
uses: engineerd/[email protected]
69+
with:
70+
name: "spin"
71+
url: "https://github.com/fermyon/spin/releases/download/v0.7.0/spin-v0.7.0-linux-amd64.tar.gz"
72+
pathInArchive: "spin"
73+
74+
- name: Run Test
75+
shell: bash
76+
run: |
77+
cd test
78+
./test.sh
79+
80+
81+

crates/spin-js-engine/src/js_sdk/modules/spinSdk.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ interface FetchOptions {
5151

5252
interface FetchHeaders {
5353
entries: () => Iterator<[string, string]>
54+
get: (key: string) => string | null
55+
has: (key: string) => boolean
5456
}
5557

5658
interface FetchResult {
@@ -74,7 +76,9 @@ function fetch(uri: string, options?: FetchOptions) {
7476
return Promise.resolve({
7577
status,
7678
headers: {
77-
entries: () => Object.entries(headers || {})
79+
entries: () => Object.entries(headers || {}),
80+
get:(key: string) => (headers && headers[key]) || null,
81+
has:(key: string) => (headers && headers[key]) ? true : false
7882
},
7983
arrayBuffer: () => Promise.resolve(body),
8084
ok: (status > 199 && status < 300),

test/test-app/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## HTTP-TS Test app
2+
3+
This app is used to test the various functionalities of the SDK.

0 commit comments

Comments
 (0)